/* VIRALCAST — self-contained styles. Warm-neutral, raspberry accent.
   Matches repo design language (Hangar family) but app-scoped. */
/* base :root = no-JS fallback (this app's default = LIGHT, warm paper) */
:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f4efe7;
  --line: #e7dfd3; --line-2: #efe9dd; --ink: #2a2320; --ink-2: #6b6258; --faint: #a99e90;
  --primary: oklch(58% 0.18 354); --primary-soft: oklch(96% 0.03 354);
  --ok: oklch(62% 0.15 150); --warn: oklch(62% 0.16 75); --err: oklch(58% 0.20 25);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Inter", "Pretendard", system-ui, -apple-system, "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}
/* 3-way theme (Light/Dark/System) — dual palettes; System = runtime picks one. */
:root[data-theme="light"] {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f4efe7;
  --line: #e7dfd3; --line-2: #efe9dd; --ink: #2a2320; --ink-2: #6b6258; --faint: #a99e90;
  --primary: oklch(58% 0.18 354); --primary-soft: oklch(96% 0.03 354);
  --ok: oklch(62% 0.15 150); --warn: oklch(62% 0.16 75); --err: oklch(58% 0.20 25);
  --theme-switch-bg: var(--surface-2); --theme-switch-border: var(--line); --theme-switch-fg: var(--ink-2);
  --theme-switch-active-bg: var(--primary); --theme-switch-active-fg: #ffffff; --theme-switch-radius: 9px;
  --i18n-switch-bg: var(--surface-2); --i18n-switch-border: var(--line); --i18n-switch-fg: var(--ink-2);
  --i18n-switch-active-bg: var(--primary-soft); --i18n-switch-active-fg: var(--primary);
  --i18n-switch-menu-bg: var(--surface); --i18n-switch-menu-border: var(--line);
}
:root[data-theme="dark"] {
  --bg: #1b1714; --surface: #241f1b; --surface-2: #2c2620;
  --line: #3a322b; --line-2: #322b25; --ink: #f2ece3; --ink-2: #b3a89b; --faint: #7d7264;
  --primary: oklch(68% 0.17 354); --primary-soft: oklch(30% 0.06 354);
  --ok: oklch(70% 0.15 150); --warn: oklch(78% 0.14 75); --err: oklch(70% 0.18 25);
  --theme-switch-bg: var(--surface-2); --theme-switch-border: var(--line); --theme-switch-fg: var(--ink-2);
  --theme-switch-active-bg: var(--primary); --theme-switch-active-fg: #2a1018; --theme-switch-radius: 9px;
  --i18n-switch-bg: rgba(255,255,255,.05); --i18n-switch-border: var(--line); --i18n-switch-fg: var(--ink-2);
  --i18n-switch-active-bg: var(--primary-soft); --i18n-switch-active-fg: var(--primary);
  --i18n-switch-menu-bg: var(--surface); --i18n-switch-menu-border: var(--line);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

/* ── topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem;
  padding: .6rem 1rem; background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: .4rem; }
.brand .prompt { color: var(--primary); font-weight: 800; }
.brand .wordmark { font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; }
.brand .ko { color: var(--ink-2); font-size: .85rem; }
.privacy-badge {
  display: inline-flex; align-items: center; gap: .4rem; margin-left: auto;
  padding: .25rem .6rem; font-size: .72rem; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.privacy-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sidebar-toggle {
  display: none; padding: .4rem .7rem; font-size: .85rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
}

/* ── layout ─────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 248px 1fr; max-width: 1180px; margin: 0 auto; min-height: calc(100vh - 53px); }
.sidebar {
  border-right: 1px solid var(--line); padding: 1rem .8rem; position: sticky; top: 53px;
  align-self: start; max-height: calc(100vh - 53px); overflow-y: auto;
}
.search-wrap { position: relative; margin-bottom: .8rem; }
.search-ico { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search {
  width: 100%; padding: .5rem .7rem .5rem 1.7rem; font-size: .85rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.search:focus { border-color: var(--primary); }
.tool-list { display: flex; flex-direction: column; gap: .15rem; }
.group-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: .8rem .5rem .3rem; }
.tool-item {
  display: flex; align-items: center; gap: .55rem; width: 100%; padding: .5rem .55rem;
  background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--ink); text-align: left; font-size: .88rem;
}
.tool-item:hover { background: var(--surface-2); }
.tool-item.active { background: var(--primary-soft); border-color: color-mix(in oklch, var(--primary) 35%, transparent); }
.tool-item .ti-ico { font-size: 1rem; }
.tool-item .ti-name { flex: 1; }
.tool-item .ti-star { color: var(--faint); font-size: .9rem; }
.tool-item .ti-star.on { color: var(--warn); }
.sidebar-foot { margin-top: 1rem; padding-top: .6rem; border-top: 1px solid var(--line-2); }
.home-link { display: inline-block; padding: .35rem .55rem; font-size: .82rem; color: var(--ink-2); text-decoration: none; border-radius: 8px; }
.home-link:hover { background: var(--surface-2); color: var(--ink); }

.work { padding: 1.6rem 1.4rem 4rem; min-width: 0; }
.view { display: none; }
.view.active { display: block; }

/* ── hero ───────────────────────────────────────────────── */
.hero { max-width: 640px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.15; font-weight: 800; }
.hero h1 .accent { color: var(--primary); }
.hero-sub { margin: .9rem 0 1.4rem; color: var(--ink-2); font-size: .98rem; }
.hero-quick .quick-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.qchip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .8rem; font-size: .85rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--ink);
}
.qchip:hover { border-color: var(--primary); background: var(--primary-soft); }
.qchip .qi { font-size: 1rem; }

