/* ────────────────────────────────────────────────────────────
   School Atlas — design system (v2)
   Warm printed-paper workspace · ink-hard borders · vermilion
   accent · editorial serif display · Unpoly drawer sheets

   Direction: the Fizzy/Hey family — a warm paper canvas, a dark
   ink top bar, squared controls with offset "sticker" shadows,
   and right-side sheets for focused entry work.
   ──────────────────────────────────────────────────────────── */

:root {
  /* canvas — warm paper, not gray */
  --paper: #f5f0e4;
  --paper-2: #ede6d4;
  --card: #fffdf6;
  --card-2: #faf6ea;

  /* ink — warm near-black */
  --ink: #221e16;
  --ink-2: #4c463a;
  --muted: #7d7563;
  --faint: #a89f89;

  /* lines — hard, ink-tinted */
  --line: #ddd4bf;
  --line-strong: #b3a98e;

  /* brand accent — vermilion */
  --accent: #e0491c;
  --accent-strong: #c13a11;
  --accent-wash: #fbe9df;
  --accent-soft: #f6d5c4;

  /* secondary state colors */
  --live: #1d7a45;
  --live-wash: #e4f2e8;
  --draft: #9a6508;
  --draft-wash: #f8ecd2;
  --review: #c2311c;
  --review-wash: #f9e3dd;

  /* top nav — warm ink bar */
  --nav: #262119;
  --nav-2: #332c20;
  --nav-line: rgba(245, 240, 228, .12);
  --nav-text: #b7ac93;
  --nav-text-strong: #f7f2e5;

  /* elevation */
  --shadow-sm: 2px 2px 0 rgba(34, 30, 22, .1);
  --shadow: 4px 4px 0 rgba(34, 30, 22, .14);
  --shadow-lg: 8px 8px 0 rgba(34, 30, 22, .16);
  --focus: 0 0 0 3px rgba(224, 73, 28, .24);

  --radius: 2px;
  --radius-lg: 3px;

  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; min-width: 320px; background: var(--paper); }
a { color: inherit; }
button, input, textarea { font: inherit; }
::selection { background: var(--accent-soft); }

/* Serif display for titles, brand, and headline numbers */
.brand-name, .page-intro h1, .panel-heading h2, .section-heading h2,
.stat-item strong, .empty-state h2, .lesson-hero h2, .sheet-title,
.access-page h1, .year-choice strong, .cell-title, .unit-label strong {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* ── Unpoly runtime chrome ─────────────────────────────── */

up-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999999;
  height: 3px;
  background-color: var(--accent);
}

