:root {
  --paper: #edf2f7;
  --sheet: #ffffff;
  --ink: #253d58;
  --blue: #315f84;
  --muted: #596c7f;
  --line: #d3dee8;
  --red: #a73d4f;
  --yellow: #8d5b10;
  --green: #23705d;
  --display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --body: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  --utility: Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; border-radius: 6px; font-weight: 600; transition: background .15s, color .15s; }
button:disabled { cursor: not-allowed; opacity: .53; }
button:not(:disabled):hover { filter: brightness(.94); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.15; }
h1 { font-size: clamp(2.3rem, 4vw, 3.65rem); letter-spacing: -.045em; }
h2 { font-size: 1.65rem; letter-spacing: -.025em; }
h3 { font-size: 1rem; line-height: 1.4; }
input, select { display: block; width: 100%; color: var(--ink); background: white; border: 1px solid #aebfce; border-radius: 6px; min-height: 44px; padding: 9px 11px; }
label { display: block; font-size: .8rem; font-weight: 600; }
label input, label select { margin-top: 6px; font-weight: 400; }
small { font-size: .75rem; }
.eyebrow { font-family: var(--utility); font-size: .68rem; font-weight: 600; letter-spacing: .12em; margin-bottom: 10px; }
.mono { font-family: var(--utility); }
.small-note, .privacy-note { font-size: .8rem; color: var(--muted); line-height: 1.65; }
.primary { background: var(--ink); color: white; padding: 12px 18px; min-height: 44px; }
.quiet { background: transparent; color: var(--blue); border: 1px solid var(--line); padding: 9px 12px; min-height: 44px; }
.text-button { padding: 10px 0; color: var(--blue); background: transparent; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; }
.skip-link { position: fixed; top: 10px; left: 16px; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); background: white; z-index: 20; }
.skip-link:focus { width: auto; height: auto; padding: 14px; overflow: visible; clip-path: none; }
.masthead { display: flex; align-items: center; gap: 20px; justify-content: space-between; max-width: 1440px; padding: 22px 4%; margin: auto; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-size: 1.1rem; font-weight: 600; line-height: 1.3; }
.brand small { display: block; font-family: var(--utility); font-size: .61rem; letter-spacing: .14em; margin-top: 3px; }
.brand-mark { width: 42px; height: 45px; display: grid; place-items: center; font-family: var(--display); font-size: 1.6rem; font-style: italic; color: white; background: var(--ink); border-radius: 4px 13px 4px 4px; }
.term-label { font-family: var(--utility); font-size: .7rem; letter-spacing: .08em; }
.account { display: flex; gap: 10px; align-items: center; margin-left: auto; }
#account-email { color: var(--muted); font-size: .8rem; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
body.signed-in .term-label { display: none; }
main { max-width: 1440px; margin: auto; padding: 0 4%; }
.loading { padding: 80px 0; font-family: var(--display); font-size: 1.6rem; }
.error-banner { margin-top: 20px; padding: 14px 18px; border-left: 4px solid var(--red); background: #fae9ed; color: #813242; display: flex; align-items: center; gap: 16px; justify-content: space-between; font-size: .9rem; }
.error-banner button { flex-shrink: 0; }
.auth-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 10%; align-items: center; min-height: 78vh; padding: 60px 4% 70px; }
.welcome h1 { font-size: clamp(3rem, 5.2vw, 5rem); margin: 20px 0 24px; }
.welcome h1 em { color: var(--blue); font-weight: 400; }
.welcome > p:not(.eyebrow) { max-width: 420px; color: var(--muted); }
.term-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin: 34px 0 18px; max-width: 420px; border-top: 2px solid var(--ink); }
.term-strip div { padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.term-strip strong { display: block; font-family: var(--display); font-weight: 400; font-size: 2.2rem; }
.term-strip span { font-family: var(--utility); font-size: .7rem; }
.welcome .welcome-note { font-size: .8rem; }
.auth-card { background: white; padding: 38px; border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 8px; box-shadow: 0 12px 40px #253d5808; }
.auth-card h2 { font-size: 2rem; margin-bottom: 12px; }
.auth-card > p:not(.eyebrow) { color: var(--muted); font-size: .9rem; }
#auth-form { margin-top: 26px; }
#auth-form label { margin: 16px 0 6px; }
#password-hint { display: block; margin-top: 7px; color: var(--muted); }
#auth-submit { width: 100%; margin-top: 22px; }
#auth-toggle { margin: 12px 0; }
.auth-card .privacy-note { font-size: .73rem !important; padding-top: 14px; border-top: 1px solid var(--line); }
.form-error { color: var(--red); font-size: .85rem; margin-top: 12px; }
.desk-intro { display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 42px 0 32px; }
.desk-intro > div > p:last-child { color: var(--muted); margin-top: 14px; font-size: .9rem; }
.headline-progress { border-left: 1px solid var(--line); padding-left: 38px; display: flex; flex-direction: column; min-width: 220px; }
.headline-progress strong { font-family: var(--display); font-size: 2.6rem; line-height: 1.2; font-weight: 400; }
.headline-progress strong span { color: #718497; font-size: 1.5rem; }
.headline-progress > span { font-size: .85rem; }
.headline-progress small { color: var(--muted); margin-top: 5px; }
.study-map { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 25px 28px 16px; position: relative; }
.study-map::before { content: ""; height: 3px; position: absolute; top: -1px; left: 28px; right: 28px; background: var(--blue); }
.section-top { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.map-legend { display: flex; gap: 16px; font-size: .7rem; color: var(--muted); flex-wrap: wrap; }
.map-legend > span { display: flex; gap: 5px; align-items: center; }
.legend-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.pending-dot { background: #527b9c; }
.done-dot { background: var(--green); }
.calendars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; margin-top: 22px; }
.month { min-width: 0; }
.month + .month { border-left: 1px solid var(--line); padding-left: 30px; }
.month-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.month-heading h3 { font-size: .94rem; font-weight: 600; }
.month-heading span { font-family: var(--utility); font-size: .7rem; color: var(--muted); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekday { text-align: center; font-family: var(--utility); font-size: .6rem; color: var(--muted); padding-bottom: 6px; }
.calendar-day { position: relative; display: flex; min-height: 42px; padding: 5px 2px 6px; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: #f3f6f9; color: var(--ink); font-size: .74rem; border: 1px solid transparent; font-weight: 400; }
.calendar-day.has-work { background: #e7eef5; }
.calendar-day.all-done { background: #e7f2ee; }
.calendar-day[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: white; }
.calendar-day.is-today::after { content: ""; width: 3px; height: 3px; border-radius: 50%; background: currentColor; position: absolute; top: 3px; right: 3px; }
.day-dots { display: flex; gap: 4px; }
.day-dots i { width: 4px; height: 4px; border: 1px solid #a9bacb; border-radius: 50%; }
.day-dots i.planned { border-color: #527b9c; background: #527b9c; }
.day-dots i.done { border-color: var(--green); background: var(--green); }
.calendar-day[aria-pressed="true"] i.planned { background: #b7d4ee; border-color: #b7d4ee; }
.calendar-day[aria-pressed="true"] i.done { background: #9cdbc4; border-color: #9cdbc4; }
.map-note { font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
.month-jumps { display: none; }
.desk-columns { display: grid; grid-template-columns: minmax(280px, .85fr) minmax(400px, 1.35fr); gap: 30px; align-items: start; margin-top: 32px; }
.day-column { min-width: 0; }
.daily-planner { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 24px; scroll-margin-top: 20px; }
.day-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.day-heading h2 { font-size: 2rem; }
.day-nav { display: flex; gap: 6px; }
.icon-button { min-width: 40px; min-height: 42px; border: 1px solid var(--line); color: var(--ink); background: transparent; font-size: 1.2rem; }
.date-label { margin-top: 22px; color: var(--muted); font-size: .73rem; }
.date-label input { font-family: var(--utility); color: var(--ink); font-size: .82rem; }
.day-slots { display: grid; gap: 14px; margin: 22px 0 16px; }
.slot { border: 1px solid var(--line); border-radius: 6px; padding: 16px; background: #fbfcfe; }
.slot.active-slot { border-color: #7395b4; }
.slot.completed-slot { background: #f0f7f4; border-color: #c2dace; }
.slot-number { font-family: var(--utility); font-size: .65rem; color: var(--muted); letter-spacing: .06em; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.empty-slot { padding: 20px 16px; border-style: dashed; }
.empty-slot h3 { font-family: var(--display); font-size: 1.2rem; font-weight: 400; margin-bottom: 10px; }
.empty-slot p { color: var(--muted); font-size: .8rem; margin-bottom: 14px; }
.slot .chapter-meta { margin-bottom: 8px; }
.slot h3 { font-size: 1rem; margin-bottom: 12px; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.slot-actions button { padding: 8px 11px; font-size: .76rem; min-height: 40px; }
.slot-actions .complete-button { width: 100%; min-height: 44px; background: var(--ink); color: white; }
.completion-label { color: var(--green); font-size: .78rem; font-weight: 600; }
.subject-progress { padding: 28px 4px 16px; }
.subject-progress h2 { font-size: 1.5rem; margin-bottom: 20px; }
.progress-row { margin-bottom: 16px; }
.progress-label { display: flex; justify-content: space-between; font-size: .8rem; margin-bottom: 7px; }
.progress-label span:last-child { font-family: var(--utility); font-size: .72rem; color: var(--muted); }
progress { display: block; width: 100%; height: 5px; border: 0; border-radius: 4px; background: #d7e2eb; accent-color: var(--blue); }
progress::-webkit-progress-bar { background: #d7e2eb; border-radius: 4px; }
progress::-webkit-progress-value { background: var(--blue); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 4px; }
details { border-top: 1px solid var(--line); padding: 16px 0; }
summary { cursor: pointer; font-size: .85rem; font-weight: 600; min-height: 28px; }
details > p { margin-top: 12px; }
.pending-item, .history-item { padding: 13px 0; border-bottom: 1px solid var(--line); font-size: .82rem; }
.pending-item .text-button { font-size: .75rem; }
.history-item small { color: var(--muted); display: block; margin-top: 5px; }
.library { padding: 6px 0 0; scroll-margin-top: 20px; }
.library-total { font-family: var(--utility); font-size: .7rem; color: var(--muted); white-space: nowrap; }
.selection-hint { border-left: 3px solid var(--blue); padding: 10px 14px; background: #e0eaf3; font-size: .8rem; margin: 20px 0; }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.filters label { color: var(--muted); font-size: .7rem; }
.search-label { grid-column: 1 / -1; }
.filters input, .filters select { font-size: .8rem; }
.library-order { display: flex; justify-content: space-between; gap: 12px; font-size: .68rem; color: var(--muted); margin: 18px 0 10px; }
.chapter-list { display: grid; gap: 9px; }
.chapter-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 17px 18px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.chapter-card > div { min-width: 0; }
.chapter-card h3 { font-size: .9rem; font-weight: 600; margin: 7px 0 4px; }
.chapter-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .66rem; color: var(--muted); }
.chapter-code { font-family: var(--utility); font-size: .65rem; }
.priority-chip { display: inline-flex; gap: 5px; align-items: center; border-radius: 4px; padding: 2px 6px; font-size: .61rem; font-weight: 600; white-space: nowrap; }
.priority-chip::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.priority-chip.red { color: var(--red); background: #fae9ed; }
.priority-chip.yellow { color: var(--yellow); background: #fcf1da; }
.priority-chip.green { color: var(--green); background: #e4f2ec; }
.chapter-status { font-size: .69rem; color: var(--muted); }
.chapter-status.learned { color: var(--green); }
.add-chapter { background: #e9f0f6; color: var(--blue); font-size: .76rem; padding: 10px 12px; min-width: 64px; min-height: 44px; flex-shrink: 0; }
.source-note { margin-top: 20px; color: var(--muted); font-size: .75rem; }
.source-note summary { font-size: .75rem; }
.no-results { padding: 30px 20px; font-size: .9rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
footer { margin-top: 45px; border-top: 1px solid var(--line); padding: 20px 0 30px; display: flex; justify-content: space-between; gap: 16px; font-size: .72rem; color: var(--muted); }
footer > span:first-child { font-family: var(--display); font-style: italic; font-size: .95rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: white; border-radius: 8px; padding: 14px 22px; font-size: .85rem; box-shadow: 0 8px 30px #253d582b; z-index: 30; max-width: calc(100% - 32px); }
dialog { padding: 28px; border: 1px solid var(--line); border-radius: 10px; max-width: 440px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: #172f49a8; }
dialog h2 { margin-bottom: 16px; }
#move-chapter { font-size: .9rem; margin-bottom: 20px; }
#move-date { margin-top: 8px; }
#move-availability { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }
@media (min-width: 1400px) { .calendar-day { min-height: 46px; } }
@media (max-width: 1000px) {
  .calendars { gap: 18px; } .month + .month { padding-left: 16px; }
  .study-map { padding: 22px 20px 16px; }
  .desk-columns { gap: 22px; grid-template-columns: minmax(265px, .9fr) minmax(340px, 1.1fr); }
  .daily-planner { padding: 20px; }
  .filters { grid-template-columns: 1fr 1fr; } .filters label:last-child { grid-column: 1 / -1; }
  .calendar-day { min-height: 38px; }
  .map-legend { max-width: 210px; gap: 8px 14px; }
  .auth-layout { gap: 6%; padding-left: 0; padding-right: 0; }
  .auth-card { padding: 28px; }
}
@media (max-width: 740px) {
  .masthead { padding: 16px 5%; gap: 10px; }
  main { padding: 0 5%; }
  .brand { font-size: 1rem; } .brand-mark { width: 36px; height: 40px; }
  .term-label { max-width: 110px; text-align: right; font-size: .62rem; }
  #account-email { display: none; } .account { gap: 4px; }
  .account .quiet { padding: 8px; border: 0; font-size: .73rem; }
  .auth-layout { grid-template-columns: 1fr; gap: 32px; padding: 32px 0; min-height: auto; }
  .welcome h1 { font-size: 3.2rem; line-height: 1.05; margin: 16px 0; }
  .welcome h1 br:first-of-type { display: none; }
  .welcome > p:not(.eyebrow) { font-size: .9rem; }
  .term-strip { margin-top: 22px; }
  .term-strip strong { font-size: 1.7rem; }
  .auth-card { padding: 26px; }
  .desk-intro { padding: 28px 0 24px; align-items: start; gap: 14px; }
  .desk-intro h1 { font-size: 2.25rem; max-width: 270px; }
  .desk-intro > div > p:last-child { font-size: .8rem; max-width: 245px; }
  .headline-progress { min-width: 95px; padding-left: 14px; margin-top: 26px; }
  .headline-progress strong { font-size: 2rem; }
  .headline-progress strong span { font-size: 1rem; }
  .headline-progress > span, .headline-progress small { font-size: .64rem; }
  .section-top { gap: 12px; align-items: start; }
  .study-map .section-top { flex-direction: column; }
  .map-legend { max-width: none; gap: 16px; }
  .study-map { padding: 20px 18px 14px; }
  .study-map h2 { font-size: 1.5rem; }
  .study-map .eyebrow { font-size: .6rem; }
  .month-jumps { display: flex; gap: 6px; margin-top: 18px; }
  .month-jumps button { flex: 1; padding: 7px; font-size: .72rem; min-height: 40px; }
  .calendars { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 18px; margin-top: 16px; padding: 3px 3px 10px; }
  .month { flex: 0 0 100%; scroll-snap-align: start; }
  .month + .month { padding-left: 0; border: 0; }
  .calendar-day { min-height: 43px; font-size: .8rem; }
  .desk-columns { grid-template-columns: 1fr; margin-top: 24px; gap: 28px; }
  .daily-planner { padding: 22px; }
  .day-heading h2 { font-size: 2.15rem; }
  .day-slots { grid-template-columns: 1fr; }
  .subject-progress { padding-top: 24px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .library-total { padding-top: 30px; }
  .chapter-card { padding: 15px; gap: 12px; }
  .chapter-card h3 { font-size: .9rem; }
  .library-order { font-size: .65rem; }
  .error-banner { align-items: start; flex-direction: column; }
  footer { flex-direction: column; gap: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  #workspace, #auth { animation: settle .3s ease-out; }
  @keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
}
