:root {
  --bg: #f6f7f9; --card: #fff; --ink: #14181f; --ink2: #4a5361; --ink3: #7b8494; --line: #e4e7ec;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #e6f4f2;
  --up: #c2410c; --up-soft: #fff1e8; --down: #1d4ed8; --down-soft: #eaf0ff;
  --warn: #a16207; --warn-soft: #fdf6e3; --bad: #b91c1c; --bad-soft: #fdecec; --good: #15803d; --good-soft: #e9f7ee;
  --r: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --tabs-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --card: #171b22; --ink: #e8ebf0; --ink2: #b3bac6; --ink3: #858d9b; --line: #272d37;
    --brand: #2dd4bf; --brand-ink: #062521; --brand-soft: #12302d;
    --up: #fb923c; --up-soft: #33200f; --down: #7aa2ff; --down-soft: #172242;
    --warn: #facc15; --warn-soft: #2e2810; --bad: #f87171; --bad-soft: #3a1717; --good: #4ade80; --good-soft: #12301d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { font-size: 15px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.top-meta { font-size: 12px; color: var(--ink3); text-align: right; }
main { padding: 4px 16px 16px; outline: none; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs a { flex: 1; max-width: 144px; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink3); font-size: 11px; font-weight: 600; }
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--brand); }
.tabs a.on svg { stroke-width: 2.3; }

/* ---------- type ---------- */
h1 { font-size: 22px; letter-spacing: -.03em; margin: 8px 0 4px; }
h2 { font-size: 17px; letter-spacing: -.02em; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.sub { color: var(--ink2); font-size: 13.5px; margin: 0 0 14px; }
.muted { color: var(--ink3); }
.small { font-size: 12.5px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.card.flat { box-shadow: none; }
.cond { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.cond .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--bg);
  border: 1px solid var(--line); font-size: 12.5px; color: var(--ink2); white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 700; }
.chip.x { cursor: pointer; padding-right: 6px; }
.chip.x::after { content: "×"; margin-left: 4px; color: var(--ink3); font-size: 14px; }

.rec { position: relative; padding: 14px 14px 12px; }
.rec-head { display: flex; gap: 10px; align-items: flex-start; }
.rank { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800;
  background: var(--brand-soft); color: var(--brand); font-size: 15px; }
.rank.r1 { background: var(--brand); color: var(--brand-ink); }
.rec-title { flex: 1; min-width: 0; }
.rec-title .name { font-weight: 750; font-size: 16px; letter-spacing: -.02em; line-height: 1.3; }
.rec-title .loc { color: var(--ink3); font-size: 12.5px; margin-top: 2px; }
.roi { text-align: right; flex: none; }
.roi .v { font-size: 24px; font-weight: 800; letter-spacing: -.03em; color: var(--up); line-height: 1.1; }
.roi .l { font-size: 11px; color: var(--ink3); }
.kv3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 8px; }
.kv3 > div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.kv3 .k { font-size: 11.5px; color: var(--ink3); }
.kv3 .v { font-weight: 700; font-size: 16px; letter-spacing: -.02em; white-space: nowrap; }
.kv3 .v.up { color: var(--up); }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink2); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700; background: var(--bg); color: var(--ink2); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.dday { font-weight: 800; color: var(--bad); }
details.more { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.more summary { cursor: pointer; color: var(--ink2); font-size: 13px; font-weight: 600; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: " ▾"; }
details.more[open] summary::after { content: " ▴"; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.t th, table.t td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.t th:first-child, table.t td:first-child { text-align: left; white-space: normal; }
table.t th { color: var(--ink3); font-weight: 600; font-size: 12px; }
.lines { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink2); }
.lines li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.lines li span:last-child { color: var(--ink); font-weight: 600; text-align: right; }

.banner { border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 12px; display: flex; gap: 10px; align-items: flex-start; }
.banner.info { background: var(--brand-soft); color: var(--ink); }
.banner.warn { background: var(--warn-soft); color: var(--ink); }
.banner.bad { background: var(--bad-soft); color: var(--ink); }
.banner b { font-weight: 700; }
.empty { text-align: center; padding: 34px 16px; color: var(--ink3); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.empty p { margin: 4px 0; }

/* ---------- segmented / list ---------- */
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 3px; margin-bottom: 12px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink2); white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .l { min-width: 0; }
.row .l .n { font-weight: 650; }
.row .r { text-align: right; flex: none; }

/* ---------- bars ---------- */
.bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--brand); }
.q5 { display: inline-flex; gap: 2px; vertical-align: middle; }
.q5 i { width: 12px; height: 8px; border-radius: 2px; background: var(--line); display: inline-block; }
.q5 i.on { background: var(--brand); }
svg.spark { width: 100%; height: 46px; display: block; }
svg.spark path.l { fill: none; stroke: var(--brand); stroke-width: 2; }
svg.spark path.a { fill: var(--brand-soft); stroke: none; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--ink2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--ink3); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=search], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-size: 16px; outline: none; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle .t1 { font-weight: 600; }
.toggle .t2 { font-size: 12.5px; color: var(--ink3); }
.sw { position: relative; flex: none; width: 46px; height: 28px; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .2s; cursor: pointer; }
.sw span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.sw input:checked + span { background: var(--brand); }
.sw input:checked + span::after { transform: translateX(18px); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700; font-size: 14.5px; cursor: pointer; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest { border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; overflow: hidden; background: var(--card); }
.suggest button { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; }
.suggest button:last-child { border-bottom: 0; }
.suggest button span { color: var(--ink3); font-size: 12px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 9vh auto 0; }
.auth .logo { text-align: center; margin-bottom: 18px; }
.auth .logo img { width: 56px; height: 56px; }
.auth .logo h1 { margin: 8px 0 2px; }

.loading { padding: 40px 0; text-align: center; color: var(--ink3); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: .25s; pointer-events: none; z-index: 20; max-width: 90vw; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
@media (min-width: 560px) { .kv3 .v { font-size: 16px; } }