@keyframes move-from-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes move-to-right { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes move-from-left { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes move-to-left { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

/* ── Sheet (Unpoly drawer) ─────────────────────────────── */

up-drawer { z-index: 2000; position: fixed; inset: 0; }
up-drawer-backdrop { position: absolute; inset: 0; background: rgba(34, 30, 22, .5); }
up-drawer-viewport {
  position: absolute; inset: 0;
  display: flex; justify-content: flex-end;
  overflow: hidden;
}
up-drawer[position=right] up-drawer-viewport { justify-content: flex-end; }
up-drawer[position=left] up-drawer-viewport { justify-content: flex-start; }

up-drawer-box {
  position: relative;
  width: min(700px, 100%);
  min-height: 100vh;
  max-width: 100%;
  padding: 0;
  background: var(--paper);
  border-left: 2px solid var(--ink);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
up-drawer[nesting="1"] up-drawer-box { width: min(600px, 96%); border-left-color: var(--accent); }
up-drawer[nesting="2"] up-drawer-box { width: min(540px, 96%); }

up-drawer-dismiss {
  position: absolute; top: 18px; right: 20px; z-index: 5;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-size: 15px; line-height: 1;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(34, 30, 22, .12);
}
up-drawer-dismiss:hover { background: var(--accent); color: #fff; }

/* Sheet document (server-rendered body inside the drawer) */

.sheet { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 100vh; }

.sheet-head {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 26px 32px 20px;
  background: var(--card);
  border-bottom: 2px solid var(--ink);
}
.sheet-head-copy { min-width: 0; padding-right: 44px; }
.sheet-title {
  margin: 8px 0 0;
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1;
  color: var(--ink);
}
.sheet-sub { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.sheet-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.sheet-main { display: grid; align-content: start; gap: 26px; padding: 24px 32px 96px; min-width: 0; }
.sheet-main .page-feedback { margin: 0 0 2px; }
.sheet-main .panel-heading { margin-bottom: 14px; }
.sheet-main form { max-width: none; }

/* ── Shell: top nav ────────────────────────────────────── */

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: stretch; gap: 8px;
  height: 58px;
  padding: 0 20px;
  background: var(--nav);
  border-bottom: 2px solid #000;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 10px 0 4px;
  text-decoration: none;
  color: var(--nav-text-strong);
}
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--accent);
  color: #fff;
  border: 2px solid #000;
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .45);
  font-size: 13px; font-weight: 800; letter-spacing: -.02em;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-sub { display: block; color: var(--nav-text); font-size: 9px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; margin-top: -2px; }

.top-nav {
  display: flex; align-items: stretch; gap: 2px;
  margin-left: 14px;
  min-width: 0; flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }

.top-link {
  position: relative;
  display: flex; align-items: center;
  padding: 0 14px;
  color: var(--nav-text);
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: color .14s ease, background .14s ease;
}
.top-link svg { margin-right: 7px; opacity: .8; }
.top-link:hover { color: var(--nav-text-strong); background: var(--nav-2); }
.top-link.active { color: var(--nav-text-strong); background: var(--nav-2); }
.top-link.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px;
  background: var(--accent);
}

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }

.context-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  color: var(--nav-text-strong);
  background: var(--nav-2);
  border: 1px solid var(--nav-line);
  border-radius: var(--radius);
  font-size: 12px; font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.context-pill:hover { border-color: var(--accent); }
.context-pill .pill-kicker { color: var(--nav-text); font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.user-chip { display: inline-flex; align-items: center; gap: 9px; padding-left: 4px; color: var(--nav-text); font-size: 12.5px; font-weight: 600; }
.user-chip strong { color: var(--nav-text-strong); font-weight: 700; }

.avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  background: var(--accent-wash); color: var(--accent-strong);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 11px; font-weight: 800;
}

/* ── Context strip ─────────────────────────────────────── */

.context-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 9px 32px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line-strong);
}
.context-path { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.context-path strong { color: var(--ink); font-weight: 750; }
.context-separator { color: var(--faint); }
.context-switch { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.context-switch-link { color: var(--accent); text-decoration: none; }
.context-switch-link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* ── Workspace & page ──────────────────────────────────── */

.workspace { min-width: 0; }

.page-content { max-width: 1340px; margin: 0 auto; padding: 34px 40px 110px; animation: page-rise .28s cubic-bezier(.22, .61, .36, 1) both; }

@keyframes page-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-size: 10.5px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 16px; height: 3px; background: var(--accent); }

.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.page-intro h1 {
  max-width: 780px; margin: 12px 0 0;
  font-size: clamp(30px, 3.2vw, 42px);
  font-weight: 700; letter-spacing: -.025em; line-height: 1.05;
  color: var(--ink);
}
.intro-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding-bottom: 4px; }
.intro-actions form { display: inline-flex; max-width: none; padding: 0; }

.page-feedback { min-height: 0; margin: -12px 0 22px; }
.page-content-lower { display: grid; gap: 40px; }
.page-content-lower > * { min-width: 0; }

/* ── Links & buttons (squared, hard-edged) ─────────────── */

.text-link, .quiet-link { color: var(--accent); text-decoration: none; }
.text-link:hover, .quiet-link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.quiet-link { font-size: 13px; font-weight: 750; }

.primary-link, .secondary-link, .table-action {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 750; text-decoration: none; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .12s ease, box-shadow .12s ease;
}

.primary-link {
  padding: 10px 16px;
  color: #fff; background: var(--accent);
  border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .22);
}
.primary-link:hover { background: var(--accent-strong); box-shadow: 1px 1px 0 rgba(34, 30, 22, .22); transform: translate(2px, 2px); }

