:root {
  --bg-page: #eef2ff;
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --accent: #0ea5e9;
  --emerald: #10b981;
  --emerald-soft: #d1fae5;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --rose: #ef4444;
  --rose-soft: #fee2e2;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 26px rgba(79, 70, 229, 0.1);
  --zh-font: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', 'Apple SD Gothic Neo', sans-serif;
  --ui-font: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--ui-font);
  height: 100%;
  overscroll-behavior-y: none;
}

.zh-font {
  font-family: var(--zh-font);
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  position: relative;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

/* 상단 바 */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-family: var(--zh-font);
  font-weight: 800;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.brand-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.live {
  background: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.status-dot.demo {
  background: var(--amber);
}

/* 메인 스크롤 영역 */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 28px;
  scroll-behavior: smooth;
}

/* 상·하 50:50 분할 따라쓰기 집중 모드일 때 스크롤 잠금 및 정확한 절반 배치 */
.main-content.split-mode {
  overflow: hidden;
  padding: 8px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split-top-half {
  flex: 1 1 50%;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.split-bottom-half {
  flex: 1 1 50%;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 11px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.split-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  flex-wrap: nowrap;
}

.chip-action {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 800;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chip-action.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.chip-action.shuffle-on {
  background: #7c3aed;
  color: #ffffff;
  border-color: #7c3aed;
}

.split-char-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 2px 0;
  min-height: 0;
}

.split-char-showcase .tw-char-box {
  padding: 8px 16px;
  border-radius: 16px;
}

.split-char-showcase .tw-hanzi-main {
  font-size: clamp(48px, 11vh, 72px);
}

.split-char-info {
  text-align: left;
  min-width: 0;
  flex: 1;
}

.split-char-info .hun {
  font-size: clamp(15px, 2.3vh, 18px);
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1.2;
}

.split-char-info .mean {
  font-size: 12.5px;
  color: var(--text-sub);
  margin-top: 2px;
}

.split-char-info .sub-meta {
  font-size: 11.5px;
  color: var(--text-sub);
  margin-top: 4px;
}

.split-quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.split-quick-actions button {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 9px;
  padding: 6px 4px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

/* 상단 필순(쓰는 순서) 단계 가이드 바 */
.stroke-step-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 5px 8px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  scrollbar-width: none;
}
.stroke-step-bar::-webkit-scrollbar {
  display: none;
}

.stroke-step-chip {
  border: 1px solid #c7d2fe;
  background: #ffffff;
  color: var(--text-sub);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
.stroke-step-chip.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28);
}
.stroke-step-chip.done {
  background: var(--emerald-soft);
  border-color: #6ee7b7;
  color: #065f46;
}

/* 터치 따라쓰기 캔버스 영역 */
.trace-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.trace-status-text {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-tools {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.trace-tools button {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.trace-canvas-holder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.trace-pad-box {
  height: 100%;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  position: relative;
  background: #fffdf9;
  border: 2px solid #cbd5e1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.04);
  touch-action: none;
  user-select: none;
}

.trace-grid-svg,
.trace-pictogram-svg,
.trace-strokes-svg,
.trace-fallback-canvas,
.trace-ink-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.trace-pictogram-svg {
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.trace-ink-canvas {
  cursor: crosshair;
  touch-action: none;
}

.stroke-pop {
  transition: fill 0.18s ease;
}

.split-nav-footer {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  gap: 6px;
}

.split-nav-footer button {
  border: none;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

/* 바둑판 타일 업그레이드 */
.checkerboard-hanzi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.checker-tile {
  position: relative;
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 6px 8px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.checker-tile:active {
  transform: scale(0.96);
}
.checker-tile.known {
  background: #f0fdf4;
  border-color: #34d399;
}
.checker-tile.learning,
.checker-tile.again {
  background: #fffbeb;
  border-color: #fbbf24;
}
.checker-tile .seq-num {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}
.checker-tile .done-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 10px;
}
.checker-tile .hz {
  font-family: var(--zh-font);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-main);
  margin-top: 4px;
}
.checker-tile .zy {
  font-family: var(--zh-font);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.checker-tile .kr {
  font-size: 10.5px;
  color: var(--text-sub);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 하단 탭바 (5탭) */
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
}

.nav-tab {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.16s ease;
}

.nav-tab .nav-icon {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
}

.nav-tab .nav-label {
  font-size: 11px;
  font-weight: 700;
}

.nav-tab.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* 공통 카드·배지·버튼 */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}

.hero-card {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 55%, #0284c7 100%);
  color: #ffffff;
  border: none;
  box-shadow: var(--shadow-md);
}

.section-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pill-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.pill-tabs::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-sub);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.primary-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.primary-btn:active {
  transform: scale(0.98);
}
.primary-btn.full-w {
  width: 100%;
}

.soft-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.soft-btn:hover {
  background: #e2e8f0;
}

/* 대시보드 숫자 카운터 UI */
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.big-counter {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
}
.big-counter small {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.85;
}

.goal-selector {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.goal-chip {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.goal-chip.active {
  background: #fde047;
  color: #1e1b4b;
  border-color: #fde047;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px;
}
.progress-fill {
  height: 100%;
  background: #fde047;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-track.light {
  background: var(--surface-soft);
  margin: 8px 0;
}
.progress-track.light .progress-fill {
  background: var(--primary);
}

.stat-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
}
.stat-box .num {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}
.stat-box .lbl {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 3px;
}

.milestone-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.milestone-item {
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1.5px solid transparent;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}
.milestone-item:active {
  transform: scale(0.985);
}
.milestone-item.achieved {
  background: var(--emerald-soft);
  border-color: #6ee7b7;
}
.milestone-item.selected {
  border-color: var(--primary);
  background: #eef2ff;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.12);
}

/* 주음부호 그리드 */
.zhuyin-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.zhuyin-tile {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.zhuyin-tile:active {
  transform: scale(0.96);
}
.zhuyin-tile.mastered {
  border-color: var(--emerald);
  background: #f0fdf4;
}
.zhuyin-tile .check-mark {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 10px;
}
.zhuyin-tile .sym {
  font-family: var(--zh-font);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}
.zhuyin-tile .pin {
  font-size: 11px;
  color: var(--primary);
  font-weight: 700;
  margin-top: 2px;
}
.zhuyin-tile .ex {
  font-family: var(--zh-font);
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* 대만식 세로 주음부호 루비 표기 (핵심 시각 장치!) */
.tw-char-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  background: var(--surface-soft);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.tw-hanzi-main {
  font-family: var(--zh-font);
  font-size: 76px;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.tw-zhuyin-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 28px;
  font-family: var(--zh-font);
}

.tw-zhuyin-vertical .neutral-dot {
  font-size: 18px;
  font-weight: 900;
  line-height: 0.6;
  color: var(--rose);
  margin-bottom: 2px;
}

.tw-zhuyin-phonetics {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--primary);
}

.tw-zhuyin-tone-side {
  position: absolute;
  right: -12px;
  bottom: 4px;
  font-size: 20px;
  font-weight: 900;
  color: var(--rose);
}

/* 한자 플래시카드 */
.flashcard {
  text-align: center;
  padding: 20px 16px;
}

.hanzi-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-sub);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--text-sub);
}
.badge.primary {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.badge.good {
  background: var(--emerald-soft);
  color: #065f46;
}
.badge.warn {
  background: var(--amber-soft);
  color: #92400e;
}
.badge.fix {
  background: var(--rose-soft);
  color: #991b1b;
}

.simp-compare {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-sub);
}
.simp-compare strong {
  font-family: var(--zh-font);
  font-size: 17px;
  color: var(--text-main);
}

.huneum-title {
  margin: 12px 0 4px;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}

.meaning-sub {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text-sub);
}

.decompose-chips {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.decomp-chip {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: var(--primary-dark);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.word-example-box {
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
}

.srs-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.srs-btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 6px;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
}
.srs-btn.again {
  background: var(--rose-soft);
  color: #991b1b;
}
.srs-btn.hard {
  background: var(--amber-soft);
  color: #92400e;
}
.srs-btn.easy {
  background: var(--emerald);
  color: #ffffff;
}

/* 주음 조합 키보드 퀴즈 */
.slot-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: #eef2ff;
  border: 2px dashed #818cf8;
  font-family: var(--zh-font);
  font-size: 26px;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 12px 0;
}

.bopomofo-keypad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.key-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 2px;
  font-family: var(--zh-font);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.key-btn:active {
  background: var(--primary-light);
}
.key-btn.tone-key {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

/* 한자 숫자 도감 그리드 */
.mini-hanzi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}
.mini-hanzi-cell {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 7px 4px;
  text-align: center;
  cursor: pointer;
}
.mini-hanzi-cell.known {
  background: var(--emerald-soft);
  border-color: #34d399;
}
.mini-hanzi-cell.learning {
  background: var(--amber-soft);
  border-color: #fbbf24;
}
.mini-hanzi-cell .hz {
  font-family: var(--zh-font);
  font-size: 20px;
  font-weight: 800;
}
.mini-hanzi-cell .zy {
  font-family: var(--zh-font);
  font-size: 10px;
  color: var(--text-sub);
}

/* AI 발음 코치 UI */
.record-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 6px;
}

.mic-record-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ef4444, #e11d48);
  color: #fff;
  font-size: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(225, 29, 72, 0.35);
  transition: transform 0.15s ease;
}
.mic-record-btn.recording {
  animation: pulseRing 1.2s infinite;
  background: #b91c1c;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.waveform-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  margin: 12px 0 6px;
}
.waveform-bars span {
  width: 5px;
  height: 8px;
  background: var(--primary);
  border-radius: 99px;
  transition: height 0.08s ease;
}

.diagnosis-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.diag-card {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.diag-card.good {
  border-left: 5px solid var(--emerald);
}
.diag-card.warn {
  border-left: 5px solid var(--amber);
}
.diag-card.fix {
  border-left: 5px solid var(--rose);
}

.diag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-weight: 800;
  font-size: 13.5px;
}

/* 바텀 시트 모달 */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}
.modal-backdrop.hidden,
.hidden {
  display: none !important;
}

