:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --not-started: #cbd5e1;
  --working: #f59e0b;
  --mastered: #16a34a;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; }

/* Auth gate -------------------------------------------------------------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #eef2ff, #fdf2f8);
}
.auth-card {
  background: #fff; border-radius: 18px; padding: 32px 28px; width: min(380px, 100%);
  box-shadow: 0 20px 60px rgba(15,23,42,.15); text-align: center;
}
.auth-mark { font-size: 46px; }
.auth-mark .logo-svg { width: 56px; height: 56px; }
.sidebar-brand .brand-mark { display: inline-flex; }
.sidebar-brand .logo-svg { width: 30px; height: 30px; flex: none; }
.auth-card h2 { margin: 6px 0 18px; font-size: 24px; font-weight: 800; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-card input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font: inherit;
}
.auth-card .btn { margin-top: 4px; padding: 12px; justify-content: center; }
.auth-error { color: #dc2626; font-size: 13.5px; text-align: center; }
/* [hidden] must win over the display rules above (same fix as the modals). */
.auth-gate[hidden] { display: none; }
.auth-card form[hidden] { display: none; }

/* App layout / sidebar --------------------------------------------------- */
.app-layout { display: flex; min-height: 100vh; }
.side-backdrop { display: none; }
.sidebar {
  width: 224px; flex: none; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
  transition: width .15s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; }