.secondary-link {
  padding: 9px 14px;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .18);
}
.secondary-link:hover { background: var(--ink); color: var(--card); box-shadow: 1px 1px 0 rgba(34, 30, 22, .18); transform: translate(2px, 2px); }

.table-action { color: var(--accent); font-size: 12.5px; font-weight: 750; }
.table-action:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

.primary-button, .secondary-button, .quiet-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: fit-content; padding: 10px 15px;
  border-radius: var(--radius); font-size: 12.5px; font-weight: 750;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .12s ease, box-shadow .12s ease;
}
.primary-button {
  color: #fff; background: var(--accent);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .22);
}
.primary-button:hover { background: var(--accent-strong); box-shadow: 1px 1px 0 rgba(34, 30, 22, .22); transform: translate(2px, 2px); }
.secondary-button {
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .18);
}
.secondary-button:hover { background: var(--ink); color: var(--card); box-shadow: 1px 1px 0 rgba(34, 30, 22, .18); transform: translate(2px, 2px); }
.quiet-button { padding: 6px 2px; color: var(--accent); background: transparent; border: 0; font-size: 12.5px; }
.quiet-button:hover, .move-action:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
.button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.button-row form { max-width: none; }

/* ── Panels & headings ─────────────────────────────────── */

.panel { min-width: 0; }
.panel-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding: 0 0 14px; margin-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}
.panel-heading h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.panel-heading p { max-width: 640px; margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.panel-heading > a, .panel-heading > .quiet-link { align-self: center; }

.section-heading {
  display: flex; align-items: baseline; justify-content: space-between; gap: 20px;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}
.section-heading h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.section-heading a { color: var(--accent); font-size: 12.5px; font-weight: 750; text-decoration: none; }
.section-heading a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

.section-copy { max-width: 680px; margin: 12px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.6; }

/* ── Stat strips ───────────────────────────────────────── */

.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 0 0 38px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat-item { display: grid; gap: 5px; min-width: 0; padding: 18px 22px; background: var(--card); }
.stat-item + .stat-item { border-left: 2px solid var(--ink); }
.stat-item span {
  overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 800;
  letter-spacing: .12em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap;
}
.stat-item strong { overflow: hidden; font-size: 30px; font-weight: 700; letter-spacing: -.03em; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.stat-item em { overflow: hidden; color: var(--accent); font-size: 12px; font-style: normal; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }

/* ── Tables ────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.table-wrap table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table-wrap th {
  padding: 12px 16px; color: var(--muted);
  font-size: 10px; font-weight: 800; letter-spacing: .12em;
  text-align: left; text-transform: uppercase; white-space: nowrap;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-2);
}
.table-wrap td {
  padding: 14px 16px; color: var(--ink-2); font-size: 13.5px; line-height: 1.45;
  vertical-align: top;
  border-top: 1px solid var(--line);
  transition: background .12s ease;
}
.table-wrap tbody tr:first-child td { border-top: 0; }
.table-wrap tbody tr:hover td { background: var(--accent-wash); }
.table-wrap th:first-child, .table-wrap td:first-child { padding-left: 18px; }
.table-wrap th:last-child, .table-wrap td:last-child { padding-right: 18px; }
.table-wrap td > span:not(.status-chip), .table-primary { display: grid; gap: 3px; }
.table-wrap td strong { color: var(--ink); font-weight: 750; }
.table-wrap td small, .table-primary span, .table-wrap td > span > span { color: var(--muted); font-size: 12.5px; }
.table-primary { color: var(--ink); text-decoration: none; }
.table-primary:hover strong { color: var(--accent-strong); }
.table-action { display: inline-block; margin-right: 14px; }
.table-wrap td form, .objective-row form { display: inline-flex; max-width: none; padding: 0; margin: 0; }
.home-grid > .panel .table-wrap table { min-width: 0; }

/* ── Status tags (squared) ─────────────────────────────── */

.status-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 9px;
  border: 1.5px solid currentColor;
  border-radius: var(--radius);
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.status-chip::before { content: ""; width: 5px; height: 5px; background: currentColor; }
.status-live { color: var(--live); background: var(--live-wash); border-color: var(--live); }
.status-draft { color: var(--draft); background: var(--draft-wash); border-color: var(--draft); }
.status-neutral { color: var(--muted); background: var(--card-2); border-color: var(--line-strong); }

/* ── Forms ─────────────────────────────────────────────── */

form { display: grid; gap: 20px; max-width: 680px; padding-top: 8px; }
form > input[type="hidden"] { display: none; }
form label { display: grid; gap: 7px; }
.field-label { display: block; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
form .field-label, .access-form label > span { margin-bottom: 0; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: end; }
.field-row > * { min-width: 0; }

input:not([type="hidden"]), select, textarea {
  width: 100%; min-width: 0; padding: 10px 12px;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius);
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input:not([type="hidden"]):hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:not([type="hidden"]):focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: var(--focus);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
button { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; align-items: start; }

/* ── Notices & empty states ────────────────────────────── */

.notice {
  display: flex; align-items: center; gap: 10px; width: fit-content; max-width: 100%;
  padding: 10px 14px;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .14);
  font-size: 13px;
}
.notice-dot { width: 8px; height: 8px; flex: 0 0 auto; background: var(--accent); }

.empty-state { padding: 30px 0 10px; }
.empty-state h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.empty-state p { max-width: 540px; margin: 9px 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }

.warning-panel {
  padding: 18px 20px; background: var(--review-wash);
  border: 2px solid var(--review); border-left-width: 4px;
  border-radius: var(--radius);
}
.warning-panel h3 { margin: 0 0 10px; font-size: 15px; color: var(--review); font-family: "Iowan Old Style", Palatino, Georgia, serif; }
.warning-panel ul { display: grid; gap: 8px; margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }

/* ── Home ──────────────────────────────────────────────── */

.home-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 40px; align-items: start; }

/* ── Planning: years & matrix ──────────────────────────── */

.year-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 0 18px; margin-bottom: 12px; }
.year-row h2 { margin: 0 0 6px; font-size: 19px; letter-spacing: -.01em; font-family: "Iowan Old Style", Palatino, Georgia, serif; }
.year-row p { margin: 0; color: var(--muted); font-size: 13px; }

