:root {
  color-scheme: light;

  --bg: #FBF6EC;
  --surface: #FFFDF8;
  --text: #2E2A26;
  --text-muted: #6B635A;
  --border: #EAE1D2;
  --input-border: #D9CEBB;

  --blue: #1F6FD6;
  --red: #E53B30;
  --yellow: #F5C020;
  --green: #2F9B45;
  --lilac: #B894E0;
  --pink: #F07BB5;
  --orange: #F08A24;
  --teal: #5CC3C3;

  --blue-soft: #E3EEFB;
  --green-soft: #E2F2E5;
  --lilac-soft: #F0E8FA;
  --orange-soft: #FDEBD9;
  --red-soft: #FBE4E2;
  --yellow-soft: #FDF3D3;
  --pink-soft: #FCE6F1;
  --teal-soft: #E0F4F4;

  --blue-ink: #1A5CB3;
  --green-ink: #237A36;
  --lilac-ink: #6E45A8;
  --orange-ink: #A9530B;

  --font-title: "Fredoka", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
}

@font-face {
  font-family: "Fredoka";
  src: url("/static/fonts/fredoka.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("/static/fonts/nunito.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--font-title);
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

p {
  margin: 0;
}

a {
  color: var(--blue);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.page-title {
  font-size: 26px;
  margin-bottom: 4px;
}

.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field-label {
  font-weight: 700;
  font-size: 14px;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-input,
.field-textarea {
  font-family: var(--font-body);
  font-size: 17px;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  min-height: 44px;
}

.field-input:focus,
.field-textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.field-textarea {
  resize: vertical;
  font-size: 16px;
}

.stack-form,
.stack-form-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stack-form-inline {
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-secondary {
  background: var(--blue-soft);
  color: var(--blue-ink);
}

.btn-block {
  width: 100%;
}

.link-button {
  background: none;
  border: none;
  color: var(--blue);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 8px 0;
  min-height: 44px;
}

.link-button-light {
  color: #fff;
  text-decoration: underline;
}

.link-button-danger {
  color: var(--red);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  min-height: 44px;
  cursor: pointer;
}

.checkbox-input {
  width: 22px;
  height: 22px;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.form-error {
  background: var(--red-soft);
  color: var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.form-success {
  background: var(--green-soft);
  color: var(--green-ink);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.form-notice {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* Public layout */

.public-body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

.public-shell {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.public-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.public-logo {
  width: 140px;
  height: auto;
}

.public-title {
  font-size: 22px;
}

.public-card {
  padding: 24px;
}

.public-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.public-link {
  font-weight: 700;
  text-decoration: none;
}

.public-link-muted {
  color: var(--text-muted);
  font-weight: 600;
}

.privacy-text {
  color: var(--text);
  white-space: pre-line;
  margin-bottom: 16px;
}

/* Parent layout */

.parent-body {
  min-height: 100vh;
  padding-bottom: 32px;
}

.parent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.parent-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.parent-header-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.parent-header-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 15px;
}

.parent-header-sub {
  color: var(--text-muted);
  font-size: 13px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.parent-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
}

.parent-tab {
  padding: 8px 4px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.parent-tab.is-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.parent-content {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

/* Note cards */

.note-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.note-card {
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--border);
}

.note-card-blue { background: var(--blue-soft); }
.note-card-green { background: var(--green-soft); }
.note-card-lilac { background: var(--lilac-soft); }
.note-card-orange { background: var(--orange-soft); }

.note-card-read {
  opacity: 0.85;
}

.note-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.note-card-date {
  color: var(--text-muted);
  font-size: 13px;
}

.note-card-meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.note-card-body {
  white-space: pre-line;
  margin-bottom: 14px;
}

.note-card-read-at {
  color: var(--text-muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-blue { background: var(--blue-soft); color: var(--blue-ink); }
.badge-green { background: var(--green-soft); color: var(--green-ink); }
.badge-lilac { background: var(--lilac-soft); color: var(--lilac-ink); }
.badge-orange { background: var(--orange-soft); color: var(--orange-ink); }

.empty-state {
  text-align: center;
  padding: 48px 16px;
}

.empty-state-title {
  font-family: var(--font-title);
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--text-muted);
}

.toast-undo {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: var(--text);
  color: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  z-index: 10;
  animation: toast-life 5.3s ease forwards;
}

@keyframes toast-life {
  0%, 88% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.pagination-link {
  font-weight: 700;
  text-decoration: none;
}

/* Teacher / admin layout */

.teacher-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.teacher-sidebar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.teacher-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.teacher-brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.teacher-brand-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 15px;
}

.teacher-brand-sub {
  color: var(--text-muted);
  font-size: 13px;
}

.teacher-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.teacher-nav-link {
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.teacher-nav-link.is-active {
  background: var(--blue-soft);
  color: var(--blue-ink);
}

.teacher-logout {
  margin-top: auto;
}

.teacher-content {
  padding: 20px 16px 48px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .teacher-body {
    flex-direction: row;
  }

  .teacher-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid var(--border);
    border-bottom: none;
    height: 100vh;
    position: sticky;
    top: 0;
  }

  .teacher-content {
    padding: 40px;
    max-width: 900px;
  }
}

/* Note form */

.note-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-option {
  position: relative;
}

.type-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.type-option span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--input-border);
  font-weight: 700;
  cursor: pointer;
}

.type-option input:checked + span {
  border-color: var(--blue);
  color: var(--blue-ink);
  background: var(--blue-soft);
}

.type-option-green input:checked + span {
  border-color: var(--green);
  color: var(--green-ink);
  background: var(--green-soft);
}

.type-option-lilac input:checked + span {
  border-color: var(--lilac);
  color: var(--lilac-ink);
  background: var(--lilac-soft);
}

.type-option-orange input:checked + span {
  border-color: var(--orange);
  color: var(--orange-ink);
  background: var(--orange-soft);
}

.student-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.student-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  min-width: 88px;
  cursor: pointer;
}

.student-option input {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 18px;
  height: 18px;
}

.student-option:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.student-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
}

.avatar-c0 { background: var(--pink-soft); }
.avatar-c1 { background: var(--yellow-soft); }
.avatar-c2 { background: var(--teal-soft); }
.avatar-c3 { background: var(--lilac-soft); }

.note-form-actions {
  display: flex;
  justify-content: flex-end;
}

/* Admin lists */

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-row-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-row-actions {
  display: flex;
  gap: 16px;
}

/* Reads */

.reads-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.reads-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.reads-count {
  font-weight: 700;
  color: var(--text-muted);
}

.reads-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.chip-read {
  background: var(--green-soft);
  color: var(--green-ink);
}

.chip-pending {
  background: var(--orange-soft);
  color: var(--orange-ink);
}

/* Audit */

.audit-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.audit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.audit-row:last-child {
  border-bottom: none;
}

.audit-row-head {
  background: var(--surface);
  font-weight: 700;
  color: var(--text-muted);
}
