/* ============ Speaking Prep — design system ============ */
:root {
  --bg: #f6f5f2;
  --bg-grain: #efede7;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e7e4dd;
  --line-strong: #d8d4ca;
  --text: #23211c;
  --text-soft: #6b675e;
  --text-faint: #a39e93;
  --accent: #5b5bd6;
  --accent-soft: #ecebfb;
  --accent-ink: #3d3db0;
  --todo: #d9534f;     /* 못했음 */
  --todo-soft: #fbeae9;
  --review: #2f86c9;   /* 복습필요 */
  --review-soft: #e7f1fa;
  --done: #3fa66a;     /* 완료 */
  --done-soft: #e7f4ec;
  --star: #e7b53b;
  --rec: #e0443a;      /* 녹음 */
  --shadow: 0 1px 2px rgba(40, 36, 28, 0.04), 0 8px 24px -12px rgba(40, 36, 28, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(30, 26, 18, 0.4);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 880px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #16151a;
  --bg-grain: #1b1a20;
  --surface: #211f27;
  --surface-2: #1b1a20;
  --line: #322f3a;
  --line-strong: #423e4d;
  --text: #ece9f1;
  --text-soft: #aaa4b6;
  --text-faint: #6f6a7a;
  --accent: #8b8bf0;
  --accent-soft: #2a2940;
  --accent-ink: #b9b9fb;
  --todo: #f0817d;
  --todo-soft: #3a2826;
  --review: #6cb3ec;
  --review-soft: #1f2c38;
  --done: #6fce96;
  --done-soft: #1e3026;
  --star: #f0c454;
  --rec: #f0655c;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 30px -14px rgba(0,0,0,0.6);
  --shadow-lg: 0 30px 80px -20px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }  /* class display rules must not override the hidden attribute */
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background-color .3s ease, color .3s ease;
}

.app { max-width: var(--maxw); margin: 0 auto; padding: 28px 20px 120px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: .5px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #8a5cf0);
  box-shadow: 0 6px 16px -6px var(--accent);
}
.brand-text h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.brand-text p { font-size: 12.5px; color: var(--text-soft); margin-top: 1px; }

.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.tab {
  cursor: pointer; font-family: var(--font); font-size: 13.5px; font-weight: 700;
  border: none; background: transparent; color: var(--text-soft);
  padding: 8px 16px; border-radius: 999px; transition: all .15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.stat {
  font-size: 12px; color: var(--text-soft); padding: 6px 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  white-space: nowrap;
}
.stat b { color: var(--accent-ink); font-weight: 700; }
.ghost-btn, .icon-btn {
  font-family: var(--font); cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); border-radius: 999px;
  transition: all .15s ease;
}
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.ghost-btn .ic { color: var(--accent); font-size: 11px; }
.ghost-btn:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-1px); }
.icon-btn { width: 38px; height: 36px; font-size: 16px; }
.icon-btn:hover { border-color: var(--line-strong); }

/* 녹음 중 표시 (헤더) */
.rec-indicator {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 700;
  color: var(--rec); background: var(--todo-soft);
  border: 1px solid transparent; border-radius: 999px; padding: 7px 12px;
}

