:root {
  --primary: #6c47ff;
  --primary-dark: #5234d8;
  --accent: #ff5a78;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #ef4444;
  --text: #111327;
  --muted: #6b7185;
  --bg: #ffffff;
  --bg-alt: #f6f4ff;
  --bg-soft: #f8f9fc;
  --border: #e6e7f0;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(108, 71, 255, 0.10);
  --shadow-sm: 0 4px 12px rgba(17, 19, 39, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.container { width: min(1180px, 92%); margin: 0 auto; }
.view[hidden] { display: none !important; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 600; font-size: 0.95rem;
  transition: transform .12s, background .15s, color .15s, box-shadow .2s;
}
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn-sm { padding: 7px 14px; font-size: 0.88rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-outline { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-link { background: none; border: none; color: var(--text); font-weight: 500; padding: 8px 12px; }
.btn-link:hover { color: var(--primary); }

/* ============================================================
   LANDING
============================================================ */
.lp-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.9); backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.lp-nav { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.lp-logo { font-size: 1.4rem; font-weight: 800; }
.lp-logo span { color: var(--primary); }
.lp-links { display: flex; gap: 26px; }
.lp-links a { color: var(--muted); font-weight: 500; }
.lp-links a:hover { color: var(--primary); }
.lp-actions { display: flex; align-items: center; gap: 8px; }

.lp-hero { padding: 70px 0 60px; background: linear-gradient(180deg, #f6f4ff 0%, #fff 100%); }
.lp-hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 60px; align-items: center; }
.lp-badge {
  display: inline-block; padding: 6px 12px; border-radius: 999px;
  background: rgba(108,71,255,0.12); color: var(--primary);
  font-size: 0.85rem; font-weight: 600; margin-bottom: 18px;
}
.lp-hero h1 { font-size: clamp(2rem, 4.4vw, 3.4rem); line-height: 1.2; margin: 0 0 16px; }
.grad { background: linear-gradient(90deg, #6c47ff, #ff5a78); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-lead { font-size: 1.1rem; color: var(--muted); margin-bottom: 26px; }
.lp-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 32px; }
.lp-trust { display: flex; gap: 32px; border-top: 1px solid var(--border); padding-top: 18px; }
.lp-trust div { display: flex; flex-direction: column; }
.lp-trust strong { font-size: 1.25rem; }
.lp-trust span { color: var(--muted); font-size: 0.85rem; }

.lp-mock { position: relative; }
.mock-window {
  background: white; border-radius: 18px; box-shadow: 0 30px 60px rgba(17,19,39,0.12);
  border: 1px solid var(--border); overflow: hidden; transform: rotate(-1deg);
}
.mock-header {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-soft); padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.mock-title { margin-left: 12px; font-size: 0.85rem; color: var(--muted); }
.mock-chat { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.mock-msg { display: flex; gap: 10px; align-items: flex-start; }
.mock-msg.me { justify-content: flex-end; }
.mock-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #ff5a78, #ffb05a); color: white;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
}
.mock-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  background: var(--bg-soft); border: 1px solid var(--border); font-size: 0.93rem;
}
.mock-msg.me .mock-bubble { background: var(--primary); color: white; border-color: var(--primary); }
.mock-tip {
  margin-top: 8px; padding: 8px 12px; border-radius: 10px;
  background: rgba(255,176,90,0.15); color: #b25800; font-size: 0.85rem;
  border: 1px dashed #ffb05a;
}

.lp-section { padding: 80px 0; }
.lp-section-alt { background: var(--bg-alt); }
.lp-h2 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); text-align: center; margin: 0 0 10px; }
.lp-sub { text-align: center; color: var(--muted); max-width: 600px; margin: 0 auto 44px; }

.lp-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.lp-feat { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; transition: transform .15s, box-shadow .2s; }
.lp-feat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.lp-feat-icon { font-size: 2rem; margin-bottom: 10px; }
.lp-feat h3 { margin: 0 0 6px; }
.lp-feat p { color: var(--muted); margin: 0; font-size: 0.95rem; }

.lp-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.plan {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 30px; display: flex; flex-direction: column; gap: 16px; position: relative;
}
.plan h3 { margin: 0; font-size: 1.25rem; }
.plan-price { font-size: 2rem; font-weight: 800; }
.plan-price span { font-size: 0.95rem; color: var(--muted); font-weight: 500; }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plan ul li { position: relative; padding-left: 22px; color: var(--text); }
.plan ul li::before { content: "✓"; position: absolute; left: 0; color: var(--primary); font-weight: 700; }
.plan .btn { margin-top: auto; }
.plan-featured { border-color: var(--primary); transform: scale(1.03); box-shadow: var(--shadow); }
.plan-badge {
  position: absolute; top: -10px; right: 20px;
  background: var(--primary); color: white; padding: 4px 12px;
  border-radius: 999px; font-size: 0.78rem; font-weight: 600;
}

.lp-faq { max-width: 760px; }
.lp-faq details { background: white; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; padding: 16px 20px; }
.lp-faq summary { cursor: pointer; font-weight: 600; }
.lp-faq details[open] summary { margin-bottom: 10px; }
.lp-faq p { margin: 0; color: var(--muted); }

.lp-footer { background: #111327; color: #aaaecb; padding: 26px 0; }

/* ============================================================
   MODAL
============================================================ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(17,19,39,0.5); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; z-index: 1; width: min(440px, 92%);
  background: white; border-radius: 18px; padding: 28px; box-shadow: 0 30px 60px rgba(0,0,0,0.25);
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-soft); border: none; font-size: 1.2rem;
}
.modal-tabs { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 12px; margin-bottom: 22px; }
.modal-tabs .tab { flex: 1; padding: 9px; border: none; background: transparent; border-radius: 9px; font-weight: 600; color: var(--muted); }
.modal-tabs .tab.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); }
.modal-form { display: grid; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; }
.field input, .field select {
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: white;
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.modal-foot { color: var(--muted); font-size: 0.82rem; text-align: center; margin: 6px 0 0; }

/* ============================================================
   APP SHELL
============================================================ */
#view-app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; background: var(--bg-soft); }

.sidebar {
  background: white; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.sb-logo { font-weight: 800; font-size: 1.3rem; padding: 0 8px 18px; border-bottom: 1px solid var(--border); }
.sb-logo span { color: var(--primary); }
.sb-nav { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; flex: 1; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent; color: var(--muted);
  padding: 10px 12px; border-radius: 10px; font-weight: 600; text-align: left;
}
.sb-item span { font-size: 1.1rem; }
.sb-item:hover { background: var(--bg-soft); color: var(--text); }
.sb-item.active { background: rgba(108,71,255,0.1); color: var(--primary); }

.sb-user {
  display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: var(--bg-soft); margin-top: 10px;
}
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; display: grid; place-items: center; font-weight: 700;
}
.sb-meta { display: flex; flex-direction: column; min-width: 0; }
.sb-meta strong { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-meta span { font-size: 0.75rem; color: var(--muted); }
.sb-logout { border: none; background: transparent; font-size: 1.1rem; color: var(--muted); padding: 6px; border-radius: 8px; }
.sb-logout:hover { background: white; color: var(--bad); }

.main { padding: 28px 32px 60px; overflow-x: hidden; }
.screen { display: none; animation: fadeIn .2s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.screen-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.screen-head h1 { margin: 0 0 4px; font-size: 1.6rem; }
.screen-head .muted { margin: 0; }

/* ===== Dashboard ===== */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi span { color: var(--muted); font-size: 0.85rem; }
.kpi strong { display: block; font-size: 1.6rem; margin-top: 4px; }
.kpi strong small { font-size: 0.8rem; color: var(--muted); margin-left: 4px; font-weight: 500; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 22px; }

/* ===== 동기부여 / 게이미피케이션 ===== */
.streak-banner { display: flex; align-items: center; gap: 16px; background: linear-gradient(135deg,#fff7ed,#fef2f2); border-color: #fed7aa; }
.streak-banner .sb-fire { font-size: 1.8rem; line-height: 1; letter-spacing: -2px; white-space: nowrap; }
.streak-banner .sb-text { display: flex; flex-direction: column; gap: 2px; }
.streak-banner .sb-text strong { font-size: 1.15rem; color: #c2410c; }
.xp-card .xp-bar { height: 12px; border-radius: 999px; background: #eef2ff; overflow: hidden; }
.xp-card .xp-bar > i { display: block; height: 100%; background: linear-gradient(90deg,#6366f1,#8b5cf6); transition: width .4s; }
.quest { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.quest:last-child { border-bottom: 0; }
.quest .q-ic { font-size: 1.25rem; width: 28px; text-align: center; }
.quest .q-body { flex: 1; }
.quest .q-title { font-weight: 600; font-size: .92rem; margin-bottom: 5px; }
.quest .q-bar { height: 6px; border-radius: 999px; background: #ecfdf5; overflow: hidden; }
.quest .q-bar > i { display: block; height: 100%; background: linear-gradient(90deg,#34d399,#10b981); transition: width .4s; }
.quest .q-count { font-weight: 700; font-size: .85rem; color: var(--muted); }
.quest.done .q-title { color: #047857; }
.quest.done .q-count { color: #10b981; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 14px; border: 1px solid var(--border); text-align: center; }
.badge .b-emo { font-size: 1.6rem; }
.badge .b-title { font-size: .78rem; font-weight: 600; }
.badge.earned { background: linear-gradient(135deg,#ecfdf5,#eff6ff); border-color: #a7f3d0; }
.badge.locked { opacity: .4; filter: grayscale(1); }
.sns-card .sns-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1.1rem; }
.card.danger { border-color: #fecaca; }

.heatmap-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.heatmap { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; width: max-content; }
.heatmap .cell { background: var(--bg-soft); border-radius: 3px; transition: transform .08s, outline .08s; cursor: default; }
.heatmap .cell[data-date]:hover { outline: 1.5px solid var(--text); outline-offset: 1px; transform: scale(1.25); z-index: 1; position: relative; }
.heatmap .l1 { background: #e9defc; }
.heatmap .l2 { background: #c5b0fa; }
.heatmap .l3 { background: #8a64f4; }
.heatmap .l4 { background: var(--primary); }

/* Custom tooltip for heatmap cells */
.stats-tooltip {
  position: fixed;
  background: #111327;
  color: #fff;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
  transform: translate(-50%, calc(-100% - 12px));
  opacity: 0;
  transition: opacity .12s ease;
}
.stats-tooltip.show { opacity: 1; }
.stats-tooltip strong { display: block; font-weight: 700; font-size: 0.88rem; margin-bottom: 2px; }
.stats-tooltip strong em { font-style: normal; font-weight: 600; margin-left: 4px; }
.stats-tooltip > span { color: #c5c8d6; font-size: 0.78rem; }
.stats-tooltip::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -5px;
  transform: translateX(-50%) rotate(45deg);
  width: 10px; height: 10px;
  background: #111327;
}

/* TOPIK 등급 기준 호버 카드 */
.level-tooltip {
  position: fixed;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  width: 360px;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 300;
  box-shadow: 0 18px 40px rgba(17,19,39,0.18);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease;
}
.level-tooltip.show { opacity: 1; transform: translateY(0); }
.lt-head { padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.lt-head strong { display: block; font-size: 0.95rem; color: var(--primary); }
.lt-head span { font-size: 0.78rem; color: var(--muted); }
.lt-head span strong { display: inline; color: var(--text); font-size: 0.78rem; }
.lt-row {
  display: grid;
  grid-template-columns: 36px 28px 1fr auto;
  gap: 8px;
  padding: 6px 4px;
  align-items: center;
  border-radius: 8px;
}
.lt-row.active {
  background: rgba(108,71,255,0.10);
  outline: 1px solid rgba(108,71,255,0.25);
}
.lt-grade { font-weight: 700; font-size: 0.9rem; }
.lt-row.active .lt-grade { color: var(--primary); }
.lt-cefr {
  font-size: 0.7rem; color: var(--muted);
  background: var(--bg-soft); padding: 2px 6px; border-radius: 4px;
  text-align: center; font-weight: 600;
}
.lt-desc { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.lt-desc strong { font-size: 0.82rem; }
.lt-desc em { font-style: normal; font-size: 0.74rem; color: var(--muted); }
.lt-min { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.lt-foot {
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 0.72rem; color: var(--muted);
}

.bars-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-bottom: 22px; min-width: 280px; box-sizing: content-box; }
.bar { flex: 1; min-width: 14px; background: linear-gradient(180deg, var(--primary), var(--accent)); border-radius: 6px 6px 0 0; min-height: 4px; position: relative; cursor: default; transition: filter .08s, transform .08s; transform-origin: bottom; }
.bar[data-date]:hover { filter: brightness(1.15); transform: scaleX(1.08); z-index: 1; }
.bar::after { content: attr(data-day); position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; color: var(--muted); white-space: nowrap; }

.topic-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.topic {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  background: var(--bg-soft); cursor: pointer; transition: transform .12s, border-color .15s;
}
.topic:hover { transform: translateY(-2px); border-color: var(--primary); }
.topic .emo { font-size: 1.6rem; }
.topic strong { display: block; margin-top: 6px; }
.topic span { color: var(--muted); font-size: 0.85rem; }

/* ===== Companions ===== */
.companions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.comp-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 10px; cursor: pointer;
  transition: transform .12s, box-shadow .2s, border-color .15s;
  position: relative;
}
.comp-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.comp-card.selected { border-color: var(--primary); box-shadow: var(--shadow); }
.comp-card.selected::after { content: "선택됨"; position: absolute; top: 12px; right: 14px; background: var(--primary); color: white; font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; }
.comp-avatar { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; color: white; font-size: 1.5rem; font-weight: 700; }
.comp-card h3 { margin: 4px 0 0; }
.comp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.comp-tag { font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); }
.comp-desc { color: var(--muted); font-size: 0.92rem; margin: 0; flex: 1; }
.comp-card .btn { align-self: flex-start; margin-top: 6px; }

/* ===== Chat ===== */
.chat-head { gap: 12px; }
.chat-who { display: flex; align-items: center; gap: 12px; }
.chat-avatar { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.chat-tools { display: flex; align-items: center; gap: 12px; }
.seg { display: flex; background: var(--bg-soft); padding: 4px; border-radius: 999px; }
.seg-btn { border: none; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 600; color: var(--muted); font-size: 0.9rem; }
.seg-btn.active { background: white; color: var(--text); box-shadow: var(--shadow-sm); }

/* 대화 수준 선택 (발음 코치 전용) */
.lvl-seg { display: flex; gap: 4px; background: var(--bg-soft); padding: 4px; border-radius: 999px; }
.lvl-btn { border: 1px solid transparent; background: transparent; padding: 8px 14px; border-radius: 999px; font-weight: 700; color: var(--muted); font-size: 0.88rem; cursor: pointer; transition: all .15s; }
.lvl-btn:hover { color: var(--text); }
.lvl-btn.active { background: linear-gradient(135deg,#34d399,#10b981); color: white; box-shadow: var(--shadow-sm); }

/* 상황(카테고리) 선택 */
.lvl-situation { display: flex; align-items: center; gap: 6px; }
.lvl-select { border: 1px solid var(--border, #e5e7eb); background: white; padding: 7px 10px; border-radius: 999px; font-weight: 600; font-size: 0.86rem; color: var(--text); cursor: pointer; max-width: 180px; }
.lvl-dice { border: 1px solid transparent; background: var(--bg-soft); width: 34px; height: 34px; border-radius: 50%; font-size: 1rem; cursor: pointer; transition: all .15s; }
.lvl-dice:hover { background: #e9fbf3; transform: rotate(-15deg); }
.coach-progress { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: #ecfdf5; color: #047857; font-weight: 700; font-size: 0.82rem; white-space: nowrap; }
.coach-progress.rp { background: #fef3c7; color: #b45309; }
.coach-progress-bar { display: inline-block; width: 52px; height: 6px; border-radius: 999px; background: #d1fae5; overflow: hidden; vertical-align: middle; }
.coach-progress-bar > i { display: block; height: 100%; background: linear-gradient(90deg,#34d399,#10b981); }

.chat-area { background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-height: 540px; }
.chat-pane { display: flex; flex-direction: column; flex: 1; }
.chat-pane[hidden] { display: none; }

.chat-log { flex: 1; padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; max-height: 60vh; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 78%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.msg.me .msg-avatar { background: linear-gradient(135deg, #111327, #444); }
.msg-bubble { background: var(--bg-soft); border: 1px solid var(--border); padding: 10px 14px; border-radius: 14px; }
.msg.me .msg-bubble { background: var(--primary); color: white; border-color: var(--primary); }
.msg-meta { display: flex; gap: 8px; margin-top: 6px; font-size: 0.78rem; color: var(--muted); align-items: center; }
.msg-meta button { border: none; background: transparent; color: var(--muted); padding: 2px 6px; border-radius: 6px; font-size: 0.78rem; }
.msg-meta button:hover { color: var(--primary); background: var(--bg-soft); }
.msg.typing .msg-bubble { display: inline-flex; gap: 4px; }
.msg.typing .msg-bubble span { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: blink 1.2s infinite; }
.msg.typing .msg-bubble span:nth-child(2) { animation-delay: 0.15s; }
.msg.typing .msg-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.chat-input {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 14px 18px; border-top: 1px solid var(--border); background: white;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.chat-input input {
  min-width: 0; /* 1fr 트랙이 실제로 줄어들게 — 좁은 화면에서 전송 버튼이 잘리지 않도록 */
  border: 1px solid var(--border); border-radius: 999px; padding: 12px 18px;
}
.chat-input .mic, .chat-input #send-btn { flex-shrink: 0; white-space: nowrap; }
.chat-input input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.mic {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: white; font-size: 1.1rem; display: grid; place-items: center;
}
.mic.listening { background: var(--bad); color: white; border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); } 100% { box-shadow: 0 0 0 14px rgba(239,68,68,0); } }

/* ===== Tutor pane ===== */
.tutor-empty { padding: 60px 20px; text-align: center; }
.te-emoji { font-size: 3rem; }
.tutor-list { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow-y: auto; }
.tutor-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: white;
}
.tutor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tutor-orig { font-size: 1.05rem; font-weight: 600; }
.score-badge { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; color: white; }
.score-1 { background: var(--bad); }
.score-2 { background: var(--warn); }
.score-3 { background: var(--ok); }
.tutor-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 0.92rem; }
.tutor-row .label { width: 80px; color: var(--muted); font-size: 0.82rem; flex-shrink: 0; }
.tutor-row .play { border: none; background: var(--bg-soft); padding: 4px 10px; border-radius: 8px; font-size: 0.78rem; }
.tutor-row .play:hover { background: var(--primary); color: white; }
.tutor-better { color: var(--primary); font-weight: 600; }
.tutor-note { color: var(--muted); font-size: 0.88rem; margin-top: 8px; }

/* ===== History ===== */
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.history-item { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.history-item h4 { margin: 0 0 4px; }
.history-item .preview { color: var(--muted); font-size: 0.88rem; margin: 8px 0; }
.history-item .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; }

/* ===== Settings ===== */
.settings-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: end; }
.settings-row label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; }
.settings-row input, .settings-row select { padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; }
.settings-row input:focus, .settings-row select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.settings-row .btn { justify-self: start; }
.plan-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

.alert {
  background: rgba(245,158,11,0.10);
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px; border-radius: 12px; font-size: 0.92rem; line-height: 1.55;
}
.alert strong { color: #78350f; }

/* ===== Auth extras (Google button, divider, error) ===== */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: white;
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background .15s, box-shadow .15s;
  margin-bottom: 6px;
}
.btn-google:hover { background: var(--bg-soft); box-shadow: var(--shadow-sm); }
.btn-google:disabled { opacity: .5; cursor: not-allowed; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0; color: var(--muted); font-size: 0.85rem;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.auth-error {
  background: rgba(239,68,68,0.08); border: 1px solid #fca5a5;
  color: #b91c1c; padding: 10px 14px; border-radius: 10px;
  font-size: 0.88rem; margin: 0;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  #view-app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 12px; overflow-x: auto; }
  .sb-logo { border: none; padding: 0 12px 0 4px; }
  .sb-nav { flex-direction: row; padding: 0; gap: 4px; }
  .sb-item { padding: 8px 10px; font-size: 0.85rem; white-space: nowrap; }
  .sb-user { margin-top: 0; }
  .lp-hero-grid, .lp-feats, .lp-plans, .dash-grid, .kpi-row, .topic-row, .settings-row {
    grid-template-columns: 1fr !important;
  }
  .lp-feats, .lp-plans { gap: 14px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
  .topic-row { grid-template-columns: repeat(2, 1fr) !important; }
  .main { padding: 18px; }

  /* 대시보드 차트 모바일 수정 */
  .card { overflow: hidden; }
  .heatmap-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .heatmap {
    grid-template-rows: repeat(7, 10px);
    grid-auto-columns: 10px;
    gap: 2px;
  }
  .bars-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .bars { height: 110px; gap: 4px; padding-bottom: 22px; }
  .bar { min-width: 12px; }
  .bar::after { font-size: 0.6rem; bottom: -16px; }
  .dash-grid { gap: 12px; }

  /* 좁은 화면(아이폰 세로)에서 입력 행이 넘쳐 전송 버튼이 잘리는 것 방지 */
  .chat-input { gap: 8px; padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .chat-input input { padding: 10px 14px; }
  .chat-input #send-btn { padding-left: 14px; padding-right: 14px; }
  .mic { width: 40px; height: 40px; }
}
/* ===== 훈민정음 (한글 입문) ===== */
.hm-lang { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.hm-lang select { border: 1px solid var(--border); background: white; padding: 7px 10px; border-radius: 999px; font-weight: 600; font-size: .86rem; color: var(--text); cursor: pointer; }
.hm-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.hm-side { position: sticky; top: 16px; }
.hm-progress { padding: 16px 18px; }
.hm-bar { height: 8px; border-radius: 999px; background: #ede9fe; overflow: hidden; }
.hm-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }
.hm-lessons { display: flex; flex-direction: column; gap: 4px; }
.hm-lesson-btn {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px;
  border: 1px solid transparent; background: white; padding: 10px 12px; border-radius: 12px;
  text-align: left; font-weight: 600; color: var(--text); font-size: .9rem; transition: all .15s;
}
.hm-lesson-btn:hover { border-color: var(--border); }
.hm-lesson-btn.active { background: rgba(108,71,255,.1); color: var(--primary); border-color: rgba(108,71,255,.25); }
.hm-lesson-btn .hm-num { width: 28px; height: 28px; border-radius: 50%; background: var(--bg-soft); display: grid; place-items: center; font-size: .78rem; color: var(--muted); }
.hm-lesson-btn.done .hm-num { background: #d1fae5; color: #047857; }
.hm-lesson-btn .hm-check { color: #10b981; font-size: .9rem; }
.hm-lesson-btn small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }

.hm-lesson-card { padding: 22px 24px; }
.hm-lesson-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.hm-lesson-emoji { font-size: 2rem; line-height: 1; }
.hm-lesson-head h2 { margin: 0 0 6px; font-size: 1.25rem; }
.hm-lesson-head .muted { margin: 0; line-height: 1.6; }
.hm-tabs { display: inline-flex; margin-bottom: 18px; }
.hm-pane[hidden] { display: none; }
.hm-tap { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }

.hm-detail {
  display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: center;
  background: linear-gradient(135deg, #f5f3ff, #fff1f2); border: 1px solid #e9d5ff; border-radius: 14px;
  padding: 16px 18px; margin-bottom: 16px; min-height: 120px;
}
.hm-detail .hm-big { font-size: 3.4rem; font-weight: 800; line-height: 1; text-align: center; color: var(--primary); }
.hm-detail .hm-big.long { font-size: 2rem; }
.hm-detail dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; }
.hm-detail dt { color: var(--muted); font-weight: 600; }
.hm-detail dd { margin: 0; }
.hm-detail .hm-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

.hm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.hm-card {
  border: 1px solid var(--border); border-radius: 12px; background: white; padding: 12px 8px 10px;
  text-align: center; cursor: pointer; transition: transform .12s, border-color .15s, background .15s; position: relative;
}
.hm-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.hm-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,71,255,.15); }
.hm-card .hm-ch { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.hm-card .hm-ch.long { font-size: 1.3rem; }
.hm-card .hm-sub { display: block; font-size: .78rem; color: var(--muted); margin-top: 4px; }
.hm-card.m-heard { background: #f5f3ff; }
.hm-card.m-mid { background: #fef9c3; border-color: #fde047; }
.hm-card.m-good { background: #dcfce7; border-color: #86efac; }
.hm-legend { font-size: .78rem; color: var(--muted); margin-top: 12px; }

.hm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 18px; }
.hm-table { border-collapse: separate; border-spacing: 4px; }
.hm-table th { font-size: .85rem; color: var(--muted); font-weight: 700; padding: 4px; }
.hm-table th.hm-cons { text-align: right; padding-right: 8px; }
.hm-table td { padding: 0; }
.hm-table button {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: white;
  font-size: 1.15rem; font-weight: 700; color: var(--text); transition: all .12s;
}
.hm-table button:hover { border-color: var(--primary); color: var(--primary); transform: scale(1.08); }
.hm-table button.m-heard { background: #f5f3ff; }
.hm-table button.m-mid { background: #fef9c3; }
.hm-table button.m-good { background: #dcfce7; }

.hm-rows { display: flex; flex-direction: column; gap: 10px; }
.hm-row { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--bg-soft); }
.hm-row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hm-row-ko { font-size: 1.5rem; font-weight: 800; letter-spacing: .04em; }
.hm-row-ko small { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.hm-row-btns { display: flex; gap: 8px; }
.hm-row-btns .btn { padding: 8px 14px; font-size: .88rem; }
.hm-row-btns .btn.listening { background: var(--accent); border-color: var(--accent); color: white; animation: hmPulse 1s infinite; }
@keyframes hmPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,90,120,.5); } 50% { box-shadow: 0 0 0 8px rgba(255,90,120,0); } }
.hm-result { margin-top: 10px; font-size: .9rem; display: none; }
.hm-result.show { display: block; }
.hm-result .hm-acc { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 700; font-size: .8rem; margin-right: 6px; }
.hm-result .hm-acc.good { background: #dcfce7; color: #047857; }
.hm-result .hm-acc.mid { background: #fef9c3; color: #a16207; }
.hm-result .hm-acc.bad { background: #fee2e2; color: #b91c1c; }
.hm-result .hm-tips { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.hm-result .hm-heard { color: var(--muted); font-size: .82rem; }

.hm-quiz { text-align: center; padding: 10px 0; }
.hm-quiz .hm-q-count { color: var(--muted); font-size: .85rem; margin-bottom: 8px; }
.hm-quiz .hm-q-prompt { font-weight: 600; margin-bottom: 14px; }
.hm-quiz .hm-q-read { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 6px 0 14px; }
.hm-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 520px; margin: 16px auto; }
.hm-opt {
  border: 2px solid var(--border); background: white; border-radius: 14px; padding: 20px 8px;
  font-size: 2rem; font-weight: 800; transition: all .15s;
}
.hm-opt.long { font-size: 1.3rem; }
.hm-opt:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); }
.hm-opt.right { background: #dcfce7; border-color: #22c55e; }
.hm-opt.wrong { background: #fee2e2; border-color: #ef4444; }
.hm-opt:disabled { cursor: default; }
.hm-q-feedback { min-height: 28px; font-weight: 600; margin: 6px 0 12px; }
.hm-q-feedback.ok { color: #047857; }
.hm-q-feedback.no { color: #b91c1c; }
.hm-q-end { padding: 20px; }
.hm-q-end .hm-q-score { font-size: 2.4rem; font-weight: 800; color: var(--primary); }
.hm-q-end .btn { margin: 6px 4px 0; }

.hm-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.hm-foot .btn-done.on { background: #10b981; border-color: #10b981; color: white; }

.hm-test-intro { text-align: center; padding: 16px 0; }
.hm-test-intro .hm-best { color: var(--muted); font-size: .9rem; margin: 10px 0 16px; }

/* 대시보드 카드 */
.hm-dash { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; background: linear-gradient(135deg, #f5f3ff, #fff1f2); border-color: #e9d5ff; }
.hm-dash .hm-dash-emoji { font-size: 2rem; }
.hm-dash h2 { margin: 0 0 4px; font-size: 1.05rem; }
.hm-dash p { margin: 0 0 8px; }
.hm-dash .hm-bar { max-width: 320px; }
.hm-dash.done { background: linear-gradient(135deg, #ecfdf5, #eff6ff); border-color: #a7f3d0; }

@media (max-width: 900px) {
  .hm-layout { grid-template-columns: 1fr; }
  .hm-side { position: static; }
  .hm-lessons { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .hm-lesson-btn { grid-template-columns: 24px auto; white-space: nowrap; }
  .hm-lesson-btn small, .hm-lesson-btn .hm-check { display: none; }
  .hm-detail { grid-template-columns: 72px 1fr; }
  .hm-detail .hm-big { font-size: 2.6rem; }
  .hm-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
  .hm-dash { grid-template-columns: 1fr; }
  .hm-options { gap: 8px; }
  .hm-opt { font-size: 1.6rem; padding: 16px 6px; }
  .hm-lang span { display: none; }
}
.hm-quiz .btn[hidden], .hm-test-intro .btn[hidden] { display: none !important; }
.hm-explain-note { font-size: .76rem; color: var(--muted); align-self: center; }
.hm-actions .btn.narrating { background: var(--accent); border-color: var(--accent); color: white; animation: hmPulse 1.2s infinite; }
.hm-explain-text { grid-column: 1 / -1; font-size: .9rem; line-height: 1.7; color: var(--muted); border-top: 1px dashed #e9d5ff; padding-top: 10px; }
.hm-explain-text span { transition: background .15s, color .15s; border-radius: 4px; padding: 0 2px; }
.hm-explain-text span.ko { font-weight: 700; color: var(--text); }
.hm-explain-text span.on { background: #fde68a; color: var(--text); }

/* ===== 조음 그림 ===== */
.hm-detail.has-fig { grid-template-columns: 96px auto 1fr; }
.hm-figs { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.hm-figs figure { margin: 0; text-align: center; }
.hm-figs img { height: 118px; width: auto; background: white; border: 1px solid #e9d5ff; border-radius: 10px; padding: 4px; }
.hm-figs figure.lips img { height: 86px; }
.hm-figs figure.gl img { height: 86px; }
.hm-figs figcaption { font-size: .7rem; color: var(--muted); margin-top: 4px; max-width: 120px; line-height: 1.3; }
.hm-credit { margin-top: 24px; font-size: .78rem; }
@media (max-width: 900px) {
  .hm-detail.has-fig { grid-template-columns: 72px 1fr; }
  .hm-figs { grid-column: 1 / -1; }
  .hm-figs img { height: 96px; }
}

/* ===== PDF 학습지 (화면 밖에서 렌더링 후 캡처) ===== */
.hm-pdf-sheet {
  position: fixed; left: -20000px; top: 0; width: 794px; height: 1123px; padding: 40px 48px; box-sizing: border-box;
  background: #fff; color: #111327; font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", -apple-system, sans-serif;
  display: flex; flex-direction: column; gap: 16px;
}
.hm-pdf-sheet .pdf-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #6c47ff; padding-bottom: 12px; }
.hm-pdf-sheet .pdf-logo { height: 40px; width: auto; }
.hm-pdf-sheet .pdf-head-txt { flex: 1; font-size: 15px; line-height: 1.4; }
.hm-pdf-sheet .pdf-head-txt span { color: #6b7185; font-size: 13px; }
.hm-pdf-sheet .pdf-date { color: #6b7185; font-size: 12px; }
.hm-pdf-sheet .pdf-hero { display: grid; grid-template-columns: 150px 1fr; grid-template-rows: auto auto; gap: 10px 18px; align-items: start;
  background: linear-gradient(135deg,#f5f3ff,#fff1f2); border: 1px solid #e9d5ff; border-radius: 14px; padding: 16px 18px; }
.hm-pdf-sheet .pdf-letter { grid-row: 1 / 3; font-size: 104px; font-weight: 800; line-height: 1; color: #6c47ff; text-align: center; align-self: center; }
.hm-pdf-sheet .pdf-letter.long { font-size: 44px; }
.hm-pdf-sheet .pdf-meta { font-size: 14px; line-height: 1.7; }
.hm-pdf-sheet .pdf-meta em { font-style: normal; color: #6b7185; font-weight: 600; display: inline-block; width: 150px; }
.hm-pdf-sheet .pdf-meta small { color: #6b7185; }
.hm-pdf-sheet .pdf-figs { display: flex; gap: 12px; align-items: flex-end; }
.hm-pdf-sheet .pdf-figs figure { margin: 0; text-align: center; }
.hm-pdf-sheet .pdf-figs img { height: 150px; width: auto; background: #fff; border: 1px solid #e9d5ff; border-radius: 10px; padding: 4px; }
.hm-pdf-sheet .pdf-figs figure.lips img, .hm-pdf-sheet .pdf-figs figure.gl img { height: 104px; }
.hm-pdf-sheet .pdf-figs figcaption { font-size: 10.5px; color: #6b7185; margin-top: 4px; max-width: 150px; line-height: 1.3; }
.hm-pdf-sheet .pdf-sec h3 { margin: 0 0 6px; font-size: 15px; color: #111327; }
.hm-pdf-sheet .pdf-sec p { margin: 0; font-size: 13.5px; line-height: 1.6; }
.hm-pdf-sheet .pdf-ko { color: #6b7185; font-size: 12.5px; margin-top: 4px !important; }
.hm-pdf-sheet .pdf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.hm-pdf-sheet ul, .hm-pdf-sheet ol { margin: 0; padding-left: 0; list-style: none; }
.hm-pdf-sheet .pdf-words li { font-size: 15px; padding: 5px 0; border-bottom: 1px dashed #e6e7f0; }
.hm-pdf-sheet .pdf-words li b { font-size: 18px; margin-right: 6px; }
.hm-pdf-sheet .pdf-words li span { color: #6b7185; font-size: 13px; }
.hm-pdf-sheet .pdf-rows li { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed #e6e7f0; }
.hm-pdf-sheet .pdf-rows li b { font-size: 20px; letter-spacing: .06em; }
.hm-pdf-sheet .pdf-rows li span { color: #6b7185; font-size: 12px; }
.hm-pdf-sheet .pdf-steps li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; padding: 6px 0; }
.hm-pdf-sheet .pdf-steps i { width: 16px; height: 16px; border: 2px solid #6c47ff; border-radius: 4px; flex: none; }
.hm-pdf-sheet .pdf-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid #e6e7f0; padding-top: 10px; font-size: 10.5px; color: #6b7185; }
.hm-pdf-sheet .pdf-intro { color: #6b7185; font-size: 12.5px; margin-top: 6px !important; }
.hm-pdf-sheet .pdf-tips li { font-size: 13px; line-height: 1.5; padding: 3px 0 3px 18px; position: relative; }
.hm-pdf-sheet .pdf-tips li::before { content: "!"; position: absolute; left: 0; top: 4px; width: 13px; height: 13px; border-radius: 50%; background: #ff5a78; color: #fff; font-size: 9px; font-weight: 800; text-align: center; line-height: 13px; }
.hm-pdf-sheet .pdf-trace { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.hm-pdf-sheet .pdf-trace span { height: 78px; border: 1.5px dashed #c4b5fd; border-radius: 10px; display: grid; place-items: center; font-size: 44px; font-weight: 800; }
.hm-pdf-sheet .pdf-trace .ghost { color: #ddd6fe; }
.hm-pdf-sheet .pdf-strip { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.hm-pdf-sheet .pdf-strip em { font-style: normal; color: #6b7185; margin-right: 6px; }
.hm-pdf-sheet .pdf-strip span { display: inline-flex; flex-direction: column; align-items: center; min-width: 34px; padding: 3px 6px; border: 1px solid #e6e7f0; border-radius: 8px; }
.hm-pdf-sheet .pdf-strip span.cur { border-color: #6c47ff; background: #f5f3ff; }
.hm-pdf-sheet .pdf-strip b { font-size: 15px; }
.hm-pdf-sheet .pdf-strip small { font-size: 9.5px; color: #6b7185; }

/* ===== 대시보드 벤토 그리드 ===== */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: minmax(96px, auto); gap: 14px; }
.tile {
  background: white; border: 1px solid var(--border); border-radius: 18px; padding: 18px 20px;
  min-width: 0; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; } .rows-2 { grid-row: span 2; }
.tile-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.tile-head h2 { margin: 0; font-size: 1.02rem; }
.tile .heatmap-scroll { margin-top: auto; }
.tile .bars { height: 120px; margin-top: auto; }
.tile .topic-row { margin-top: 2px; }

/* 히어로 */
.tile-hero { background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 55%, var(--accent) 130%); color: white; border: none; justify-content: space-between; }
.tile-hero::after { content: "한"; position: absolute; right: -10px; bottom: -40px; font-size: 11rem; font-weight: 800; color: rgba(255,255,255,.08); line-height: 1; pointer-events: none; }
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.tile-hero h1 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.25; }
.hero-sub { margin: 0; opacity: .85; font-size: .95rem; }
.hero-streak { text-align: right; flex: none; }
.hero-streak .hs-fire { font-size: 1.6rem; line-height: 1; letter-spacing: -2px; white-space: nowrap; }
.hero-streak .hs-num { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.hero-streak .hs-num small { font-size: .8rem; font-weight: 600; margin-left: 4px; opacity: .85; }
.hero-streak .hs-sub { font-size: .8rem; opacity: .85; }
.hero-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 18px; position: relative; z-index: 1; }
.hero-quest { font-size: .88rem; opacity: .9; }
.hero-quest b { color: #fde68a; }
.btn-light { background: white; color: var(--primary); border-color: white; font-weight: 700; }
.btn-light:hover { background: #f5f3ff; transform: translateY(-1px); }

/* KPI 타일 */
.tile-kpi { justify-content: center; }
.tile-kpi > span { color: var(--muted); font-size: .84rem; }
.tile-kpi > strong { display: block; font-size: 1.75rem; margin-top: 4px; line-height: 1.2; }
.tile-kpi > strong small { font-size: .78rem; color: var(--muted); margin-left: 4px; font-weight: 500; }
.tile-kpi .kpi-ic { position: absolute; right: 16px; top: 14px; font-style: normal; font-size: 1.4rem; opacity: .55; }

/* 레벨 링 */
.xp-wrap { display: flex; align-items: center; gap: 16px; margin-top: auto; }
.xp-ring { width: 84px; height: 84px; flex: none; transform: rotate(-90deg); }
.xp-ring .ring-bg { fill: none; stroke: #eef2ff; stroke-width: 8; }
.xp-ring .ring-fg { fill: none; stroke: var(--primary); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .5s; }
.xp-ring .ring-txt { transform: rotate(90deg); transform-origin: 40px 40px; font-size: 15px; font-weight: 800; fill: var(--text); }
.xp-txt { display: flex; flex-direction: column; gap: 4px; }
.xp-txt strong { font-size: .95rem; }

/* 훈민정음 타일 */
#hm-dash { background: linear-gradient(135deg, #f5f3ff, #fff1f2); border-color: #e9d5ff; }
#hm-dash.done { background: linear-gradient(135deg, #ecfdf5, #eff6ff); border-color: #a7f3d0; }
#hm-dash .hm-dash-pct { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 8px; }
#hm-dash .hm-dash-pct strong { font-size: 1.9rem; line-height: 1; color: var(--primary); }
#hm-dash .btn { align-self: flex-start; margin-top: auto; }

/* SNS·배지 타일 */
.tile-sns { background: linear-gradient(135deg, #fff7ed, #fef2f2); border-color: #fed7aa; }
.tile .badge-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tile .badge { padding: 10px 6px; }
.tile .badge .b-emo { font-size: 1.4rem; }
.tile .quest { padding: 8px 0; }

@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .span-8 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; grid-auto-rows: auto; }
  .span-3 { grid-column: span 1; }
  .span-4, .span-6, .span-8, .span-12 { grid-column: span 2; }
  .rows-2 { grid-row: auto; }
  .tile { padding: 14px 16px; border-radius: 14px; }
  .tile-hero h1 { font-size: 1.2rem; }
  .tile-hero::after { font-size: 7rem; }
  .tile-kpi > strong { font-size: 1.4rem; }
  .tile-kpi .kpi-ic { font-size: 1.1rem; }
}
/* 좁은 타일의 14일 막대: 날짜 라벨은 하나 걸러 표시 */
.tile .bars { gap: 4px; min-width: 0; }
.tile .bar { min-width: 8px; }
.tile .bar::after { font-size: .62rem; }
.tile .bar:nth-child(even)::after { display: none; }

/* ===== 모바일 보정 (실기기 확인 후) ===== */
@media (max-width: 900px) {
  /* 상단 바: 사용자 블록을 아바타만 남겨 높이를 줄이고, 가로 스크롤바는 숨김 */
  .sidebar { padding: 8px 10px; gap: 6px; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sb-logo { font-size: 1.05rem; flex: none; }
  .sb-nav { flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .sb-nav::-webkit-scrollbar { display: none; }
  .sb-user { grid-template-columns: 32px auto; padding: 4px; gap: 4px; flex: none; }
  .sb-user .sb-meta { display: none; }
  .sb-avatar { width: 32px; height: 32px; font-size: .85rem; }
  .sb-logout { padding: 4px; }

  /* 훈민정음 상세 패널: 글자 → 그림 → 설명 → 버튼을 세로로 */
  .hm-detail, .hm-detail.has-fig { grid-template-columns: 1fr; gap: 10px; }
  .hm-detail .hm-big { text-align: left; font-size: 2.8rem; }
  .hm-detail dl { grid-column: 1 / -1; grid-template-columns: auto 1fr; }
  .hm-figs { justify-content: flex-start; }
  .hm-explain-note { flex-basis: 100%; }

  /* 14일 막대 라벨: 모바일에선 3개 중 1개만 */
  .tile .bar::after { display: none; }
  .tile .bar:nth-child(3n+1)::after { display: block; }
}
/* 그리드 아이템의 min-width:auto 때문에 가로 스크롤 영역(레슨 목록)이 레이아웃을 넓히는 것 방지 */
.hm-layout > *, .hm-main, .hm-side, .hm-lesson-card, .hm-pane, .hm-detail { min-width: 0; }
.hm-lesson-card { overflow: hidden; }
.sb-item .sb-label { font-size: inherit; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.plan-card #plan-meta { margin: 4px 0 0; font-size: .82rem; }
.plan-note { margin: -6px 0 10px; color: var(--muted); font-size: .85rem; }
.modal-title { margin: 0 0 18px; font-size: 1.25rem; text-align: center; }
#modal-onboard .modal-form { margin-top: 4px; }