.bottom-sheet {
  width: 100%;
  max-height: 86%;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sheet-header h3 {
  margin: 0;
  font-size: 17px;
}
.close-btn {
  border: none;
  background: var(--surface-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
}
.sheet-desc {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0 0 14px;
}

/* 폼 요소 */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}
.field input, .field select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
}

/* 퀴즈 선택지 */
.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.quiz-choice-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.quiz-choice-btn.correct {
  background: var(--emerald-soft);
  border-color: var(--emerald);
  color: #065f46;
}
.quiz-choice-btn.wrong {
  background: var(--rose-soft);
  border-color: var(--rose);
  color: #991b1b;
}

/* 토스트 */
.toast {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* 🔍 옥편·검색 탭 (방안 A 키패드 + 방안 B 손글씨 인식) */
.dict-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 14px;
  padding: 6px 10px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

.dict-search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--zh-font);
  background: transparent;
  color: var(--text-main);
  min-width: 0;
}

.dict-keypad-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  margin-top: 8px;
}

.dict-keypad-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.dict-key {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 0;
  font-family: var(--zh-font);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
}
.dict-key:active {
  background: var(--primary-light);
}
.dict-key.medial {
  background: #eff6ff;
  color: #1d4ed8;
}
.dict-key.final {
  background: #f5f3ff;
  color: #5b21b6;
}
.dict-key.tone {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.hw-draw-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hw-canvas-box {
  width: min(100%, 248px);
  aspect-ratio: 1 / 1;
  position: relative;
  background: #fffdf9;
  border: 2px solid var(--primary);
  border-radius: 16px;
  overflow: hidden;
  touch-action: none;
  box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.05);
}