/* ---------- Composer ---------- */
.composer {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 20px;
}
.composer-inner { display: flex; gap: 10px; align-items: flex-end; }
#koInput {
  flex: 1; resize: none; border: none; outline: none; background: transparent;
  font-family: var(--font); font-size: 16px; color: var(--text);
  line-height: 1.5; padding: 8px 6px; max-height: 160px;
}
#koInput::placeholder { color: var(--text-faint); }
.add-btn {
  flex-shrink: 0; cursor: pointer; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-family: var(--font);
  font-weight: 700; font-size: 14px; padding: 11px 20px; min-width: 90px;
  transition: all .15s ease; box-shadow: 0 6px 16px -8px var(--accent);
}
.add-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.add-btn:disabled { opacity: .65; cursor: default; transform: none; }
.add-spin { font-size: 13px; }
.composer-hint { font-size: 11.5px; color: var(--text-faint); margin: 8px 4px 2px; }
kbd {
  font-family: var(--font); font-size: 11px; background: var(--surface-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 6px; color: var(--text-soft);
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.filters { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-soft); transition: all .14s ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.search input {
  font-family: var(--font); font-size: 13.5px; padding: 8px 14px; width: 180px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--text); outline: none; transition: all .14s ease;
}
.search input:focus { border-color: var(--accent); width: 220px; }

/* ---------- List & rows ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px 14px 22px; transition: border-color .15s ease, transform .12s ease;
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row:hover { border-color: var(--line-strong); }
.row::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--todo);
}
.row[data-status="review"]::before { background: var(--review); }
.row[data-status="done"]::before { background: var(--done); }

.row-ko {
  font-size: 16.5px; font-weight: 600; color: var(--text); outline: none;
  border-radius: 6px; padding: 1px 3px; margin: -1px -3px;
}
.row-en {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 7px;
}
.row-en .en-text {
  font-size: 15.5px; color: var(--accent-ink); font-weight: 500; outline: none;
  border-radius: 6px; padding: 1px 3px; margin: -1px -3px; flex: 1;
  font-feature-settings: "ss01";
}
.row-en .en-text.empty::before { content: "영어 표현… (클릭해 입력)"; color: var(--text-faint); font-weight: 400; }
.row-ko:focus, .en-text:focus, .note-text:focus { background: var(--accent-soft); }
.speak-btn {
  flex-shrink: 0; cursor: pointer; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; width: 30px; height: 26px; font-size: 13px; color: var(--text-soft);
  transition: all .14s ease; margin-top: 1px;
}
.speak-btn:hover { border-color: var(--accent); color: var(--accent); }
.speak-btn.speaking { background: var(--accent); color: #fff; border-color: var(--accent); }

.row-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.status-select, .cat-input {
  font-family: var(--font); font-size: 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
  padding: 4px 10px; cursor: pointer; outline: none;
}
.status-select[data-status="todo"] { color: var(--todo); background: var(--todo-soft); border-color: transparent; }
.status-select[data-status="review"] { color: var(--review); background: var(--review-soft); border-color: transparent; }
.status-select[data-status="done"] { color: var(--done); background: var(--done-soft); border-color: transparent; }
.cat-input { width: 110px; cursor: text; }
.cat-input::placeholder { color: var(--text-faint); }

.meta-spacer { flex: 1; }
.mini-btn {
  cursor: pointer; border: none; background: transparent; color: var(--text-faint);
  font-size: 13px; font-family: var(--font); padding: 4px 7px; border-radius: 7px;
  transition: all .14s ease;
}
.mini-btn:hover { background: var(--surface-2); color: var(--text-soft); }
.star-btn.on { color: var(--star); }
.del-btn:hover { color: var(--todo); background: var(--todo-soft); }
.date-tag { font-size: 11px; color: var(--text-faint); }

.note-text {
  display: none; margin-top: 10px; font-size: 13.5px; color: var(--text-soft);
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 10px;
  padding: 9px 12px; outline: none; line-height: 1.6;
}
.note-text.show { display: block; }
.note-text:empty:not(:focus)::before { content: "메모 — 왜 못했는지, 뉘앙스, 대체 표현…"; color: var(--text-faint); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 70px 20px; color: var(--text-soft); }
.empty-art { font-size: 46px; opacity: .35; }
.empty h2 { font-size: 18px; margin: 14px 0 6px; color: var(--text); }
.empty p { font-size: 13.5px; }

/* ---------- Record card ---------- */
.rec-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 20px;
}
.rec-idle { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rec-btn {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  border: none; border-radius: 999px; font-family: var(--font);
  font-weight: 800; font-size: 15.5px; color: #fff; padding: 14px 26px;
  background: linear-gradient(135deg, var(--rec), #c73a68);
  box-shadow: 0 10px 24px -10px var(--rec); transition: all .15s ease;
}
.rec-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.upload-btn {
  cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--text-soft);
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: 12px 18px; transition: all .15s ease;
}
.upload-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.rec-hint { flex-basis: 100%; font-size: 12.5px; color: var(--text-faint); margin-top: 6px; line-height: 1.7; }
.rec-hint b { color: var(--text-soft); }

.rec-live { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.rec-status { display: flex; align-items: center; gap: 12px; }
.rec-pulse {
  width: 14px; height: 14px; border-radius: 50%; background: var(--rec);
  animation: pulse 1.2s ease infinite;
}
.rec-pulse.small { width: 9px; height: 9px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 68, 58, .45); }
  70% { box-shadow: 0 0 0 12px rgba(224, 68, 58, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 68, 58, 0); }
}
.rec-time { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rec-label { font-size: 12.5px; color: var(--text-faint); }
.rec-actions { display: flex; gap: 8px; }
.rec-stop {
  cursor: pointer; border: none; border-radius: 999px; font-family: var(--font);
  font-weight: 800; font-size: 14.5px; color: #fff; padding: 12px 22px;
  background: var(--rec); box-shadow: 0 8px 20px -8px var(--rec); transition: all .15s ease;
}
.rec-stop:hover { filter: brightness(1.08); }
.rec-cancel {
  cursor: pointer; font-family: var(--font); font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft);
  border-radius: 999px; padding: 12px 18px; transition: all .15s ease;
}
.rec-cancel:hover { border-color: var(--line-strong); color: var(--text); }

