/* Doorpost — direction A "Lintel". Evergreen doorframe, warm page, ink text.
   Bricolage Grotesque for display, Instrument Sans for everything else. */

:root {
  --evergreen: #0F6B5C;
  --evergreen-deep: #0A4A40;
  --evergreen-soft: #E3F1EC;
  --ink: #10201C;
  --ink-2: #33403C;
  --ink-3: #46524E;
  --lamp: #E8A33D;
  --lamp-soft: #FFF4DF;
  --lamp-ink: #5C4310;
  --mist: #EEF1EC;
  --mist-2: #F6F8F5;
  --line: #D5DBD3;
  --line-2: #E6EAE4;
  --line-3: #B9C2B8;
  --page: #FBFBF8;
  --white: #FFFFFF;
  --red: #9E3F24;
  --red-soft: #FBE9E3;
  --accent: var(--evergreen);
  --accent-deep: var(--evergreen-deep);
  --display: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --body: 'Instrument Sans', 'Segoe UI', sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--page); text-wrap: pretty; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-deep); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.display { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
h1.display { font-size: 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.mt-0 { margin-top: 0 !important; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.grow { flex-grow: 1; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .span-2 { grid-column: span 1; } }

/* ---- wordmark ---- */
.wordmark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark span { font-family: var(--display); font-weight: 700; letter-spacing: -0.03em; font-size: 24px; }
.wordmark svg { width: 30px; height: 30px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.btn.secondary { background: var(--white); color: var(--ink); border-color: var(--line-3); }
.btn.secondary:hover { background: var(--mist); color: var(--ink); border-color: var(--line-3); }
.btn.ink { background: var(--ink); border-color: var(--ink); }
.btn.ink:hover { background: #000; }
.btn.lamp { background: var(--lamp); border-color: var(--lamp); color: #2A1E05; }
.btn.danger { background: var(--white); color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-soft); color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn.ghost:hover { background: var(--mist); color: var(--accent-deep); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.lg { min-height: 56px; padding: 0 28px; font-size: 18px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.white { background: var(--white); color: var(--ink); border-color: var(--white); }

/* ---- pills / badges ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--evergreen-soft); color: var(--evergreen-deep); }
.pill.lamp { background: var(--lamp-soft); color: var(--lamp-ink); }
.pill.ink { background: var(--ink); color: #fff; }
.pill.grey { background: var(--mist); color: var(--ink-3); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gold { background: var(--lamp); color: #2A1E05; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- cards ---- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.card.mist { background: var(--mist); border-color: transparent; }
.card.ink { background: var(--ink); color: #F4F6F2; border-color: var(--ink); }
.card.ink .muted { color: #C9D2CC; }
.card.ink a { color: #fff; }
.card.lamp { background: var(--lamp-soft); border-color: transparent; }
.card-title { font-size: 18px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.stat { font-family: var(--display); font-size: 48px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat.sm { font-size: 30px; }
.tile { padding: 16px; border-radius: 12px; background: var(--mist-2); }
.tile.lamp { background: var(--lamp-soft); color: var(--lamp-ink); }
.tile.green { background: var(--evergreen-soft); color: var(--evergreen-deep); }

/* ---- lists ---- */
.list { display: flex; flex-direction: column; }
.list > .item { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.list > .item:first-child { border-top: 0; }
.list > .item .body { flex-grow: 1; min-width: 0; }
.list > .item .title { font-weight: 600; font-size: 15px; }
.list > .item .detail { font-size: 14px; color: var(--ink-3); }
.list.linked > .item { padding: 0; }
.list.linked > .item > a { display: flex; align-items: center; gap: 16px; padding: 14px 0; width: 100%; color: inherit; text-decoration: none; }
.list.linked > .item > a:hover .title { color: var(--accent); }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: var(--evergreen-soft); color: var(--evergreen-deep); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }

/* ---- spine rows (admin tables) ---- */
.spine { display: flex; flex-direction: column; gap: 8px; }
.spine-row { display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: var(--white); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 12px; color: inherit; text-decoration: none; }
.spine-row:hover { border-color: var(--line-3); border-left-color: var(--accent-deep); }
.spine-row.lamp { border-left-color: var(--lamp); }
.spine-row.grey { border-left-color: var(--line-3); }
.spine-row.red { border-left-color: var(--red); }
.spine-row.ink { border-left-color: var(--ink); }
.spine-row .body { flex-grow: 1; min-width: 0; }
.spine-row .title { font-weight: 600; }
.spine-row .detail { font-size: 14px; color: var(--ink-3); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; background: var(--mist-2); }
table.data tr:hover td { background: var(--mist-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data input.cell { width: 72px; padding: 6px 8px; border: 1px solid var(--line-3); border-radius: 6px; text-align: right; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--ink-3); }
.field .from-record { font-size: 12px; color: var(--evergreen-deep); font-weight: 600; }
.field .confirm { font-size: 12px; color: var(--lamp-ink); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-3); border-radius: var(--radius-sm); background: var(--white); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(15,107,92,.35); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 44px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 44px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: 18px; font-weight: 600; padding: 0; margin-bottom: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--line-3); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button, .segmented a { min-height: 44px; padding: 0 16px; border: 0; background: var(--white); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.segmented .on { background: var(--ink); color: #fff; }
.segmented .on.present { background: var(--accent); }
.segmented .on.tardy { background: var(--lamp); color: #2A1E05; }
.segmented .on.absent { background: var(--ink); }
.toggle { position: relative; width: 52px; height: 30px; border-radius: 999px; background: #7C8A83; border: 0; padding: 3px; cursor: pointer; display: inline-flex; align-items: center; justify-content: flex-start; flex-shrink: 0; }
.toggle span { width: 24px; height: 24px; border-radius: 999px; background: #fff; display: block; }
.toggle[aria-checked=true] { background: var(--accent); justify-content: flex-end; }
.toggle[disabled] { opacity: .45; cursor: not-allowed; }

/* ---- flash ---- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 15px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: var(--evergreen-soft); color: var(--evergreen-deep); }
.flash.warn { background: var(--lamp-soft); color: var(--lamp-ink); }
.flash.error { background: var(--red-soft); color: var(--red); }

/* ---- progress bar ---- */
.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--mist); }
.bar > span { display: block; height: 100%; }

/* ---- public site ---- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0; }
.site-nav { display: flex; align-items: center; gap: 28px; font-weight: 500; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 12px 0; border-bottom: 2px solid transparent; }
.site-nav a.on { border-bottom-color: var(--accent); }
.site-nav .btn { padding: 0 20px; border-bottom: 0; color: #fff; }
.container { width: min(1200px, 100% - 32px); margin: 0 auto; }
.narrow { width: min(720px, 100% - 32px); margin: 0 auto; }
section.band { padding: 80px 0; }
section.band.mist { background: var(--mist); }
section.band.ink { background: var(--ink); color: #F4F6F2; }
section.band.green { background: var(--evergreen); color: #fff; }
section.band.tight { padding: 48px 0; }
.hero h1 { font-size: clamp(38px, 6vw, 64px); line-height: 1.04; letter-spacing: -0.035em; }
.hero p.lead { font-size: 20px; line-height: 1.55; color: var(--ink-2); max-width: 560px; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
h2.section { font-size: clamp(30px, 4vw, 44px); letter-spacing: -0.03em; line-height: 1.08; }
.site-footer { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 40px 0; font-size: 15px; color: var(--ink-3); flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 20px; }
.site-footer a { color: var(--ink-3); text-decoration: none; }
.step-num { font-family: var(--display); font-size: 40px; font-weight: 700; color: var(--accent); line-height: 1; }
.quote { font-family: var(--display); font-size: 28px; font-weight: 600; line-height: 1.3; }
@media (max-width: 760px) { .site-nav { gap: 14px; font-size: 14px; } .site-nav a.hide-sm { display: none; } section.band { padding: 56px 0; } }
.burger { display: none; }

/* ---- app shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; flex-shrink: 0; background: var(--ink); color: #F4F6F2; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .school { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.sidebar .school .name { font-weight: 600; font-size: 15px; line-height: 1.2; }
.sidebar .school .sub { font-size: 12px; color: #C9D2CC; }
.sidebar .crest { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; font-size: 15px; font-weight: 500; }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #C9D2CC; text-decoration: none; }
.sidebar nav a:hover { background: #1B2B26; color: #fff; }
.sidebar nav a.on { background: #24362F; color: #fff; }
.sidebar nav .group { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7C8A83; padding: 14px 12px 4px; }
.sidebar nav .count { background: var(--lamp); color: #2A1E05; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; }
.sidebar .foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: #C9D2CC; display: flex; flex-direction: column; gap: 8px; }
.sidebar .foot a { color: #C9D2CC; }
.main { flex-grow: 1; min-width: 0; padding: 32px 40px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; }
.page-head .sub { color: var(--ink-3); font-size: 15px; margin-top: 4px; }
.topbar { display: none; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; width: 280px; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar .burger { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; background: transparent; border: 0; color: #fff; }
  .main { padding: 20px 16px 96px; }
  .page-head h1 { font-size: 26px; }
}

/* ---- family (mobile-first) ---- */
.family .main { max-width: 760px; margin: 0 auto; }
.tabbar { display: none; }
@media (max-width: 900px) {
  .family .sidebar { display: none; }
  .family .topbar { background: var(--white); color: var(--ink); border-bottom: 1px solid var(--line-2); }
  .family .topbar .burger { display: none; }
  .tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--white); border-top: 1px solid var(--line-2); z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; font-size: 11px; font-weight: 600; color: var(--ink-3); text-decoration: none; min-height: 56px; }
  .tabbar a.on { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
}
.hero-card { background: var(--accent); color: #fff; border-radius: 16px; padding: 20px; }
.hero-card .btn.white { margin-top: 12px; }
.student-card { display: flex; gap: 14px; align-items: flex-start; }

/* ---- attendance ---- */
.att-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.att-row .name { font-weight: 600; }
.att-row .note { font-size: 13px; color: var(--ink-3); }
.att-row .segmented { margin-left: auto; }
@media (max-width: 640px) { .att-row { flex-wrap: wrap; } .att-row .segmented { margin-left: 0; width: 100%; } .att-row .segmented button { flex: 1; } }

/* ---- gradebook grid ---- */
.gradebook { overflow-x: auto; }
.gradebook table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.gradebook th, .gradebook td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.gradebook th.sticky, .gradebook td.sticky { position: sticky; left: 0; background: var(--white); z-index: 1; min-width: 160px; }
.gradebook th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); background: var(--mist-2); vertical-align: bottom; }
.gradebook th a { color: var(--ink); text-decoration: none; }
.gradebook input { width: 64px; padding: 6px; border: 1px solid var(--line-3); border-radius: 6px; text-align: right; }
.gradebook td.mark { font-weight: 700; text-align: right; }

/* ---- print ---- */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .tabbar, .no-print, .flash { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
  .print-only { display: block; }
}

/* ---- misc ---- */
.kbd { font-family: ui-monospace, monospace; font-size: 13px; background: var(--mist); padding: 2px 6px; border-radius: 4px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre { background: var(--mist-2); padding: 14px; border-radius: 10px; overflow-x: auto; }
.divider { border: 0; border-top: 1px solid var(--line-2); margin: 20px 0; }
.empty { padding: 32px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line-3); border-radius: 12px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline .t { display: flex; gap: 14px; align-items: baseline; }
.timeline .t .when { font-weight: 600; min-width: 56px; }
details summary { cursor: pointer; font-weight: 600; }
.calendar-day { display: flex; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.calendar-day .date { min-width: 64px; font-weight: 600; }
.step-dots { display: flex; gap: 6px; }
.step-dots span { width: 28px; height: 6px; border-radius: 3px; background: var(--line); }
.step-dots span.on { background: var(--accent); }