.year-picker { display: grid; gap: 10px; }
.year-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 14px 16px;
  color: var(--ink); text-decoration: none;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--card);
  box-shadow: 3px 3px 0 rgba(34, 30, 22, .1);
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease, transform .12s ease;
}
.year-choice span:not(.status-chip) { color: var(--muted); font-size: 13px; }
.year-choice strong { display: block; margin-bottom: 2px; font-size: 15px; }
.year-choice:hover { box-shadow: 1px 1px 0 rgba(34, 30, 22, .1); transform: translate(2px, 2px); }
.year-choice:hover strong { color: var(--accent-strong); }
.year-choice.active { background: var(--accent-wash); border-color: var(--accent); }

.plan-note { display: flex; align-items: center; gap: 9px; margin: 4px 0 18px; color: var(--muted); font-size: 12.5px; }
.plan-note .icon { color: var(--accent); font-weight: 800; }

.matrix-wrap { min-width: 0; overflow-x: auto; background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.matrix { width: 100%; min-width: 920px; border-collapse: collapse; table-layout: fixed; }
.matrix th {
  padding: 13px 16px; color: var(--muted);
  font-size: 10px; font-weight: 800; letter-spacing: .12em;
  text-align: left; text-transform: uppercase;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-2);
}
.matrix th:first-child { width: 118px; }
.matrix td { height: 148px; padding: 0; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.matrix td:last-child, .matrix th:last-child { border-right: 0; }
.matrix tbody tr:last-child td { border-bottom: 0; }

.week-label { display: grid; align-content: start; gap: 4px; height: 100%; padding: 16px 14px; background: var(--paper-2); }
.week-label strong { font-size: 13px; color: var(--ink); }
.week-label span { color: var(--muted); font-size: 11.5px; }

.matrix tr.unit-row td { height: auto; padding: 0; background: var(--paper); border-bottom: 2px solid var(--ink); }
.unit-label { display: flex; align-items: baseline; gap: 12px; padding: 10px 16px; }
.unit-label strong { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-strong); }
.unit-label span { color: var(--muted); font-size: 11.5px; }