/* ---------- Lessons ---------- */
.lessons { display: flex; flex-direction: column; gap: 10px; }
.lesson {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; animation: pop .25s ease;
}
.lesson-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.lesson-title { font-size: 15.5px; font-weight: 700; }
.lesson-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.badge {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 12px;
}
.badge.ok { color: var(--done); background: var(--done-soft); }
.badge.half { color: var(--review); background: var(--review-soft); }
.badge.err { color: var(--todo); background: var(--todo-soft); }
.badge.busy { color: var(--accent-ink); background: var(--accent-soft); }
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lesson-error {
  margin-top: 10px; font-size: 12.5px; color: var(--todo);
  background: var(--todo-soft); border-radius: var(--radius-sm); padding: 8px 12px;
  line-height: 1.6; word-break: break-all;
}
.lesson-actions { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.lesson-btn {
  cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
  border-radius: 999px; padding: 6px 13px; transition: all .14s ease;
}
.lesson-btn:hover { border-color: var(--line-strong); color: var(--text); }
.lesson-btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 6px 14px -8px var(--accent);
}
.lesson-btn.primary:hover { filter: brightness(1.07); }
.lesson-btn.subtle { border-color: transparent; background: transparent; color: var(--text-faint); }
.lesson-btn.subtle:hover { background: var(--surface-2); color: var(--text-soft); }
.lesson-btn.danger { border-color: transparent; background: transparent; color: var(--text-faint); }
.lesson-btn.danger:hover { color: var(--todo); background: var(--todo-soft); }

/* ---------- Live (class) mode ---------- */
.live {
  position: fixed; inset: 0; z-index: 50;
  background:
    radial-gradient(1000px 700px at 50% -10%, var(--accent-soft) 0%, transparent 60%),
    var(--bg-grain);
  display: grid; place-items: center; animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.live-close {
  position: absolute; top: 22px; right: 26px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-soft);
  width: 42px; height: 42px; border-radius: 50%; font-size: 16px; transition: all .15s ease;
}
.live-close:hover { border-color: var(--todo); color: var(--todo); }
.live-stage { width: min(760px, 88vw); text-align: center; padding: 20px; }
.live-counter { font-size: 13px; color: var(--text-faint); letter-spacing: .1em; margin-bottom: 22px; }
.live-ko { font-size: clamp(22px, 4vw, 34px); font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.live-en {
  font-size: clamp(20px, 3.4vw, 30px); font-weight: 600; color: var(--accent-ink);
  margin-top: 18px; line-height: 1.4;
}
.live-note {
  font-size: 15px; color: var(--text-soft); margin-top: 18px; line-height: 1.6;
  max-width: 600px; margin-left: auto; margin-right: auto;
}
.live-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 40px; }
.live-nav {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 54px; height: 54px; border-radius: 50%; font-size: 24px; line-height: 1;
  transition: all .15s ease; box-shadow: var(--shadow);
}
.live-nav:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
.live-speak {
  cursor: pointer; border: none; background: var(--accent); color: #fff; font-family: var(--font);
  font-weight: 700; font-size: 16px; padding: 15px 28px; border-radius: 999px;
  box-shadow: 0 10px 24px -10px var(--accent); transition: all .15s ease;
}
.live-speak:hover { filter: brightness(1.07); transform: translateY(-2px); }
.live-filterhint { font-size: 12px; color: var(--text-faint); margin-top: 26px; }

