:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --coach: #ffffff;
  --me: #2f6fed;
  --me-text: #ffffff;
  --warn: #c2410c;
  /* 스크롤바 (2026-11-16): 손잡이는 배경과 대비 3:1 이상 (WCAG 1.4.11) */
  --scrollbar-thumb: #848b95;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1b1e24;
    --text: #e8eaed;
    --muted: #9aa0a8;
    --border: #2c3038;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --coach: #1f232a;
    --me: #3a6fe0;
    --me-text: #ffffff;
    --warn: #fb923c;
  --scrollbar-thumb: #6a717c;
  }
}
:root[data-theme="dark"] {
  --bg: #111317;
  --surface: #1b1e24;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --border: #2c3038;
  --accent: #5b8cff;
  --accent-text: #0b1020;
  --coach: #1f232a;
  --me: #3a6fe0;
  --me-text: #ffffff;
  --warn: #fb923c;
  --scrollbar-thumb: #6a717c;
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* 한글 줄바꿈 (2026-11-16): 단어 중간에서 끊지 않고, 정말 넘치는 긴 단어·주소만 끊는다 */
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* 제목은 줄 길이를 고르게, 문단은 마지막 줄에 한 단어만 남지 않게 (지원 안 하면 무시) */
h1, h2, .section-title, .sheet-title { text-wrap: balance; }
p, li, .bubble { text-wrap: pretty; }
/* 스크롤 영역은 테마에 맞는 얇은 스크롤바 */
.chat, .sheet-body, .crew-pop, #input {
  scrollbar-color: var(--scrollbar-thumb) transparent;
  scrollbar-width: thin;
}
#app { max-width: 640px; margin: 0 auto; height: 100%; }
.view { display: flex; flex-direction: column; min-height: 100%; padding: 16px; gap: 12px; }
.view[hidden] { display: none; }

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 8px 0 0; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { margin: auto; text-align: center; }
.center-text { text-align: center; margin: 0; }
.hello { margin: 4px 0 0; font-size: 1.05rem; }
.home-head { padding: 24px 0 8px; }
.section-title { font-size: 1rem; color: var(--muted); margin-top: 20px; }

button { font: inherit; cursor: pointer; }
.btn-primary {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 12px;
  padding: 10px 16px; font-weight: 600;
}
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-primary.big { padding: 16px; font-size: 1.1rem; width: 100%; }
.btn-text { background: none; border: 0; color: var(--muted); padding: 8px; }

.card, .history-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.history { display: flex; flex-direction: column; gap: 8px; }
.history-item .date { color: var(--muted); font-size: 0.85rem; }
.history-item p { margin: 4px 0 0; }

/* lesson */
#view-lesson { height: 100%; padding-bottom: 0; }
.lesson-head { display: flex; justify-content: space-between; align-items: center; }
.lesson-title { font-weight: 600; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; }
.bubble {
  max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere;
}
.bubble.coach { align-self: flex-start; background: var(--coach); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--me); color: var(--me-text); border-bottom-right-radius: 4px; }
.bubble.typing::after { content: "▍"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.silence { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.silence-bar { height: 100%; width: 0; background: var(--warn); transition: width 0.25s linear; }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); position: sticky; bottom: 0;
}
.composer textarea {
  flex: 1; resize: none; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; max-height: 140px;
}
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* summary */
.summary-block + .summary-block { margin-top: 14px; }
.summary-block h3 { font-size: 0.9rem; color: var(--muted); margin: 0 0 4px; }
.summary-block p, .summary-block ul { margin: 0; }
.summary-block ul { padding-left: 18px; }
.fix .wrong { text-decoration: line-through; color: var(--muted); }
.fix .note { color: var(--muted); font-size: 0.9rem; }