.matrix-cell {
  display: block; height: 100%; padding: 14px 14px;
  text-decoration: none;
  transition: background .14s ease, box-shadow .14s ease;
}
.matrix-cell:hover { background: var(--card-2); }
.matrix-cell-filled:hover { box-shadow: inset 4px 0 0 var(--accent); background: var(--accent-wash); }
.cell-kicker { display: block; margin-bottom: 8px; color: var(--accent); font-size: 9.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.cell-title { display: block; margin-bottom: 7px; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; line-height: 1.18; color: var(--ink); }
.cell-summary { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.cell-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.cell-meta span { padding: 2px 7px; color: var(--accent-strong); background: var(--accent-wash); border: 1px solid var(--accent-soft); border-radius: var(--radius); font-size: 9.5px; font-weight: 800; letter-spacing: .03em; }
.matrix-empty {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 100%; min-height: 148px;
  color: var(--faint); font-size: 12px; font-weight: 700;
  background: repeating-linear-gradient(-45deg, transparent, transparent 9px, rgba(34, 30, 22, .025) 9px, rgba(34, 30, 22, .025) 18px);
}
.matrix-empty strong { color: var(--accent); font-size: 18px; font-weight: 700; }
.matrix-empty:hover { background: var(--accent-wash); color: var(--accent-strong); }

/* ── Entry sheet & objectives ──────────────────────────── */

.sheet-copy-input { width: 100%; min-height: 84px; padding: 10px 12px; color: var(--ink-2); background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); resize: vertical; font-size: 14px; line-height: 1.55; }
.sheet-copy-input:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }

.objective-group { display: grid; gap: 10px; margin-top: 18px; }
.objective-group-label { color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.objective-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--card); border: 2px solid var(--ink); border-left-width: 4px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.objective-row.supporting { border-left-color: var(--draft); background: var(--draft-wash); }
.objective-code { color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .02em; }
.objective-row.supporting .objective-code { color: var(--draft); }
.objective-label { display: grid; gap: 3px; }
.objective-label strong { font-size: 13.5px; }
.objective-label span { color: var(--muted); font-size: 12px; }
.move-action { color: var(--accent); font-size: 12px; font-weight: 750; text-decoration: none; }
.add-objective {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  color: var(--accent); font-size: 13px; font-weight: 800; text-decoration: none;
}
.add-objective:hover { color: var(--accent-strong); }
.add-objective span {
  display: grid; place-items: center; width: 20px; height: 20px;
  border: 2px solid var(--accent); border-radius: var(--radius); font-size: 14px; line-height: 1;
}