.sidebar-brand .brand-mark { font-size: 26px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; padding: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 13px; border: none; background: none;
  border-radius: 10px; font: inherit; font-weight: 600; font-size: 14.5px; color: var(--muted);
  text-align: left; cursor: pointer; white-space: nowrap; width: 100%;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.ni-icon { font-size: 17px; width: 22px; text-align: center; flex: none; }
.sidebar-foot { margin-top: auto; padding: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hamburger { display: none; width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 18px; cursor: pointer; }

.app-layout.collapsed .sidebar { width: 66px; }
.app-layout.collapsed .ni-label, .app-layout.collapsed .sb-name { display: none; }
.app-layout.collapsed .sidebar-brand { justify-content: center; padding: 18px 0 14px; }
.app-layout.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.app-layout.collapsed .side-collapse .ni-icon { transform: rotate(180deg); }

@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .app-layout.side-open .sidebar { transform: none; }
  .app-layout.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 39; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
}

/* Top bar ---------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.status-seg button { padding: 7px 11px; font-size: 12.5px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; }
.brand-name { font-weight: 800; font-size: 21px; letter-spacing: -.02em; }
.brand-accent {
  background: linear-gradient(90deg, var(--brand), #db2777);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-style: italic;
}
.brand-sub { font-size: 12.5px; color: var(--muted); }
.child-picker { display: flex; align-items: center; gap: 8px; }
.child-picker select {
  font: inherit; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-width: 160px;
}
.year-select { min-width: 110px !important; font-weight: 600; color: var(--brand); background: var(--brand-soft); border-color: transparent !important; }
.pupil-name { font-weight: 700; font-size: 15px; padding: 0 4px; white-space: nowrap; }

/* Segmented toggle (planner list/month) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 8px 14px; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--brand); color: #fff; }

/* Lesson objective filter row + inline new-objective */
.obj-filter-row { display: flex; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.obj-filter-row select, .obj-filter-row input { flex: 1; min-width: 120px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; margin: 0 !important; }
.new-obj-inline { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; padding: 10px; background: var(--brand-soft); border-radius: 10px; }
.new-obj-inline input { flex: 1; min-width: 110px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; margin: 0 !important; }
.co-hint { padding: 14px 6px; text-align: center; color: var(--muted); font-size: 13px; }
.stage-mini { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 0 6px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.co-count { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 2px 4px 6px; }
.co-legend { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--muted); margin: 4px 2px 8px; flex-wrap: wrap; }
.co-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.lesson-sel-objs { display: flex; flex-direction: column; gap: 6px; }
.lesson-sel-objs .obj { box-shadow: none; }
.lesson-sel-objs .obj-detail textarea { background: #fff; }
/* In the narrow modal, stack each row: full-width text on top, status below. */
.lesson-sel-objs .obj-main { flex-wrap: wrap; align-items: center; }
.lesson-sel-objs .obj-text { flex: 1 1 100%; order: -1; padding-top: 0; margin-bottom: 8px; line-height: 1.4; }

/* Lesson status control (card + calendar) */
.lesson-status { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-weight: 600; font-size: 12.5px; }
.lesson-status[data-s="complete"] { color: var(--mastered); border-color: var(--mastered); }
.lesson-status[data-s="revisit"] { color: var(--working); border-color: var(--working); }
.cal-lesson.revisit { background: #fff7ed; border-left-color: var(--working); }

/* Monthly calendar */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.cal-head h3 { margin: 0; flex: 1; text-align: center; font-size: 18px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-weekdays span { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  min-height: 92px; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: .12s;
}
.cal-day:hover { border-color: var(--brand); }
.cal-day.other { background: #fafbfc; opacity: .55; }
.cal-day.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.cal-daynum { font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-day.today .cal-daynum { color: var(--brand); }
.cal-lesson {
  font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft); color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--brand);
}
.cal-lesson.done { background: #eafaf0; border-left-color: var(--mastered); color: var(--muted); text-decoration: line-through; }
.cal-lesson.has-note::after { content: ' 📝'; }
.cal-more { font-size: 11px; color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
  .cal-day { min-height: 62px; }
  .cal-lesson { font-size: 10px; }
}
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; font-size: 16px; color: var(--muted);
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* Tabs ------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; background: var(--bg); }
.tab {
  border: none; background: transparent; padding: 10px 18px; border-radius: 10px 10px 0 0;
  color: var(--muted); font-weight: 600; font-size: 15px;
}
.tab.active { background: var(--card); color: var(--brand); box-shadow: 0 -2px 0 var(--brand) inset; }

main { max-width: 980px; margin: 0 auto; padding: 22px; }
.view { display: none; }
.view.active { display: block; }

/* Toolbar ---------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar input[type=search] {
  flex: 1 1 220px; min-width: 180px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.active { color: #fff; border-color: transparent; }

.btn {
  border: none; background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-weight: 600; font-size: 14px; transition: .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { background: #fef2f2; color: #dc2626; }

/* Tracker ---------------------------------------------------------------- */
.subject-block { margin-bottom: 26px; }
.subject-head {
  display: flex; align-items: center; gap: 10px; margin: 0 0 6px;
  font-size: 17px; font-weight: 700;
}
.subject-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.subject-count { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.subject-head .subject-tools { margin-left: auto; display: flex; gap: 6px; }
.subject-head .subject-tools button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 4px 10px; font-size: 12.5px; font-weight: 600;
}
.subject-head .subject-tools button:hover { border-color: var(--brand); color: var(--brand); }
.subject-head .subject-tools button.rm:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.strand-row {
  display: flex; align-items: center; gap: 8px; margin: 16px 0 8px 22px;
}
.strand-name {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted);
}
.strand-add {
  border: none; background: none; color: var(--brand); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.strand-add:hover { background: var(--brand-soft); }

.show-hidden { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; cursor: pointer; }
.show-hidden input { cursor: pointer; }
.stage-filter {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; font-weight: 600; color: var(--ink);
}
.lib-stage-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.lib-stage-label select { width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.stage-group-head {
  font-size: 12px; font-weight: 700; color: #fff; background: var(--brand); display: inline-block;
  padding: 2px 10px; border-radius: 999px; margin: 4px 0 8px 22px; letter-spacing: .02em;
}
.obj .stage-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 1px 8px; border-radius: 999px; vertical-align: middle;
}

/* Suppressed / hidden objectives */
.obj.suppressed { opacity: .55; background: #fbfbfd; }
.obj .hidden-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 700; color: var(--muted);
  background: #eef1f6; padding: 1px 8px; border-radius: 999px; vertical-align: middle;
}
.tracker-list { }

.obj {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 8px; box-shadow: var(--shadow);
}
.obj-main { display: flex; align-items: flex-start; gap: 12px; }
.obj-text { flex: 1; padding-top: 3px; }
.obj-text .ev-badge {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 8px;
  font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft);
  padding: 1px 8px; border-radius: 999px; vertical-align: middle;
}
.obj-actions { display: flex; align-items: center; gap: 6px; }

/* 3-state status control */
.status { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.status button {
  border: none; background: #fff; padding: 6px 11px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); border-right: 1px solid var(--line);
}
.status button:last-child { border-right: none; }
.status button.on[data-s="not_started"] { background: var(--not-started); color: #334155; }
.status button.on[data-s="working_on"] { background: var(--working); color: #fff; }
.status button.on[data-s="mastered"] { background: var(--mastered); color: #fff; }

.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; padding: 4px; }
.link-btn:hover { color: var(--brand); }

.obj-detail { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.obj-detail textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font: inherit; resize: vertical;
}
.obj-detail .detail-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.mini-evidence { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mini-thumb {
  width: 66px; height: 66px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line);
  background: #f1f5f9; display: grid; place-items: center; font-size: 24px; cursor: pointer;
}
.status-date { font-size: 12px; color: var(--muted); }

/* Dated notes on an objective ------------------------------------------- */
.notes-log { display: flex; flex-direction: column; gap: 10px; }
.notes-empty { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.note-entry { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; }
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.note-date-lbl { font-size: 12px; font-weight: 700; color: var(--muted); }
.note-head .link-btn { font-size: 12.5px; }
.note-head .note-del { color: var(--muted); }
.note-head .note-del:hover { color: #dc2626; }
.note-text {
  font-size: 14px; line-height: 1.45; white-space: pre-wrap; outline: none;
  border-radius: 6px; padding: 2px 4px; margin: -2px -4px;
}
.note-text:focus { background: var(--brand-soft); }
.note-ev { margin-top: 8px; }
.note-ev:empty { margin-top: 0; }
.add-note { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.add-note .note-input {
  flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font: inherit;
}
.add-note .note-date { border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px; font: inherit; }
.other-ev { margin-top: 12px; }
.other-ev-head { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }

/* Portfolio -------------------------------------------------------------- */
.portfolio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.ev-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.ev-media {
  height: 150px; background: #f1f5f9; display: grid; place-items: center;
  cursor: pointer; overflow: hidden;
}
.ev-media img { width: 100%; height: 100%; object-fit: cover; }
.ev-media .filetype { font-size: 44px; }
.ev-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ev-caption { font-weight: 600; font-size: 14px; }
.ev-meta { font-size: 12px; color: var(--muted); }
.ev-tag {
  align-self: flex-start; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; color: #fff; margin-top: 2px;
}
.ev-card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 12px; }
.ev-card-actions .btn { padding: 6px 10px; font-size: 13px; }
.ev-card-actions [data-act=del] { margin-left: auto; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Progress --------------------------------------------------------------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; }
.report-head h2 { margin: 0; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 22px; }
.summary-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.summary-card .num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.summary-card .label { font-size: 13px; color: var(--muted); }
.subject-progress .subject-row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.subject-row .row-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.subject-row .row-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.bar { height: 12px; border-radius: 999px; background: #eef1f6; overflow: hidden; display: flex; }
.bar span { display: block; height: 100%; }
.bar .b-mastered { background: var(--mastered); }
.bar .b-working { background: var(--working); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

/* Modal ------------------------------------------------------------------ */
.modal, .lightbox {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
/* The [hidden] attribute must win over the display:grid above, otherwise
   every modal shows on load and covers the whole app. */
.modal[hidden], .lightbox[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: 16px; padding: 22px; width: min(460px, 100%);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
/* The lesson modal embeds full tracker rows, so give it more room. */
#lessonModal .modal-card { width: min(580px, 100%); max-height: 92vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; color: var(--ink);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.lightbox-body { max-width: 90vw; max-height: 85vh; }
.lightbox-body img, .lightbox-body video { max-width: 90vw; max-height: 85vh; border-radius: 8px; }
.lightbox-body iframe { width: 90vw; height: 85vh; border: none; background: #fff; border-radius: 8px; }
.lightbox-close {
  position: absolute; top: 18px; right: 22px; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 20px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 80; box-shadow: var(--shadow);
}

/* Home / dashboard ------------------------------------------------------- */
.dash-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, var(--brand), #6366f1); color: #fff;
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.dash-hero h2 { margin: 0 0 4px; font-size: 22px; }
.dash-hero .muted { color: rgba(255,255,255,.85); }
.dash-ring {
  width: 88px; height: 88px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; color: #fff;
  background: conic-gradient(#fff var(--pct,0%), rgba(255,255,255,.25) 0);
}
.dash-ring::after {
  content: attr(data-label); position: absolute; width: 66px; height: 66px; border-radius: 50%;
  background: rgba(0,0,0,.12); display: grid; place-items: center;
}
.dash-ring span { position: relative; z-index: 1; }

.dash-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.action-tile {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid var(--line);
  background: var(--card); border-radius: var(--radius); font-weight: 600; font-size: 14px;
  color: var(--ink); box-shadow: var(--shadow); transition: .15s; text-align: left;
}
.action-tile:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.action-tile span { font-size: 20px; width: 30px; height: 30px; display: grid; place-items: center; background: var(--brand-soft); border-radius: 8px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dash-grid .dash-panel:first-child { grid-column: 1 / -1; }
.dash-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.dash-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dash-panel-head h3 { margin: 0; font-size: 15px; }
.dash-hero-right { display: flex; align-items: center; gap: 14px; }
.dash-subject { border-bottom: 1px solid var(--line); }
.dash-subject:last-child { border-bottom: none; }
.dash-subject-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; border-radius: 8px; }
.dash-subject-row:hover { background: var(--brand-soft); }
.dash-subject-row .caret { color: var(--muted); font-size: 11px; width: 12px; }
.dash-subject-row .nm { flex: 1; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dash-subject-detail { padding: 4px 0 12px 22px; }
.dash-subject-row .bar { flex: 1.4; }
.dash-subject-row .pct { font-size: 12.5px; color: var(--muted); width: 60px; text-align: right; }
.dash-evidence { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-evidence .mini-thumb { width: 58px; height: 58px; }
.dash-empty { color: var(--muted); font-size: 13.5px; padding: 6px 0; }
.dash-lesson { display: flex; gap: 9px; align-items: baseline; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.dash-lesson:last-child { border-bottom: none; }
.dash-lesson .d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dash-lesson .t { flex: 1; }
.dash-lesson.done .t { text-decoration: line-through; color: var(--muted); }

@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .dash-panel:first-child { grid-column: auto; }
}

/* Settings modal --------------------------------------------------------- */
.settings-row {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.settings-row .btn { flex: none; text-decoration: none; }
.settings-row strong { display: block; }
.settings-row .muted { font-size: 12.5px; }
.danger-zone strong { color: #dc2626; }

/* Curriculum library ----------------------------------------------------- */
.library-list { max-height: 55vh; overflow-y: auto; margin: 4px -4px; }
.library-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 8px;
  border-bottom: 1px solid var(--line);
}
.library-item .lib-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex: 1; }
.library-item .lib-count { font-size: 12.5px; color: var(--muted); }
.library-item .badge-in { font-size: 12px; color: var(--mastered); font-weight: 600; }

/* Planner ---------------------------------------------------------------- */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: flex-start;
}
.lesson-card.done { opacity: .62; }
.lesson-check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  background: #fff; flex: none; display: grid; place-items: center; font-size: 15px; color: #fff;
}
.lesson-check.on { background: var(--mastered); border-color: var(--mastered); }
.lesson-body { flex: 1; }
.lesson-title { font-weight: 700; font-size: 15.5px; }
.lesson-card.done .lesson-title { text-decoration: line-through; }
.lesson-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lesson-subject-tag { color: #fff; padding: 1px 9px; border-radius: 999px; font-weight: 600; font-size: 11.5px; }
.lesson-notes { margin-top: 8px; font-size: 14px; white-space: pre-wrap; }
.lesson-objs { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.lesson-obj-link {
  font-size: 13px; color: var(--ink); background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; cursor: pointer; display: flex; gap: 7px; align-items: center;
}
.lesson-obj-link:hover { border-color: var(--brand); }
.lesson-obj-link .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.lesson-actions { display: flex; flex-direction: column; gap: 6px; }

.field-row { display: flex; gap: 10px; }
.obj-checklist {
  max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; margin-top: 5px; font-weight: 400;
}
.obj-search { margin-bottom: 6px !important; }
.co-empty { padding: 10px 5px; font-size: 13px; color: var(--muted); text-align: center; }
.obj-checklist .co { display: flex; gap: 8px; align-items: flex-start; padding: 4px 5px; font-size: 13px; color: var(--ink); }
.obj-checklist .co input { width: auto; margin: 3px 0 0; }
.obj-checklist optgroup { font-weight: 700; }
.co-subject { font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 5px 3px; }

/* Progress — mastered objectives with evidence --------------------------- */
.subject-row .row-title { cursor: pointer; }
.mastered-detail { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.mastered-obj { padding: 7px 0; border-bottom: 1px solid var(--line); }
.mastered-obj:last-child { border-bottom: none; }
.mastered-obj .mo-text { font-size: 13.5px; display: flex; gap: 7px; align-items: baseline; }
.mastered-obj .mo-text .tick { color: var(--mastered); }
.mastered-obj .mo-evidence { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 0 20px; }
.no-print-note { }

@media (max-width: 600px) {
  .obj-main { flex-wrap: wrap; }
  .brand-sub { display: none; }
}

/* Print ------------------------------------------------------------------ */
@media print {
  .topbar, .sidebar, .no-print, .toolbar, .dash-actions { display: none !important; }
  body { background: #fff; }
  .view { display: none !important; }
  #view-home { display: block !important; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-subject-detail { display: block !important; }
  .summary-card, .dash-panel, .dash-subject { box-shadow: none; break-inside: avoid; }
}
