:root {
  --bg: #F2F0EA;
  --surface: #FFFFFF;
  --surface-2: #E9E6DE;
  --ink: #151514;
  --ink-2: #45433E;
  --muted: #8A867C;
  --line: #DEDAD0;
  --accent: #FF4B1F;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(255, 75, 31, .10);
  --ok: #1F8A4C;
  --ok-soft: rgba(31, 138, 76, .10);
  --radius: 18px;
  --serif: 'Literata', Georgia, serif;
  --sans: 'Onest', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html.dark {
  --bg: #0E0E0D;
  --surface: #191917;
  --surface-2: #232320;
  --ink: #F1EEE7;
  --ink-2: #C4C0B6;
  --muted: #7F7B72;
  --line: #2C2B28;
  --accent-soft: rgba(255, 75, 31, .16);
  --ok: #3BC274;
  --ok-soft: rgba(59, 194, 116, .14);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.muted { color: var(--muted); }

#app { max-width: 560px; margin: 0 auto; position: relative; }

/* ── screens ── */
.screen { display: none; padding: 0 20px; min-height: 100vh; }
.screen.is-active { display: block; animation: rise .45s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── type ── */
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.display { font-family: var(--serif); font-weight: 600; font-size: 38px; line-height: 1.05; letter-spacing: -.02em; margin-top: 10px; }
.display.sm { font-size: 30px; }
.lead { color: var(--ink-2); margin-top: 12px; font-size: 15.5px; max-width: 30em; }

/* ── setup ── */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 18px 0 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .22em; font-size: 13px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); position: relative; }
.brand-dot::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0; animation: ping 2.2s infinite; }
@keyframes ping { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }

.setup-hero { padding: 28px 0 22px; }

.niche-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.niche {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 6px;
  padding: 15px 2px; border-bottom: 1px solid var(--line); text-align: left;
  transition: background .2s;
}
.niche-idx { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.niche-name { font-weight: 600; font-size: 16.5px; }
.niche-hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 1px; }
.niche-mark {
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line);
  display: grid; place-items: center; transition: all .2s;
}
.niche-mark svg { opacity: 0; transform: scale(.6); transition: all .2s; }
.niche.is-on .niche-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.niche.is-on .niche-mark svg { opacity: 1; transform: none; }
.niche.is-on .niche-idx { color: var(--accent); }
.niche:active { background: var(--surface-2); }

.custom { padding: 24px 0 8px; }
.custom-label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 8px; }
.custom-field { position: relative; }
.custom-field input {
  width: 100%; height: 52px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); padding: 0 44px 0 16px; font-size: 15.5px; outline: none;
  transition: border-color .2s;
}
.custom-field input:focus { border-color: var(--ink); }
.custom-field input::placeholder { color: var(--muted); }
.custom-clear { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; font-size: 22px; color: var(--muted); display: none; }
.custom-field.has-value .custom-clear { display: block; }

.cta-wrap {
  position: sticky; bottom: 0; padding: 18px 0 calc(18px + var(--safe-b));
  background: linear-gradient(to bottom, transparent, var(--bg) 35%);
  margin-top: 12px;
}
.cta {
  width: 100%; height: 56px; border-radius: 16px; background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; font-size: 16px; transition: transform .15s, opacity .2s;
}
.cta:active { transform: scale(.98); }
.cta:disabled { opacity: .28; }

/* ── scan ── */
#screen-scan { display: none; }
#screen-scan.is-active { display: flex; align-items: center; justify-content: center; }
.scan { width: 100%; display: flex; flex-direction: column; align-items: center; padding: 40px 0; }
.scope { width: 220px; height: 220px; position: relative; border-radius: 50%; }
.scope-ring { position: absolute; border-radius: 50%; border: 1px solid var(--line); }
.scope-ring.r1 { inset: 0; }
.scope-ring.r2 { inset: 22%; }
.scope-ring.r3 { inset: 42%; }
.scope-cross { position: absolute; inset: 0; }
.scope-cross::before, .scope-cross::after { content: ''; position: absolute; background: var(--line); }
.scope-cross::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.scope-cross::after { top: 50%; left: 0; right: 0; height: 1px; }
.scope-sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 290deg, var(--accent-soft) 330deg, rgba(255,75,31,.45) 360deg);
  animation: sweep 2s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.blip { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); animation: blip 1.6s ease-out forwards; }
