:root {
  color-scheme: light;
  --sea-950: #15343a;
  --sea-800: #175c58;
  --sea-600: #247f77;
  --sea-100: #dcebe7;
  --sea-050: #edf4f1;
  --paper: #fbfcfa;
  --ink: #1d3035;
  --muted: #64777a;
  --line: #d7e2df;
  --orange: #e87345;
  --orange-soft: #fae9df;
  --gold: #d8a93f;
  --white: #fff;
  --display: "Gowun Batang", "Noto Serif KR", serif;
  --body: "IBM Plex Sans KR", "Noto Sans KR", sans-serif;
  --mono: "DM Mono", monospace;
  font-family: var(--body);
  color: var(--ink);
  background: var(--sea-050);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background-color: var(--sea-050);
  background-image: linear-gradient(rgba(23, 92, 88, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(23, 92, 88, .035) 1px, transparent 1px);
  background-size: 32px 32px;
}
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}
.app-shell { min-height: 100vh; }
.boot-state { padding: 48px; color: var(--muted); }

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
  background: var(--paper);
}
.auth-visual {
  position: relative;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(32px, 6vw, 88px);
  color: var(--white);
  background-color: var(--sea-950);
  background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 44px 44px;
}
.auth-visual::after {
  position: absolute;
  right: -9rem;
  bottom: 8%;
  width: min(58vw, 680px);
  aspect-ratio: 1;
  border: 1px solid rgba(207, 228, 218, .35);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(207,228,218,.04), 0 0 0 98px rgba(207,228,218,.04), 0 0 0 180px rgba(207,228,218,.035);
  content: "";
  pointer-events: none;
}
.brand-lockup, .auth-bottom { position: relative; z-index: 1; }
.brand-lockup { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.4); color: #f0bf64; font-family: var(--mono); font-size: 19px; }
.auth-copy { position: relative; z-index: 1; max-width: 650px; margin: auto 0; padding: 72px 0; }
.eyebrow, .mono-label { color: var(--sea-600); font: 500 11px/1.4 var(--mono); letter-spacing: 0; text-transform: uppercase; }
.auth-visual .eyebrow { color: #f0bf64; }
.auth-copy h1 { max-width: 620px; margin: 22px 0 20px; font: 400 clamp(38px, 5vw, 70px)/1.28 var(--display); letter-spacing: 0; }
.auth-copy p { max-width: 420px; margin: 0; color: #c6d9d4; font-size: 15px; line-height: 1.9; }
.chart-coordinate { display: flex; justify-content: space-between; max-width: 440px; margin-top: 56px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.23); color: #a9c2bc; font: 11px var(--mono); }
.auth-bottom { color: #a9c2bc; font: 11px var(--mono); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 36px; }
.auth-card { width: min(100%, 360px); }
.auth-card h2 { margin: 12px 0 8px; font: 700 28px/1.35 var(--body); }
.auth-card > p { margin: 0 0 30px; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 17px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .search-input {
  width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 3px; padding: 0 13px; background: var(--white); color: var(--ink);
}
.field input::placeholder, .search-input::placeholder { color: #9aa8a6; }
.primary-button, .quiet-button, .icon-button, .mode-button, .choice-button {
  min-height: 42px; border: 1px solid transparent; border-radius: 3px; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; color: var(--white); background: var(--sea-800); font-weight: 600; }
.primary-button:hover { background: var(--sea-950); }
.primary-button:disabled { cursor: not-allowed; opacity: .48; }
.auth-form .primary-button { min-height: 48px; margin-top: 4px; }
.quiet-button { padding: 0 12px; background: transparent; color: var(--sea-800); font-size: 13px; font-weight: 600; }
.quiet-button:hover { background: var(--sea-100); }
.auth-switch { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; color: var(--muted); font-size: 13px; }
.form-error { min-height: 20px; margin: 0; color: #b4422d; font-size: 13px; }

.study-layout { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 24px 18px 18px; border-right: 1px solid var(--line); background: rgba(251,252,250,.94);
}
.sidebar .brand-lockup { color: var(--sea-950); padding: 0 8px 26px; }
.sidebar .brand-mark { border-color: var(--sea-800); color: var(--orange); }
.nav-label { padding: 14px 10px 8px; color: #879795; font: 500 10px var(--mono); }
.mode-list { display: grid; gap: 4px; }
.mode-button { display: flex; width: 100%; align-items: center; justify-content: space-between; padding: 0 11px; background: transparent; color: #526669; text-align: left; font-size: 13px; }
.mode-button:hover { background: var(--sea-050); }
.mode-button[aria-current="page"] { border-color: #c9ddd7; background: var(--sea-100); color: var(--sea-950); font-weight: 700; }
.mode-name { display: flex; align-items: center; gap: 10px; }
.nav-symbol { width: 20px; color: var(--sea-600); font: 15px var(--mono); text-align: center; }
.mode-count { color: #748582; font: 11px var(--mono); }
.sidebar-spacer { flex: 1; }
.sidebar-progress { margin: 14px 5px 22px; padding: 15px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sidebar-progress .mono-label { color: var(--muted); }
.progress-number { display: flex; align-items: baseline; gap: 5px; margin: 8px 0 10px; font: 500 22px var(--mono); }
.progress-number small { color: var(--muted); font: 12px var(--mono); }
.progress-track { height: 4px; overflow: hidden; background: #dce6e2; }
.progress-fill { width: 0; height: 100%; background: var(--orange); transition: width .3s ease; }
.user-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 0; }
.user-name { overflow: hidden; color: var(--sea-950); font-size: 13px; font-weight: 600; text-overflow: ellipsis; }
.icon-button { display: inline-grid; min-width: 38px; min-height: 38px; place-items: center; border-color: var(--line); background: var(--paper); color: var(--sea-800); }
.icon-button:hover { background: var(--sea-100); }
.icon-button[aria-pressed="true"] { border-color: #efc0a9; background: var(--orange-soft); color: #b84d2d; }
.workspace { min-width: 0; padding: 30px clamp(22px, 5vw, 68px) 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 1120px; margin: 0 auto 36px; }
.topbar .eyebrow { color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.search-form { display: flex; width: min(32vw, 290px); }
.search-input { min-height: 38px; background: rgba(255,255,255,.72); font-size: 12px; }
.search-form button { min-width: 42px; border: 0; background: transparent; color: var(--sea-800); cursor: pointer; font-size: 18px; }
.mobile-brand { display: none; }
.content { max-width: 960px; margin: 0 auto; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-heading h1 { margin: 8px 0 0; color: var(--sea-950); font: 700 clamp(25px, 3vw, 34px)/1.35 var(--body); }
.section-date { color: var(--muted); font: 11px var(--mono); }
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(251,252,250,.65); }
.stat { min-height: 88px; padding: 16px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value { display: block; margin-top: 5px; color: var(--sea-950); font: 500 24px var(--mono); }
.stat-value em { color: var(--sea-600); font: 500 11px var(--body); }
.question-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.question-index { color: var(--muted); font: 12px var(--mono); }
.question-index strong { color: var(--sea-950); font-size: 15px; font-weight: 500; }
.order-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); background: rgba(251,252,250,.72); }
.order-switch button { min-height: 30px; padding: 0 11px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.order-switch button[aria-pressed="true"] { background: var(--sea-800); color: var(--white); }
.question-actions { display: flex; gap: 7px; }
.question-card { position: relative; overflow: hidden; border: 1px solid #d5e0dc; background: var(--paper); box-shadow: 0 16px 40px rgba(21,52,58,.045); animation: rise-in .38s ease both; }
.question-card::before { position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--sea-600); content: ""; }
.question-inner { padding: clamp(22px, 4vw, 42px); }
.question-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 11px var(--mono); }
.meta-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--orange); }
.question-text { max-width: 770px; margin: 24px 0 30px; color: var(--sea-950); font: 500 clamp(18px, 2.2vw, 24px)/1.85 var(--body); word-break: keep-all; }
.choices { display: grid; gap: 9px; }
.choice-button { display: grid; width: 100%; grid-template-columns: 38px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 58px; padding: 8px 16px; border-color: var(--line); background: #fff; text-align: left; }
.choice-button:hover:not(:disabled) { border-color: var(--sea-600); background: #f5faf8; }
.choice-button[aria-pressed="true"] { border-color: var(--sea-600); background: var(--sea-100); box-shadow: inset 3px 0 var(--sea-600); }
.choice-button:disabled { cursor: default; }
.choice-key { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid #dce5e2; border-radius: 50%; color: var(--sea-800); font: 12px var(--mono); }
.choice-button[aria-pressed="true"] .choice-key { border-color: var(--sea-800); color: var(--sea-950); }
.choice-copy { font-size: 14px; line-height: 1.7; word-break: keep-all; }
.answer-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line); }
.answer-hint { color: var(--muted); font-size: 12px; }
.answer-result { display: none; margin-top: 24px; padding: 20px; border-left: 3px solid var(--sea-600); background: var(--sea-050); animation: reveal-in .25s ease both; }
.answer-result.is-visible { display: block; }
.answer-result.is-wrong { border-color: var(--orange); background: #fff6f1; }
.result-heading { display: flex; align-items: baseline; gap: 10px; margin: 0 0 9px; color: var(--sea-800); font-size: 17px; font-weight: 700; }
.is-wrong .result-heading { color: #b84d2d; }
.result-heading small { font: 12px var(--mono); }
.explanation-toggle { min-height: 32px; margin: 0 0 10px; padding: 0 10px; border: 1px solid #c5d9d3; border-radius: 3px; background: var(--paper); color: var(--sea-800); cursor: pointer; font-size: 12px; font-weight: 600; }
.is-wrong .explanation-toggle { border-color: #efc0a9; color: #b84d2d; }
.explanation-panel { display: none; }
.explanation-panel.is-open { display: block; animation: reveal-in .2s ease both; }
.explanation { margin: 0; color: #43595a; font-size: 13px; line-height: 1.9; white-space: pre-wrap; }
.source-details { margin-top: 16px; border-top: 1px solid var(--line); }
.source-details summary { width: fit-content; padding: 14px 0 0; color: var(--sea-800); cursor: pointer; font-size: 12px; font-weight: 600; }
.source-image { display: block; width: min(100%, 620px); margin-top: 14px; border: 1px solid var(--line); background: #fff; }
.no-explanation { color: var(--muted); font-size: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; }
.pager .quiet-button { border: 1px solid var(--line); background: var(--paper); }
.pager .quiet-button:hover:not(:disabled) { border-color: var(--sea-600); }
.pager .quiet-button:disabled { cursor: not-allowed; opacity: .45; }
.pager-count { color: var(--muted); font: 11px var(--mono); }
.empty-state { padding: 54px 24px; border: 1px dashed #bbd0ca; background: rgba(251,252,250,.62); text-align: center; }
.empty-state h2 { margin: 0 0 8px; color: var(--sea-950); font: 700 19px var(--body); }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 5; max-width: min(90vw, 380px); padding: 12px 16px; border: 1px solid #c9ddd7; background: var(--sea-950); color: var(--white); font-size: 13px; opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@keyframes rise-in { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes reveal-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (max-width: 880px) {
  .study-layout { grid-template-columns: 205px minmax(0, 1fr); }
  .workspace { padding-right: 24px; padding-left: 24px; }
  .stat { padding-right: 12px; padding-left: 12px; }
}
@media (max-width: 680px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { min-height: 42vh; padding: 24px; }
  .auth-copy { padding: 42px 0 28px; }
  .auth-copy h1 { margin: 12px 0; font-size: 34px; }
  .auth-copy p { font-size: 13px; }
  .chart-coordinate { margin-top: 23px; }
  .auth-bottom { display: none; }
  .auth-panel { min-height: 53vh; padding: 30px 24px 42px; }
  .study-layout { display: block; padding-bottom: 65px; }
  .sidebar { position: fixed; z-index: 4; top: auto; right: 0; bottom: 0; left: 0; height: auto; padding: 0; border-top: 1px solid var(--line); border-right: 0; background: var(--paper); }
  .sidebar .brand-lockup, .sidebar .nav-label, .sidebar-spacer, .sidebar-progress, .user-strip { display: none; }
  .mode-list { grid-template-columns: repeat(4, 1fr); gap: 0; }
  .mode-button { min-height: 58px; flex-direction: column; justify-content: center; gap: 3px; padding: 5px 2px; border: 0; border-radius: 0; font-size: 10px; }
  .mode-button[aria-current="page"] { border-top: 2px solid var(--orange); background: var(--sea-050); }
  .mode-name { flex-direction: column; gap: 1px; }
  .nav-symbol { font-size: 16px; }
  .mode-count { display: none; }
  .workspace { padding: 16px 16px 28px; }
  .topbar { margin-bottom: 25px; }
  .topbar > .eyebrow { display: none; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; color: var(--sea-950); font-size: 13px; font-weight: 700; }
  .mobile-brand .brand-mark { width: 28px; height: 28px; font-size: 14px; }
  .search-form { width: min(52vw, 230px); }
  .search-input { min-height: 36px; padding: 0 9px; }
  .section-heading { align-items: start; }
  .section-heading h1 { font-size: 24px; }
  .section-date { padding-top: 8px; font-size: 9px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); margin-bottom: 24px; }
  .stat { min-height: 68px; padding: 10px 13px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(n+3) { border-bottom: 0; }
  .stat-value { font-size: 20px; }
  .question-inner { padding: 22px 17px; }
  .order-switch { margin-left: auto; }
  .order-switch button { padding: 0 8px; }
  .question-text { margin: 18px 0 22px; font-size: 17px; }
  .choice-button { grid-template-columns: 32px minmax(0, 1fr); gap: 8px; min-height: 54px; padding: 7px 10px; }
  .choice-copy { font-size: 12px; }
  .answer-footer { align-items: end; }
  .answer-hint { max-width: 150px; font-size: 10px; }
  .answer-footer .primary-button { padding: 0 12px; font-size: 12px; }
  .toast { right: 12px; bottom: 75px; }
}