.hw-canvas-box canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hw-candidates-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  width: 100%;
  padding: 6px 2px;
  min-height: 50px;
  align-items: center;
}

.hw-cand-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  min-width: 46px;
  height: 46px;
  padding: 0 10px;
  font-family: var(--zh-font);
  font-size: 23px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s ease;
}
.hw-cand-btn.picked,
.hw-cand-btn:first-child {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary-dark);
}

.dict-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 9px;
  box-shadow: var(--shadow-sm);
}

.dict-result-card .tw-char-box {
  padding: 6px 12px;
  border-radius: 14px;
  flex-shrink: 0;
}

.dict-result-card .tw-hanzi-main {
  font-size: 42px;
}

.dict-result-card .tw-zhuyin-phonetics {
  font-size: 14px;
}

.dict-result-card .tw-zhuyin-tone-side {
  font-size: 15px;
  right: -9px;
}

/* 클릭 없이 바로 보이는 듀얼 그림카드 + 인라인 레고 공식 + 전체 스토리 + 형제 한자 바 */
.dual-visual-card {
  width: 66px;
  height: 66px;
  border-radius: 14px;
  background: #fffdf7;
  border: 1.5px solid #fde68a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.inline-lego-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.inline-lego-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}
.inline-lego-tag.meaning {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}
.inline-lego-tag.sound {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
  cursor: pointer;
}

.etym-story-open-box {
  background: linear-gradient(90deg, #fffbeb 0%, #fef9c3 100%);
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.32;
  color: #78350f;
}

.inline-siblings-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 3px 2px;
  scrollbar-width: none;
}
.inline-siblings-strip::-webkit-scrollbar {
  display: none;
}

.sib-mini-chip {
  border: 1px solid #cbd5e1;
  background: var(--surface);
  border-radius: 8px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.sib-mini-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.checker-picto-mini {
  width: 28px;
  height: 28px;
  margin: 2px auto 0;
  display: block;
}

.lego-equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  background: var(--surface-soft);
  border-radius: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.lego-block {
  background: var(--surface);
  border: 2px solid #c7d2fe;
  border-radius: 14px;
  padding: 8px 12px;
  text-align: center;
  min-width: 84px;
}
.lego-block.meaning-block {
  border-color: #6ee7b7;
  background: #ecfdf5;
}
.lego-block.sound-block {
  border-color: #93c5fd;
  background: #eff6ff;
  cursor: pointer;
}
.lego-block .b-char {
  font-family: var(--zh-font);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
}
.lego-block .b-role {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-sub);
  margin-top: 2px;
}

.picto-compare-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  background: #fffdf9;
  border: 1.5px solid #fde68a;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.picto-preview-box {
  width: 96px;
  height: 96px;
  margin: 0 auto;
  position: relative;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  display: grid;
  place-items: center;
}