.head-actions { display: flex; gap: 4px; }
#btn-voice[aria-pressed="false"] { opacity: 0.5; text-decoration: line-through; }
.voicebar {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); background: var(--bg);
  position: sticky; bottom: 0;
}
.voicebar[hidden] { display: none; }
.live { min-height: 1.5em; margin: 0; text-align: center; font-size: 1.05rem; }
.status { margin: 0; font-size: 0.9rem; min-height: 1.35em; text-align: center; }
.voice-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 100%; gap: 8px; }
.voice-controls .btn-text:first-child { justify-self: end; }
.voice-controls .btn-text:last-child { justify-self: start; }
.btn-mic {
  width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: grid; place-items: center;
}
.btn-mic:disabled { opacity: 0.4; }
.btn-mic.listening { background: var(--warn); border-color: var(--warn); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.btn-mic.korean.listening { background: var(--accent); border-color: var(--accent); }
@keyframes pulse { 50% { transform: scale(1.06); } }
.composer[hidden] { display: none; }
.history-item { position: relative; }
.history-item .del {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); transition: background 0.15s, color 0.15s;
}
.history-item .del:hover { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.history-item .date { display: inline-block; margin-right: 40px; cursor: default; }

.voices { display: flex; flex-direction: column; gap: 6px; }
.voice-group { font-size: 0.85rem; color: var(--muted); margin: 6px 0 0; }
/* 다섯 명을 늘 한 줄에 (좁은 화면에선 카드를 줄인다) */
.voice-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.voice {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 10px 10px; cursor: pointer;
}
.voice.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.voice .avatar { width: min(64px, 100%); height: auto; aspect-ratio: 1; }
.voice strong { font-size: 1.05rem; }
.voice .meta { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.voice .badge {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 0.75rem; display: none; place-items: center;
}
.voice.selected .badge { display: grid; }
.voice .play {
  margin-top: 4px; background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 4px 12px; font-size: 0.85rem;
  white-space: nowrap; max-width: 100%;
}
.avatar { border-radius: 50%; display: block; }
.avatar.sm { width: 28px; height: 28px; }
.lesson-title { display: flex; align-items: center; gap: 8px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 20px; }
.section-head .section-title { margin-top: 0; }
.section-head .btn-text:hover { color: var(--warn); }

@media (max-width: 520px) {
  .voice-row { gap: 6px; }
  .voice { padding: 10px 4px 8px; border-radius: 12px; gap: 3px; }
  .voice strong { font-size: 0.9rem; }
  .voice .meta { font-size: 0.68rem; }
  .voice .badge { width: 16px; height: 16px; top: 4px; right: 4px; font-size: 0.6rem; }
  /* [▶ 듣기] → [▶] */
  .voice .play { font-size: 0; padding: 4px 12px; }
  .voice .play::before { content: "▶"; font-size: 0.75rem; }
}

/* 수업 시작 버튼 (코치 아바타 + 두 줄 글 + 화살표) */
.start-cta {
  --cta-a: #3f7cff;
  --cta-b: #2b5be0;
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 14px 14px 16px; border: 0; border-radius: 22px;
  background: linear-gradient(135deg, var(--cta-a), var(--cta-b));
  color: #fff; text-align: left; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(43, 91, 224, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.start-cta:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -8px rgba(43, 91, 224, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.start-cta:active { transform: scale(0.985); }
.start-cta:focus-visible { outline: 3px solid color-mix(in srgb, var(--cta-a) 45%, transparent); outline-offset: 3px; }
.start-avatar {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85);
}
.start-avatar[hidden] { display: none; }
.start-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; word-break: keep-all; }
/* 큰 줄: 연속 일수/오늘 한마디, 작은 줄: 실력 점수 (버튼 이름 '수업 시작'은 화면에선 빼고 aria-label로) */
.start-text strong { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.35; }
.start-text small { font-size: 0.85rem; opacity: 0.85; line-height: 1.35; }
.start-go {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transition: transform 0.15s ease, background 0.15s ease;
}
.start-cta:hover .start-go { transform: translateX(3px); background: rgba(255, 255, 255, 0.26); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .start-cta { --cta-a: #4a84ff; --cta-b: #3263e6; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
}
:root[data-theme="dark"] .start-cta { --cta-a: #4a84ff; --cta-b: #3263e6; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15); }
@media (prefers-reduced-motion: reduce) {
  .start-cta, .start-go { transition: none; }
  .start-cta:hover, .start-cta:active, .start-cta:hover .start-go { transform: none; }
}

/* 학습 현황 카드 */
.progress-card {
  margin-top: 4px; padding: 6px 2px 2px;
  display: flex; flex-direction: column; gap: 8px;
}
.progress-card[hidden] { display: none; }
/* 초급→중급 한 줄 길: 레벨 버튼이 --pos(0~100)만큼 오른쪽에 (양 끝에서도 길 안에 머문다) */
.lv-track { position: relative; height: 34px; }
.lv-line {
  position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px;
  border-radius: 999px; background: var(--border); overflow: hidden;
}
.pc-bar-fill { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #3f7cff, #2b5be0); transition: width 0.9s cubic-bezier(0.4, 0.8, 0.5, 1); }
.lv-badge {
  position: absolute; top: 50%; left: calc(var(--pos, 0) * 1%);
  transform: translate(calc(var(--pos, 0) * -1%), -50%);
  transition: left 0.9s cubic-bezier(0.4, 0.8, 0.5, 1), transform 0.9s cubic-bezier(0.4, 0.8, 0.5, 1), background 0.15s;
  display: inline-flex; align-items: center; gap: 4px; font: inherit; white-space: nowrap;
  font-weight: 700; font-size: 0.95rem; padding: 2px 8px 2px 6px; border: 0; border-radius: 999px; cursor: pointer;
  /* 길 위에 올라가니 불투명하게 */
  background: color-mix(in srgb, var(--accent) 14%, var(--bg)); color: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}
.lv-badge:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.lv-badge .pc-chevron { color: inherit; }
.lv-badge[aria-expanded="true"] .pc-chevron { transform: rotate(180deg); }
/* 레벨 동물 (거북이·토끼·치타): 걸을 때 다리를 엇갈려 흔들고 몸이 살짝 통통 */
.lv-ani-wrap { display: block; line-height: 0; }
.lv-ani { width: 32px; height: auto; display: block; margin: -1px 0; overflow: visible; }
.lv-ani .lg1, .lv-ani .lg2 { transform-box: fill-box; transform-origin: 50% 0; }
.lv-badge.walking .lv-ani { animation: lv-bob 0.18s ease-in-out infinite alternate; }
.lv-badge.walking .lv-ani .lg1 { animation: lv-leg 0.18s ease-in-out infinite alternate; }
.lv-badge.walking .lv-ani .lg2 { animation: lv-leg 0.18s ease-in-out infinite alternate-reverse; }
@keyframes lv-leg { from { transform: rotate(24deg); } to { transform: rotate(-24deg); } }
@keyframes lv-bob { from { transform: translateY(0); } to { transform: translateY(-1.5px); } }
@media (prefers-reduced-motion: reduce) { .lv-badge { transition: none; } .lv-badge.walking .lv-ani, .lv-badge.walking .lv-ani * { animation: none; } }
.pc-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; font-size: 0.9rem; }
.pc-week { flex: none; }
.pc-week {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; color: inherit;
  background: none; border: 0; padding: 2px 4px; margin: -2px -4px; border-radius: 8px; cursor: pointer;
}
.pc-week:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.pc-chevron { color: var(--muted); transition: transform 0.2s ease; }
.pc-week[aria-expanded="true"] .pc-chevron { transform: rotate(180deg); }
.pc-totals[hidden] { display: none; }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.pc-totals { margin: 0; font-size: 0.8rem; color: var(--muted); text-align: right; }
/* 설정 한 줄: [난이도 선택] [− 주 N회 +] [↺] */
.pc-settings {
  display: flex; align-items: center; gap: 8px; padding: 6px 0 12px;
  border-bottom: 1px solid var(--border); /* 설정 줄 아래 구분선 */
}
.pc-settings .icon-danger { margin-left: auto; } /* 초기화만 오른쪽 끝 */
.pc-settings[hidden] { display: none; }
/* 세그먼트 선택 [초급|기초|중급] + 자동 칩 */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.seg button {
  font: inherit; font-size: 0.8rem; border: 0; background: none; color: var(--muted);
  padding: 5px 9px; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
/* 미끄러지는 선택 표시: [초급|기초|중급] 위의 하얀 알약이 지금 레벨(--i)로 옮겨 간다 */
.seg-slide { position: relative; display: inline-grid; grid-template-columns: repeat(3, 1fr); }
.seg-slide button { position: relative; z-index: 1; padding: 5px 12px; }
.seg-slide button[aria-checked="true"] { background: none; box-shadow: none; }
.seg-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3);
  border-radius: 999px; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 0.35s cubic-bezier(0.3, 1.3, 0.5, 1);
}
@media (prefers-reduced-motion: reduce) { .seg-thumb { transition: none; } }
:root[data-theme="dark"] .seg-thumb { background: color-mix(in srgb, var(--text) 18%, var(--surface)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg-thumb { background: color-mix(in srgb, var(--text) 18%, var(--surface)); }
}
/* 자동 칩: 켜지면 파란 알약 + ✓ */
.auto-chip {
  flex: none; display: inline-flex; align-items: center; gap: 3px; font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s;
  border: 1px solid var(--border); background: none; color: var(--muted);
}
.auto-chip svg { display: none; }
.auto-chip:hover { color: var(--text); }
.auto-chip[aria-pressed="true"] {
  border-color: transparent; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.auto-chip[aria-pressed="true"] svg { display: block; }
.icon-danger {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: none; color: var(--warn);
}
.icon-danger:hover { background: color-mix(in srgb, var(--warn) 10%, transparent); }
@media (max-width: 380px) {
  .seg button { padding: 5px 9px; font-size: 0.76rem; }
  .auto-chip { padding: 5px 9px; font-size: 0.76rem; }
}

/* 수업 중 단계 표시 */
.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; padding: 0; }
.stepper li {
  font-size: 0.72rem; color: var(--muted); text-align: center; padding-top: 6px;
  border-top: 3px solid var(--border); transition: color 0.3s, border-color 0.3s;
}
.stepper li.done { border-top-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.stepper li.current { border-top-color: var(--accent); color: var(--text); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .pc-bar-fill, .ring-fg, .stepper li { transition: none; } }

/* 안내 말풍선 (코치 아바타 + 말풍선) */
.coach-tip { display: flex; align-items: flex-end; gap: 10px; margin: 6px 0 2px; }
.tip-avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; }
.tip-avatar[hidden] { display: none; }
.tip-bubble {
  position: relative; margin: 0; padding: 10px 14px; font-size: 0.88rem; line-height: 1.55;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
}

/* 로고 (시안 E: talk 말풍선) - 글자를 도형으로 바꾼 SVG, 색은 테마 변수 */
.logo-h1 { margin: 0; line-height: 0; }
.site-logo { height: 46px; width: auto; display: block; }
.site-logo .lg-ink { fill: var(--text); }
.site-logo .lg-accent { fill: var(--accent); }
.site-logo .lg-talk { fill: var(--accent-text); }
#view-login .site-logo { height: 56px; margin: 0 auto 12px; }

/* 로고 줄 + 테마 아이콘 (오른쪽 끝) */
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme-btn {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-btn svg { width: 22px; height: 22px; }
.theme-btn .ic-moon { fill: currentColor; }
.theme-btn .ic-sun { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn .ic-sun circle { fill: currentColor; stroke: none; }
/* 지금 밝으면 달(어둡게), 어두우면 해(밝게) */
.theme-btn .ic-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ic-sun { display: block; }
:root[data-theme="dark"] .theme-btn .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .ic-sun { display: block; }
  :root:not([data-theme="light"]) .theme-btn .ic-moon { display: none; }
}

/* 응원단만 하는 사람: 수업 부분을 숨긴다 */
.cheer-only .learner-only { display: none !important; }

/* 재촉 배너 */
.nudge-banner {
  display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); font-weight: 600;
}
.nudge-banner[hidden] { display: none; }
.nudge-banner > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nudge-banner small { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.nudge-close { flex: none; background: none; border: 0; color: var(--muted); width: 32px; height: 32px; border-radius: 50%; }
.nudge-close:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }

/* 크루: 로고 줄 오른쪽 아이콘 → 아이콘 아래 작은 창 */
.head-btns { position: relative; flex: none; display: flex; align-items: center; gap: 2px; }
.theme-btn[hidden] { display: none; }
.theme-btn .ic-crew { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-btn[aria-expanded="true"] { background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text); }
.crew-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: min(320px, calc(100vw - 32px));
  padding: 6px; border-radius: 22px;
  /* 반투명 + 흐림(유리), 얇은 테두리 대신 은은한 링, 겹친 부드러운 그림자 */
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--text) 7%, transparent),
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 8px 16px -6px rgba(0, 0, 0, 0.08),
    0 24px 48px -16px rgba(0, 0, 0, 0.22);
  transform-origin: top right;
  animation: crew-pop-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes crew-pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.96); } }
