/* ============================================================
   Lim's 투자 대시보드 — 디자인 토큰
   ============================================================ */
:root {
  color-scheme: light;
  --page: #f4f3fa;
  --surface: #ffffff;
  --surface-2: #f1f0f7;
  --text: #191a23;
  --text-2: #565868;
  --muted: #8e90a0;
  --grid: #ecebf3;
  --axis: #d6d5e0;
  --border: rgba(25, 26, 35, 0.07);
  --shadow: 0 1px 2px rgba(25, 26, 35, 0.04), 0 8px 24px rgba(25, 26, 35, 0.05);

  --accent: #6d4aff;
  --accent-soft: rgba(109, 74, 255, 0.10);
  --hero: linear-gradient(135deg, #5b3cff 0%, #8f4dff 48%, #ff5c9d 100%);

  /* 한국식: 상승/수익/매수 = 빨강, 하락/손실/매도 = 파랑 */
  --up: #f04452;
  --down: #3182f6;
  --up-soft: rgba(240, 68, 82, 0.10);
  --down-soft: rgba(49, 130, 246, 0.10);

  /* 카테고리 색 (검증된 순서, 빨강은 손익색과 겹쳐 제외) */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c-other: #b9b8c6;

  --radius: 20px;
  --radius-sm: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b0b11;
    --surface: #15151e;
    --surface-2: #1d1d29;
    --text: #f4f4f8;
    --text-2: #b6b7c6;
    --muted: #7f8194;
    --grid: #252534;
    --axis: #34344a;
    --border: rgba(255, 255, 255, 0.07);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --accent: #8d76ff;
    --accent-soft: rgba(141, 118, 255, 0.16);
    --up: #ff5b69;
    --down: #4d9bff;
    --up-soft: rgba(255, 91, 105, 0.14);
    --down-soft: rgba(77, 155, 255, 0.14);
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #9085e9; --c-other: #55556a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0b11;
  --surface: #15151e;
  --surface-2: #1d1d29;
  --text: #f4f4f8;
  --text-2: #b6b7c6;
  --muted: #7f8194;
  --grid: #252534;
  --axis: #34344a;
  --border: rgba(255, 255, 255, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --accent: #8d76ff;
  --accent-soft: rgba(141, 118, 255, 0.16);
  --up: #ff5b69;
  --down: #4d9bff;
  --up-soft: rgba(255, 91, 105, 0.14);
  --down-soft: rgba(77, 155, 255, 0.14);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #9085e9; --c-other: #55556a;
}

/* ============================================================
   기본
   ============================================================ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* display를 지정한 요소도 hidden 속성이면 숨김 */
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 "Pretendard Variable", Pretendard, system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px 16px 40px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }

/* ============================================================
   헤더
   ============================================================ */
header.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 20px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
#brandHome { cursor: pointer; border-radius: 16px; -webkit-tap-highlight-color: transparent; }
#brandHome:hover .brand-name { color: var(--accent); }
#brandHome:active .logo { transform: scale(.94); }
#brandHome:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.logo { transition: transform .15s; }
.logo {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  background: var(--hero); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 20px; box-shadow: 0 6px 16px rgba(109, 74, 255, 0.35);
}
.logo svg { width: 100%; height: 100%; display: block; }
.brand-name { font-weight: 750; font-size: 18px; letter-spacing: -0.02em; white-space: nowrap; }
.greet { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: 6px; flex: none; }
.badge {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.badge.demo { background: var(--surface-2); color: var(--text-2); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center;
  color: var(--text-2); transition: transform .15s, background .15s;
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   탭 (데스크톱: 상단 알약 / 모바일: 하단 탭바)
   ============================================================ */
.tabs {
  display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px;
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow);
}
.tabs button {
  border: 0; background: none; cursor: pointer; border-radius: 999px;
  padding: 8px 18px; font-weight: 600; font-size: 14px; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px; transition: background .2s, color .2s;
}
.tabs button svg { width: 18px; height: 18px; }
.tabs button.active { background: var(--text); color: var(--surface); }
.panel { display: none; animation: rise .35s ease both; }
.panel.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }

/* ============================================================
   카드
   ============================================================ */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.card h2 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.card .hint { color: var(--muted); font-size: 13px; margin: 2px 0 16px; text-wrap: pretty; }
.grid { display: grid; gap: 14px; }
.two { grid-template-columns: 1.35fr 1fr; margin-top: 14px; }
.stack { display: grid; gap: 14px; }

/* ============================================================
   히어로 (총자산)
   ============================================================ */
.hero {
  position: relative; overflow: hidden; color: #fff; border: 0;
  background: var(--hero); padding: 24px; box-shadow: 0 16px 40px rgba(109, 74, 255, 0.28);
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, 0.12);
}
.hero::before { width: 260px; height: 260px; right: -70px; top: -110px; }
.hero::after { width: 160px; height: 160px; right: 90px; bottom: -100px; background: rgba(255, 255, 255, 0.08); }
.hero > * { position: relative; }
.hero-label { font-size: 14px; font-weight: 600; opacity: .85; }
.hero-value { font-size: clamp(32px, 7vw, 46px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; margin: 4px 0 10px; }
.hero-value small { font-size: .5em; font-weight: 700; margin-left: 2px; opacity: .9; }
.hero-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px;
  padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.22); white-space: nowrap;
}
.hero-sub { opacity: .85; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.hero-stat { background: rgba(255, 255, 255, 0.14); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(6px); min-width: 0; }
.hero-stat .l { font-size: 12px; opacity: .85; }
.hero-stat .v { font-size: 17px; font-weight: 750; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-stat .s { font-size: 12px; opacity: .85; white-space: nowrap; }
.hero-stat.link { cursor: pointer; transition: background .15s; -webkit-tap-highlight-color: transparent; }
.hero-stat.link:hover { background: rgba(255, 255, 255, 0.22); }
.hero-stat.link:active { transform: scale(.98); }
.hero-stat.link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ============================================================
   세그먼트 / 칩 / 입력
   ============================================================ */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.seg button {
  border: 0; background: none; cursor: pointer; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; }
.filters select, .filters input {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 12px; min-width: 0;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text); outline: none;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); }
.filters input[type="search"] { flex: 1 1 160px; }
.btn {
  border: 0; cursor: pointer; padding: 8px 14px; border-radius: 12px; font-weight: 600; font-size: 14px;
  background: var(--accent-soft); color: var(--accent);
}

