:root {
  color-scheme: light;
  --bg: #f4f5ef;
  --surface: #fffefa;
  --ink: #1d3028;
  --muted: #57675f;
  --line: #dfe5dc;
  --forest: #1c5140;
  --forest-dark: #153b30;
  --green-soft: #e4efe3;
  --amber: #805017;
  --amber-soft: #f9edda;
  --purple: #574976;
  --purple-soft: #ede9f5;
  --danger: #a13b36;
  --radius: 18px;
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.55;
  font-synthesis: none;
  background: var(--bg);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 280px; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #819944; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, strong { font-weight: 680; }
h1 { font-size: clamp(1.65rem, 3.2vw, 2.4rem); line-height: 1.19; letter-spacing: -.034em; overflow-wrap: anywhere; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; }
h3 { font-size: 1rem; }
small { font-size: .82rem; }
p, small, label, strong { overflow-wrap: anywhere; }
img { max-width: 100%; height: auto; display: block; }
legend { padding: 0; font-weight: 620; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); font-size: .92rem; }
.rich { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich-heading { display: block; }
.formula-fallback { overflow-wrap: anywhere; background: #ecf1e9; border-radius: 4px; padding: 1px 4px; }
math { font-size: 1.12em; max-width: 100%; }
math[display="block"] { margin: 8px 0; }
.back { display: inline-block; margin-bottom: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid transparent;
  min-height: 42px; line-height: 1.28; font-weight: 640; font-size: .88rem;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.primary { background: var(--forest); color: #fff; border-color: var(--forest); }
.primary:hover { background: var(--forest-dark); border-color: var(--forest-dark); }
.secondary { background: #fffefa; color: var(--forest); border-color: #dce4d8; }
.secondary:hover { background: #edf3eb; border-color: #c7d8c9; }
.danger { color: var(--danger); }
.btn.danger { background: #fffefa; border-color: #ead8d2; }
.btn.danger:hover { background: #faebe7; }
.text-link {
  background: none; color: var(--forest); border: 0; padding: 0;
  font-weight: 650; font-size: .88rem; text-align: left; overflow-wrap: anywhere;
}
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.text-link.danger { color: var(--danger); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.icon-button { background: #eef2eb; border: 0; border-radius: 10px; color: var(--ink); width: 40px; height: 40px; font-size: 1.35rem; }

.pill {
  display: inline-flex; align-items: center; vertical-align: middle; gap: 4px;
  border-radius: 999px; padding: 3px 9px; background: #eef0eb; color: #4c5d53;
  font-size: .72rem; font-weight: 660; line-height: 1.35;
}
.pill.green, .pill.correct, .pill.solid { background: var(--green-soft); color: #255a44; }
.pill.amber, .pill.wrong, .pill.weak, .pill.pending { background: var(--amber-soft); color: var(--amber); }
.pill.purple, .pill.learning { background: var(--purple-soft); color: var(--purple); }
.notice {
  margin: 0 0 18px; padding: 11px 14px; border: 1px solid #dae6d7; border-radius: 10px;
  background: #edf4eb; color: #355b48; font-size: .9rem;
}
.notice.error, .form-error { border-color: #ead0cb; background: #fcf0ed; color: #8c302b; }
.form-error { border: 1px solid #ead0cb; border-radius: 8px; padding: 9px 12px; font-size: .91rem; }

.startup { display: grid; align-content: center; justify-items: center; min-height: 65vh; gap: 13px; color: var(--muted); padding: 20px; }
.loading { color: var(--muted); padding: 36px 0; }
.logo-mark {
  width: 38px; height: 38px; flex: 0 0 auto; display: inline-grid; place-items: center;
  background: var(--forest); color: #edf6e7; border-radius: 11px;
  font-size: 1.3rem; font-family: "STIX Two Text", Cambria, Georgia, serif; line-height: 1;
}
.brand-name { font-size: 1.13rem; font-weight: 730; letter-spacing: -.025em; }
.brand, .mobile-brand, .auth-brand, .auth-mobile { display: flex; align-items: center; gap: 11px; }

.shell { min-height: 100svh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar {
  align-self: start; position: sticky; top: 0; height: 100svh; background: #fbfcf7;
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 24px 17px 20px;
}
.sidebar .brand { margin: 0 9px 35px; }
.side-nav { display: grid; gap: 5px; }
.nav-item { min-height: 46px; padding: 10px 13px; display: flex; align-items: center; gap: 13px; border-radius: 10px; font-weight: 590; color: #4d6155; font-size: .93rem; }
.nav-item:hover { background: #eff3ed; }
.nav-item.active { background: #e4efe3; color: #174d39; font-weight: 720; }
.nav-icon { font-size: 1.15rem; width: 21px; text-align: center; color: #32624b; line-height: 1; }
.nav-divider { margin: 10px 10px 9px; height: 1px; background: var(--line); }
.sidebar-foot { display: flex; align-items: center; gap: 11px; margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f5f7ef; }
.subject-icon { display: grid; place-items: center; background: #e6ead5; color: #3d5830; width: 31px; height: 31px; border-radius: 8px; font-size: 1.19rem; }
.sidebar-foot strong, .sidebar-foot small { display: block; line-height: 1.4; }
.sidebar-foot small { color: var(--muted); }
.work { min-width: 0; }
.topbar {
  background: #fafbf6; border-bottom: 1px solid var(--line); min-height: 70px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px clamp(22px, 4vw, 54px);
}
.breadcrumb { color: var(--muted); font-size: .88rem; }
.breadcrumb span { color: #849087; margin: 0 7px; }
.top-actions { display: flex; align-items: center; gap: 17px; min-width: 0; }
.top-date { font-size: .86rem; color: var(--muted); white-space: nowrap; }
.profile-button { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--ink); font-weight: 650; padding: 4px 3px; max-width: 240px; }
.profile-button span:nth-child(2) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; background: #e9ecd7; color: #3a5137; border-radius: 50%; width: 33px; height: 33px; }
.mobile-brand, .bottom-nav { display: none; }
.main { max-width: 1410px; margin: 0 auto; padding: 34px clamp(22px, 4vw, 54px) 46px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading > div:first-child { min-width: 0; }
.page-heading p { margin-top: 8px; color: var(--muted); font-size: .93rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; max-width: 48%; }
.page-actions:empty { display: none; }
.box {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: clamp(17px, 2vw, 24px); min-width: 0; margin-bottom: 18px;
}
.section-heading { display: flex; flex-wrap: wrap; gap: 11px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-heading h2 { min-width: 0; overflow-wrap: anywhere; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: 16px; align-items: start; }
.empty { min-height: 148px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; padding: 18px 8px; }
.empty > span { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: #edf1e8; color: #4e6b52; font-size: 1.1rem; }
.empty > p { font-size: .88rem; color: var(--muted); }
.empty > .btn { margin-top: 6px; }

.hero {
  position: relative; isolation: isolate; overflow: hidden; min-height: 236px;
  background: linear-gradient(113deg, #163e33 16%, #225640 78%, #326950); color: #f6faf0;
  border-radius: 20px; display: flex; align-items: center; padding: clamp(25px, 3.4vw, 40px);
  margin-bottom: 18px;
}
.hero-copy { position: relative; z-index: 1; min-width: 0; width: 64%; }
.hero-label { display: block; color: #cfdfbd; font-size: .84rem; font-weight: 650; margin-bottom: 10px; }
.hero h2 { font-size: clamp(1.55rem, 3vw, 2.38rem); line-height: 1.24; overflow-wrap: anywhere; }
.hero p { color: #dfead9; margin: 10px 0 21px; font-size: .92rem; }
.hero-button { background: #dce8b3; color: #213d2e; border-color: #dce8b3; }
.hero-button:hover { background: #eef3d3; }
.hero-graph { position: absolute; z-index: 0; right: 0; width: 43%; height: 100%; object-fit: cover; opacity: .88; mask-image: linear-gradient(to right, transparent, black 18%); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.metric {
  display: grid; gap: 2px; background: var(--surface); border-radius: 16px;
  padding: 16px 19px; border: 1px solid var(--line); transition: border-color .16s, background .16s;
}
.metric:hover { background: #f9fcf6; border-color: #b8cdbb; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.metric-icon { flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; height: 32px; width: 32px; font-size: 1.12rem; background: var(--green-soft); color: #316046; }
.metric-icon.amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon.purple { background: var(--purple-soft); color: var(--purple); }
.metric > strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; letter-spacing: -.04em; line-height: 1.2; margin: 2px 0; }
.metric > small { color: var(--muted); }
.coverage { display: block; width: 100%; height: 9px; margin: 0 0 17px; appearance: none; accent-color: #568c63; border: 0; background: #e7ede5; border-radius: 999px; }
.coverage::-webkit-progress-bar { background: #e7ede5; border-radius: 999px; }
.coverage::-webkit-progress-value { background: #568c63; border-radius: 999px; }
.coverage::-moz-progress-bar { background: #568c63; border-radius: 999px; }
.topic-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.topic-card { display: grid; justify-items: start; align-content: start; gap: 7px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fcfdf9; min-height: 95px; }
.topic-card:hover { border-color: #a8c4ad; }
.topic-card strong { font-size: .92rem; }
.topic-card small { color: var(--muted); }

.recent-list { display: grid; }
.recent { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-top: 1px solid var(--line); padding: 12px 2px; }
.recent:hover strong { color: var(--forest); text-decoration: underline; text-underline-offset: 4px; }
.recent small { display: block; color: var(--muted); }
.task { display: flex; align-items: flex-start; gap: 11px; padding: 13px 0; border-top: 1px solid var(--line); }
.task-content { flex: 1; min-width: 0; }
.task-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.task-title .pill { flex: 0 0 auto; }
.task.done strong { color: var(--muted); text-decoration: line-through; }
.task-meta { color: var(--muted); font-size: .81rem; margin-top: 5px; }
.task .rich { margin: 8px 0; }
.task-actions { display: flex; gap: 17px; margin-top: 6px; align-items: center; }
.check-button { flex: 0 0 auto; margin-top: 1px; width: 32px; height: 32px; border: 1px solid #b9cabb; border-radius: 9px; background: #fbfdf9; color: white; font-weight: 710; }
.check-button:hover { border-color: var(--forest); }
.check-button[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); }
.calendar-nav, .calendar-nav > div { display: flex; align-items: center; gap: 12px; }
.calendar-nav { justify-content: space-between; padding-bottom: 14px; }
.calendar-nav strong { text-align: center; }
.agenda-day { border-top: 1px solid var(--line); padding: 16px 4px; display: grid; grid-template-columns: minmax(118px, 158px) minmax(0, 1fr); gap: 16px; }
.agenda-date { display: flex; align-items: flex-start; flex-direction: column; gap: 6px; }
.agenda-date small { color: var(--muted); }
.agenda-tasks .task:first-child { border-top: 0; padding-top: 0; }
.agenda-tasks .task:last-child { padding-bottom: 0; }

.field, .math-input > label { display: grid; gap: 6px; min-width: 0; font-size: .89rem; font-weight: 620; }
.field > input, .field > textarea, .field > select, .math-input > textarea, .mastery select {
  display: block; width: 100%; min-height: 43px; min-width: 0; background: #fffefa;
  border: 1px solid #cfdacf; border-radius: 9px; padding: 9px 11px; color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #64726a; font-weight: 400; }
textarea { resize: vertical; }
.stack { display: grid; gap: 15px; }
.stack > .btn { justify-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-box { max-width: 925px; }
.settings-box { max-width: 920px; }
.settings-content { padding: 19px 0 0; }
.settings-content > .muted { margin: 0 0 12px; }
.capabilities { border-top: 1px solid var(--line); margin-top: 20px; padding-top: 14px; }
.ai-fields { border: 0; margin: 0; min-width: 0; padding: 0; }
.ai-protocol .pill { margin-left: 9px; font-weight: 500; }
.ai-protocol > .stack { margin: 12px 0 4px; }
.ai-clear { display: flex; align-items: center; gap: 7px; font-size: .88rem; }
[data-ai-result] > .notice:last-child { margin-bottom: 0; }
.tabs { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.tab { display: inline-flex; min-height: 40px; padding: 8px 11px; align-items: center; border-radius: 8px; color: var(--muted); font-size: .9rem; font-weight: 640; }
.tab:hover, .tab.selected { color: var(--forest); background: #e8f1e7; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-bar .field { min-width: min(100%, 190px); }
.filter-bar > .muted { padding: 0 2px 9px; }
.filter-box { padding-top: 15px; padding-bottom: 15px; }
.scope { margin-top: 13px; border-top: 1px solid var(--line); padding: 11px 0 0; }
.scope summary, .source-list summary { cursor: pointer; font-size: .88rem; color: var(--forest); font-weight: 650; }
.scope ul { margin: 8px 0 2px; padding-left: 22px; color: var(--muted); }
.scope p, .scope .rich { margin-top: 8px; }
.question-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.question-card {
  border: 1px solid var(--line); background: var(--surface); border-radius: 13px; padding: 15px;
  display: grid; gap: 7px; align-content: start; justify-items: start; min-height: 132px;
}
.question-card > div { display: flex; flex-wrap: wrap; gap: 5px; }
.question-card:hover { border-color: #a5c1a9; }
.question-card small { color: var(--muted); }
.question-arrow { color: var(--forest); font-weight: 700; }
.question-stem-box { max-width: 925px; }
.question-stem { font-size: 1.14rem; padding: 18px 0 5px; line-height: 1.75; }
.choices { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.choices legend { margin-bottom: 7px; }
.choices label { display: flex; align-items: center; gap: 10px; min-height: 48px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; cursor: pointer; }
.choices label:has(input:checked) { border-color: #699775; background: #edf5eb; }
.choices input { accent-color: var(--forest); }
.option-letter { font-weight: 670; color: var(--forest); }
.math-input { display: grid; gap: 8px; min-width: 0; }
.math-keys { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.math-keys button {
  border: 1px solid #d6e2d4; border-radius: 8px; background: #edf3eb; color: #234935;
  padding: 5px 9px; min-width: 38px; min-height: 35px; font-weight: 610; font-size: .9rem;
}
.math-keys button:hover { background: #dcebd9; }
.math-input textarea { font-family: "IBM Plex Mono", ui-monospace, "Noto Sans SC", monospace; font-size: .95rem; }
.math-preview { background: #f3f6f0; border-radius: 9px; border: 1px solid #e4ebe1; padding: 8px 10px; }
.math-preview > span { color: var(--muted); font-size: .75rem; }
.math-preview > div { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 22px; }
.feedback { max-width: 925px; }
.answer-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 15px; }
.answer-comparison > div { border: 1px solid var(--line); border-radius: 10px; background: #f6f8f2; padding: 10px 12px; }
.answer-comparison small { color: var(--muted); display: block; margin-bottom: 5px; }
.solution { margin: 8px 0 15px; }
.mistake-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.mistake-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mistake-top h2 { margin-top: 6px; }
.mistake-list small { color: var(--muted); }
.mistake-top .btn { flex: 0 0 auto; }

.materials-layout { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.dropzone {
  min-height: 230px; border: 1px dashed #b7cbb7; background: #f3f8f1;
  border-radius: 12px; padding: 17px 12px; text-align: center; display: grid; place-items: center; align-content: center; gap: 8px;
}
.dropzone label { font-weight: 660; }
.dropzone input { max-width: 100%; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.dropzone input::file-selector-button {
  border: 1px solid #ccdcca; background: #fff; border-radius: 8px; color: var(--forest); font: inherit;
  margin-right: 8px; padding: 8px 10px; cursor: pointer;
}
.upload-icon { display: grid; place-items: center; width: 39px; height: 39px; color: #315f43; background: #e0eee0; border-radius: 11px; font-size: 1.35rem; }
.search { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.search .field { flex: 1; min-width: min(100%, 150px); }
.search > .text-link { align-self: center; }
.file { display: grid; grid-template-columns: 45px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 2px; border-top: 1px solid var(--line); }
.file:hover strong { color: var(--forest); text-decoration: underline; text-underline-offset: 4px; }
.file small { display: block; color: var(--muted); }
.file-icon { display: grid; place-items: center; border-radius: 8px; width: 42px; height: 42px; background: var(--purple-soft); color: var(--purple); font-size: .73rem; font-weight: 710; }
.file-icon.pdf { background: var(--amber-soft); color: var(--amber); }
.page-picker { padding: 13px 20px; }
.page-toolbar { display: flex; align-items: flex-end; gap: 8px; }
.page-toolbar .edge { visibility: hidden; pointer-events: none; }
.document-layout { grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr); }
.document-layout .box > .muted { margin: 8px 0 12px; }
.original { border-radius: 10px; min-height: 144px; display: grid; place-items: center; text-align: center; background: #f1f4ec; padding: 12px; overflow: hidden; }
.original img { border-radius: 4px; width: 100%; }
.source-list { margin-top: 10px; }
.source {
  padding: 11px 13px; margin-top: 8px; border: 1px solid #dce6d9;
  border-left: 3px solid #88a992; border-radius: 8px; background: #f6f9f3;
}
.source small { display: block; color: var(--muted); margin: 4px 0; }
.excerpt { color: #3b5347; font-size: .89rem; max-height: 230px; overflow: auto; }

.chat-layout { display: grid; grid-template-columns: minmax(155px, 215px) minmax(0, 1fr); gap: 15px; align-items: start; }
.chat-history { padding: 16px; }
.thread-list { display: grid; gap: 5px; max-height: 55vh; overflow: auto; }
.thread-link { display: block; padding: 9px 10px; border-radius: 8px; font-size: .88rem; overflow-wrap: anywhere; color: var(--muted); }
.thread-link:hover, .thread-link.selected { background: #e9f1e6; color: var(--forest); }
.chat-top .section-heading { margin-bottom: 9px; }
.dialogue {
  display: flex; flex-direction: column; gap: 12px; min-height: 245px; max-height: min(64vh, 700px);
  padding: 11px 3px; overflow: auto; border-top: 1px solid var(--line); margin-bottom: 15px;
}
.message { padding: 11px 14px; border-radius: 13px; border: 1px solid var(--line); max-width: 94%; background: #f8faf5; }
.message.user { align-self: flex-end; background: #eaf2e8; border-color: #d9e7d7; }
.message.assistant { align-self: flex-start; }
.message-meta { color: var(--forest); font-size: .77rem; font-weight: 690; margin-bottom: 4px; }
.message-body { font-size: .95rem; }
.chat-empty { text-align: center; padding: 24px 10px; display: grid; justify-items: center; gap: 8px; align-content: center; min-height: 220px; }
.starter-list { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; margin-top: 5px; }
.ref-controls { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
#chat-form textarea { min-height: 105px; }
.memory-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.memory, .mastery { border-top: 1px solid var(--line); padding: 13px 0; }
.memory-body { margin: 7px 0; }
.mastery { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, .72fr); align-items: center; gap: 8px; }
.mastery small { color: var(--muted); display: block; }
.mastery select { font-size: .85rem; }
.memory-layout .section-heading + .muted { margin-bottom: 12px; }

.auth-layout { min-height: 100svh; display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr); }
.auth-art { min-height: 100%; background: linear-gradient(145deg, #163f32, #22533f 68%, #3e7658); color: #f3f7ed; position: relative; isolation: isolate; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: clamp(35px, 7vw, 105px); }
.auth-art .auth-brand { position: absolute; top: 35px; left: clamp(35px, 7vw, 105px); }
.auth-brand .logo-mark { background: #dce8b6; color: #1a4533; }
.auth-art-copy { z-index: 1; position: relative; }
.auth-art-copy h1 { font-size: clamp(2.3rem, 4.4vw, 4.25rem); line-height: 1.19; margin: 16px 0; }
.auth-art-copy p { color: #d9e7d6; }
.auth-graph { position: absolute; z-index: 0; bottom: 0; right: 0; width: 72%; height: 38%; object-fit: cover; opacity: .58; mask-image: linear-gradient(133deg, transparent 7%, black 43%); }
.auth-content { display: grid; align-content: center; justify-items: center; background: var(--surface); padding: 32px clamp(23px, 4vw, 70px); }
.auth-panel { max-width: 400px; width: 100%; }
.auth-panel .muted { margin-top: 7px; }
#auth-form { margin: 24px 0 13px; }
#auth-form .btn { width: 100%; }
.auth-switch { color: var(--muted); }
.auth-mobile { display: none; }
dialog { width: min(560px, calc(100% - 30px)); max-height: calc(100svh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(14, 33, 26, .43); }
.dialog-inner { padding: 20px; }
.dialog-inner .notice { margin-bottom: 0; }
.more-list { display: grid; gap: 9px; grid-template-columns: 1fr 1fr; }
.profile-name { margin-bottom: 15px; }
#toast {
  position: fixed; z-index: 10; bottom: 22px; right: 22px; max-width: min(460px, calc(100% - 36px)); 
  padding: 12px 16px; background: var(--forest-dark); color: #f3f7ef; border-radius: 11px;
  font-size: .92rem; opacity: 0; transform: translateY(10px); visibility: hidden;
  pointer-events: none; transition: opacity .15s, transform .15s, visibility .15s; overflow-wrap: anywhere;
}
#toast.visible { opacity: 1; visibility: visible; transform: none; }

@media (max-width: 1130px) {
  .topic-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main { padding-left: 25px; padding-right: 25px; }
}
@media (max-width: 930px) {
  .shell { grid-template-columns: 180px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .topbar { padding-inline: 24px; }
  .topic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .question-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-layout, .materials-layout, .memory-layout { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar, .breadcrumb, .top-date { display: none; }
  .topbar { min-height: 58px; padding: 9px 14px; }
  .mobile-brand { display: flex; min-width: 0; }
  .mobile-brand .logo-mark { width: 33px; height: 33px; }
  .mobile-brand .brand-name { font-size: 1.05rem; }
  .profile-button { max-width: min(40vw, 170px); font-size: .86rem; }
  .main { padding: 24px 14px calc(92px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; position: fixed; z-index: 5; inset: auto 0 0; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px 3px calc(5px + env(safe-area-inset-bottom)); background: #fcfdf7;
    border-top: 1px solid var(--line);
  }
  .bottom-nav a, .bottom-nav button {
    color: #4a6053; background: transparent; border: 0; border-radius: 9px; padding: 3px 1px;
    min-height: 50px; display: grid; justify-items: center; align-content: center;
    font-size: .72rem; font-weight: 660; line-height: 1.4;
  }
  .bottom-nav a span, .bottom-nav button span { font-size: 1.1rem; }
  .bottom-nav .active { background: #e7f0e4; color: var(--forest); }
  .page-heading { margin-bottom: 17px; align-items: flex-start; flex-direction: column; gap: 10px; }
  .page-actions { max-width: 100%; justify-content: flex-start; }
  .hero { min-height: 205px; padding: 22px; margin-bottom: 12px; }
  .hero-copy { width: 83%; }
  .hero-graph { width: 55%; opacity: .38; mask-image: linear-gradient(to right, transparent 10%, black 65%); }
  .hero-label { margin-bottom: 7px; }
  .hero p { margin: 8px 0 14px; }
  .metrics { gap: 7px; margin-bottom: 13px; }
  .metric { padding: 11px 9px; border-radius: 11px; }
  .metric-top { font-size: .77rem; }
  .metric-icon { display: none; }
  .metric > strong { font-size: 1.43rem; }
  .metric > small { font-size: .72rem; line-height: 1.35; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .box { padding: 15px; margin-bottom: 12px; }
  .chat-layout { grid-template-columns: 1fr; gap: 0; }
  .thread-list { display: flex; max-height: 102px; overflow: auto; flex-wrap: wrap; gap: 4px; }
  .thread-link { max-width: 100%; background: #f1f4ee; }
  .dialogue { max-height: min(60vh, 650px); }
  .chat-main .message { max-width: 98%; }
  .mistake-list { grid-template-columns: 1fr; }
  .agenda-day { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .agenda-date { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .calendar-nav { flex-wrap: wrap; gap: 8px; }
  .calendar-nav strong { order: -1; width: 100%; text-align: left; }
  .calendar-nav > div { gap: 8px; }
  .check-button { width: 39px; height: 39px; }
  .math-keys button { min-height: 42px; min-width: 42px; }
  .field > input, .field > textarea, .field > select, .math-input > textarea, .mastery select { font-size: 16px; }
  .auth-layout { display: block; }
  .auth-art { display: none; }
  .auth-content { min-height: 100svh; align-content: start; gap: 35px; padding: 26px 20px; }
  .auth-mobile { display: flex; justify-self: start; }
  #toast { bottom: calc(70px + env(safe-area-inset-bottom)); right: 12px; }
}
@media (max-width: 405px) {
  .topic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .ref-controls { grid-template-columns: 1fr; }
  .file { grid-template-columns: 38px minmax(0, 1fr); }
  .file .pill { grid-column: 2; justify-self: start; }
  .file-icon { width: 36px; height: 36px; }
  .page-toolbar { flex-wrap: wrap; }
  .page-toolbar .field { order: -1; width: 100%; }
  .page-toolbar .edge { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
