/* 주식 레이더 — 밝은·어두운 화면을 각각 고른 색으로. 오름=빨강, 내림=파랑 (한국 관례), 분류는 색 + 기호 + 글자. */
:root {
  color-scheme: light;
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --line: #e3e6ea;
  --text: #191b1f; --text-2: #5d636c; --text-3: #8a9099;
  --accent: #3b5bdb; --accent-ink: #ffffff;
  --up: #d22f3c; --down: #1f63d6; --up-soft: rgba(210, 47, 60, .28); --down-soft: rgba(31, 99, 214, .26);
  --series: #6a4ce2; --grid: #eceef1; --base: #c9cdd3;
  --good: #c92a3a; --good-bg: #fdecee; --risk: #a65b00; --risk-bg: #fff3df; --event: #5b3fd0; --event-bg: #efebfe;
  --watch: #4d5560; --watch-bg: #eceff3; --flow: #00806b; --flow-bg: #e2f5f1;
  --bad: #b42318; --warn-bg: #fff7e6; --bad-bg: #fdecea;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 2px 8px rgba(20, 24, 30, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121417; --surface: #1b1e23; --surface-2: #23272d; --line: #2e333a;
    --text: #eceef1; --text-2: #a4abb4; --text-3: #7c838c;
    --accent: #7b93ff; --accent-ink: #0f1115;
    --up: #ff6b72; --down: #5c9dff; --up-soft: rgba(255, 107, 114, .32); --down-soft: rgba(92, 157, 255, .3);
    --series: #9887ef; --grid: #262a30; --base: #3a4048;
    --good: #ff7a85; --good-bg: #3a1d21; --risk: #f0a647; --risk-bg: #36290f; --event: #a593ff; --event-bg: #29233f;
    --watch: #b3bac3; --watch-bg: #2a2e34; --flow: #35c4a8; --flow-bg: #12322c;
    --bad: #ff8a80; --warn-bg: #33290f; --bad-bg: #3a1f1d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 12px 0 4px; color: var(--text-2); }
p { margin: 6px 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.err { color: var(--bad); }
button, .btn, select, input, textarea { font: inherit; color: inherit; }
button, .btn {
  border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 9px; cursor: pointer;
  min-height: 36px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; }
.small.btn, button.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; min-height: 36px;
}
textarea { width: 100%; resize: vertical; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- 틀 ---- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 17px; color: var(--text); letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); white-space: nowrap; font-weight: 500; }
.tabs a.on { background: var(--surface-2); color: var(--text); font-weight: 700; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.search { position: relative; margin-left: auto; }
.search input { width: 220px; }
.drop {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 260px; margin: 0; padding: 4px; list-style: none; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.drop li { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.drop li:hover { background: var(--surface-2); }
.activity { display: flex; flex-direction: column; gap: 2px; padding: 6px 16px; background: var(--event-bg); border-bottom: 1px solid var(--line); font-size: 13px; }
.activity .act { color: var(--text); display: flex; gap: 8px; align-items: center; }
main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); }
body.signed-out .top, body.signed-out .activity { display: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
details.card > summary { cursor: pointer; font-weight: 600; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 20px 0 10px; }
.sec-head h2 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.two { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.col { min-width: 0; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.row-end { display: flex; justify-content: flex-end; margin-top: 8px; gap: 8px; }
.scroll { overflow-x: auto; }
.note { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.note.warn { background: var(--warn-bg); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty p:first-child { font-size: 17px; color: var(--text); }
.loading { display: flex; gap: 10px; align-items: center; color: var(--text-2); padding: 24px 4px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

/* ---- 배지·칩 ---- */
.badge { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; margin-left: 4px; }
.cat-good.badge { background: var(--good-bg); color: var(--good); }
.cat-risk.badge { background: var(--risk-bg); color: var(--risk); }
.cat-event.badge { background: var(--event-bg); color: var(--event); }
.cat-watch.badge, .cat-none.badge { background: var(--watch-bg); color: var(--watch); }
.cat-flow.badge { background: var(--flow-bg); color: var(--flow); }
.badge.mark { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.badge.mark-watch { border-color: var(--accent); color: var(--accent); }
.badge.mark-own { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge.mark-drop { color: var(--text-3); text-decoration: line-through; }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-head .chips { margin: 0; }
.chip { min-height: 32px; padding: 4px 12px; border-radius: 999px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 30px; padding: 4px 12px; font-size: 13px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.seg.wide { display: flex; margin-bottom: 10px; }
.seg.wide button { flex: 1; justify-content: center; }

/* ---- 리포트 ---- */
.summary .prose { font-size: 15.5px; }
.market { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.pick { display: flex; flex-direction: column; border-top: 3px solid var(--line); margin: 0; }
.pick.cat-good { border-top-color: var(--good); }
.pick.cat-risk { border-top-color: var(--risk); }
.pick.cat-event { border-top-color: var(--event); }
.pick.cat-flow { border-top-color: var(--flow); }
.pick-head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pick-name { font-weight: 800; font-size: 17px; color: var(--text); margin-right: 4px; }
.pick-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; margin: 4px 0; align-items: center; }
.pick h3 { color: var(--text); font-size: 15px; margin: 6px 0 2px; }
.pick > p { margin: 4px 0 6px; color: var(--text); }
.attn { color: var(--accent); letter-spacing: 1px; font-size: 11px; }
.attn .off { color: var(--line); }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 6px; font-size: 13.5px; margin-top: 4px; }
.kv b { color: var(--text-2); font-weight: 600; }
.kv ul { margin: 0; padding-left: 16px; }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; justify-content: flex-end; }
.cal { list-style: none; margin: 0; padding: 0; }
.cal li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.cal li:last-child { border: 0; }
.date { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 64px; display: inline-block; font-size: 13px; }
.stage .lines { margin: 8px 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.prose p { margin: 6px 0; }
.prose ul, .bul { margin: 4px 0; padding-left: 18px; }
.sources { font-size: 13px; color: var(--text-2); margin: 8px 0; }
.sources summary { cursor: pointer; }
.sources ul { padding-left: 18px; }
.asks { margin-top: 10px; }
.ask { border-top: 1px solid var(--line); padding: 10px 0; }
.ask .q { font-weight: 600; margin: 0 0 4px; }

/* ---- 표 ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl thead th { color: var(--text-2); font-weight: 600; font-size: 12.5px; position: sticky; top: 0; background: var(--surface); }
.tbl td.n, .tbl.num td { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.num td:first-child, .tbl.num tbody th { text-align: left; }
.tbl th.est { color: var(--text-3); }
.tbl .tags { color: var(--text-2); white-space: normal; min-width: 180px; }
.st-error { color: var(--bad); }
.st-running, .st-queued, .st-preparing { color: var(--accent); }

/* ---- 종목 ---- */
.code { font-size: 14px; font-weight: 500; }
.price { font-size: 17px; margin: 2px 0; }
.price b { font-size: 22px; font-variant-numeric: tabular-nums; }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 14px; margin: 0; }
.metrics div { border-bottom: 1px solid var(--line); padding: 4px 0; }
.metrics dt { font-size: 12px; color: var(--text-2); }
.metrics dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.disc, .news { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.disc li, .news li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.disc li:last-child, .news li:last-child { border: 0; }
.disc.feed { padding: 4px 16px; }
.disc li.day { font-weight: 700; color: var(--text-2); padding-top: 14px; font-size: 13px; }
.analysis .lead { font-size: 15.5px; font-weight: 600; }
.analysis .sec h3 { margin-top: 14px; }
.bullbear { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.bullbear > div { padding: 10px 12px; border-radius: 10px; }
.bull { background: var(--good-bg); }
.bear { background: var(--down-soft); }
.bullbear h3 { margin-top: 0; color: var(--text); }
@media (max-width: 520px) { .bullbear { grid-template-columns: 1fr; } }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 3px 0; }
.older { margin: 8px 0 0 8px; }
.mark-box .memo { white-space: pre-wrap; }
.marklog { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.marklog li { padding: 3px 0; }
.markcard { color: var(--text); margin: 0; }
.markcard:hover { text-decoration: none; border-color: var(--accent); }
.markcard .memo { white-space: pre-wrap; font-size: 14px; }
.pick-note { border-left: 4px solid var(--line); }
.pick-note.cat-good { border-left-color: var(--good); }
.pick-note.cat-risk { border-left-color: var(--risk); }
.pick-note.cat-event { border-left-color: var(--event); }
.pick-note.cat-flow { border-left-color: var(--flow); }

/* ---- 차트 ---- */
.chart { position: relative; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.chart-title { font-weight: 700; font-size: 14px; }
.plot { width: 100%; touch-action: pan-y; }
.plot svg { display: block; width: 100%; height: auto; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--base); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .vol.up { fill: var(--up-soft); }
.chart .vol.down { fill: var(--down-soft); }
.tip { position: absolute; top: 8px; min-width: 150px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 6px 18px rgba(0, 0, 0, .16); font-size: 12.5px; pointer-events: none; font-variant-numeric: tabular-nums; }
.table-view { margin-top: 6px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--text-2); }

/* ---- 로그인·알림 ---- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
.login h1 { font-size: 24px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-2); }
.login label.check { flex-direction: row; align-items: center; gap: 6px; }
.login input:not([type=checkbox]) { width: 100%; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .2s; background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 50; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .top { gap: 8px; }
  .search { margin-left: 0; flex: 1; }
  .search input { width: 100%; }
  .top > button { display: none; }
  .grid { grid-template-columns: 1fr; }
  h1 { font-size: 19px; }
}
[hidden] { display: none !important; }

/* ---- 0.2.0 보유 · 0.3.0 예측 ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.alerts { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.alert-list { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.alert-list li { padding: 5px 9px; border-radius: 8px; font-size: 14px; }
.al-bad { background: var(--bad-bg); }
.al-warn { background: var(--warn-bg); }
.al-good { background: var(--good-bg); }
.al-info { color: var(--text-2); }
.tbl.holdings td, .tbl.holdings th { white-space: nowrap; }
.hrow { cursor: pointer; }
.hrow:hover, .hrow.open { background: var(--surface-2); }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.hdetail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 8px 4px; white-space: normal; }
@media (max-width: 760px) { .hdetail { grid-template-columns: 1fr; } }
.levels tr.lv-avg th, .levels tr.lv-avg td { background: var(--event-bg); font-weight: 700; }
.levels tr.lv-close th, .levels tr.lv-close td { background: var(--surface-2); font-weight: 700; }
.levels tr.lv-stop th { color: var(--down); }
.levels tr.lv-target th { color: var(--up); }
.hform { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hform label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--text-2); }
.frow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.frow > label { flex: 1 1 140px; }
.search.inline { margin-left: 0; }
.search.inline input { width: 100%; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }
.badge.act { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.badge.act-buy, .badge.act-add { background: var(--good-bg); color: var(--up); border-color: transparent; }
.badge.act-reduce, .badge.act-sell, .badge.act-avoid { background: color-mix(in srgb, var(--down) 14%, var(--surface)); color: var(--down); border-color: transparent; }
.badge .conv { font-size: 9px; letter-spacing: -1px; opacity: .8; }
.badge.warn { background: var(--warn-bg); color: var(--risk); }
.forecast { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: var(--surface-2); }
.forecast .tbl { margin: 8px 0; }
.fc-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.fc-line { margin: 4px 0 6px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.hold-one { border-bottom: 1px solid var(--line); padding: 6px 0; }
.hold-one:last-of-type { border-bottom: 0; }
.hold-check { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hold-check p { margin: 4px 0 0; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.meter span { display: block; height: 100%; background: var(--series); border-radius: 4px; }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin: 10px 0; }
.pick-list fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto; }
.pick-list legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; min-height: 0; }
.tbl.board td.why { min-width: 260px; white-space: normal; }
.tbl.preds td { white-space: nowrap; }
.note { border-radius: 10px; }
.pick-list label.check { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; font-size: 14px; }
.card > .sec-head:first-child { margin-top: 0; }
/* 전 종목 훑기 */
.tbl.sweep td.stars { color: var(--accent); letter-spacing: -1px; white-space: nowrap; }
.tbl.sweep td.why { min-width: 180px; }