/* ── panel ──────────────────────────────────────────────── */
.panel-head { margin-bottom: 1.2rem; }
.panel-head h2 { display: flex; align-items: center; gap: .5rem; font-size: 1.3rem; }
.panel-head .ph-ico { font-size: 1.4rem; }
.panel-head .desc { color: var(--ink-2); font-size: .9rem; margin-top: .3rem; max-width: 60ch; }

.field { margin-bottom: 1rem; }
.field-label { font-size: .76rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem; }
.sub { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 1.2rem 0 .6rem; }
.divider { height: 1px; background: var(--line); margin: 1.3rem 0; }
.note { font-size: .78rem; color: var(--faint); margin-top: .9rem; line-height: 1.5; }

.code-area {
  width: 100%; padding: .65rem .8rem; font-size: .9rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; outline: none; resize: vertical;
}
.code-area:focus { border-color: var(--primary); }
.num-in {
  padding: .5rem .7rem; font-size: 1rem; font-weight: 600; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; outline: none; width: 140px;
}
.num-in:focus { border-color: var(--primary); }

.seg { display: inline-flex; flex-wrap: wrap; gap: .3rem; background: var(--surface-2); padding: .25rem; border-radius: 10px; border: 1px solid var(--line); }
.seg button { padding: .4rem .7rem; font-size: .82rem; font-weight: 600; background: transparent; border: none; border-radius: 7px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.chk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.chk { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .86rem; }
.chk input { position: absolute; opacity: 0; }
.chk .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--line); flex-shrink: 0; display: grid; place-items: center; }
.chk input:checked + .box { background: var(--primary); border-color: var(--primary); }
.chk input:checked + .box::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 700; }
.chk input:checked ~ .lbl { color: var(--ink); }
.chk .lbl { color: var(--ink-2); }