.blip.dim { background: var(--muted); }
@keyframes blip { 0% { transform: scale(0); opacity: 0; } 15% { transform: scale(1.4); opacity: 1; } 100% { transform: scale(1); opacity: .25; } }
.scan-count { margin-top: 28px; color: var(--muted); font-size: 13px; }
.scan-count span { color: var(--ink); font-weight: 500; }
.scan-steps { list-style: none; margin-top: 22px; width: 100%; max-width: 300px; }
.scan-steps li {
  display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 14.5px; color: var(--muted);
  opacity: 0; transform: translateY(4px); transition: all .3s;
}
.scan-steps li.show { opacity: 1; transform: none; }
.scan-steps li.done { color: var(--ink); }
.scan-steps .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line); flex: none; display: grid; place-items: center; }
.scan-steps li.run .dot { border-color: var(--accent); border-top-color: transparent; animation: spin .7s linear infinite; }
.scan-steps li.done .dot { background: var(--ink); border-color: var(--ink); }
.scan-steps li.done .dot::after { content: ''; width: 6px; height: 3px; border: solid var(--bg); border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg) translate(1px,-1px); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── digest ── */
.digest-bar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; background: var(--bg);
}
.chip-btn {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px;
  border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 500; font-size: 14px;
  max-width: 75%; white-space: nowrap; overflow: hidden;
}
.chip-btn span { overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }

.digest-head { padding: 14px 0 20px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 20px; border-top: 1px solid var(--ink); }
.stat { padding: 12px 0 0; }
.stat + .stat { padding-left: 14px; border-left: 1px solid var(--line); }
.stat b { display: block; font-family: var(--serif); font-size: 26px; font-weight: 600; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); }
.note { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; color: var(--ink-2); }

.tabs { position: sticky; top: 60px; z-index: 4; background: var(--bg); display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 12px 0; font-weight: 600; font-size: 14.5px; color: var(--muted); transition: color .2s; }
.tab.is-active { color: var(--ink); }
.tab-n { font-family: var(--mono); font-size: 11px; font-weight: 400; margin-left: 2px; }
.tab-ink { position: absolute; bottom: -1px; height: 2px; background: var(--accent); transition: transform .3s cubic-bezier(.2,.8,.2,1), width .3s; left: 0; }
.tab-hint { font-size: 13px; color: var(--muted); padding: 14px 0 4px; }

.feed { display: flex; flex-direction: column; gap: 12px; padding: 10px 0 20px; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 18px 18px 14px;
  border: 1px solid var(--line); animation: rise .4s both;
  transition: opacity .3s, transform .3s;
}
.card-meta { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; }
.card-meta .src { color: var(--ink-2); font-weight: 500; text-transform: uppercase; }
.card-meta .sep { opacity: .5; }
.rel { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.rel-bar { width: 34px; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.rel-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.card h3 { font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.25; letter-spacing: -.01em; margin-top: 10px; }
.card p.sum { color: var(--ink-2); margin-top: 8px; font-size: 14.5px; }
.why { margin-top: 14px; padding: 11px 13px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; color: var(--ink); }
.why b { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 500; margin-bottom: 3px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 8px; }
.link { font-size: 13.5px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; padding: 6px 0; text-decoration: none; }
.rate { display: flex; gap: 6px; }
.rate button {
  height: 34px; padding: 0 12px; border-radius: 99px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 5px; transition: all .2s;
}
.rate button:active { transform: scale(.95); }
.rate .yes.on { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.card.signal { background: transparent; border-style: dashed; border-width: 1.5px; }
.strength { display: inline-flex; gap: 3px; margin-left: auto; align-items: flex-end; }
.strength i { width: 3px; border-radius: 2px; background: var(--line); }
.strength i.on { background: var(--accent); }
.signal-tag { color: var(--accent); font-weight: 500; text-transform: uppercase; }

.card.hidden-card { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; opacity: .7; }
.card.hidden-card span { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 10px; }
.card.hidden-card button { font-size: 13px; font-weight: 600; color: var(--ink); flex: none; }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); font-size: 14px; }

.learn { margin: 6px 0 0; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.learn-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.learn-bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 10px; overflow: hidden; }
.learn-bar i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 4px; transition: width .4s; }
.demo-note { text-align: center; font-family: var(--mono); font-size: 10.5px; color: var(--muted); padding: 18px 0 calc(28px + var(--safe-b)); letter-spacing: .04em; }

/* ── toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .3s; white-space: nowrap; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
