:root {
  color-scheme: dark;
  --bg: #0b1115;
  --bg-deep: #080d10;
  --surface: #111a20;
  --surface-raised: #172229;
  --surface-soft: #1b272d;
  --ink: #f2f0e9;
  --ink-soft: #d8d7d1;
  --muted: #97a4a6;
  --line: rgba(222, 231, 226, .1);
  --line-strong: rgba(222, 231, 226, .17);
  --accent: #dfbb73;
  --accent-bright: #efd296;
  --accent-ink: #241b0e;
  --sage: #94c5b4;
  --shadow: 0 26px 80px rgba(0, 0, 0, .34);
  --shadow-soft: 0 14px 38px rgba(0, 0, 0, .2);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(148, 197, 180, .11), transparent 31rem),
    radial-gradient(circle at 92% 12%, rgba(223, 187, 115, .075), transparent 28rem),
    linear-gradient(150deg, var(--bg) 0%, var(--bg-deep) 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .18;
  background-image:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 62%);
}

[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
a { color: var(--accent-bright); text-underline-offset: .2em; }

.shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 100px max(24px, env(safe-area-inset-left));
}

.card {
  position: relative;
  margin: 22px 0;
  padding: clamp(26px, 4.5vw, 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(24, 35, 41, .96), rgba(15, 23, 28, .97));
  box-shadow: var(--shadow);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.16), transparent);
}

h1, h2, h3 { letter-spacing: -.035em; }
h1 { margin: 0; font-size: clamp(2.3rem, 6vw, 4.35rem); line-height: .98; }
h2 { margin: 5px 0 12px; font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.08; }
h3 { margin: 8px 0 14px; font-size: 1.18rem; line-height: 1.25; }
p { margin-top: 0; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: .66rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.lede { max-width: 33rem; color: var(--muted); font-size: 1.02rem; }
.status, .source {
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.55;
}
.error { min-height: 1.5em; margin: 12px 0 0; color: var(--accent-bright); font-size: .82rem; }
.warning { color: var(--muted); }

.narrow { width: min(100%, 520px); margin: 9vh auto; }
.login-card { padding: clamp(34px, 7vw, 58px); }
.login-card .brand-mark { margin-bottom: 30px; }
.login-card h1 { max-width: 430px; font-size: clamp(2.55rem, 8vw, 4.4rem); }
.login-card .lede { margin: 18px 0 34px; }
.login-card button { width: 100%; justify-content: space-between; }
.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 18px;
  color: var(--accent-bright);
  background: linear-gradient(145deg, rgba(223,187,115,.2), rgba(148,197,180,.08));
  box-shadow: 0 14px 35px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.12);
}
.brand-mark span { font-family: Georgia, "Times New Roman", serif; font-size: 1.65rem; font-style: italic; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 13px; }
.brand-mark.small span { font-size: 1.2rem; }

.app-header {
  position: sticky;
  top: max(8px, env(safe-area-inset-top));
  z-index: 10;
  min-height: 70px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(11, 17, 21, .82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(120%);
}
.brand-lockup { display: flex; align-items: center; gap: 11px; padding-right: 4px; }
.brand-lockup h1 { font-size: 1.04rem; line-height: 1; letter-spacing: -.025em; }
.brand-lockup .eyebrow { margin-bottom: 4px; font-size: .56rem; }
.source-notes { display: none; }

#views {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.025);
}
#views button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
#views button span { color: #748184; font-size: .85rem; pointer-events: none; }
#views button:hover { color: var(--ink); background: rgba(255,255,255,.045); }
#views button.active { color: var(--accent-ink); background: linear-gradient(105deg, var(--accent-bright), var(--accent)); box-shadow: 0 7px 20px rgba(223,187,115,.16); }
#views button.active span { color: var(--accent-ink); }

button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 11px 19px;
  border: 0;
  border-radius: 14px;
  color: var(--accent-ink);
  background: linear-gradient(105deg, var(--accent-bright), var(--accent));
  box-shadow: 0 10px 24px rgba(223,187,115,.1);
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, border-color .18s ease;
}
button:hover { filter: brightness(1.05); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { cursor: default; opacity: .48; transform: none; }
.secondary {
  border: 1px solid rgba(148,197,180,.4);
  color: var(--sage);
  background: rgba(148,197,180,.055);
  box-shadow: none;
}
.quiet {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.025);
  box-shadow: none;
  font-weight: 700;
}
.quiet:hover, .secondary:hover { color: var(--ink); border-color: var(--line-strong); }
.library-button { white-space: nowrap; }