.sibling-mindmap-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 8px;
}

.sibling-node {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.sibling-node:active {
  transform: scale(0.96);
}
.sibling-node.current-char {
  border-color: var(--primary);
  background: #eef2ff;
}
.sibling-node .s-hz {
  font-family: var(--zh-font);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}
.sibling-node .s-zy {
  font-family: var(--zh-font);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 2px;
}
.sibling-node .s-kr {
  font-size: 10px;
  color: var(--text-sub);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   📲 아이폰 · 안드로이드 스마트 앱 설치 알림 배너 & 그림 가이드
   ========================================================================== */
.install-header-pill {
  border: 1.5px solid #c7d2fe;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.12);
}
.install-header-pill:active {
  transform: scale(0.96);
}

.install-banner {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  z-index: 48;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #ffffff;
  border-radius: 18px;
  padding: 12px 13px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.34);
  border: 1px solid rgba(199, 210, 254, 0.28);
  animation: slideUpBanner 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpBanner {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.install-banner-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.install-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%);
  display: grid;
  place-items: center;
  font-family: var(--zh-font);
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
}

.install-banner-sub {
  font-size: 11.5px;
  line-height: 1.38;
  color: #e0e7ff;
  margin-top: 3px;
}

.install-banner-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 9px;
}

.install-cta-btn {
  border: none;
  background: #fde047;
  color: #1e1b4b;
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.install-sub-btn {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #e0e7ff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.install-close-x {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
}

.guide-os-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-soft);
  padding: 5px;
  border-radius: 13px;
  margin-bottom: 12px;
}

.guide-os-tab {
  border: none;
  background: transparent;
  padding: 9px 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-sub);
  cursor: pointer;
}

.guide-os-tab.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.guide-step-card {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 15px;
  padding: 12px 13px;
  margin-bottom: 10px;
}

.guide-step-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.35;
}

.guide-step-num {
  width: 23px;
  height: 23px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.guide-visual-mock {
  margin-top: 9px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ios-toolbar-mock {
  justify-content: space-around;
  color: #94a3b8;
  font-size: 17px;
}

.ios-share-highlight {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eff6ff;
  border: 2px solid #2563eb;
  color: #1d4ed8;
  padding: 5px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 900;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.ios-sheet-row-mock {
  background: #f8fafc;
  border: 2px solid var(--primary);
  border-radius: 11px;
  padding: 9px 13px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
}

.inapp-warn-box {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 13px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #78350f;
  margin-bottom: 11px;
}
