:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --ink: #1d2433;
  --ink-2: #4a5263;
  --muted: #6b7280;
  --line: #e2e0da;
  --line-strong: #cfccc4;
  --brand: #365f91;          /* the faculty template's heading blue */
  --brand-ink: #ffffff;
  --brand-soft: #e8eef6;
  --focus: #2f6fd6;
  --good: #2e7d4f;
  --warn: #9a6200;
  --bad: #b3261e;
  --ai: #6b4fbb;
  --ai-soft: #f1edfb;
  --music: #365f91; --va: #a14a2a; --drama: #7a2e6b; --pdm: #2c6e6a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 4px 16px rgba(20, 24, 33, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --surface: #1c2028; --surface-2: #232833; --ink: #e8eaf0; --ink-2: #c3c8d4; --muted: #9098a8;
    --line: #2d3340; --line-strong: #3b4252; --brand: #7ea6dc; --brand-ink: #0f1520; --brand-soft: #22324a;
    --ai: #b49cf2; --ai-soft: #2a2442; --music: #7ea6dc; --va: #e09a7b; --drama: #d18cc3; --pdm: #7cc4bf;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
a { color: var(--brand); }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 24px 0; }
.err { color: var(--bad); }
.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; color: var(--ink-2); }

/* buttons */
.btn {
  font: inherit; font-weight: 550; font-size: .92rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: .84rem; }
.btn.ai { border-color: color-mix(in srgb, var(--ai) 35%, transparent); color: var(--ai); background: var(--ai-soft); }
.btn.ai:hover { border-color: var(--ai); }
.spark { font-size: .8em; }
.icon-btn {
  font: inherit; cursor: pointer; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 1rem;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--bad); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link-quiet { font: inherit; background: none; border: 0; padding: 0; color: var(--ink-2); cursor: pointer; text-decoration: none; font-size: .88rem; }
.link-quiet:hover { color: var(--brand); text-decoration: underline; }

/* gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 10px;
}
.gate-card h1 { color: var(--brand); }
.gate-card label { font-weight: 600; font-size: .9rem; margin-top: 6px; }

/* inputs */
input[type=text], input[type=url], input[type=number], input[type=password], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.45; min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--ink-2); cursor: pointer; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 5px 6px; border: 2px solid var(--brand-ink); border-radius: 2px; border-right-width: 0; border-left-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.save-state { font-size: .84rem; color: var(--muted); min-width: 7em; text-align: right; }
.save-state.bad { color: var(--bad); }

/* list */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }
.list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.list-head p { margin: 6px 0 0; }
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .86rem; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.group-head { margin: 26px 0 10px; font-size: .95rem; color: var(--muted); font-weight: 650; letter-spacing: .02em; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card-main { padding: 14px 16px 10px; color: inherit; text-decoration: none; flex: 1; }
.card-main h3 { font-size: 1.05rem; margin: 8px 0 4px; }
.card-main p { margin: 0; font-size: .9rem; }
.card-meta { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line); }
.card-actions { display: flex; gap: 12px; }
.empty { text-align: center; padding: 56px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 14px; margin-top: 16px; }
.empty p { color: var(--ink-2); max-width: 46ch; margin: 10px auto 18px; }