.btn { padding: .5rem .9rem; font-size: .85rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: .3rem .6rem; font-size: .76rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.empty-list { color: var(--faint); font-size: .88rem; padding: .5rem 0; }

/* ── score ──────────────────────────────────────────────── */
.score-out { margin-top: .5rem; }
.gauge { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.gauge-ring { position: relative; width: 120px; height: 120px; }
.gauge-ring svg { width: 120px; height: 120px; transform: rotate(-90deg); }
.gauge-ring circle { fill: none; stroke-width: 12; }
.gauge-ring circle.bg { stroke: var(--line); }
.gauge-ring circle.fg { stroke: var(--c, var(--primary)); stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: calc(327 - 327 * var(--p, 0) / 100); transition: stroke-dashoffset .5s ease; }
.gauge-num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.gauge-num b { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.gauge-num span { font-size: .7rem; color: var(--faint); }
.verdict { font-weight: 700; font-size: 1.05rem; }
.verdict.ok { color: var(--ok); } .verdict.warn { color: var(--warn); } .verdict.err { color: var(--err); }
.breakdown { margin-bottom: 1.2rem; }
.bd-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: .6rem; padding: .25rem 0; font-size: .82rem; }
.bd-k { color: var(--ink-2); }
.bd-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bd-bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bd-v { text-align: right; color: var(--faint); font-family: var(--mono); font-size: .76rem; }
.tips { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.tip { font-size: .85rem; color: var(--ink-2); padding: .2rem 0; }
.tip.ok { color: var(--ok); font-weight: 600; }

/* ── kfactor ────────────────────────────────────────────── */
.kf-head { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; padding: .9rem 1.1rem; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 1.2rem; }
.kf-k b { font-size: 2rem; font-weight: 800; color: var(--primary); }
.kf-k span { display: block; font-size: .72rem; color: var(--faint); font-family: var(--mono); }
.kf-v { font-weight: 700; }
.kf-head.ok { border-color: color-mix(in oklch, var(--ok) 50%, transparent); }
.kf-head.warn { border-color: color-mix(in oklch, var(--warn) 50%, transparent); }
.kf-head.err { border-color: color-mix(in oklch, var(--err) 50%, transparent); }
.proj-table { width: 100%; max-width: 320px; border-collapse: collapse; font-size: .88rem; }
.proj-table th, .proj-table td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line-2); }
.proj-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.proj-table td:last-child { font-family: var(--mono); font-weight: 600; }

/* ── hooks ──────────────────────────────────────────────── */
.hook-list { display: flex; flex-direction: column; gap: .5rem; }
.hook-card { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.hook-text { flex: 1; font-size: .92rem; }

/* ── timing ─────────────────────────────────────────────── */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; }
.slot-card { padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.slot-label { font-size: .8rem; color: var(--ink-2); margin-bottom: .2rem; }
.slot-time { font-size: 1.15rem; font-weight: 700; font-family: var(--mono); color: var(--primary); }

/* ── spec ───────────────────────────────────────────────── */
.check-list { display: flex; flex-direction: column; gap: .45rem; }
.check-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: .6rem; padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; }
.check-row.pass { border-left-color: var(--ok); }
.check-row.warn { border-left-color: var(--warn); }
.check-row.fail { border-left-color: var(--err); }
.ch-ico { font-weight: 800; text-align: center; }
.check-row.pass .ch-ico { color: var(--ok); }
.check-row.warn .ch-ico { color: var(--warn); }
.check-row.fail .ch-ico { color: var(--err); }
.ch-status { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; }
.check-row.pass .ch-status { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.check-row.warn .ch-status { background: color-mix(in oklch, var(--warn) 20%, transparent); color: var(--warn); }
.check-row.fail .ch-status { background: color-mix(in oklch, var(--err) 18%, transparent); color: var(--err); }

/* ── ad slots ───────────────────────────────────────────── */
.ad-slot { margin: 1.6rem 0; min-height: 0; border: 1px dashed transparent; border-radius: 12px; padding: 0; overflow: hidden; }
.ad-slot .ad-label { display: none; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.ad-slot .ad-ph { display: none; padding: 1.4rem; text-align: center; font-size: .78rem; color: var(--faint); }
.ad-slot.is-preview { border-color: var(--line); min-height: 90px; }
.ad-slot.is-preview .ad-label, .ad-slot.is-preview .ad-ph { display: block; }
.ad-slot.is-live { min-height: 100px; }
.ad-slot.is-live .ad-label { display: block; padding: .4rem .6rem 0; }

/* ── toast / scrim ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translate(-50%, 1rem);
  background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.srim, .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 25; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ── responsive ─────────────────────────────────────────── */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 53px; left: 0; bottom: 0; width: 280px; max-height: none;
    background: var(--surface); z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 20px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-block; }
  .privacy-badge { display: none; }
  .work { padding: 1.2rem 1rem 4rem; }
  .bd-row { grid-template-columns: 110px 1fr 50px; }
}