:root[data-theme="dark"] .crew-pop { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 48px -12px rgba(0, 0, 0, 0.7); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .crew-pop { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 48px -12px rgba(0, 0, 0, 0.7); }
}
@media (prefers-reduced-motion: reduce) { .crew-pop { animation: none; } }
.crew-pop[hidden] { display: none; }
.cheer-only .crew-pop { position: static; width: auto; animation: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 7%, transparent), 0 6px 20px -10px rgba(0, 0, 0, 0.15); }
.crew-pop-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; padding: 4px 10px 0; }
.crew-pop-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.crew-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.crew-member { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 16px; }
.crew-member.me { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.crew-av {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 0.8rem;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 700;
}
.crew-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.crew-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.crew-top strong { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crew-stat { flex: none; font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.crew-stat.done { color: #1f9d63; font-weight: 600; }
.crew-bar { height: 4px; border-radius: 999px; background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.crew-bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.4s ease; }
.crew-member.done .crew-bar-fill { background: #22a06b; }
.nudge-btn {
  flex: none; border: 0; border-radius: 999px; padding: 5px 11px; font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  background: var(--accent); color: var(--accent-text);
}
.nudge-btn:disabled { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); cursor: default; }
.crew-cheer { margin: 2px 10px 6px; font-size: 0.78rem; color: var(--muted); }
.bell-btn { background: none; border: 0; font-size: 0.95rem; width: 28px; height: 28px; padding: 0; border-radius: 50%; }
.bell-btn:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }

/* 머리 줄 선 아이콘 (지난 수업) */
.theme-btn .ic-line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* 지난 수업 시트: 휴대폰은 아래에서 올라오고, 넓은 화면은 가운데 상자 */
.sheet {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px;
  max-height: min(82vh, 720px); border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px -12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1); }
.sheet.dragging { transition: none; }
.sheet::backdrop { background: rgba(10, 12, 16, 0.4); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in 0.25s ease; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
/* 위쪽 손잡이 */
.sheet-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 20px 14px 10px 20px; touch-action: none; }
.sheet-head::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px;
  border-radius: 999px; background: color-mix(in srgb, var(--text) 16%, transparent);
}
.sheet-title { margin: 0; font-size: 1.1rem; }
/* 열 때 포커스는 제목에 ('전체 삭제'가 먼저 잡혀 선택된 것처럼 보이지 않게) */
.sheet-title:focus { outline: none; }
.sheet-close { margin-left: auto; }
.history-clear {
  display: block; margin: 14px auto 2px; padding: 8px 14px; border: 0; border-radius: 999px;
  background: none; color: var(--warn); font-size: 0.85rem; font-weight: 600;
}
.history-clear:hover { background: color-mix(in srgb, var(--warn) 10%, transparent); }
.sheet-close {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--muted);
}
.sheet-close:hover { color: var(--text); }
.sheet-body {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet .history-item { background: var(--bg); border: 0; }
.sheet-note { margin: -6px 20px 8px; font-size: 0.8rem; color: var(--muted); }
.history-empty { margin: 24px 0 32px; text-align: center; color: var(--muted); }
/* 기록 창이 열린 동안 뒤 페이지가 스크롤되지 않게 (modern-web-guidance: prevent-page-scroll-under-modal-dialog).
   예전엔 html에 overflow: hidden을 걸어 PC에서 스크롤바가 사라지며 화면이 옆으로 밀렸다 */
.sheet:modal { overscroll-behavior: contain; }
.sheet::backdrop { overflow: hidden; overscroll-behavior: contain; }
/* 아이폰 사파리는 아직 위 방식을 지원하지 않아, 스크롤바가 없는 터치 화면에서만 예전 방식을 남긴다 */
@media (pointer: coarse) { html:has(.sheet[open]) { overflow: hidden; } }
@media (min-width: 700px) {
  .sheet { inset: 0; margin: auto; width: min(560px, calc(100vw - 48px)); max-height: min(76vh, 680px); border-radius: 24px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.35); }
  .sheet[open] { animation: sheet-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
  .sheet-head::before { display: none; }
  .sheet-head { padding-top: 16px; }
}
@keyframes sheet-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@media (prefers-reduced-motion: reduce) { .sheet[open], .sheet::backdrop { animation: none; } }

/* 계절·이벤트 장식 (수업 시작 버튼 위) */
.start-cta { position: relative; }
.start-cta > :not(.cta-deco) { position: relative; z-index: 1; }
.cta-deco { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 0; }
.cta-deco:empty { display: none; }
/* 윗변 장식: 화살표 왼쪽 빈 곳 위. 그림 아래쪽 --lip만큼이 버튼 안으로 걸친다 */
.deco-edge { position: absolute; right: 76px; bottom: 100%; line-height: 0; transform: translateY(var(--lip, 0)); }
.deco-edge svg { display: block; overflow: visible; }
@media (max-width: 480px) { .deco-edge { right: 62px; transform-origin: 100% 100%; transform: translateY(calc(var(--lip, 0) * .8)) scale(.8); } }
/* 움직이는 것들: 버튼 안에서만 */
.deco-parts { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.dp { position: absolute; display: block; animation: linear infinite; animation-name: none; }
.dp svg { display: block; width: 100%; height: 100%; }
.dp-fall { top: -8px !important; animation-name: dp-fall; }
.dp-flutter-fall { top: -14px !important; animation-name: dp-flutter-fall; animation-timing-function: ease-in-out; }
.dp-rise { top: auto !important; bottom: -12px; animation-name: dp-rise; }
.dp-twinkle { animation-name: dp-twinkle; animation-timing-function: ease-in-out; }
@keyframes dp-fall {
  from { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; }
  to { transform: translate(var(--dx), 90px); opacity: 0; }
}
@keyframes dp-flutter-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 0; }
  12% { opacity: 1; }
  25% { transform: translate(9px, 24px) rotate(calc(var(--rot) * .25)); }
  50% { transform: translate(-7px, 48px) rotate(calc(var(--rot) * .5)); }
  75% { transform: translate(8px, 72px) rotate(calc(var(--rot) * .75)); }
  88% { opacity: 1; }
  100% { transform: translate(var(--dx), 96px) rotate(var(--rot)); opacity: 0; }
}
@keyframes dp-rise {
  from { transform: translate(0, 0); opacity: 0; } 20% { opacity: .9; } 80% { opacity: .9; }
  to { transform: translate(var(--dx), -95px); opacity: 0; }
}
@keyframes dp-twinkle { 0%, 100% { transform: scale(.3) rotate(0); opacity: 0; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }
/* 나비: 버튼 빈 곳을 천천히 오가며 날갯짓 */
.dp-butterfly { width: 28px; height: 23px; left: 50%; top: 30%; animation: dp-butterfly 14s ease-in-out infinite; }
.dp-butterfly .wing { transform-box: fill-box; transform-origin: 100% 50%; animation: dp-flap .28s ease-in-out infinite alternate; }
.dp-butterfly .wing-r { transform-origin: 0% 50%; }
@keyframes dp-flap { to { transform: scaleX(.35); } }
@keyframes dp-butterfly {
  0% { left: 46%; top: 55%; } 20% { left: 60%; top: 20%; } 40% { left: 78%; top: 45%; }
  50% { left: 82%; top: 25%; transform: scaleX(-1); } 70% { left: 66%; top: 60%; transform: scaleX(-1); }
  90% { left: 52%; top: 28%; transform: scaleX(-1); } 100% { left: 46%; top: 55%; }
}
/* 크리스마스 전구 깜빡임, 여름 해 살짝 돌기 */
.deco-edge .bulb { animation: dp-bulb 1.6s ease-in-out infinite; }
@keyframes dp-bulb { 50% { opacity: .45; } }
.deco-edge .rays { transform-origin: 30px 20px; animation: dp-rays 6s ease-in-out infinite alternate; }
@keyframes dp-rays { to { transform: rotate(8deg); } }
@media (prefers-reduced-motion: reduce) { .deco-parts { display: none; } .deco-edge * { animation: none !important; } }