.subj { font-size: .75rem; font-weight: 650; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; color: var(--music); background: color-mix(in srgb, currentColor 11%, transparent); }
.subj-visual-arts { color: var(--va); } .subj-drama { color: var(--drama); } .subj-pdm { color: var(--pdm); }
.status { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.status-submitted { background: #fff3d6; color: var(--warn); }
.status-registered { background: #e3f3e8; color: var(--good); }
.status-evaluated { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) {
  .status-submitted { background: #3a2f12; } .status-registered { background: #183324; }
}
.status-select { width: auto; padding: 6px 8px; font-size: .86rem; font-weight: 600; }
.badge { display: inline-block; margin-left: 6px; font-size: .7rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #fff3d6; color: var(--warn); vertical-align: 1px; }
@media (prefers-color-scheme: dark) { .badge { background: #3a2f12; } }

/* editor */
.ed-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.side { position: sticky; top: 64px; align-self: start; padding: 24px 0; }
.side .back { display: inline-block; font-size: .88rem; text-decoration: none; margin-bottom: 14px; color: var(--ink-2); }
.side ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.side li a { display: block; padding: 5px 12px; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; font-size: .92rem; }
.side li a:hover { color: var(--brand); border-left-color: var(--brand); }
.editor { padding: 24px 0 120px; min-width: 0; }
.ed-head { margin-bottom: 18px; }
.ed-head h1 { margin: 8px 0 4px; }
.ed-head p { margin: 0; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 20px; margin-bottom: 14px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h2 { color: var(--brand); }
.sec-tools { display: flex; align-items: center; gap: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.span2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lbl { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.hint { font-size: .78rem; color: var(--muted); }
.mini { font-size: .9rem; margin: 18px 0 8px; color: var(--ink-2); }
.row-inline { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.row-inline .grow { flex: 1; }
.code-in { width: 120px !important; flex: none; }

.bank { display: grid; gap: 2px; }
.bank > p { margin: 0 0 6px; }
.outcome { display: grid; grid-template-columns: auto 104px 1fr; gap: 10px; align-items: start; padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: .93rem; }
.outcome:hover { background: var(--surface-2); }
.outcome input { margin-top: 4px; }
.outcome .code { font-weight: 700; font-variant-numeric: tabular-nums; font-size: .86rem; padding-top: 1px; }

.assess { display: grid; gap: 6px; }
.assess-row { display: grid; grid-template-columns: 1.4fr 1.4fr 1fr 64px 30px; gap: 8px; align-items: center; }
.assess-headrow { font-size: .78rem; font-weight: 650; color: var(--muted); }
.assess > .btn { justify-self: start; margin-top: 4px; }

.weeks { display: grid; gap: 8px; margin: 10px 0 12px; }
.week { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.week[open] { border-color: var(--line-strong); box-shadow: var(--shadow); }
.week summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; }
.week summary::-webkit-details-marker { display: none; }
.week summary::before { content: "▸"; color: var(--muted); font-size: .8rem; margin-right: -2px; transition: transform .15s; }
.week[open] summary::before { transform: rotate(90deg); }
.week-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-tools { display: flex; gap: 2px; align-items: center; }
.week-tools .btn { margin-right: 6px; }
.week-body { padding: 4px 14px 16px; border-top: 1px solid var(--line); padding-top: 14px; }

/* dialogs */
.dlg { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(560px, calc(100vw - 32px)); }
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(20, 24, 33, .45); }
.dlg-inner { padding: 22px; display: grid; gap: 14px; max-height: calc(100vh - 40px); overflow: auto; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -22px; background: var(--surface); padding: 10px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; }
.subject-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 5px; }
.subject-opt { font: inherit; font-weight: 600; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--music); cursor: pointer; text-align: left; }
.subject-opt.on { border-color: currentColor; background: color-mix(in srgb, currentColor 9%, var(--surface)); }
.versions { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.versions li { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }

.suggest { display: grid; gap: 10px; }
.suggest > p { margin: 0; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--ai); padding: 14px; background: var(--ai-soft); border-radius: 10px; }
.dots { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dots { animation: none; } * { transition: none !important; } }
.sug-list { display: grid; gap: 8px; }
.sug-all { font-size: .85rem; color: var(--muted); }
.sug-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.sug-item:has(input:checked) { border-color: color-mix(in srgb, var(--ai) 50%, transparent); background: var(--ai-soft); }
.sug-item input { margin-top: 4px; }
.sug-label { font-weight: 650; font-size: .9rem; margin-bottom: 3px; }
.sug-text { white-space: pre-wrap; font-size: .9rem; color: var(--ink-2); }
.sug-weeks { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.sug-weeks .sug-text { max-height: 4.5em; overflow: hidden; }
.modes { border: 0; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; transition: opacity .4s, transform .4s; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translate(-50%, 8px); }

@media (max-width: 860px) {
  .ed-layout { grid-template-columns: 1fr; padding: 0 16px; }
  .side { display: none; }
  .grid { grid-template-columns: 1fr; }
  .assess-row { grid-template-columns: 1fr 1fr; }
  .assess-headrow { display: none; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 16px; }
  .page { padding: 20px 16px 60px; }
  .save-state { display: none; }
}
.sug-block { display: block; cursor: default; }
.sug-block .modes { margin: 8px 0 8px 22px; }
.sug-block .sug-weeks { margin-left: 22px; }
.note { white-space: pre-line; }
.note strong { color: var(--ink); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.head-actions.center { justify-content: center; }
