:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #23262f;
  --muted: #6b7080;
  --line: #e6e2d8;
  --brand: #3f6fd8;
  --brand-soft: #e7eefc;
  --ok: #1f9d6b;
  --ok-soft: #e1f5ec;
  --warn: #d98a00;
  --warn-soft: #fff3d6;
  --bad: #d64545;
  --bad-soft: #fde7e7;
  --wait: #7a5cd6;
  --wait-soft: #efeafd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c; --card: #1e2128; --ink: #eceef3; --muted: #9aa0ad; --line: #2e323b;
    --brand: #7aa2ff; --brand-soft: #22304f; --ok: #3ccf91; --ok-soft: #173a2c; --warn: #f2b13a; --warn-soft: #3d311a;
    --bad: #ff7676; --bad-soft: #432222; --wait: #a891ff; --wait-soft: #2d2747; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.3; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }

button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; min-height: 38px;
}
button:hover, .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { color: var(--bad); }
button.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { background: transparent; border-color: transparent; }
button.sm { padding: 4px 9px; min-height: 30px; font-size: .85rem; border-radius: 8px; }
button.big { font-size: 1.1rem; padding: 14px 22px; border-radius: 14px; min-height: 54px; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
textarea { width: 100%; min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.field { display: block; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
label.field input:not([type=checkbox]):not([type=radio]), label.field select { width: 100%; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--muted); white-space: nowrap; }
.badge.todo { background: var(--line); color: var(--muted); }
.badge.doing { background: var(--warn-soft); color: var(--warn); }
.badge.done, .badge.approved { background: var(--ok-soft); color: var(--ok); }
.badge.submitted { background: var(--wait-soft); color: var(--wait); }
.badge.rejected { background: var(--bad-soft); color: var(--bad); }
.badge.none { opacity: .6; }

.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; position: relative; }
.progress > i { position: absolute; top: 0; bottom: 0; background: var(--ok); border-radius: 999px; }
.progress.brand > i { background: var(--brand); }
.coverage { height: 14px; background: var(--line); border-radius: 6px; position: relative; overflow: hidden; }
.coverage > i { position: absolute; top: 0; bottom: 0; background: var(--ok); }
.coverage > b { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--ink); border-radius: 2px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 700; white-space: nowrap; }
.tabs a.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { padding-top: 10px; padding-bottom: 8px; }
.brand { font-weight: 800; font-size: 1.05rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 700; }
.table-wrap { overflow-x: auto; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 92px; height: 92px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
audio { width: 100%; max-width: 420px; height: 40px; }

.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; margin: 1px; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }
.wd-pick { display: flex; gap: 4px; flex-wrap: wrap; }
.wd-pick label { cursor: pointer; }
.wd-pick input { display: none; }
.wd-pick span { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--line); font-weight: 700; font-size: .85rem; }
.wd-pick input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }

.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat div { aspect-ratio: 1; border-radius: 6px; background: var(--line); font-size: .7rem; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.heat .l1 { background: color-mix(in srgb, var(--ok) 25%, var(--card)); }
.heat .l2 { background: color-mix(in srgb, var(--ok) 55%, var(--card)); color: #fff; }
.heat .l3 { background: var(--ok); color: #fff; font-weight: 800; }

.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { font-size: .8rem; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,12,18,.55); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); color: var(--ink); width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px 24px; }
@media (min-width: 700px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.modal-head h3 { margin: 0; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 480px; }
#toast div { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); text-align: center; }
#toast div.err { background: var(--bad); color: #fff; }
#toast div.ok { background: var(--ok); color: #fff; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
img.zoom { max-width: 100%; border-radius: 12px; }
.pre { white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: .9rem; max-height: 260px; overflow: auto; }
.missed .chip { border-color: var(--bad); color: var(--bad); }
.day-col { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--card); }
.day-col.today { border-color: var(--brand); }
.day-col.past { opacity: .8; }
.pl-item { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-top: 1px dashed var(--line); }
.pl-item:first-of-type { border-top: 0; }
.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.audio-pick { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.audio-pick label { display: flex; gap: 8px; align-items: center; padding: 4px; border-radius: 8px; }
.audio-pick label:hover { background: var(--bg); }
.order-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .75rem; align-items: center; justify-content: center; font-weight: 800; }

/* 듣기 퀴즈 */
.quiz-sentence { font-size: 1.2rem; line-height: 1.6; background: var(--bg); border-radius: 12px; padding: 12px 14px; min-height: 52px; }
.quiz-sentence .blank { display: inline-block; min-width: 64px; border-bottom: 3px solid var(--brand); text-align: center; color: var(--brand); font-weight: 800; }
.quiz-built .chip { font-size: 1rem; padding: 3px 10px; }
.quiz-choice { text-align: left; font-size: 1.05rem; padding: 12px 14px; min-height: 50px; width: 100%; }
.quiz-choice.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.quiz-choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { font-size: 1.05rem; padding: 10px 14px; min-height: 46px; }
.tile:disabled { opacity: .3; }
.quiz-feedback { text-align: center; padding: 10px; border-radius: 12px; font-size: 1.05rem; }
.quiz-feedback.right { background: var(--ok-soft); color: var(--ok); }
.quiz-feedback.wrong { background: var(--bad-soft); color: var(--bad); }
.quiz-review { margin: 6px 0 0; padding-left: 18px; }
.quiz-review li.wrong { color: var(--bad); }