label { display: block; margin: 20px 0; color: var(--muted); font-size: .78rem; font-weight: 650; }
label > span:first-child { display: block; margin-bottom: 8px; }
input, textarea, select {
  width: 100%;
  display: block;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(5, 10, 12, .48);
  box-shadow: inset 0 1px 8px rgba(0,0,0,.12);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { min-height: 180px; resize: vertical; line-height: 1.65; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(223,187,115,.5);
  background: rgba(5, 10, 12, .68);
  box-shadow: 0 0 0 4px rgba(223,187,115,.075), inset 0 1px 8px rgba(0,0,0,.12);
}
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }

.section-heading, .stage, .actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading { align-items: flex-start; }
.section-heading h2 { margin-bottom: 0; }
.focus-chip {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid rgba(148,197,180,.24);
  border-radius: 999px;
  color: var(--sage);
  background: rgba(148,197,180,.055);
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.focus-card { padding-top: clamp(25px, 4vw, 40px); }
.focus-card::after {
  content: "";
  position: absolute;
  top: -160px;
  right: -140px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(223,187,115,.105), transparent 68%);
}
.focus-card > * { position: relative; z-index: 1; }
.question-panel {
  max-width: 790px;
  margin: clamp(20px, 4vw, 36px) 0 8px;
  padding: 0 0 0 20px;
  border-left: 2px solid var(--accent);
}
#todayQuestion {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.23rem, 3vw, 1.75rem);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -.025em;
}
#todayMeta { margin: 9px 0 0; }
.writing-field { margin-top: 26px; }
.reveal-panel, .verdict {
  margin-top: 28px;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(5,10,12,.28);
}
.verdict:empty { display: none; }

pre {
  width: min(100%, 760px);
  max-height: 440px;
  margin: 18px 0;
  padding: 22px 24px;
  overflow: auto;
  white-space: pre-wrap;
  border: 0;
  border-left: 2px solid rgba(223,187,115,.6);
  border-radius: 0 16px 16px 0;
  color: #e2ded4;
  background: linear-gradient(90deg, rgba(223,187,115,.055), rgba(5,10,12,.22));
  font: 1.02rem/1.78 Georgia, "Times New Roman", serif;
  letter-spacing: .003em;
}
code { color: var(--accent-bright); }

.workspace-card { max-width: 900px; margin-inline: auto; }
.section-copy { max-width: 660px; font-size: .9rem; }
.practice-prompt { max-width: 760px; margin: 24px 0; color: var(--ink-soft); font-size: clamp(1.15rem, 2.5vw, 1.42rem); line-height: 1.48; letter-spacing: -.018em; }
.chip-row { justify-content: flex-start; flex-wrap: wrap; margin: 24px 0; }
.chip-row .quiet { color: var(--ink-soft); }
.reading-list { display: grid; gap: 10px; margin-top: 24px; }
.reading-list > p, .evidence-item, .evidence-history {
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.024);
}
.reading-list > p strong { color: var(--ink-soft); font-size: .95rem; }
.evidence-history { margin-top: 10px; }
.evidence-history p:last-child { margin-bottom: 0; }

.archive-details {
  max-width: 900px;
  margin: 28px auto;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(17,26,32,.48);
}
details > summary {
  color: var(--ink-soft);
  font-size: .82rem;
  font-weight: 750;
  cursor: pointer;
}
details > summary::marker { color: var(--accent); }
#lessonNav { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
#lessonNav button { width: 42px; min-height: 42px; padding: 0; color: var(--muted); background: var(--surface-raised); box-shadow: none; }
#lessonNav button.active { color: var(--accent-ink); background: var(--accent); }
#lesson.card { margin-bottom: 2px; box-shadow: var(--shadow-soft); }
.tool { padding: 14px 0 14px 18px; border-left: 2px solid var(--accent); color: var(--ink-soft); font-size: 1.08rem; }
.choice {
  width: 100%;
  min-height: 52px;
  justify-content: flex-start;
  margin: 8px 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink-soft);
  background: rgba(255,255,255,.025);
  box-shadow: none;
  text-align: left;
}
.choice.good { border-color: rgba(148,197,180,.5); background: rgba(148,197,180,.09); }
.feedback { margin-top: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); }
.editor-card { margin-top: 28px; }
.stage { padding-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .77rem; }
#rubric { margin-top: 28px; }
#rubric label { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.022); }
#rubric input[type="checkbox"] { width: auto; display: inline-block; margin-right: 8px; accent-color: var(--sage); }
#exportBox, #evidenceAggregate { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.network-state {
  position: sticky;
  top: 10px;
  z-index: 30;
  margin: 0 auto 10px;
  padding: 11px 16px;
  border: 1px solid rgba(223,187,115,.25);
  border-radius: 14px;
  color: var(--ink-soft);
  background: rgba(37,30,18,.94);
  box-shadow: var(--shadow-soft);
}

