/* ScoopDraft brand: blue #5170FF, yellow #FEBF02, yellow shadow #E29C00, outline brown #2E2218. */
:root {
  --blue: #5170FF;
  --blue-ink: #3550D6;
  --yellow: #FEBF02;
  --ink: #2E2218;
  --muted: #5A5148;
  --bg: #F6F7FB;
  --line: #E3E6EF;
  --danger: #B3261E;
  --ok: #1E6B3A;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.55; }
a { color: var(--blue-ink); }
a:hover { color: var(--ink); }
h1, h2 { line-height: 1.2; margin: 0 0 0.6rem; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }

.shell { max-width: 64rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 1.35rem; }

.hero { text-align: center; padding: 2rem 0 2.5rem; }
.hero-logo { display: block; margin: 0 auto 1.5rem; }
.lead { max-width: 40rem; margin: 0 auto 1.5rem; font-size: 1.15rem; color: var(--muted); }
.pill { display: inline-block; background: var(--yellow); color: var(--ink); font-weight: 700; padding: 0.4rem 1rem; border-radius: 999px; border: 2px solid var(--ink); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.foot { margin-top: 3rem; text-align: center; color: var(--muted); }

.card { background: #FFFFFF; border: 1px solid var(--line); border-radius: 20px; padding: 1.5rem; margin-bottom: 1rem; }
.card.narrow { max-width: 32rem; margin: 2rem auto; }
.muted-card { background: transparent; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.eyebrow { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 1.25rem; border-radius: 999px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; border: 2px solid var(--ink); }
.btn--primary { background: var(--ink); color: #FFFFFF; }
.btn--primary:hover { background: var(--yellow); color: var(--ink); }
.btn--ghost { background: #FFFFFF; color: var(--ink); }
.btn--ghost:hover { background: var(--yellow); }
.btn:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.notice { border-radius: 14px; padding: 0.9rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); background: #FFFFFF; }
.notice--danger { border-color: var(--danger); color: var(--danger); }
.notice--ok { border-color: var(--ok); color: var(--ok); }

.plan { display: grid; grid-template-columns: minmax(10rem, max-content) 1fr; gap: 0.5rem 1.5rem; margin: 1rem 0; }
.plan dt { color: var(--muted); }
.plan dd { margin: 0; font-weight: 700; }
@media (max-width: 30rem) { .plan { grid-template-columns: 1fr; } .plan dd { margin-bottom: 0.5rem; } }

/* ---- app shell */
.top-right { display: flex; align-items: center; gap: 0.75rem; }
.who { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 34rem) { .who { display: none; } }
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: -0.75rem 0 1.25rem; border-bottom: 2px solid var(--line); }
.tabs a { padding: 0.7rem 1rem; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; min-height: 44px; display: inline-flex; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-on { color: var(--ink); border-bottom-color: var(--blue); }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.btn--small { min-height: 36px; padding: 0 0.9rem; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- forms */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field--inline { margin-bottom: 0; }
.field label { font-weight: 700; font-size: 0.95rem; }
input[type=text], input[type=url], textarea, select { font: inherit; color: var(--ink); background: #FFFFFF; border: 1px solid #CBD2E6; border-radius: 12px; padding: 0.6rem 0.8rem; min-height: 44px; width: 100%; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; }
fieldset { margin: 0 0 1rem; }

/* ---- stories */
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.filters select { width: auto; min-width: 10rem; }
.segmented { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.segmented button { font: inherit; font-weight: 700; background: #FFFFFF; color: var(--ink); border: 0; padding: 0 1rem; min-height: 40px; cursor: pointer; }
.segmented button.is-on { background: var(--ink); color: #FFFFFF; }
.story-meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.3rem; }
.story-title { font-size: 1.15rem; }
.story-title a { color: var(--ink); text-decoration: none; }
.story-title a:hover { text-decoration: underline; }
.story-summary { color: var(--muted); }
/* Long links or codes in feed text must wrap inside the card, never push past it. */
.card, .dialog-body { overflow-wrap: anywhere; min-width: 0; }
.story-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { display: inline-block; font-size: 0.82rem; font-weight: 700; padding: 0.2rem 0.65rem; border-radius: 999px; background: #E6EBFF; color: #22307A; }
.chip--slate { background: #ECEEF3; color: #43495A; }
.chip--danger { background: #FCE8E6; color: #8C1D18; }
.chip--amber { background: #FFF4D6; color: #6B4A00; }
.empty { text-align: center; }

/* ---- feeds */
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.feed-main { min-width: 0; flex: 1 1 16rem; }
.feed-main p { margin: 0 0 0.25rem; }
.feed-name { font-weight: 700; }
.feed-url { overflow-wrap: anywhere; }
.feed-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }

/* ---- toasts */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 0.5rem; z-index: 10; width: min(32rem, calc(100% - 2rem)); }
.toast { background: var(--ink); color: #FFFFFF; padding: 0.8rem 1rem; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.18); }
.toast.is-error { background: var(--danger); }

pre { background: #FFFFFF; border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; overflow-x: auto; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92rem; }

/* ---- onboarding, sources, persona */
.steps-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: step; }
.steps-bar li { counter-increment: step; font-weight: 700; font-size: 0.9rem; color: var(--muted); padding: 0.35rem 0.85rem; border-radius: 999px; background: #ECEEF3; }
.steps-bar li::before { content: counter(step) ". "; }
.steps-bar li.is-on { background: var(--ink); color: #FFFFFF; }
.steps-bar li.is-done { background: #E6EBFF; color: #22307A; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.75rem; }
.card.choice { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0; cursor: pointer; }
.card.choice span { display: flex; flex-direction: column; gap: 0.2rem; }
.card.choice:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--ink); flex-shrink: 0; }
.check { display: inline-flex; gap: 0.5rem; align-items: flex-start; cursor: pointer; min-height: 32px; }
.checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 1rem; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 0.6rem 1.5rem; }
.source-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-status { display: inline-flex; align-items: center; gap: 0.4rem; }
details.group > summary { cursor: pointer; font-weight: 700; padding: 0.2rem 0; min-height: 32px; }
details.group[open] > summary { margin-bottom: 0.5rem; }
.counter { font-weight: 700; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 0.75rem 0; margin-top: 0; }
.actions--center { justify-content: center; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0 0.25rem; }
fieldset.card { border: 1px solid var(--line); }
.label { font-weight: 700; font-size: 0.95rem; }
.help { color: var(--muted); font-size: 0.88rem; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 1rem; }
.persona-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filter-preview { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.filter-preview p { margin: 0.2rem 0 0; }

/* ---- drafting */
.story-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
dialog.dialog { border: 0; border-radius: 20px; padding: 0; width: min(44rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); box-shadow: 0 20px 60px rgba(0,0,0,0.25); color: var(--ink); background: #FFFFFF; }
dialog.dialog::backdrop { background: rgba(20, 24, 40, 0.45); }
.dialog-body { padding: 1.5rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-head h2 { margin: 0; }
.dialog-body ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.writing { display: flex; align-items: center; gap: 0.75rem; padding: 2rem 0; font-weight: 700; }
.spinner { width: 1.4rem; height: 1.4rem; border: 3px solid #E6EBFF; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
#d-text { min-height: 14rem; line-height: 1.55; }
