/* marketing.pensieve.kr — 글씨는 적게, 상태는 색·크기·움직임으로.
   토큰은 계획 문서(마케팅 시스템 구성)와 같은 계열. */
:root {
  --bg: #f3f7f7;
  --surface: #ffffff;
  --ink: #10262a;
  --muted: #5c7275;
  --line: #d3dedf;
  --accent: #0b7c7c;
  --accent-soft: #dceeed;
  --ok: #1c7447;
  --warn: #a86a00;
  --stop: #ad3329;
  --sans: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "D2Coding", ui-monospace, Menlo, Consolas, monospace;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1719; --surface: #132225; --ink: #e2eded; --muted: #8fa5a8; --line: #25393d;
    --accent: #52c7c1; --accent-soft: #123534;
    --ok: #62c592; --warn: #e2b458; --stop: #f08a7b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1719; --surface: #132225; --ink: #e2eded; --muted: #8fa5a8; --line: #25393d;
  --accent: #52c7c1; --accent-soft: #123534;
  --ok: #62c592; --warn: #e2b458; --stop: #f08a7b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--sans);
  word-break: keep-all;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── 입장 ─────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .3s ease;
}
.gate.off { opacity: 0; pointer-events: none; }
.gate form {
  width: min(320px, calc(100vw - 32px));
  display: flex; flex-direction: column; align-items: center; gap: 36px;
  animation: rise .4s ease-out both;
}
.mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft);
}
.gate .field {
  display: flex; align-items: center; width: 100%;
  border-bottom: 2px solid var(--line);
  transition: border-color .2s;
}
.gate .field:focus-within { border-color: var(--accent); }
.gate input {
  flex: 1; min-width: 0; padding: 10px 0;
  font: 18px var(--mono); letter-spacing: .12em; color: var(--ink);
  background: none; border: 0; outline: none;
}
.gate input::placeholder { letter-spacing: 0; font-family: var(--sans); color: var(--muted); opacity: .7; }
.gate button {
  background: none; border: 0; padding: 4px 6px; cursor: pointer;
  font: 500 20px var(--mono); color: var(--muted);
  transition: color .2s, transform .2s;
}
.gate .field:focus-within button { color: var(--accent); }
.gate button:hover { transform: translateX(3px); }
.gate form[data-state="wrong"] .field { border-color: var(--stop); animation: shake .4s ease; }
.gate form[data-state="wrong"] .mark { background: var(--stop); box-shadow: 0 0 0 6px color-mix(in srgb, var(--stop) 18%, transparent); }
.gate form[data-state="nocrypto"]::after { content: "https 또는 localhost 에서 열어 주세요"; font-size: 12.5px; color: var(--muted); }

/* ── 뼈대 ─────────────────────────────── */
.app {
  min-height: 100vh;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  opacity: 0; transition: opacity .35s ease;
}
.app.on { opacity: 1; }
main {
  min-width: 0; width: 100%; max-width: 680px;
  padding: 20px 16px 72px;
}

/* 탭: 노선 하나에 역 다섯. 켜진 역만 찬다 */
.tabs {
  position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  padding: 12px 8px 4px;
}
.brand { display: none; margin: 0; font: 11.5px/1.4 var(--mono); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.tabs ul { list-style: none; margin: 0; padding: 0; position: relative; display: flex; }
.tabs ul::before {
  content: ""; position: absolute; left: 10%; right: 10%; top: 7px; height: 2px;
  background: var(--line); border-radius: 1px;
}
.tabs li { flex: 1 1 0; min-width: 0; }
.tabs button {
  position: relative; width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 0 0 6px; background: none; border: 0; cursor: pointer;
  font-size: 11px; line-height: 1.2; letter-spacing: -.01em; white-space: nowrap; color: var(--muted);
  transition: color .2s;
}
.tabs button > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.st {
  display: block; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--bg);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .2s, background .2s, box-shadow .2s;
}
.tabs button:hover .st { border-color: var(--accent); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tabs button[aria-selected="true"] .st {
  border-color: var(--accent); background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft); transform: scale(1.1);
}

