@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

/* Paper canvas, hairline borders, ink-black actions, one blue accent.
   Color carries state only: blue = listening, red = recording, green = done, amber = in progress. */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1c1a17;
  --body: #3d3a35;
  --muted: #7a756d;
  --line: #e4e1db;
  --line-strong: #cfcac2;
  --surface: #f9f8f6;
  --neutral: #efede9;
  --ink: #1c1a17;
  --brand: #2346c2;
  --brand-soft: #eef1fb;
  --danger: #c0352b;
  --danger-soft: #fbeeec;
  --success: #1f7a4d;
  --success-soft: #eaf5ee;
  --warning: #9a5b0b;
  --warning-soft: #fbf3e4;
  --radius: 8px;
  --radius-sm: 6px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-underline-offset: 2px; }
h1, h2, h3, h4 { letter-spacing: -0.01em; color: var(--text); }
.hidden { display: none !important; }

/* Layout */
.app-shell { max-width: 1040px; margin: 0 auto; padding: 0 20px 120px; }
.student-shell { max-width: 680px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.wordmark { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.wordmark small { margin-left: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.topbar-user { font-size: 14px; color: var(--muted); }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; }
.card > h2:first-child, .card > h3:first-child, .panel > h2:first-child { margin-top: 0; }
.card h2 { font-size: 17px; font-weight: 650; margin: 0 0 6px; }
.card h3 { font-size: 15px; font-weight: 650; margin: 18px 0 8px; }
.eyebrow { display: block; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > .grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.help { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 4px 0 10px; }
.card > .help:first-of-type { margin-top: 0; }

/* Forms */
.field { margin: 0 0 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--body); margin-bottom: 6px; }
.field input, .field textarea, .field select, input.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--text);
}
.field textarea, textarea.input { min-height: 120px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus, input.input:focus, textarea.input:focus, select.input:focus, .btn:focus-visible, .tab-btn:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); vertical-align: -3px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--body); cursor: pointer; }
.option-card { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.option-card input { margin-top: 2px; flex: 0 0 auto; }
.option-card span { display: grid; gap: 2px; }
.option-card small { color: var(--muted); font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary, .btn.success { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover, .btn.success:hover { background: #34312c; }
.btn.danger { color: var(--danger); border-color: #e9c3be; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--body); }
.btn.ghost:hover { background: var(--neutral); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 5px; }
.btn.block { width: 100%; }

/* Tags and notices */
.status-pill, .tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 18px; background: var(--neutral); color: var(--body); white-space: nowrap; }
.status-pill:empty { display: none; }
.status-pill.success { background: var(--success-soft); color: var(--success); }
.status-pill.warn, .tag.warn { background: var(--warning-soft); color: var(--warning); }
.status-pill.danger { background: var(--danger-soft); color: var(--danger); }
.notice { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; color: var(--body); }
.notice.error { border-left-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

/* Student: login */
.login { max-width: 360px; margin: 14vh auto 0; }
.login .wordmark { display: block; font-size: 22px; margin: 0 0 24px; }

/* Student: choices */
.group-buttons { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.group-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 0; padding: 11px 12px; text-align: left; white-space: normal; font-size: 15px; }
.group-btn:disabled { opacity: .6; }
.student-choice-status { font-size: 12px; font-weight: 500; color: var(--muted); }
.group-btn.in-progress .student-choice-status { color: var(--warning); }
.group-btn.done { border-color: #b9dcc7; }
.group-btn.done .student-choice-status { color: var(--success); }
.student-set-buttons { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.student-set-buttons .group-btn { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 13px 14px; }
.student-set-buttons .group-btn:last-child { border-bottom: 0; }
.student-set-buttons .group-btn[aria-pressed="true"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--ink); }
.student-set-buttons .tag { margin-right: 6px; }
.resume-target { font-size: 15px; color: var(--body); }
.student-resume-btn { margin-top: 12px; }
.device-test summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--body); }
.device-test[open] summary { margin-bottom: 12px; }

/* Student: practice */
.progress-strip { position: sticky; top: 8px; z-index: 10; }
.progress-strip h2 { font-size: 16px; margin: 0; }
.read-status { font-size: 14px; color: var(--body); }
.read-steps { display: grid; grid-template-columns: repeat(var(--read-step-count, 6), 1fr); gap: 4px; margin-top: 12px; }
.read-step { padding-top: 6px; border-top: 3px solid var(--line); font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; }
.read-step.listen.done { border-top-color: var(--brand); color: var(--body); }
.read-step.record.done { border-top-color: var(--danger); color: var(--body); }
.read-step.active { border-top-color: var(--ink); color: var(--text); font-weight: 700; }
.script-card { padding: 16px 16px 20px; }
.script-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.script-heading .eyebrow { margin: 0; }
.script-text { font-size: 17px; line-height: 1.65; }
.group-script-list { display: grid; gap: 20px; }
.question-script-title { margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.bilingual-table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-top: 1px solid var(--line); }
.bilingual-head { padding: 6px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.bilingual-cell { position: relative; padding: 10px; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.bilingual-cell.english-col { color: var(--text); }
.bilingual-cell.korean-col { color: var(--body); font-size: 15px; background: var(--surface); }
.bilingual-cell.masked { user-select: none; }
.bilingual-cell.masked span { visibility: hidden; }
.bilingual-cell.masked::after { content: ""; position: absolute; inset: 12px 10px; border-radius: 3px; background: var(--neutral); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented .btn { border: 0; border-radius: 0; min-height: 30px; padding: 0 10px; font-size: 13px; background: var(--card); }
.segmented .btn + .btn { border-left: 1px solid var(--line-strong); }
.segmented .btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.student-listen-resume { margin: 0 0 10px; font-size: 14px; }

.floating-controls { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; width: min(520px, calc(100% - 20px)); display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 8px; border-radius: 12px; background: var(--ink); color: #fff; }
.floating-controls button, .floating-controls select { min-height: 42px; border: 0; border-radius: 8px; padding: 0 14px; font-weight: 600; background: #34312c; color: #fff; }
.floating-controls .play { flex: 1; max-width: 160px; background: #fff; color: var(--ink); }
.student-listen-percentage { flex-basis: 100%; text-align: center; font-size: 12px; color: #c9c4bb; }

.record-panel { text-align: center; padding: 8px 0 0; }
.record-btn { width: 76px; height: 76px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-weight: 700; font-size: 15px; }
.record-btn:disabled { opacity: .5; }
.record-btn.recording { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(192, 53, 43, .14); } }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 22px; margin: 8px 0 2px; }
.timer.compact { font-size: 16px; margin: 0; }
#recordStatus { font-size: 14px; }
#retrySavePanel .btn { margin-top: 8px; }
.saving-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(28, 26, 23, .45); }
.saving-overlay > div { padding: 14px 20px; border-radius: var(--radius); background: var(--card); font-weight: 600; }
body.is-busy { overflow: hidden; }
.audio-mini { width: 100%; height: 40px; margin-top: 8px; }

/* Teacher: tabs and tables */
.tabs { display: flex; gap: 22px; overflow-x: auto; margin: -8px 0 20px; border-bottom: 1px solid var(--line); }
.tab-btn { padding: 10px 0; border: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 600; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); box-shadow: inset 0 -2px 0 var(--ink); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; min-width: 720px; background: var(--card); }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.progress-toolbar { display: grid; gap: 10px; margin-bottom: 12px; }
.progress-toolbar input[type="date"] { margin-left: 6px; min-height: 30px; padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--card); }
.view-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.view-switch .btn { border: 0; border-radius: 0; background: var(--card); color: var(--body); }
.view-switch .btn + .btn { border-left: 1px solid var(--line-strong); }
.view-switch .btn.primary { background: var(--ink); color: #fff; }
.weekly-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.weekly-status { display: inline-block; min-width: 20px; text-align: center; font-size: 18px; line-height: 1; font-weight: 700; }
.weekly-status.complete { color: var(--success); }
.weekly-status.partial { color: var(--warning); }
.weekly-status.none { color: var(--line-strong); }
.weekly-legend .weekly-status { font-size: 13px; min-width: 0; }
.weekly-cell, .weekly-day-head { min-width: 56px; text-align: center; vertical-align: middle; }
.weekly-day-head span { color: var(--muted); font-size: 11px; font-weight: 500; }
#progressTableHead th, #progressTableBody [data-round-progress] { white-space: nowrap; }
.round-progress-bar { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.round-progress-bar progress { flex: 1; min-width: 0; height: 6px; accent-color: var(--ink); }
.round-student-cells { display: flex; flex-wrap: wrap; gap: 4px; }
.progress-cell { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--neutral); color: var(--muted); }
.progress-cell.done { background: var(--success-soft); color: var(--success); }
.progress-cell.partial { background: var(--warning-soft); color: var(--warning); }
.round-progress-detail > td { background: var(--surface); }
.round-student-list { display: grid; gap: 6px; }
.round-student { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--card); }
.round-student-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }

/* Teacher: rounds */
.round-year-box { padding: 4px 0 10px; }
.round-year-box + .round-year-box { border-top: 1px solid var(--line); padding-top: 14px; }
.round-year-head { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.round-grade-row { display: flex; align-items: flex-start; gap: 14px; padding: 6px 0; }
.round-grade-label { flex: 0 0 64px; padding-top: 6px; font-weight: 600; font-size: 13px; color: var(--muted); }
.round-grade-chips { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.round-grade-chips .round-card { flex: 1 1 100%; min-width: 0; }
.round-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 16em; min-height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); font-size: 14px; font-weight: 600; }
.round-chip:hover { background: var(--surface); }
.round-chip.active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.round-chip-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-chip-badge { font-size: 11px; font-weight: 500; color: var(--muted); }
.round-chip-badge + .round-chip-badge::before { content: "·"; margin-right: 6px; color: var(--line-strong); }
.round-chip-badge.warn { color: var(--warning); }
.round-chip-badge.muted { color: var(--danger); }
.round-list-empty { padding: 12px 0; }
.round-card { margin: 8px 0 10px; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); }
.round-summary { margin-bottom: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.round-summary h3 { margin: 0 0 2px; font-size: 16px; }
.round-details { padding-top: 14px; }
.round-edit-section { padding: 0 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.round-edit-section h4 { margin: 0 0 10px; font-size: 14px; }
details.round-edit-section > summary { cursor: pointer; list-style-position: inside; }
.round-edit-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.round-edit-section .timing-editor { margin-top: 10px; padding-top: 0; border-top: 0; }
.round-edit-section select.input.round-grade-select { width: 120px; flex: 0 0 120px; }
.round-script-textarea { min-height: 260px !important; margin-bottom: 10px; font-size: 14px; }
.timing-editor { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.timing-editor h3 { margin-top: 0; }
.timing-editor textarea { min-height: 120px; margin: 8px 0; font-size: 14px; }
.timing-review:empty { display: none; }
.timing-review { margin-top: 12px; }
.timing-review-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; font-size: 14px; }
.timing-review-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.timing-review-row { display: grid; grid-template-columns: 44px 100px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.timing-review-row:last-child { border-bottom: 0; }
.timing-review-row.playing { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.timing-review-time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--body); }
.timing-review-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.timing-review-actions { display: flex; gap: 4px; }
.group-editor { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.preview-list { max-height: 350px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 12px; background: var(--card); }
.preview-q { padding: 10px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; font-size: 14px; }
.preview-q:last-child { border-bottom: 0; }
.bilingual-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 6px; border-top: 1px solid var(--line); }
.bilingual-preview > div { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); }
.bilingual-preview > div:nth-child(even) { color: var(--muted); padding-left: 8px; }
.bilingual-preview > div:nth-last-child(-n+2) { border-bottom: 0; }
.exam-prep-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.exam-prep-editor .field:first-child { margin-top: 0; }
.exam-prep-editor textarea { min-height: 200px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(28, 26, 23, .45); }
.modal { width: min(760px, 100%); max-height: 88vh; overflow: auto; padding: 20px; border-radius: var(--radius); background: var(--card); }
.modal h3 { font-size: 14px; color: var(--muted); margin: 18px 0 6px; }
.log-item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-item:last-child { border-bottom: 0; }

/* Teacher: import */
.settings-card summary { cursor: pointer; font-size: 15px; font-weight: 650; }
.settings-card[open] summary { margin-bottom: 14px; }
.import-selectors { align-items: end; }
.import-selectors .field { flex: 1; min-width: 90px; margin: 0; }
.import-selectors input { max-width: 180px; }
.import-editor { border: 0; margin: 16px 0 0; padding: 16px 0 0; min-width: 0; border-top: 1px solid var(--line); }
.import-warnings:empty { display: none; }
.import-warnings { margin: 8px 0; padding-left: 18px; color: var(--warning); font-size: 13px; }
.import-raw { max-height: 250px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
#importQuestions { max-height: 480px; margin: 12px 0; }
#importSources { margin-bottom: 8px; }
#importSources p { margin: 0 0 4px; }
#importSources a { overflow-wrap: anywhere; }
details > summary { color: var(--body); }
.bulk-choices { display: grid; gap: 8px; margin: 14px 0; }
.bulk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.bulk-row > b { min-width: 36px; font-size: 14px; }
.bulk-choice { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 14px; }
.bulk-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.bulk-progress progress { flex: 1; min-width: 0; height: 6px; accent-color: var(--ink); }

@media (max-width: 680px) {
  .app-shell { padding: 0 12px 120px; }
  .topbar { margin-bottom: 14px; }
  .card, .panel { padding: 16px; }
  .grid-2, .exam-prep-grid { grid-template-columns: 1fr; }
  .script-card { padding: 14px 12px 16px; }
  .bilingual-cell { padding: 9px 8px; font-size: 15px; }
  .bilingual-cell.korean-col { font-size: 14px; }
  .round-grade-row { flex-direction: column; gap: 6px; }
  .round-grade-label { padding-top: 0; }
  .round-grade-chips { width: 100%; }
  .round-summary, .round-edit-section .row { flex-wrap: wrap; }
  .round-edit-section .row > .grow { flex-basis: 100%; min-width: 0; }
  .round-card input[type="file"] { max-width: 100%; }
  .group-editor .row input { min-width: 0; width: 0; flex: 1; }
  .timing-review-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .timing-review-text { display: none; }
}