/* ---------- Document viewer ---------- */
.doc {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(20, 18, 14, .45);
  display: grid; place-items: center; padding: 24px;
  animation: fade .2s ease;
}
.doc-panel {
  width: min(720px, 100%); max-height: min(82vh, 900px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.doc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.doc-head h2 { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.doc-close {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-soft); width: 34px; height: 34px; border-radius: 50%;
  font-size: 14px; transition: all .15s ease; flex-shrink: 0;
}
.doc-close:hover { border-color: var(--todo); color: var(--todo); }
.doc-body { overflow-y: auto; padding: 20px 24px 28px; }

.doc-body h3 {
  font-size: 15.5px; font-weight: 800; margin: 22px 0 10px;
  padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.doc-body h3:first-child { margin-top: 0; }
.doc-body h4 { font-size: 14px; font-weight: 700; margin: 16px 0 8px; }
.doc-body p { font-size: 14px; color: var(--text); margin: 8px 0; line-height: 1.7; }
.doc-body ul { margin: 8px 0 8px 4px; list-style: none; }
.doc-body li {
  font-size: 14px; line-height: 1.7; padding: 4px 0 4px 16px; position: relative;
}
.doc-body li::before {
  content: ""; position: absolute; left: 2px; top: 15px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  opacity: .55;
}
.doc-body code {
  font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}
.transcript {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  line-height: 1.8; white-space: pre-wrap; word-break: break-word;
  color: var(--text-soft);
}

/* 복습 노트 → 문장뱅크 */
.practice-box {
  margin-top: 24px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); padding: 14px 16px;
}
.practice-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; font-weight: 800; margin-bottom: 6px;
}
.p-add-all {
  cursor: pointer; border: none; border-radius: 999px; font-family: var(--font);
  font-size: 12px; font-weight: 700; color: #fff; background: var(--accent);
  padding: 6px 14px; transition: all .15s ease;
}
.p-add-all:hover { filter: brightness(1.07); }
.practice-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 2px; border-top: 1px solid var(--line);
}
.practice-row:first-of-type { border-top: none; }
.p-en { font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.p-ko { font-size: 12.5px; color: var(--text-soft); margin-top: 1px; }
.p-add {
  flex-shrink: 0; cursor: pointer; font-family: var(--font); font-size: 12px;
  font-weight: 700; color: var(--accent-ink); background: var(--accent-soft);
  border: none; border-radius: 999px; padding: 6px 13px; transition: all .15s ease;
}
.p-add:hover { filter: brightness(.97); }
.p-add:disabled { color: var(--done); background: var(--done-soft); cursor: default; }

/* ---------- Auth (login) ---------- */
.auth {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(1000px 700px at 50% -10%, var(--accent-soft) 0%, transparent 60%),
    var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: min(360px, 100%); text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg); padding: 36px 30px;
}
.auth-mark {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #8a5cf0);
  box-shadow: 0 8px 20px -8px var(--accent);
}
.auth-card h2 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.auth-card p { font-size: 13px; color: var(--text-soft); margin: 6px 0 18px; }
#authCode {
  width: 100%; font-family: var(--font); font-size: 16px; font-weight: 700;
  text-align: center; letter-spacing: .08em; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: all .15s ease;
}
#authCode:focus { border-color: var(--accent); }
#authBtn {
  width: 100%; margin-top: 10px; cursor: pointer; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-family: var(--font);
  font-weight: 700; font-size: 15px; padding: 12px;
  box-shadow: 0 8px 20px -8px var(--accent); transition: all .15s ease;
}
#authBtn:hover { filter: brightness(1.06); }
#authBtn:disabled { opacity: .6; cursor: default; }
.auth-err { margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--todo); }