/* ============================================================
   차트
   ============================================================ */
.chart-box { position: relative; height: 260px; }

/* 비중 막대 */
.alloc-bar { display: flex; gap: 2px; height: 14px; margin: 4px 0 18px; }
.alloc-bar span { border-radius: 4px; min-width: 4px; transition: flex-grow .6s ease; }
.alloc-bar span:first-child { border-radius: 7px 4px 4px 7px; }
.alloc-bar span:last-child { border-radius: 4px 7px 7px 4px; }
.alloc-bar span:only-child { border-radius: 7px; }
.legend { display: grid; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: 14px; }
.legend-row .dot { width: 10px; height: 10px; border-radius: 4px; }
.legend-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.legend-row .pct { font-weight: 700; }
.legend-row .amt { color: var(--muted); font-size: 13px; min-width: 64px; text-align: right; }

/* MVP 카드 */
.movers { grid-template-columns: 1fr 1fr; margin-top: 14px; }
.mover { display: flex; align-items: center; gap: 14px; }
.mover .emoji { font-size: 30px; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.mover.best .emoji { background: var(--up-soft); }
.mover.worst .emoji { background: var(--down-soft); }
.mover .t { font-size: 13px; color: var(--muted); font-weight: 600; }
.mover .n { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mover .r { font-weight: 800; font-size: 20px; margin-left: auto; white-space: nowrap; }

/* ============================================================
   종목 리스트
   ============================================================ */
.list { display: grid; }
.item {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 8px; margin: 0 -8px; border-radius: 14px; transition: background .15s;
}
.item:hover { background: var(--surface-2); }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px; letter-spacing: -0.03em;
}
.item .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .right { text-align: right; }
.item .amt { font-weight: 700; white-space: nowrap; }
.chg { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 8px; margin-top: 2px; white-space: nowrap; }
.chg.up { background: var(--up-soft); }
.chg.down { background: var(--down-soft); }
.chg.flat { background: var(--surface-2); color: var(--muted); }
.weight { grid-column: 2 / -1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: -4px; }
.weight i { display: block; height: 100%; border-radius: 4px; }

/* 거래 리스트 */
.day { font-size: 13px; font-weight: 700; color: var(--muted); padding: 16px 0 4px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.day:first-child { padding-top: 4px; }
.side { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.side.buy { background: var(--up-soft); color: var(--up); }
.side.sell { background: var(--down-soft); color: var(--down); }

.empty { text-align: center; padding: 40px 0; color: var(--muted); }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ============================================================
   수익 탭
   ============================================================ */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 14px; min-width: 0; }
.stat .l { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; text-wrap: pretty; }
.tip { cursor: help; font-weight: 400; }
.chart-box.short { height: 200px; margin-bottom: 8px; }

.legend-inline { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); font-weight: 600; margin: -8px 0 8px; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--c); border-radius: 2px; }
.swatch.dash { border-top-style: dashed; }