@media (min-width: 760px) {
  .app { grid-template-columns: 208px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  main { padding: 48px 40px 96px; }
  .tabs {
    height: 100vh; align-self: start;
    display: flex; flex-direction: column; gap: 32px;
    padding: 44px 24px 32px; background: none; backdrop-filter: none;
  }
  .brand { display: block; }
  .tabs ul { flex-direction: column; gap: 2px; }
  .tabs ul::before { left: 7px; right: auto; top: 20px; bottom: 20px; width: 2px; height: auto; }
  .tabs li { flex: none; }
  .tabs button { flex-direction: row; gap: 14px; padding: 9px 0; font-size: 14px; }
  .tabs button > span:last-child { overflow: visible; }
}

/* ── 섹션 공통 ─────────────────────────── */
main > section:not([hidden]) { animation: rise .25s ease-out both; }
.sh { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.sh time { font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
h2.sub { margin: 34px 0 4px; font: 500 11.5px var(--mono); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.ph, .empty {
  margin: 0; padding: 40px 0; text-align: center;
  font-size: 14px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.ph::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px dashed var(--line); }
.empty .st { border-style: dashed; }

/* ── 오늘: 신호 네 줄 ─────────────────── */
.signals { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sig {
  --c: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px 16px 20px;
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "n l" "n d";
  column-gap: 16px; row-gap: 2px; align-items: center;
  box-shadow: inset 4px 0 0 var(--c);
  animation: rise .4s ease-out both; animation-delay: calc(var(--i, 0) * 60ms);
  transition: opacity .3s, box-shadow .3s;
}
.sig[data-k="pending"] { --c: var(--warn); }
.sig[data-k="unfinished"], .sig[data-k="failed"] { --c: var(--stop); }
.sig[data-k="cost"] { --c: var(--accent); }
.sig .n { grid-area: n; min-width: 1.3em; font: 500 34px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--c); }
.sig .l { grid-area: l; font-size: 13px; color: var(--muted); }
.sig .d { grid-area: d; font: 12.5px/1.5 var(--mono); color: var(--ink); display: flex; flex-wrap: wrap; gap: 2px 6px; min-width: 0; }
.sig .d span { padding: 0 7px; border-radius: 999px; background: var(--bg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* 0건이면 조용히: 색을 빼고 흐리게, 세부는 숨긴다 */
.sig[data-level="0"] { opacity: .55; box-shadow: inset 4px 0 0 var(--line); }
.sig[data-level="0"] .n { color: var(--muted); }
.sig[data-level="0"] .d { display: none; }

.sig.cost { grid-template-areas: "l" "b"; grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
.bars { grid-area: b; display: grid; gap: 6px; min-width: 0; }
.bar { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; align-items: center; gap: 10px; font: 12.5px var(--mono); color: var(--muted); }
.bar b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar i { display: block; height: 8px; border-radius: 4px; background: var(--line); width: var(--w, 0%); min-width: 3px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar.t i { background: var(--accent); }
.sig[data-level="0"] .bar.t i { background: var(--line); }

/* ── 최근 실행 ─────────────────────────── */
.runs { list-style: none; margin: 0; padding: 0; }
.run {
  --c: var(--muted);
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; grid-template-areas: "dot svc time" ". out out";
  column-gap: 12px; row-gap: 1px; align-items: baseline;
  padding: 11px 2px; border-top: 1px solid var(--line);
}
.run:first-child { border-top: 0; }
.run[data-r="성공"] { --c: var(--ok); }
.run[data-r="실패"] { --c: var(--stop); }
.run[data-r="승인 대기"] { --c: var(--warn); }
.run .dot { grid-area: dot; align-self: center; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.run .svc { grid-area: svc; display: flex; align-items: baseline; gap: 8px; min-width: 0; font: 500 14px var(--mono); }
.run .svc > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run .res { flex: none; font-size: 11px; font-family: var(--sans); color: var(--c); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; line-height: 1.5; }
.run time { grid-area: time; font: 12px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.run .out { grid-area: out; font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.run[data-r="실패"] .out { color: var(--stop); white-space: normal; overflow-wrap: anywhere; }

/* ── 키워드 지도(모듈 3 전까지는 목록만) ── */
.clusters { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cl {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name count vol" "bar bar bar";
  column-gap: 14px; row-gap: 8px; align-items: baseline;
  animation: rise .35s ease-out both; animation-delay: calc(var(--i, 0) * 40ms);
}
.cl .name { grid-area: name; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cl .count, .cl .vol { font: 12.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cl .count { grid-area: count; }
.cl .vol { grid-area: vol; color: var(--ink); }
.cl .bar { grid-area: bar; display: block; }
.cl .bar i { display: block; height: 6px; border-radius: 3px; background: var(--accent); width: var(--w, 0%); min-width: 3px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