@media (max-width: 820px) {
  .shell { padding-inline: max(14px, env(safe-area-inset-left)); }
  .app-header {
    grid-template-columns: 1fr auto;
    background: rgba(11, 17, 21, .97);
    backdrop-filter: none;
  }
  #views {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
    padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: rgba(9, 14, 17, .94);
    box-shadow: 0 -16px 42px rgba(0,0,0,.26);
    backdrop-filter: blur(24px) saturate(125%);
  }
  #views button {
    min-width: 0;
    min-height: 53px;
    flex-direction: column;
    gap: 2px;
    padding: 5px 3px;
    border-radius: 13px;
    font-size: .62rem;
  }
  #views button span { font-size: 1rem; line-height: 1; }
  #views button.active { color: var(--ink); background: rgba(223,187,115,.1); box-shadow: none; }
  #views button.active span { color: var(--accent-bright); }
}

@media (max-width: 600px) {
  :root { font-size: 15px; }
  .shell {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }
  .narrow { margin: 4vh auto; }
  .login-card { padding: 30px 24px; border-radius: 25px; }
  .login-card .brand-mark { margin-bottom: 24px; }
  .app-header {
    top: max(7px, env(safe-area-inset-top));
    min-height: 58px;
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
  }
  .brand-lockup { gap: 9px; }
  .brand-mark.small { width: 36px; height: 36px; border-radius: 12px; }
  .brand-lockup h1 { font-size: .96rem; }
  .brand-lockup .eyebrow { font-size: .5rem; }
  .library-button { min-height: 38px; padding: 7px 11px; font-size: .72rem; }
  .card { margin: 11px 0; padding: 21px 18px; border-radius: 23px; box-shadow: 0 18px 48px rgba(0,0,0,.28); }
  .focus-card { padding-top: 19px; }
  h2 { font-size: 1.65rem; }
  .focus-chip { padding: 6px 9px; font-size: .57rem; }
  .question-panel { margin: 16px 0 4px; padding-left: 14px; }
  #todayQuestion { font-size: 1.18rem; line-height: 1.34; }
  #todayMeta { margin-top: 6px; font-size: .7rem; }
  .writing-field { margin-top: 20px; }
  textarea { min-height: 31vh; }
  .actions { align-items: stretch; flex-direction: column; }
  .actions button { width: 100%; }
  .assessment-actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .assessment-actions button { min-width: 0; padding-inline: 6px; font-size: .72rem; }
  pre { max-height: 48vh; padding: 17px 16px; font-size: .96rem; line-height: 1.72; }
  .reveal-panel, .verdict { margin-top: 22px; padding: 19px 16px; border-radius: 18px; }
  .workspace-card { margin-inline: 0; }
  .chip-row { flex-direction: row; }
  .chip-row button { width: auto; }
  .archive-details { margin: 16px 0; padding: 15px 17px; }
  #lesson.card { margin-top: 16px; }
}

@media (max-width: 370px) {
  .library-button span { display: none; }
  .brand-lockup .brand-mark { display: none; }
  .section-heading { gap: 8px; }
  .focus-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media(max-width:700px){
  /* The domain chips are navigation, not content: two per row reads faster than
     one per row and keeps the list itself above the fold. */
  #learnDomains{gap:8px}
  #learnDomains button{flex:1 1 calc(50% - 8px);min-width:0;padding:10px 12px;font-size:.9rem}
}
