:root {
  color-scheme: light;
  --ink: #171a2b;
  --muted: #73778b;
  --line: #e8e9ef;
  --paper: #ffffff;
  --canvas: #f5f5f8;
  --violet: #6456e8;
  --violet-dark: #4e42c8;
  --violet-soft: #efedff;
  --mint: #1aa784;
  --rose: #df526a;
  --shadow: 0 18px 50px rgba(35, 35, 61, 0.08);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.58; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; padding-bottom: 92px; }
.topbar { height: 74px; padding: 0 max(24px, calc((100vw - 1160px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(245,245,248,.9); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid rgba(232,233,239,.8); }
.brand { display: flex; gap: 10px; align-items: center; border: 0; background: transparent; padding: 0; text-align: left; color: var(--ink); }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: white; font-weight: 900; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.03em; }
.brand small { display: block; color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.engine-pill, .count-badge { border: 1px solid #deddff; color: var(--violet-dark); background: var(--violet-soft); border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 700; }
main { width: min(1160px, calc(100% - 48px)); margin: 0 auto; }
.learning-mode-switch { width: min(360px, 100%); margin: 20px auto 0; padding: 5px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 6px 18px rgba(35,35,61,.035); }
.learning-mode-switch button { border: 0; border-radius: 10px; padding: 10px 14px; background: transparent; color: var(--muted); font-weight: 800; }
.learning-mode-switch button.active { color: white; background: var(--violet); }
.view { display: none; padding: 38px 0 24px; }
.view.active { display: block; animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.eyebrow { margin: 0 0 7px; font-size: 11px; font-weight: 850; letter-spacing: .14em; color: var(--violet); }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); line-height: 1.15; letter-spacing: -.05em; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.035em; }
.hero { min-height: 255px; border-radius: 30px; padding: 42px 46px; color: white; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; background: radial-gradient(circle at 82% 25%, rgba(129,116,255,.9), transparent 28%), linear-gradient(130deg, #171a2b 10%, #2e2c58 65%, #4f46a9); box-shadow: var(--shadow); }
.hero .eyebrow { color: #aaa4ff; }
.hero-summary { color: #d7d7e4; margin: 18px 0 0; }
.primary-button, .secondary-button, .ghost-button, .danger-button, .text-button { border-radius: 13px; padding: 12px 17px; font-weight: 750; border: 1px solid transparent; }
.primary-button { background: var(--violet); color: white; box-shadow: 0 8px 22px rgba(100,86,232,.22); }
.primary-button:hover { background: var(--violet-dark); }
.secondary-button { background: var(--violet-soft); color: var(--violet-dark); border-color: #ddd9ff; }
.ghost-button { background: white; color: #555a70; border-color: var(--line); }
.danger-button { background: #fff0f2; color: #c83c55; border-color: #ffd4dc; }
.text-button { background: transparent; color: var(--violet); padding-right: 0; }
.hero-button { background: white; color: var(--ink); white-space: nowrap; box-shadow: none; }
.hero-button:hover { background: #f2f1ff; }
.full-width { width: 100%; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.metric-card { min-height: 125px; padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 20px; display: grid; grid-template-columns: 1fr auto; align-items: end; box-shadow: 0 8px 24px rgba(35,35,61,.035); }
.metric-card.accent { background: var(--violet-soft); border-color: #ddd9ff; }
.metric-card span { grid-column: 1 / -1; align-self: start; color: var(--muted); font-size: 13px; }
.metric-card strong { font-size: 34px; letter-spacing: -.05em; }
.metric-card small { color: var(--muted); padding-bottom: 5px; }
.dashboard-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 18px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 24px; padding: 26px; box-shadow: 0 8px 30px rgba(35,35,61,.035); }
.panel-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading { align-items: flex-end; margin-bottom: 24px; }
.section-heading h1 { font-size: clamp(31px, 4vw, 44px); }
.test-toolbar { display: flex; align-items: center; gap: 14px; }
.speech-engine-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 750; }
.speech-engine-control select { width: auto; border: 1px solid var(--line); border-radius: 11px; padding: 9px 30px 9px 11px; background: white; color: var(--ink); font-weight: 750; }
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.legend-total { color: var(--violet); }
.legend-correct { color: var(--mint); }
.chart { min-height: 190px; margin-top: 18px; }
.chart svg { width: 100%; height: 190px; overflow: visible; }
.chart-grid { stroke: #ececf2; stroke-width: 1; }
.chart-total { fill: none; stroke: var(--violet); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-correct { fill: none; stroke: var(--mint); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: white; stroke-width: 2.5; }
.chart-label { fill: #9295a6; font-size: 10px; }
.weak-list { display: grid; gap: 10px; margin-top: 18px; }
.weak-item { padding: 13px 14px; background: #fafafd; border: 1px solid #ededf3; border-radius: 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.weak-item strong { font-size: 13px; }
.weak-item span { grid-column: 1; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weak-item em { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--rose); font-style: normal; font-weight: 800; }
.empty-state { color: var(--muted); text-align: center; padding: 28px 8px; font-size: 13px; }
.cost-panel { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.cost-panel p:not(.eyebrow) { color: var(--muted); font-size: 13px; margin: 7px 0 0; }
.cost-value { text-align: right; }
.cost-value strong { display: block; font-size: 25px; }
.cost-value span { color: var(--violet); font-weight: 800; }
.test-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.question-card { min-height: 550px; background: var(--paper); border: 1px solid var(--line); border-radius: 28px; padding: 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.question-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 700; }
#question-content { padding: 72px 5% 44px; text-align: center; }
.pattern-chip { display: inline-flex; padding: 7px 11px; border-radius: 999px; background: var(--violet-soft); color: var(--violet-dark); font-size: 11px; font-weight: 800; }
#korean-question { margin-top: 20px; font-size: clamp(27px, 5vw, 42px); line-height: 1.3; }
.prompt-caption { color: var(--muted); font-size: 13px; margin: 15px 0 0; }
.hint-box { margin: 0 auto 18px; width: min(520px, 100%); padding: 14px 17px; border: 1px dashed #cfcaff; background: #faf9ff; border-radius: 14px; text-align: center; }
.hint-box span { display: block; color: var(--violet); font-size: 10px; font-weight: 800; margin-bottom: 4px; }
.hint-box strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.feedback { width: min(620px, 100%); margin: 0 auto 18px; padding: 17px; border-radius: 16px; font-size: 13px; }
.feedback.success { background: #edfbf7; border: 1px solid #c8eee4; color: #08775c; }
.feedback.mismatch { background: #fff7f8; border: 1px solid #ffd9df; color: #872638; }
.feedback.warning { background: #fff9ea; border: 1px solid #f5e3a8; color: #795d09; }
.feedback p { margin: 5px 0; }
.word-diff { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.word-diff span { padding: 4px 7px; border-radius: 7px; background: white; border: 1px solid transparent; }
.word-diff .missing { text-decoration: line-through; border-color: #ffb8c4; }
.word-diff .extra { border-color: #f0cf72; background: #fff8df; }
.native-audio-actions { width: min(620px, 100%); margin: -4px auto 18px; display: flex; justify-content: center; }
.recognition-actions, .answer-actions { margin-top: auto; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.mic-button { min-width: 210px; border: 0; border-radius: 15px; padding: 14px 19px; color: white; background: var(--ink); font-weight: 800; display: flex; justify-content: center; align-items: center; gap: 10px; }
.mic-button.listening { background: var(--rose); animation: pulse 1.2s infinite; }
.mic-icon { width: 17px; height: 17px; display: grid; place-items: center; font-size: 8px; border-radius: 50%; background: rgba(255,255,255,.18); }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(223,82,106,.12); } }
.typing-fallback { width: min(560px, 100%); margin: 18px auto 0; text-align: center; color: var(--muted); font-size: 12px; }
.typing-fallback div { display: flex; margin-top: 10px; }
.typing-fallback input { flex: 1; border-radius: 11px 0 0 11px; border: 1px solid var(--line); padding: 11px; }
.typing-fallback button { border: 0; border-radius: 0 11px 11px 0; background: var(--violet); color: white; padding: 0 16px; }
.session-panel { background: var(--ink); color: white; border-radius: 24px; padding: 25px; position: sticky; top: 92px; }
.session-panel .eyebrow { color: #aaa4ff; }
.session-panel dl { margin: 24px 0; display: grid; gap: 13px; }
.session-panel dl div { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,.11); padding-bottom: 12px; }
.session-panel dt { color: #b9bac7; font-size: 12px; }
.session-panel dd { margin: 0; font-weight: 850; }
.session-note { color: #aeb0bf; font-size: 11px; line-height: 1.6; margin: 14px 0 0; }
.library-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; margin-bottom: 18px; }
.photo-drop { width: 100%; min-height: 190px; margin: 18px 0 10px; padding: 0; color: var(--ink); border: 1.5px dashed #cbcbd7; border-radius: 18px; display: grid; place-items: center; overflow: hidden; background: #fafafd; text-align: center; cursor: pointer; }
.photo-drop span strong, .photo-drop span small { display: block; }
.photo-drop span small { color: var(--muted); margin-top: 7px; }
.photo-preview-grid { width: 100%; padding: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.photo-preview-item { min-width: 0; position: relative; }
.photo-preview-item img { width: 100%; aspect-ratio: 3 / 4; display: block; object-fit: cover; border-radius: 10px; background: #efeff4; }
.photo-preview-item small { position: absolute; right: 4px; bottom: 4px; max-width: calc(100% - 8px); padding: 3px 5px; overflow: hidden; border-radius: 6px; background: rgba(23,26,43,.82); color: white; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.photo-preview-item.success small { background: rgba(8,119,92,.9); }
.photo-preview-item.error small, .photo-preview-item.cancelled small { background: rgba(200,60,85,.9); }
.photo-source-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.photo-source-actions label { display: flex; justify-content: center; align-items: center; cursor: pointer; text-align: center; }
.photo-source-actions input { display: none; }
.photo-batch-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 10px; }
.photo-batch-actions > strong { font-size: 12px; color: var(--violet-dark); }
.photo-batch-actions > div { display: flex; gap: 6px; }
.photo-batch-actions button { padding: 8px 10px; font-size: 11px; }
.form-help { font-size: 11px; color: var(--muted); line-height: 1.5; }
textarea, input { width: 100%; border: 1px solid #dfe0e8; background: white; border-radius: 12px; padding: 12px 13px; color: var(--ink); outline: none; }
textarea:focus, input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(100,86,232,.1); }
textarea { resize: vertical; line-height: 1.55; }
.import-panel textarea { margin-bottom: 12px; }
#sentence-form { display: grid; gap: 12px; margin-top: 18px; }
#sentence-form label { display: grid; gap: 6px; color: #4f5366; font-size: 12px; font-weight: 700; }
#sentence-form label small { color: var(--muted); font-weight: 400; }
.sentence-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.sentence-toolbar > input { max-width: 420px; }
.sentence-toolbar > div { display: flex; gap: 8px; }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
.file-button input { display: none; }
.sentence-list { display: grid; gap: 9px; margin-top: 18px; }
.sentence-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 15px 17px; border-radius: 15px; border: 1px solid #ededf3; background: #fbfbfd; }
.sentence-row strong { font-size: 13px; }
.sentence-row p { grid-column: 1; margin: 0; color: #676b7d; font-size: 13px; }
.sentence-row small { grid-column: 1; color: #a0a2af; }
.sentence-row button { grid-column: 2; grid-row: 1 / 4; align-self: center; border: 0; color: var(--violet); background: var(--violet-soft); border-radius: 9px; padding: 8px 10px; font-size: 11px; font-weight: 750; }
.bottom-nav { position: fixed; z-index: 30; bottom: 18px; left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 28px)); padding: 7px; background: rgba(23,26,43,.94); backdrop-filter: blur(16px); border-radius: 20px; display: grid; grid-template-columns: repeat(3,1fr); box-shadow: 0 15px 38px rgba(23,26,43,.22); }
.bottom-nav button { border: 0; border-radius: 14px; background: transparent; color: #aeb0bd; padding: 9px; font-size: 11px; font-weight: 700; }
.bottom-nav button span { display: block; font-size: 14px; margin-bottom: 3px; }
.bottom-nav button.active { color: white; background: rgba(255,255,255,.1); }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 100px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: #171a2b; color: white; border-radius: 12px; padding: 12px 16px; font-size: 12px; box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  main { width: min(100% - 28px, 680px); }
  .topbar { padding: 0 18px; }
  .hero { min-height: 300px; padding: 30px; align-items: flex-start; flex-direction: column; justify-content: space-between; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .test-layout, .library-grid { grid-template-columns: 1fr; }
  .session-panel { position: static; }
  .sentence-toolbar { align-items: stretch; flex-direction: column; }
  .sentence-toolbar > input { max-width: none; }
}

@media (max-width: 520px) {
  .view { padding-top: 24px; }
  .hero { border-radius: 24px; padding: 27px 24px; }
  .hero h1 { font-size: 34px; }
  .metric-grid { gap: 9px; }
  .metric-card { min-height: 111px; padding: 17px; }
  .metric-card strong { font-size: 29px; }
  .panel, .question-card { border-radius: 20px; padding: 20px; }
  .cost-panel { align-items: flex-start; flex-direction: column; }
  .cost-value { text-align: left; }
  #question-content { padding: 48px 0 34px; }
  .question-card { min-height: 570px; }
  #view-test > .section-heading { align-items: stretch; flex-direction: column; }
  .test-toolbar { justify-content: space-between; }
  .recognition-actions > *, .answer-actions > * { flex: 1 1 42%; }
  .native-audio-actions > * { width: 100%; }
  .mic-button { flex-basis: 100%; order: -1; }
  .sentence-toolbar > div { display: grid; grid-template-columns: 1fr 1fr; }
  .legend { display: none; }
  .photo-preview-grid { grid-template-columns: repeat(3, 1fr); }
}
