/* ============ 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: 5px;
  background: rgba(255, 255, 255, .5);
  -webkit-backdrop-filter: blur(18px) saturate(1.7);
  backdrop-filter: blur(18px) saturate(1.7);
  border: 1px solid rgba(255, 255, 255, .75); border-radius: 999px;
  box-shadow: 0 18px 44px -18px rgba(45, 35, 100, .35),
              inset 0 1px 0 rgba(255, 255, 255, .8);
}
[data-theme="dark"] .tabs {
  background: rgba(30, 29, 38, .55);
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .6),
              inset 0 1px 0 rgba(255, 255, 255, .08);
}
.tabs-ph { display: none; }
.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: rgba(91, 91, 214, .13); color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px rgba(91, 91, 214, .22);
}
[data-theme="dark"] .tab.active {
  background: rgba(139, 139, 240, .16);
  box-shadow: inset 0 0 0 1px rgba(139, 139, 240, .3);
}

.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); }

/* 묶어보기 — 대분류 폴더(나의 언어 패턴/예습/수업복습) + 헤더의 날짜 칩 */
.group-toggle {
  cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 600;
  padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-soft); transition: all .14s ease;
}
.group-toggle:hover { border-color: var(--line-strong); color: var(--text); }
.group-toggle.active { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.cat-group { margin-bottom: 4px; }
.cat-group > summary {
  cursor: pointer; list-style: none; user-select: none;
  font-size: 12.5px; font-weight: 800; color: var(--text-soft);
  padding: 10px 6px 6px;
}
.cat-group > summary::-webkit-details-marker { display: none; }
.cat-group > summary::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .15s ease; }
.cat-group[open] > summary::before { transform: rotate(90deg); }
.cg-cnt {
  font-weight: 700; font-size: 11px; color: var(--text-faint);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 1px 8px; margin-left: 4px;
}
.cg-dates { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 10px; vertical-align: 1px; }
.cg-date {
  cursor: pointer; font-family: var(--font); font-size: 11px; font-weight: 700;
  padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-soft); transition: all .12s ease;
}
.cg-date i { font-style: normal; color: var(--text-faint); margin-left: 4px; font-size: 10px; }
.cg-date:hover { border-color: var(--accent); color: var(--accent-ink); }
.cg-date.on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.cg-date.on i { color: var(--accent-ink); }
.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-en .en-star { display: none; color: #e7b53b; font-size: 13px; margin-top: 3px; flex-shrink: 0; }
.row.starred .en-star { display: inline; }
.row.starred .en-text:not(.empty) {
  text-decoration: underline;
  text-decoration-color: rgba(231, 181, 59, .45);
  text-decoration-thickness: .45em;
  text-underline-offset: -.18em;
  text-decoration-skip-ink: none;
}
.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 {
  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;
}
/* 클린 필: 네이티브 ▲▼ 제거, 작은 ▾ 하나만 (background-color 로 써야 셰브런 이미지가 안 지워짐) */
.status-select {
  -webkit-appearance: none; appearance: none;
  padding-right: 25px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="5" viewBox="0 0 8 5"><path d="M1 1l3 3 3-3" fill="none" stroke="%23a39e93" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center;
}
[data-theme="dark"] .status-select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="8" height="5" viewBox="0 0 8 5"><path d="M1 1l3 3 3-3" fill="none" stroke="%236f6a7a" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>');
}
.status-select[data-status="todo"] { color: var(--todo); background-color: var(--todo-soft); border-color: transparent; }
.status-select[data-status="review"] { color: var(--review); background-color: var(--review-soft); border-color: transparent; }
.status-select[data-status="done"] { color: var(--done); background-color: var(--done-soft); border-color: transparent; }
/* 카테고리 태그 — 자동 부여된 태그의 읽기전용 표시 (입력칸은 심플 원칙으로 제거, 2026-07-19) */
.cat-tag {
  font-size: 12px; color: var(--text-faint); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  white-space: nowrap;
}

.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-note { font-size: 11.5px; color: var(--text-faint); margin-top: 7px; }
.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; }

/* 업로드 실패로 보관된 녹음 — 유실 방지 배너 */
.upload-retry {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
}
.upload-retry .ur-txt { font-size: 13px; font-weight: 600; word-break: break-all; }
.upload-retry .ur-actions { display: flex; gap: 8px; }