.suggestion {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 14px; border-radius: 14px; margin-bottom: 10px;
  background: var(--accent-soft); color: var(--text);
}
.suggestion .emoji { font-size: 22px; }
.suggestion .msg { flex: 1 1 200px; font-size: 14px; }
.suggestion .msg b { font-weight: 750; }
.suggestion .msg small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.suggestion .acts { display: flex; gap: 6px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--text-2); }

.flow-form { display: grid; grid-template-columns: auto 150px 1fr 1fr auto; gap: 8px; margin: 4px 0 8px; align-items: center; }
.flow-form input {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 12px; min-width: 0;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text); outline: none;
}
.flow-form input:focus { border-color: var(--accent); }
.flow-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; }
.flow-icon.in { background: var(--up-soft); }
.flow-icon.out { background: var(--down-soft); }
.del {
  border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1;
  width: 32px; height: 32px; border-radius: 10px; margin-left: 4px;
}
.del:hover { background: var(--surface-2); color: var(--up); }
.tag-auto { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; margin-left: 4px; }

/* ============================================================
   퀴즈
   ============================================================ */
:root { --good: #0ca30c; --bad: #d03b3b; --good-soft: rgba(12, 163, 12, 0.10); --bad-soft: rgba(208, 59, 59, 0.10); --fire: #e8590c; --fire-soft: rgba(232, 89, 12, 0.12); }
.quiz-seg { margin-bottom: 12px; }
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; margin-left: 2px; }
.quiz-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.dots { display: flex; gap: 6px; margin-top: 8px; }
.dots button { width: 30px; height: 7px; padding: 0; border: 0; border-radius: 4px; background: var(--surface-2); cursor: pointer; }
.dots button.cur { background: var(--accent); }
.dots button.ok { background: var(--good); }
.dots button.no { background: var(--bad); }
.streak-pill { font-size: 14px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: var(--fire-soft); color: var(--fire); white-space: nowrap; }
.q-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.fire { background: var(--bad-soft); color: var(--bad); }
.q-text { font-size: 19px; font-weight: 750; line-height: 1.5; letter-spacing: -0.02em; margin: 12px 0 18px; text-wrap: pretty; }
.opts { display: grid; gap: 10px; }
.opts.ox { grid-template-columns: 1fr 1fr; }
.opt {
  display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer; width: 100%;
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 14px; padding: 14px 16px;
  font-size: 15px; font-weight: 600; color: var(--text); transition: border-color .15s, background .15s, transform .1s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:active:not(:disabled) { transform: scale(.99); }
.opt:disabled { cursor: default; }
.opt .key { width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--text-2); flex: none; }
.opts.ox .opt { justify-content: center; font-size: 32px; font-weight: 800; padding: 20px; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .key { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }
.verdict { font-size: 18px; font-weight: 800; margin-top: 16px; animation: pop .35s ease; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
@keyframes pop { 0% { transform: scale(.8); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: none; opacity: 1; } }
.explain { margin-top: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); font-size: 14px; line-height: 1.65; color: var(--text); }
.explain .basis { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.quiz-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.summary { text-align: center; padding: 18px 8px 6px; }
.summary .big { font-size: 52px; line-height: 1.1; }
.summary .score { font-size: 30px; font-weight: 800; margin-top: 8px; }
.summary p { color: var(--text-2); margin: 6px 0 0; }
.summary .quiz-actions { justify-content: center; }
.quiz-home { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.quiz-home .emoji { font-size: 28px; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); flex: none; }
.quiz-home .t { font-size: 13px; color: var(--muted); font-weight: 600; }
.quiz-home .n { font-weight: 700; font-size: 16px; }
.quiz-home .btn { margin-left: auto; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 0; cursor: pointer; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chips button.active { background: var(--text); color: var(--surface); }
.note { padding: 18px 0; border-top: 1px solid var(--grid); }
.note:first-child { border-top: 0; padding-top: 6px; }
.note .q-text { font-size: 16px; margin: 10px 0 8px; }
.ans-line { font-size: 14px; margin: 3px 0; display: flex; gap: 6px; }
.ans-line.bad { color: var(--bad); }
.ans-line.good { color: var(--good); font-weight: 700; }
.memo { width: 100%; margin-top: 10px; font: inherit; font-size: 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); color: var(--text); resize: vertical; min-height: 42px; outline: none; }
.memo:focus { border-color: var(--accent); }
.note .quiz-actions { justify-content: flex-start; margin-top: 10px; }
.bars { display: grid; gap: 12px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: 84px 1fr 56px; gap: 10px; align-items: center; font-size: 14px; font-weight: 600; }
.bar-row .pct { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width .6s ease; }
.tipbox { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); font-size: 14px; line-height: 1.6; }

/* NCS 연습 */
.ncs-areas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 16px; }
.area {
  border: 1.5px solid var(--border); background: var(--surface); border-radius: 14px; padding: 14px; text-align: left;
  cursor: pointer; color: var(--text); font: inherit;
}
.area.active { border-color: var(--accent); background: var(--accent-soft); }
.area .t { font-weight: 750; font-size: 15px; }
.area .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ncs-opts { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.opt-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.big-btn { width: 100%; padding: 14px; font-size: 16px; border-radius: 14px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.passage { margin-top: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); font-size: 14px; line-height: 1.65; }
.qtable-wrap { margin-top: 12px; overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.qtable-cap { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; margin-top: 14px; }
.qtable-cap span { color: var(--muted); font-weight: 500; }
table.qtable { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.qtable th, .qtable td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
.qtable th { background: var(--surface-2); color: var(--text-2); font-weight: 700; }
.qtable th:first-child, .qtable td:first-child { text-align: left; font-weight: 700; }
.qtable tr:last-child td { border-bottom: 0; }
.qtable-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.steps { margin: 10px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }
.steps li::marker { color: var(--accent); font-weight: 800; }
.note .qtable-wrap, .note .passage { font-size: 12px; }
@media (max-width: 720px) {
  .ncs-areas { grid-template-columns: 1fr; }
  .qtable th, .qtable td { padding: 7px 6px; font-size: 12px; }
}

/* ============================================================
   종목 상세 시트
   ============================================================ */
.item.clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.item.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.item.clickable:active { transform: scale(.99); }
.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--text);
  width: min(720px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  border-radius: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
.sheet::backdrop { background: rgba(10, 10, 20, .45); backdrop-filter: blur(2px); }
.sheet[open] { animation: rise .25s ease both; }
.sheet-body { padding: 20px 22px 24px; }
.sheet-grip { display: none; }
.sheet-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.sheet-title { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .meta { font-size: 13px; color: var(--muted); }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 12px; cursor: pointer;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2);
}
.icon-btn svg { width: 18px; height: 18px; }
.sheet-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 16px 0 12px; }
.sheet-price .v { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.sheet-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sheet-tools .legend-inline { margin: 0; gap: 12px; font-size: 12px; }
.tri { display: inline-block; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.tri.up { border-bottom: 9px solid var(--up); }
.tri.down { border-top: 9px solid var(--down); }
.sheet .chart-box { height: 280px; }
.sheet .hint { color: var(--muted); font-size: 12px; margin: 6px 0 14px; }
.sheet-sub { font-size: 15px; font-weight: 700; margin: 20px 0 4px; }
.stat .v.sm { font-size: 17px; }
body:has(.sheet[open]) { overflow: hidden; }

/* ============================================================
   토스트
   ============================================================ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px);
  background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 14px;
  font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: calc(100% - 32px); z-index: 20; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 860px) {
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .wrap { padding-bottom: 96px; }
  .tabs {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 10; margin: 0;
    display: grid; grid-template-columns: repeat(5, 1fr); border-radius: 22px; padding: 6px;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .14); border: 1px solid var(--border);
  }
  .tabs button { flex-direction: column; gap: 2px; padding: 8px 2px; font-size: 11px; border-radius: 16px; justify-content: center; white-space: nowrap; }
  .quiz-seg { display: flex; }
  .quiz-seg button { flex: 1; padding: 7px 4px; }
  .q-text { font-size: 17px; }
  .tabs button.active { background: var(--accent-soft); color: var(--accent); }
  .toast { bottom: 96px; }
  .badge { display: none; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .hero-stat:first-child { grid-column: 1 / -1; }
  .movers { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .v { font-size: 18px; }
  .flow-form { grid-template-columns: 1fr 1fr; }
  .flow-form #flowMemo { grid-column: 1 / -1; }
  .flow-form #flowAmount, .flow-form button[type="submit"] { grid-column: 1 / -1; }
  /* 거래내역 필터: 2열로 정리 (시장·구분 / 시작일·종료일 / 검색) */
  #trades .filters { display: grid; grid-template-columns: 1fr 1fr; }
  #trades .filters input[type="search"] { grid-column: 1 / -1; }
  #trades .filters input[type="date"] { width: 100%; font-size: 13px; padding: 8px 10px; }
  /* 종목 상세: 휴대폰에서는 아래에서 올라오는 시트 */
  .sheet { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh; border-radius: 24px 24px 0 0; }
  .sheet[open] { animation: sheet-up .3s cubic-bezier(.2, .8, .2, 1) both; }
  .sheet-body { padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
  .sheet-grip { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--axis); margin: 0 auto 12px; }
  .sheet .chart-box { height: 240px; }
  .sheet-tools .seg { width: 100%; }
  .sheet-tools .seg button { flex: 1; }
}
@media (max-width: 520px) {
  .chg-amt { display: none; }  /* 좁은 화면에서는 손익 금액을 숨기고 수익률만 */
}
@media (max-width: 400px) {
  .brand-name { font-size: 16px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* ============================================================
   로그인
   ============================================================ */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; text-align: center; padding: 32px 24px; }
.login .logo { width: 64px; height: 64px; border-radius: 20px; font-size: 30px; margin: 0 auto 16px; }
.login h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.03em; }
.login p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login input {
  width: 100%; font: inherit; padding: 14px 16px; border-radius: 14px; margin-bottom: 12px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text); outline: none; font-size: 16px;
}
.login input:focus { border-color: var(--accent); }
.login button {
  width: 100%; padding: 14px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--hero); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 10px 24px rgba(109, 74, 255, 0.3);
}
.err { color: var(--up); font-size: 14px; margin-bottom: 12px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