/* ---------- Student bar ---------- */
.studentbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow);
  padding: 8px 14px; margin-bottom: 20px;
}
.sb-label { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-right: 2px; }
.sb-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sb-chip {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
  border-radius: 999px; padding: 6px 12px; transition: all .14s ease;
}
.sb-chip:hover { border-color: var(--line-strong); color: var(--text); }
.sb-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sb-chip .sb-x {
  font-size: 10px; opacity: 0; width: 0; overflow: hidden;
  transition: all .15s ease; border-radius: 50%;
}
.sb-chip:hover .sb-x { opacity: .7; width: 12px; }
.sb-chip .sb-x:hover { opacity: 1; }
.sb-add {
  cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 700;
  color: var(--accent-ink); background: var(--accent-soft);
  border: none; border-radius: 999px; padding: 7px 13px; transition: all .15s ease;
}
.sb-add:hover { filter: brightness(.97); }
.sb-academy { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.sb-logout {
  cursor: pointer; font-family: var(--font); font-size: 11.5px; font-weight: 600;
  color: var(--text-faint); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  transition: all .15s ease;
}
.sb-logout:hover { color: var(--todo); border-color: var(--todo); }

/* ---------- Progress bars ---------- */
.prog { display: flex; align-items: center; gap: 10px; margin-top: 11px; }
.prog-bar {
  flex: 1; height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line);
}
.prog-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #8a5cf0);
  transition: width .6s ease;
}
.prog-txt { flex-shrink: 0; font-size: 11.5px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.upload-prog { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---------- Usage table (admin) ---------- */
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th {
  text-align: left; font-size: 11.5px; color: var(--text-faint); font-weight: 700;
  padding: 6px 8px; border-bottom: 1px solid var(--line-strong);
}
.usage-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.usage-table td:nth-child(n+2), .usage-table th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.usage-table tfoot td { border-bottom: none; border-top: 2px solid var(--line-strong); }
.u-code { font-size: 10.5px; color: var(--text-faint); }
.usage-note { font-size: 11.5px; color: var(--text-faint); margin-top: 14px; line-height: 1.7; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; transition: all .25s ease; pointer-events: none; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .app { padding: 16px 12px 100px; }
  .brand-text p { display: none; }
  .ghost-btn .ic { display: none; }
  .search { flex: 1; }
  .search input, .search input:focus { width: 100%; font-size: 16px; } /* 16px = iOS 자동 확대 방지 */
  .topbar { gap: 10px; }
  .tabs { order: 3; width: 100%; justify-content: stretch; }
  .tab { flex: 1; padding: 10px 12px; }

  /* 학생 바 */
  .studentbar { border-radius: 16px; padding: 10px 12px; }
  .sb-academy { display: none; }
  .sb-chip { padding: 8px 14px; }
  .sb-chip .sb-x { opacity: .55; width: 12px; } /* 터치에선 hover 가 없으므로 항상 표시 */

  /* 녹음 카드 */
  .rec-card { padding: 16px; }
  .rec-idle { flex-direction: column; align-items: stretch; }
  .rec-btn, .upload-btn { justify-content: center; text-align: center; padding: 15px 20px; }
  .rec-live { flex-direction: column; align-items: stretch; gap: 12px; }
  .rec-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
  .rec-stop { padding: 14px 22px; }

  /* 수업 카드 & 문서 뷰어 */
  .lesson-btn { padding: 9px 15px; font-size: 13px; } /* 터치 타깃 확대 */
  .doc { padding: 0; align-items: end; }
  .doc-panel { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .doc-body { padding: 16px 18px 40px; }

  .row { padding: 14px 14px 12px 18px; }
  .composer-inner { align-items: stretch; }
  .add-btn { min-width: 74px; }
}

/* ---------- 수업 모드: 해석 보기 버튼 ---------- */
.live-reveal {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-family: var(--font); font-weight: 700; font-size: 15px;
  padding: 14px 22px; border-radius: 999px; box-shadow: var(--shadow);
  transition: all .15s ease;
}
.live-reveal:hover { border-color: var(--accent); color: var(--accent-ink); transform: translateY(-2px); }

/* ---------- 복습 노트: 교정 Before/After 카드 & 대화 말풍선 ---------- */
.fix-card { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 11px 14px; margin: 9px 0; }
.fx-bad { font-size: 13px; color: #c0524e; line-height: 1.55; }
[data-theme="dark"] .fx-bad { color: #ef8a86; }
.fx-good { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 14.5px; color: var(--done, #3fa66a); line-height: 1.55; }
.fx-good b { color: inherit; }
.fx-speak { flex-shrink: 0; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text-soft); border-radius: 8px; width: 38px; height: 32px; font-size: 13px; transition: all .15s ease; }
.fx-speak:active, .fx-speak.speaking { background: var(--accent); color: #fff; border-color: var(--accent); }
.fx-why { font-size: 12.5px; color: var(--text-soft); margin-top: 6px; line-height: 1.6; }
.chat-row { display: flex; margin: 7px 0; }
.chat-row.me { justify-content: flex-end; }
.bub { max-width: 86%; padding: 8px 13px; border-radius: 14px; border-bottom-left-radius: 5px; font-size: 13.5px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--line); }
.chat-row.me .bub { background: var(--accent-soft); border-color: transparent; border-bottom-left-radius: 14px; border-bottom-right-radius: 5px; }
.bub .who { display: block; font-size: 10.5px; font-weight: 800; color: var(--text-faint); margin-bottom: 2px; }
.chat-row.me .bub .who { color: var(--accent-ink); }

/* ---------- 학생 링크 버튼 (눈에 띄게) ---------- */
.sb-mylink {
  cursor: pointer; border: none; background: var(--accent); color: #fff;
  font-family: var(--font); font-size: 12.5px; font-weight: 700;
  padding: 9px 15px; border-radius: 999px; flex-shrink: 0;
  box-shadow: 0 6px 14px -8px var(--accent); transition: all .15s ease;
}
.sb-mylink:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ---------- 수업준비 탭 ---------- */
.prep-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.prep-title { font-size: 15.5px; font-weight: 800; margin-bottom: 4px; }
.prep-hint { font-size: 12.5px; color: var(--text-faint); margin-bottom: 12px; line-height: 1.6; }
#prepNote {
  width: 100%; resize: vertical; min-height: 110px;
  font-family: var(--font); font-size: 14px; line-height: 1.7; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none;
}
#prepNote:focus { border-color: var(--accent); }
.prep-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.prep-save { font-size: 12px; color: var(--text-faint); }
.prep-files { margin-top: 12px; }
.prep-empty { font-size: 13px; color: var(--text-faint); padding: 6px 2px; }
.prep-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-top: 1px solid var(--line);
}
.pf-name {
  cursor: pointer; border: none; background: none; text-align: left;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--accent-ink);
  padding: 2px 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pf-name:hover { text-decoration: underline; }
.pf-mark { color: var(--text-faint); font-size: 11px; }
.prep-file.sel .pf-mark { color: var(--accent); }
.prep-file.sel .pf-name { font-weight: 800; }
.pf-size { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.prep-gen {
  cursor: pointer; border: none; background: var(--accent); color: #fff;
  font-family: var(--font); font-weight: 700; font-size: 14.5px;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: 0 8px 20px -10px var(--accent); transition: all .15s ease;
}
.prep-gen:hover:not(:disabled) { filter: brightness(1.07); }
.prep-gen:disabled { opacity: .6; cursor: default; }
.prep-gen-out { margin-top: 6px; }
.prep-gen-out .practice-box { margin-top: 12px; }
.prep-viewer {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  margin-bottom: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.pv-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.pv-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-close {
  cursor: pointer; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text-soft); font-family: var(--font); font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; flex-shrink: 0;
}
.pv-close:hover { border-color: var(--todo); color: var(--todo); }
.pv-btns { display: flex; gap: 8px; flex-shrink: 0; }
.pv-pages {
  width: 100%; height: 82vh; overflow-y: auto; background: #525659;
  padding: 10px 0; text-align: center; -webkit-overflow-scrolling: touch;
}
.pv-page {
  display: block; margin: 0 auto 10px; background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); border-radius: 2px;
}
.pv-loading { color: #cfd2d6; font-size: 13px; padding: 28px 16px; }
/* 전체화면 모드 — 수업 중 PDF 를 화면 가득 (녹음 중 플로팅 메모는 그 위에 뜬다) */
.prep-viewer.full {
  position: fixed; inset: 0; z-index: 58; margin: 0;
  border: none; border-radius: 0;
  display: flex; flex-direction: column;
}
.prep-viewer.full .pv-pages { height: auto; flex: 1; }

/* ---------- 녹음 중 수업 메모 (→ 선생님 코멘트로 자동 반영) ---------- */
.rec-memo { margin-top: 14px; }
.rec-memo-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 13px; font-weight: 700; margin-bottom: 6px;
}
.rec-memo-hint { font-size: 11.5px; font-weight: 500; color: var(--text-faint); }
#recMemoInput {
  width: 100%; resize: vertical; min-height: 60px;
  font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
#recMemoInput:focus { border-color: var(--accent); }

/* ---------- 녹음 중 플로팅 수업 메모 ---------- */
.float-memo {
  position: fixed; right: 16px; bottom: 16px; z-index: 60;
  width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.fm-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; cursor: pointer; border: none; background: var(--surface-2);
  font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--text);
  padding: 10px 14px;
}
.fm-title { display: flex; align-items: center; gap: 8px; }
.fm-arrow { color: var(--text-faint); font-size: 12px; }
.fm-body { padding: 10px; }
#fmInput {
  width: 100%; resize: vertical; min-height: 84px;
  font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; outline: none;
}
#fmInput:focus { border-color: var(--accent); }

/* ---------- 수업 카드: 선생님 코멘트 ---------- */
.lesson-comment {
  margin: 10px 0 2px; padding: 10px 14px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.lc-label { font-size: 12px; font-weight: 700; color: var(--accent-ink); margin-bottom: 4px; }
.lc-text { font-size: 13.5px; color: var(--text); line-height: 1.6; white-space: pre-wrap; }
.lesson-commentedit { margin-top: 10px; }
.lc-input {
  width: 100%; resize: vertical; min-height: 64px;
  font-family: var(--font); font-size: 13.5px; line-height: 1.6; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.lc-input:focus { border-color: var(--accent); }
.lc-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ============ 조직(업체) 총 관리자 — 현황판 + 읽기 전용 열람 ============ */
.org-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.org-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.org-hint { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.org-table-wrap { overflow-x: auto; }
.org-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.org-table th, .org-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.org-table th { color: var(--muted); font-weight: 700; font-size: 11.5px; }
.org-table td b { font-weight: 800; }
.org-table .ot-code { color: var(--muted); font-size: 11px; margin-left: 6px; }
.org-table .ot-dim { color: var(--muted); }
.org-view-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--accent-ink);
  border-radius: 8px; padding: 5px 12px; font-family: var(--font);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.org-view-btn:hover { border-color: var(--accent); }
.org-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

.org-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent-soft); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 12px;
  padding: 9px 14px; margin-bottom: 12px; font-size: 13px;
}
.org-banner b { font-weight: 800; }
.org-banner button {
  margin-left: auto; border: none; background: var(--accent); color: #fff;
  border-radius: 8px; padding: 6px 12px; font-family: var(--font);
  font-size: 12px; font-weight: 700; cursor: pointer;
}

/* 현황판 모드 — 선생님용 UI 숨김 */
body.orgdash .tabs, body.orgdash .stat, body.orgdash #liveBtn,
body.orgdash .sb-label, body.orgdash .sb-chips, body.orgdash .sb-add,
body.orgdash .sb-mylink { display: none !important; }

/* 읽기 전용 열람 모드 — 수정·입력 UI 숨김/비활성 */
body.readonly .composer, body.readonly .sb-add, body.readonly .rec-card,
body.readonly .prep-actions, body.readonly .prep-gen, body.readonly .prep-gen-out,
body.readonly .pf-del,
body.readonly .lesson-btn[data-act="process"],
body.readonly .lesson-btn[data-act="regen"],
body.readonly .lesson-btn[data-act="comment"],
body.readonly .lesson-btn[data-act="delete"] { display: none !important; }
body.readonly .row [contenteditable],
body.readonly .status-select, body.readonly .cat-input,
body.readonly .row .note-input { pointer-events: none; }
body.readonly .row .mini-btn:not(.speak-btn) { display: none !important; }