/* ---------- 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; }
  /* 터치에선 hover 가 없으므로 항상 표시 + 누르는 영역을 손가락 크기로 확장 */
  .sb-chip .sb-x {
    opacity: .55; width: auto; font-size: 14px;
    padding: 10px 12px; margin: -10px -12px -10px -4px;
  }

  /* 녹음 카드 */
  .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-pagewrap { position: relative; margin: 0 auto 10px; }
.pv-page {
  display: block; background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.35); border-radius: 2px;
}
/* 텍스트 레이어 — 캔버스 위 투명 글자로 드래그 선택·복사 지원 (pdf.js v4) */
.pv-pagewrap .textLayer {
  position: absolute; inset: 0; overflow: hidden; line-height: 1;
  text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0;
  caret-color: CanvasText; z-index: 1;
}
.pv-pagewrap .textLayer :is(span, br) {
  color: transparent; position: absolute; white-space: pre;
  cursor: text; transform-origin: 0% 0%;
}
.pv-pagewrap .textLayer ::selection { background: rgba(91, 91, 214, .32); }
/* 링크 레이어 — PDF 속 URL 클릭 */
.pv-link {
  position: absolute; z-index: 2; border-radius: 3px;
  background: transparent; cursor: pointer;
}
.pv-link:hover { background: rgba(91, 91, 214, .15); box-shadow: 0 0 0 1.5px rgba(91, 91, 214, .5); }
.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; }
/* 전체화면 공통(PC·모바일) — 상단 바를 유튜브식 오버레이로: 잠시 뒤 자동 숨김,
   화면 탭/마우스 움직임으로 다시 표시 */
.prep-viewer.full .pv-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; border-bottom: none;
  background: linear-gradient(rgba(15, 14, 18, .72), rgba(15, 14, 18, 0));
  transition: opacity .25s ease;
}
.prep-viewer.full .pv-name { color: #fff; }
.prep-viewer.full .pv-close {
  background: rgba(30, 28, 36, .55); color: #eee; border-color: rgba(255, 255, 255, .18);
}
.prep-viewer.full .pv-close:hover { border-color: #fff; color: #fff; }
.prep-viewer.full .pv-head.pv-fade { opacity: 0; pointer-events: none; }

/* ---------- 녹음 중 수업 메모 (→ 선생님 코멘트로 자동 반영) ---------- */
.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); }

/* 녹음 복구 창 — 새로고침으로 끊긴 녹음 */
.rec-recover {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20, 18, 26, .45);
  display: grid; place-items: center; padding: 20px;
}
.rr-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px 22px 18px;
}
.rr-card h3 { font-size: 16px; font-weight: 800; margin-bottom: 8px; }
.rr-card p { font-size: 13.5px; color: var(--text); }
.rr-card .rr-hint { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.rr-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.rr-btn {
  cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 700;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 14px; flex: 1 1 auto;
}
.rr-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rr-btn.subtle { color: var(--text-faint); flex: 0 0 auto; }

/* 녹음 중 플로팅 번역(왼쪽 아래) — 한↔영 자동 감지해 문장뱅크로 */
.float-trans { left: 16px; right: auto; }
#ftInput {
  width: 100%; resize: vertical; min-height: 52px;
  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;
}
#ftInput:focus { border-color: var(--accent); }
.ft-add {
  margin-top: 8px; width: 100%; cursor: pointer; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-family: var(--font);
  font-weight: 700; font-size: 13px; padding: 9px 0; transition: filter .15s ease;
}
.ft-add:hover { filter: brightness(1.06); }
.ft-add:disabled { opacity: .6; cursor: default; }
/* 번역 결과 — 문장뱅크 카드와 같은 문법(한글 위, 영어 아래) */
.ft-result {
  margin-top: 9px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.ft-ko { font-size: 14px; font-weight: 600; color: var(--text); }
.ft-en-line { display: flex; align-items: flex-start; gap: 8px; margin-top: 5px; }
.ft-en { flex: 1; font-size: 13.5px; font-weight: 500; color: var(--accent-ink); line-height: 1.55; }
.ft-note { margin-top: 7px; font-size: 11px; font-weight: 700; color: var(--done); }
/* 모바일 — 카드 2장 대신 알약 버튼 2개 + 바텀시트 (수업 화면 공간 확보) */
.fab-row, .fab-backdrop { display: none; }
@media (max-width: 760px) {
  .float-memo { display: none; }            /* 카드는 기본 숨김 — 시트로만 열림 */
  .float-memo.sheet-open {
    display: block; left: 0; right: 0; bottom: 0; width: auto; z-index: 80;
    border-radius: 18px 18px 0 0; border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-up .22s ease;
  }
  .sheet-open .fm-arrow { display: none; }  /* 시트에선 접기 화살표 대신 배경/헤더 탭으로 닫기 */
  .fab-row {
    position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 60; display: flex; gap: 8px;
  }
  .fab-row[hidden] { display: none; }
  .fab-btn {
    cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 800;
    color: var(--text); background: var(--surface); border: 1px solid var(--line);
    border-radius: 999px; padding: 10px 15px; box-shadow: var(--shadow-lg);
  }
  .fab-backdrop { display: block; position: fixed; inset: 0; z-index: 70; background: rgba(20, 18, 26, .38); }
  .fab-backdrop[hidden] { display: none; }
  /* iOS는 16px 미만 입력창에 포커스하면 화면을 강제 확대(줌)한다 — 시트 입력창은 16px로 줌 방지 */
  .sheet-open #ftInput, .sheet-open #fmInput { font-size: 16px; }
}
@keyframes sheet-up { from { transform: translateY(60%); opacity: .6; } to { transform: none; opacity: 1; } }
/* 터치 기기 전체(가로모드 폭 760px 초과 포함) — iOS는 16px 미만 입력창 포커스 시 화면을 확대하므로
   타이핑하는 입력창은 모두 16px 이상으로. 데스크톱(마우스)에는 적용 안 됨 */
@media (pointer: coarse) {
  #ftInput, #fmInput, #recMemoInput, .search input, .row-en .en-text { font-size: 16px; }
}

/* ---------- 수업 카드: 선생님 코멘트 ---------- */
.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; }