.resource-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.resource-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.resource-row:last-child { border-bottom: 0; }
.resource-row span { color: var(--muted); font-size: 13px; }
.resource-row strong { font-size: 13.5px; font-weight: 700; }
.resource-kind { color: var(--accent) !important; font-size: 11px !important; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

/* ── Tags ──────────────────────────────────────────────── */

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
.tag-list span {
  padding: 6px 11px; color: var(--ink-2); background: var(--card);
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  font-size: 12.5px; font-weight: 650;
}

/* ── Lessons & tasks ───────────────────────────────────── */

.lesson-hero {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding-bottom: 20px; margin-bottom: 22px;
  border-bottom: 2px solid var(--ink);
}
.lesson-hero h2 { margin: 7px 0 8px; font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.lesson-hero p { max-width: 620px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.task-state { display: flex; align-items: center; gap: 10px; padding: 0 0 16px; color: var(--muted); font-size: 13px; }
.lesson-target-links > div > strong { display: block; margin-top: 14px; font-size: 13px; }
.lesson-target-links li { display: flex; align-items: baseline; gap: 12px; }

/* ── Templates ─────────────────────────────────────────── */

.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px; align-items: start; }
.template-list { display: grid; gap: 22px; padding-top: 8px; }
.template-version { display: grid; gap: 14px; padding-bottom: 20px; border-bottom: 2px solid var(--line-strong); }
.template-version > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.template-category-list { display: grid; gap: 10px; }
.template-category {
  display: grid; gap: 8px; padding: 13px 15px;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.template-category-list span { color: var(--ink); font-size: 13px; font-weight: 700; }
.template-category-list small { color: var(--muted); font-size: 12px; }
.template-version form { padding-top: 5px; }

/* ── Access / login ────────────────────────────────────── */

.access-page {
  display: grid; align-content: center; gap: 18px;
  width: min(460px, calc(100vw - 44px)); min-height: 100vh; margin: 0 auto; padding: 50px 0;
}
.access-mark {
  display: grid; place-items: center; width: 48px; height: 48px;
  color: #fff; background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 rgba(34, 30, 22, .2);
  font-weight: 800; font-size: 20px;
}
.access-page h1 { margin: 0; font-size: 38px; font-weight: 700; letter-spacing: -.03em; line-height: 1.02; }
.access-page > p { margin: -3px 0 6px; color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.access-form {
  width: 100%; max-width: none; padding: 26px;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.access-form label > span { color: var(--muted); font-size: 12px; font-weight: 700; }

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1020px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-item:nth-child(n + 3) { border-left: 0; border-top: 2px solid var(--ink); }
  .template-grid { grid-template-columns: 1fr; }
  .top-nav { margin-left: 4px; }
  .top-link { padding: 0 10px; }
}

@media (max-width: 900px) {
  .brand-sub { display: none; }
  .topbar { padding: 0 12px; }
  .topbar-right .user-chip > span:not(.avatar), .context-pill .pill-kicker { display: none; }
  .context-pill { padding: 7px 9px; }
  .context-strip, .page-content { padding-left: 20px; padding-right: 20px; }
  .home-grid { grid-template-columns: 1fr; gap: 40px; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .sheet-head, .sheet-main { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 560px) {
  .context-switch { display: none; }
  .context-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .page-content { padding: 26px 14px 60px; }
  .page-intro { margin-bottom: 26px; }
  .page-intro h1 { font-size: 32px; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-item { padding: 15px 16px; }
  .home-grid > .panel .table-wrap table { min-width: 0; table-layout: fixed; }
  .home-grid > .panel .table-wrap th, .home-grid > .panel .table-wrap td,
  .home-grid + .panel .table-wrap th, .home-grid + .panel .table-wrap td { padding-right: 6px; padding-left: 2px; }
  .home-grid > .panel .table-wrap td:nth-last-child(2), .home-grid + .panel .table-wrap td:nth-last-child(2) { padding-right: 22px !important; }
  .home-grid > .panel .table-wrap td:last-child, .home-grid + .panel .table-wrap td:last-child { padding-left: 16px !important; text-align: right; }
  .home-grid > .panel .table-wrap td:last-child .table-action, .home-grid + .panel .table-wrap td:last-child .table-action { display: inline-block; margin-right: 0; }
  .home-grid > .panel:first-child .table-wrap th:last-child, .home-grid > .panel:first-child .table-wrap td:last-child { display: none; }
  .home-grid + .panel .status-chip { padding: 3px 7px; font-size: 9px; }
  .top-nav { margin-left: 0; }
  .top-link svg { display: none; }
  .sheet-head { flex-direction: column; gap: 12px; }
  .sheet-title { font-size: 22px; }
  up-drawer-box { border-left-width: 1px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Small screens ─────────────────────────────────────── */

@media (max-width: 860px) {
  .brand-sub { display: none; }
  .topbar { padding: 0 10px; gap: 4px; }
  .topbar-right { min-width: 0; }
  .topbar .context-pill { display: none; }
  .user-chip strong { display: none; }
  .context-strip { padding: 8px 14px; }
  .context-switch { display: none; }
  .page-content { padding: 22px 14px 80px; }
  .sheet-head { padding: 20px 16px 16px; }
  .sheet-main { padding: 18px 16px 80px; }
  .sheet-actions { flex-wrap: wrap; }
  .matrix-scroll { overflow-x: auto; }
}
