/* 리천 도구함 — 공통 스타일 */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --text: #1f1e1c;
  --text-2: #5f5e5a;
  --text-3: #888780;
  --border: rgba(31, 30, 28, 0.12);
  --border-strong: rgba(31, 30, 28, 0.25);
  --primary: #26215c;
  --on-primary: #ffffff;
  --accent: #534ab7;
  --accent-bg: #eeedfe;
  --accent-text: #3c3489;
  --bar: #afa9ec;
  --bar-hi: #7f77dd;
  --theory: #d85a30;
  --ok: #3b6d11;
  --ok-bg: #eaf3de;
  --warn: #854f0b;
  --warn-bg: #faeeda;
  --radius: 10px;
  --radius-lg: 16px;
  --ui-scale: 1;
  --tap: 48px;
  --opt: 36px;   /* 옵션(선택 버튼·숫자 조절) 높이 */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a19;
    --surface: #242423;
    --surface-2: #2c2c2a;
    --text: #f1efe8;
    --text-2: #b4b2a9;
    --text-3: #888780;
    --border: rgba(241, 239, 232, 0.12);
    --border-strong: rgba(241, 239, 232, 0.28);
    --primary: #cecbf6;
    --on-primary: #26215c;
    --accent: #afa9ec;
    --accent-bg: #3c3489;
    --accent-text: #eeedfe;
    --bar: #534ab7;
    --bar-hi: #afa9ec;
    --theory: #f0997b;
    --ok: #c0dd97;
    --ok-bg: #27500a;
    --warn: #fac775;
    --warn-bg: #633806;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1a19;
  --surface: #242423;
  --surface-2: #2c2c2a;
  --text: #f1efe8;
  --text-2: #b4b2a9;
  --text-3: #888780;
  --border: rgba(241, 239, 232, 0.12);
  --border-strong: rgba(241, 239, 232, 0.28);
  --primary: #cecbf6;
  --on-primary: #26215c;
  --accent: #afa9ec;
  --accent-bg: #3c3489;
  --accent-text: #eeedfe;
  --bar: #534ab7;
  --bar-hi: #afa9ec;
  --theory: #f0997b;
  --ok: #c0dd97;
  --ok-bg: #27500a;
  --warn: #fac775;
  --warn-bg: #633806;
  color-scheme: dark;
}

/* 수업 모드: 전자칠판용 확대 */
body.classroom { --ui-scale: 1.3; --tap: 60px; --opt: 46px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: calc(16px * var(--ui-scale));
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 700; font-size: 1.1em; display: flex; align-items: center; gap: 8px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; cursor: pointer; font-size: 0.9em;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-text); }
.icon-btn svg { width: 20px; height: 20px; }

/* 칩 / 버튼 */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  cursor: pointer; font-size: 0.9em; white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on, .chip[aria-selected="true"] { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent); }

.btn {
  min-height: var(--tap); padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 600;
  transition: transform 0.08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; padding: 0 32px; font-size: 1.1em; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.9em; font-weight: 500; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stepper button { width: var(--opt); height: var(--opt); border: 0; background: transparent; cursor: pointer; font-size: 1.1em; }
.stepper button:hover { background: var(--surface-2); }
.stepper output { min-width: 52px; font-size: 0.92em; text-align: center; font-weight: 600; }

select.select {
  height: var(--tap); padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: 0.85em; }

/* 도구 화면 공통 레이아웃 */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  min-height: calc(100vh - 61px);
}
.stage { padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.panel { background: var(--surface); border-left: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-body { flex: 1; min-height: 0; }
@media (max-width: 860px) {
  .tool-layout { grid-template-columns: minmax(0, 1fr); }
  .panel { border-left: 0; border-top: 1px solid var(--border); }
  .stage { padding: 20px 16px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 상단 바 공통 창: 명단 일괄 등록 · 저장/불러오기 */
.et-dlg { width: min(560px, 94vw); max-height: 88vh; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); padding: 18px 18px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.et-dlg::backdrop { background: rgba(0,0,0,.45); }
.et-dlg h2 { margin: 0 32px 6px 0; font-size: 1.2em; }
.et-dlg h2 small { font-size: .7em; color: var(--text-2); font-weight: 700; margin-left: 6px; }
.et-x { position: absolute; top: 10px; right: 10px; margin: 0; }
.et-x button { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 1.1em; color: var(--text-2); }
.et-x button:hover { background: var(--surface-2); }
.et-hint { color: var(--text-2); font-size: .85em; margin: 4px 0 8px; }
.et-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.et-in { flex: 1; min-width: 10em; height: 38px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 0 10px; }
.et-ta { width: 100%; min-height: 200px; font: inherit; font-size: .95em; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px; resize: vertical; }
.et-check { display: inline-flex; gap: 6px; align-items: center; font-size: .9em; }
.et-list { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow: auto; }
.et-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.et-list li > div { display: flex; flex-direction: column; min-width: 0; }
.et-list li .et-hint { margin: 0; }
.et-list li > span { display: flex; gap: 4px; flex-shrink: 0; }
.et-list .et-empty { justify-content: center; color: var(--text-2); }
.et-err { color: #e2453c; }
label.btn { cursor: pointer; }
@media (max-width: 700px) { .topbar .et-label { display: none; } }
.et-card { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin: 8px 0; font-size: .92em; }
.et-dlg .et-h3 { margin: 14px 0 4px; font-size: 1em; }
.et-choices { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.et-choices .btn { justify-content: flex-start; text-align: left; flex-wrap: wrap; }
.et-choices .btn small { font-weight: 400; opacity: .75; margin-left: 6px; font-size: .82em; }
.et-drive { margin-top: 12px; }
.et-update { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; z-index: 50; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 12px; background: #1d4ed8; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: .92em; max-width: calc(100vw - 24px); }
.et-update button { white-space: nowrap; flex: none; border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; cursor: pointer; background: #fff; color: #1d4ed8; font-weight: 700; }
.et-update button.ghost { background: transparent; color: #fff; opacity: .8; font-weight: 400; }