/* ---- 현황판 v2: 요약 카드 + 호스트 카드 ---- */
.od-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
/* ① 주간 다이제스트 */
.od-digest { font-size: 15px; line-height: 1.9; }
.od-digest b { font-weight: 800; }
.od-up { color: var(--done); font-weight: 700; }
.od-dn { color: var(--todo); font-weight: 700; }
.od-same { color: var(--text-faint); font-weight: 600; }

/* ② 액션 인박스 */
.od-todo { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; border-top: 1px solid var(--line); }
.od-todo:first-child { border-top: none; }
.od-todo b { font-size: 13.5px; }
.od-todo p { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.od-ticon {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 14px;
}
.od-ticon.warn { background: #fdf2dd; }
.od-ticon.bad { background: var(--todo-soft); }
[data-theme="dark"] .od-ticon.warn { background: #3a3222; }
.od-allgood { text-align: center; padding: 14px; color: var(--text-soft); font-size: 13.5px; }

/* ③ 학생 로스터 */
.od-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.od-tbl th {
  text-align: left; font-size: 11px; color: var(--text-faint); font-weight: 700;
  padding: 6px 8px; border-bottom: 1px solid var(--line-strong);
}
.od-tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.od-tbl tr:last-child td { border-bottom: none; }
.od-pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 2px 9px; white-space: nowrap; }
.od-pill.ok { color: var(--done); background: var(--done-soft); }
.od-pill.warn { color: #b26a00; background: #fdf2dd; }
.od-pill.bad { color: var(--todo); background: var(--todo-soft); }
.od-pill.info { color: var(--accent-ink); background: var(--accent-soft); }
[data-theme="dark"] .od-pill.warn { color: #f0c454; background: #3a3222; }

.od-sumcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow);
}
.od-sumcard .k { font-size: 11.5px; color: var(--text-faint); font-weight: 700; }
.od-sumcard .v { font-size: 21px; font-weight: 800; margin-top: 4px; }
.od-sumcard .s { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
.od-host {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 2px; border-bottom: 1px solid var(--line);
}
.od-host:last-child { border-bottom: none; }
.od-id { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.od-id b { font-size: 14px; }
.od-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.od-badge.on { background: var(--done-soft); color: var(--done); }
.od-badge.idle { background: var(--todo-soft); color: var(--todo); }
.od-badge.off { background: var(--surface-2); color: var(--text-faint); border: 1px solid var(--line); }
.od-stats { display: flex; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.od-stat { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.od-stat .k { font-size: 10.5px; color: var(--text-faint); font-weight: 700; white-space: nowrap; }
.od-stat .v { font-size: 14px; font-weight: 800; white-space: nowrap; }
.od-stat.dim .v { color: var(--text-faint); font-weight: 600; }
.od-legend { font-size: 11.5px; color: var(--text-faint); line-height: 1.8; margin-top: 12px; }
.od-event {
  display: flex; gap: 12px; align-items: baseline;
  font-size: 12.5px; color: var(--text-soft); padding: 5px 0;
}
.od-ev-ts { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; min-width: 76px; }
@media (max-width: 640px) {
  .od-stats { margin-left: 0; gap: 14px; width: 100%; justify-content: space-between; }
  .od-stat { align-items: flex-start; }
  .od-host .org-view-btn { margin-left: auto; }
}

.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 .row .note-input { pointer-events: none; }
body.readonly .row .mini-btn:not(.speak-btn) { display: none !important; }

/* ---------- 문장 입력: 모바일 힌트 분기 + 입력 중 '추가' 버튼 강조 ---------- */
.composer-hint .hint-m { display: none; }
@media (max-width: 640px) {
  .composer-hint .hint-pc { display: none; }
  .composer-hint .hint-m { display: inline; }
}
.add-btn.ready {
  filter: brightness(1.12);
  box-shadow: 0 6px 18px -8px var(--accent);
  transform: translateY(-1px);
}

/* ---------- 모바일: 학생 드롭다운(프라이버시) + 카드 메타 한 줄 ---------- */
/* 상단바 학생 칩 — PC·모바일 공통 (E안: 학생 바 섹션 제거, 상단바 통합) */
.sb-current {
  display: flex; align-items: center; gap: 7px; flex: 0 1 auto; max-width: 200px;
  font: 700 13px/1.3 var(--font); color: var(--accent-ink); text-align: left;
  background: var(--accent-soft); border: 1px solid rgba(91, 91, 214, .35);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; transition: all .14s ease;
}
[data-theme="dark"] .sb-current { border-color: rgba(139, 139, 240, .4); }
.sb-current:hover { border-color: var(--accent); filter: brightness(1.04); transform: translateY(-1px); }
.sb-current .sbc-name { color: var(--accent-ink); }
.sb-current .sbc-chev { color: var(--accent-ink) !important; font-size: 12px; }
.sb-current .sbc-avatar { background: var(--accent); color: #fff; }
.sb-current .sbc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-current .sbc-chev { color: var(--text-faint); font-size: 10px; }
body.orgdash .sb-current { display: none !important; }
.sbc-avatar {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  font-size: 10.5px; font-weight: 800; flex-shrink: 0;
}
.sheet-academy { font-size: 11.5px; font-weight: 700; color: var(--text-faint); margin-left: 6px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-act {
  flex: 1; padding: 11px 8px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text-soft); cursor: pointer;
  font: 700 12.5px var(--font); white-space: nowrap;
}
.sheet-act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (max-width: 640px) {
  .stat { display: none; }  /* 상단바 공간 확보 — 오늘/전체 통계는 모바일에서 숨김 */
  /* 카드 하단 메타(상태·카테고리·날짜·버튼)가 🗑 하나만 다음 줄로 떨어지지 않게 */
  .row-meta { flex-wrap: nowrap; gap: 6px; }
  .row-meta .date-tag, .row-meta .mini-btn { flex-shrink: 0; }
}

/* ---------- 학생 선택 바텀시트 ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(12, 11, 16, .45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end;
  opacity: 0; transition: opacity .2s ease;
}
.sheet.open { opacity: 1; }
.sheet-panel {
  width: 100%; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 16px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
  transform: translateY(24px); transition: transform .2s ease;
}
.sheet.open .sheet-panel { transform: none; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 800; margin-bottom: 10px;
}
.sheet-close {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-soft);
  border-radius: 50%; width: 30px; height: 30px; font-size: 13px; cursor: pointer;
}
.sheet-list { max-height: 46vh; overflow-y: auto; }
.sheet-row {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 8px; border-radius: 12px; cursor: pointer;
  font-size: 15.5px; font-weight: 600;
}
.sheet-row:active { background: var(--surface-2); }
.sheet-row.cur { background: var(--accent-soft); }
.sheet-row.cur .sr-name { color: var(--accent-ink); font-weight: 800; }
.sheet-row .sr-name { flex: 1; }
.sheet-row .sr-check { color: var(--accent-ink); font-weight: 800; }
.sheet-row .sr-del {
  border: none; background: none; font-size: 15px; opacity: .5;
  padding: 8px 10px; margin: -8px -6px -8px 0; cursor: pointer;
}
.sheet-empty { color: var(--muted); font-size: 13.5px; padding: 14px 8px; }
.sheet-add {
  width: 100%; margin-top: 10px; padding: 13px;
  border: none; border-radius: 13px; cursor: pointer;
  background: var(--accent-soft); color: var(--accent-ink);
  font: 700 15px var(--font);
}

/* 학생 선택 패널: PC 에선 가운데 모달로 (모바일=바텀시트, 같은 컴포넌트) */
@media (min-width: 641px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet-panel {
    width: 420px; border-radius: 20px; padding: 18px 20px 20px;
    transform: translateY(8px) scale(.98);
  }
  .sheet.open .sheet-panel { transform: none; }
}

/* (구 푸터 개발자 버튼 제거됨 — 개발자 콘솔은 로컬 전용 /admin 페이지로 분리) */

/* ---------- 상단 탭바: 화면(뷰)과 무관하게 우측 상단 고정 ---------- */
@media (min-width: 641px) {
  .tabs { margin-left: auto; }
  .topbar-actions { flex-basis: 100%; justify-content: flex-start; }
}

/* ---------- 헤더 둘째 줄 우측: 학생 링크 + logout ---------- */
.topbar-actions .sb-mylink { flex-shrink: 0; }
.tb-logout {
  cursor: pointer; font: 600 12px var(--font); color: var(--text-faint);
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; flex-shrink: 0; transition: all .14s ease;
}
.tb-logout:hover { color: var(--todo); border-color: var(--todo); }
@media (max-width: 640px) {
  .topbar { position: relative; }
  .topbar-actions .sb-mylink { font-size: 11px; padding: 8px 10px; }
  .sb-mylink .lf { display: none; }              /* '복사' 생략 → 한 줄 확보 */
  .sb-current { max-width: 34vw; }               /* 긴 학생 이름은 말줄임 */
  /* logout 은 로고 줄 우측 상단으로 */
  .tb-logout {
    position: absolute; top: 10px; right: 0;
    font-size: 11px; padding: 7px 11px;
  }
  .topbar-actions { gap: 6px; flex-wrap: wrap; row-gap: 8px; }
  .ghost-btn { white-space: nowrap; }
  .topbar-actions .meta-spacer { display: none; }
  .tb-group { margin-left: auto; }
}

.tb-group { display: inline-flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ---------- 시트 안 학생 추가 입력 (인앱 브라우저는 prompt 차단) ---------- */
.sheet-addrow { display: flex; gap: 8px; margin-top: 10px; }
.sheet-addrow input {
  flex: 1; padding: 12px 13px; border: 1px solid var(--accent); border-radius: 13px;
  background: var(--surface-2); color: var(--text); font: 600 15px var(--font); outline: none;
}
.sheet-addrow button {
  padding: 12px 18px; border: none; border-radius: 13px; cursor: pointer;
  background: var(--accent); color: #fff; font: 700 14px var(--font);
}

/* ---------- 인앱 브라우저 안내 배너 ---------- */
.inapp-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff7e6; border: 1px solid #f0c36d; color: #6b5312;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 12.5px; line-height: 1.5;
}
[data-theme="dark"] .inapp-banner { background: #3a2f14; border-color: #7a6224; color: #f0d48a; }
.inapp-banner .ib-btns { margin-left: auto; display: flex; gap: 6px; }
.inapp-banner button {
  border: 1px solid currentColor; background: transparent; color: inherit;
  border-radius: 8px; padding: 5px 10px; font: 700 11.5px var(--font); cursor: pointer;
}

/* ---------- 터치 클릭 안정화 ----------
   iOS(인앱 브라우저 포함)에서 빠른 연속 탭이 '더블탭 확대'로 해석돼
   버튼 클릭이 씹히는 문제 방지 — 탭을 즉시 클릭으로 처리 (핀치 줌은 유지) */
button, .tab, .chip, .sb-current, .sheet-row, .row, input, select, textarea, label.upload-btn {
  touch-action: manipulation;
}

/* 🙈 영어 가리기(셀프 테스트) — 영어를 블러로 가리고 탭해서 확인 */
.en-text.hidden-en { filter: blur(7px); user-select: none; cursor: pointer; }
.peek-chip {
  font-size: 11px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 99px; padding: 3px 10px; align-self: center; white-space: nowrap;
  cursor: pointer; flex-shrink: 0;
}
