:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --ink: #1b2233;
  --ink-2: #4a5268;
  --muted: #7a8196;
  --line: #e2ddd0;
  --navy: #14213d;
  --gold: #b8872b;
  --gold-2: #d9a441;
  --accent: #1f5f8b;
  --ok: #2e7d4f;
  --warn: #a86a00;
  --err: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .06);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1320; --surface: #151c2e; --surface-2: #1c2438; --ink: #eef0f6; --ink-2: #c3c8d6;
    --muted: #8d94a8; --line: #273049; --navy: #0b1122; --accent: #6fb3e0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1320; --surface: #151c2e; --surface-2: #1c2438; --ink: #eef0f6; --ink-2: #c3c8d6;
  --muted: #8d94a8; --line: #273049; --navy: #0b1122; --accent: #6fb3e0; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
img, video, canvas { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 .92rem/1 var(--sans); padding: .72em 1.05em; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
:root[data-theme="dark"] .btn.primary { background: var(--gold); border-color: var(--gold); color: #14100a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--gold); border-color: var(--gold); color: #14100a; } }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); }
.btn.sm { padding: .5em .75em; font-size: .82rem; }
.btn svg { width: 1.1em; height: 1.1em; }
label { display: block; font-weight: 600; font-size: .86rem; margin: 0 0 .35em; color: var(--ink-2); }
input[type=text], input[type=url], input[type=date], input[type=password], input[type=search], input[type=email], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .65em .8em; }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 1px; }
.field { margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: .35em; font-size: .75rem; font-weight: 600; padding: .25em .6em; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.pill.ok { background: rgba(46,125,79,.12); color: var(--ok); }
.pill.warn { background: rgba(168,106,0,.12); color: var(--warn); }
.pill.err { background: rgba(179,38,30,.12); color: var(--err); }
.pill.run { background: rgba(31,95,139,.12); color: var(--accent); }

/* App shell */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-weight: 700; }
.brand small { display: block; font-weight: 500; opacity: .7; font-size: .72rem; }
.brand .logo { width: 34px; height: 34px; flex: none; }
.topnav { display: flex; gap: .25rem; margin-left: auto; }
.topnav .btn { background: transparent; color: #dfe3ee; border-color: transparent; }
.topnav .btn:hover, .topnav .btn[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; }
.main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
@media (max-width: 640px) { .topnav .btn span { display: none; } .brand small { display: none; } }

.banner { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.banner.err { background: rgba(179,38,30,.08); border-color: rgba(179,38,30,.3); color: var(--err); }
.banner.warn { background: rgba(168,106,0,.08); border-color: rgba(168,106,0,.3); color: var(--warn); }
.banner.info { background: rgba(31,95,139,.08); border-color: rgba(31,95,139,.25); color: var(--accent); }

/* Drop zone */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop.over, .drop:hover { border-color: var(--gold); }
.drop strong { display: block; font-size: 1.05rem; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; font: 600 .88rem var(--sans); color: var(--ink-2); padding: .55em .9em; border-radius: 8px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s; }

/* Workspace */
.ws-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1rem; }
.ws-head h1 { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.1rem); margin: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: .8em 1em; font: 600 .95rem var(--sans); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }

.content-grid { display: grid; grid-template-columns: 270px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .content-grid { grid-template-columns: 1fr; } }
.fmt-list { display: flex; flex-direction: column; gap: .35rem; }
.fmt-item { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: .7rem .75rem; border-radius: 10px; cursor: pointer; font: 600 .92rem var(--sans); color: var(--ink); }
.fmt-item:hover { background: var(--surface-2); }
.fmt-item[aria-selected="true"] { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.fmt-item .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); flex: none; font-size: 1rem; }
.fmt-item .st { margin-left: auto; }
.output { min-height: 420px; }
.output-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; padding-bottom: .9rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.md { font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; }
.md h1 { font-family: var(--serif); font-size: 1.7rem; }
.md h2 { font-family: var(--serif); font-size: 1.3rem; margin-top: 1.4em; }
.md h3 { font-size: 1.05rem; margin-top: 1.2em; }
.md blockquote { margin: 1em 0; padding: .5em 1em; border-left: 4px solid var(--gold); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.streaming::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--gold); }
@keyframes blink { 50% { opacity: 0; } }
.editor { min-height: 520px; font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.transcript { min-height: 560px; font: 15px/1.7 var(--sans); }

/* Clips */
.clips-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .clips-layout { grid-template-columns: 1fr; } }
.clip { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--surface); margin-bottom: .8rem; }
.clip.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184,135,43,.2); }
.clip .times { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.clip .times input { width: 92px; }
.clip-title { font-weight: 700; }
.player { width: 100%; background: #000; border-radius: 12px; max-height: 360px; }
.render-out video { width: 100%; max-height: 520px; background: #000; border-radius: 12px; }
.canvas-preview { width: 100%; height: auto; border-radius: 10px; background: #000; display: block; }

/* Quotes */
.quote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.quote-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.quote-card textarea { min-height: 80px; font-size: .9rem; }

/* Library */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.lib-card { cursor: pointer; transition: border-color .15s, transform .15s; }
.lib-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.lib-card h3 { font-family: var(--serif); font-size: 1.15rem; margin-bottom: .25rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .75rem 1.1rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: .92rem; max-width: calc(100vw - 32px); }
.gate { max-width: 460px; margin: 8vh auto; text-align: center; }
.gate .card { text-align: left; }
details summary { cursor: pointer; font-weight: 600; }

/* ===================== v2 additions ===================== */
.h-md { font-size: 1.2rem; margin: 0 0 .6rem; }
.h-sm { font-size: .95rem; margin: .6rem 0 .3rem; }
.err-text { color: var(--err); min-height: 1.2em; }
.btn.xs { padding: .35em .6em; font-size: .75rem; border-radius: 8px; }
.sel-sm { width: auto; padding: .45em .6em; font-size: .82rem; border-radius: 8px; }
.seg.sm { padding: 3px; }
.seg.sm button { padding: .35em .7em; font-size: .8rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.progress.thin { height: 6px; }
.toolbar-row { margin-bottom: 1rem; align-items: flex-end; }
.toolbar-row .field { margin: 0; }
.file-btn { cursor: pointer; }
a.ref { color: inherit; text-decoration: underline; text-decoration-color: var(--gold-2); text-underline-offset: 3px; }
a.ref:hover { color: var(--gold); }

/* sync chip */
.sync-chip { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; color: #dfe3ee; background: rgba(255,255,255,.08); padding: .3rem .65rem; border-radius: 999px; cursor: pointer; margin-left: .5rem; white-space: nowrap; }
.sync-chip i { width: 8px; height: 8px; border-radius: 50%; background: #6fcf97; flex: none; }
.sync-chip[data-state="syncing"] i, .sync-chip[data-state="pending"] i { background: #f2c94c; }
.sync-chip[data-state="offline"] i { background: #eb5757; }
@media (max-width: 640px) { .sync-chip span { display: none; } }

/* gate */
.gate2 { display: grid; grid-template-columns: 1.1fr 1fr 1fr; gap: 1.25rem; align-items: start; margin-top: 2vh; }
.gate-intro h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); line-height: 1.1; }
.gate-intro h1 em { color: var(--gold); }
@media (max-width: 1000px) { .gate2 { grid-template-columns: 1fr; max-width: 560px; margin-inline: auto; } }
.welcome { max-width: 640px; margin: 6vh auto; text-align: center; }
.key-box { display: flex; gap: .6rem; align-items: center; justify-content: center; flex-wrap: wrap; margin: 1.2rem 0 .6rem; }
.key-box code { font: 700 clamp(1.1rem, 3.5vw, 1.6rem) ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; background: var(--surface-2); padding: .6rem 1rem; border-radius: 10px; overflow-wrap: anywhere; }

/* content kit */
.kit-meter { margin-bottom: .8rem; }
.lang-row { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .6rem; }
.lang-row:empty { display: none; }
.lang-chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 600 .78rem var(--sans); padding: .3em .7em; border-radius: 999px; cursor: pointer; }
.lang-chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.output-toolbar .seg { margin-left: .4rem; }

/* social calendar */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .9rem; }
.cal-day { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: .8rem; display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.cal-head { display: flex; flex-direction: column; gap: .1rem; }
.cal-post { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.cal-text { white-space: pre-wrap; font-size: .88rem; line-height: 1.5; margin-top: .4rem; overflow-wrap: anywhere; }
.chip-p { font: 700 .68rem var(--sans); letter-spacing: .06em; text-transform: uppercase; padding: .2em .55em; border-radius: 999px; color: #fff; background: #1877f2; }
.chip-p.instagram { background: #c13584; }
.chip-p.x { background: #111; }
.over { color: var(--err); font-weight: 700; }

/* insights */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.tile b { font: 700 1.7rem/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.tile b i { font: 500 .8rem var(--sans); color: var(--muted); margin-left: .2rem; font-style: normal; }
.tile span { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.tile small { font-size: .75rem; color: var(--ink-2); line-height: 1.35; }
.ins-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .ins-grid { grid-template-columns: 1fr; } }
.ins-map { margin-top: .8rem; }
.big-idea { font: italic 700 1.25rem/1.35 var(--serif); padding: .9rem 1rem; border-left: 4px solid var(--gold); background: var(--surface-2); border-radius: 0 10px 10px 0; margin-bottom: .8rem; }
.big-idea span { display: block; font: 700 .7rem var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-style: normal; margin-bottom: .3rem; }
.points { padding-left: 1.3em; display: grid; gap: .7rem; }
.points li { padding-left: .2rem; }
.tag-wrap { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag, .tag-link { font-size: .82rem; background: var(--surface-2); border-radius: 8px; padding: .25em .6em; color: var(--ink); text-decoration: none; }
.tag-link:hover { background: var(--gold-2); color: #14100a; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 32px; gap: .5rem; align-items: center; font-size: .85rem; margin-bottom: .3rem; }
.bar-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--gold); border-radius: 99px; }

/* slides */
.slide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 1rem; }
.slide-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: .75rem; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.slide-card textarea { min-height: 54px; font-size: .9rem; }
.slide-card select, .slide-card input { font-size: .85rem; padding: .5em .6em; }

.lib-idea { margin: .5rem 0 0; color: var(--ink-2); font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clip .times label { margin: 0; display: inline-flex; align-items: center; gap: .35rem; }
.clip-title { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===================== v2 home ===================== */
.home-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2rem; align-items: center; background: radial-gradient(900px 400px at 85% -20%, rgba(217,164,65,.35), transparent 60%), linear-gradient(160deg, #1a2a4d, #0b1122); color: #fff; border-radius: 20px; padding: clamp(1.5rem, 4vw, 3rem); }
.home-hero h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); line-height: 1.08; margin: .4rem 0 .8rem; }
.home-hero h1 em { color: var(--gold-2); }
.home-hero p { color: #cfd5e6; max-width: 36em; margin: 0; }
.eyebrow-gold { font: 700 .75rem var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-2); }
.lg-btn { font-size: 1rem; padding: .9em 1.3em; }
.btn.ghost-light { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.3); }
.btn.ghost-light:hover { background: rgba(255,255,255,.16); }
.home-hero-stack { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.home-hero-stack div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: .8rem; font-weight: 600; font-size: .9rem; display: flex; gap: .5rem; align-items: center; }
@media (max-width: 860px) { .home-hero { grid-template-columns: 1fr; } }
.h-lg { font-size: 1.5rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: .8rem; }
.feature-grid button { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1rem; cursor: pointer; display: flex; flex-direction: column; gap: .3rem; color: var(--ink); font: inherit; transition: border-color .15s, transform .15s; }
.feature-grid button:hover, .feature-grid button:focus-visible { border-color: var(--gold); transform: translateY(-2px); outline: none; }
.feature-grid span { font-size: 1.5rem; }
.feature-grid strong { font-size: .98rem; }
.feature-grid small { color: var(--ink-2); font-size: .85rem; line-height: 1.4; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; margin-top: 1.5rem; align-items: start; }
@media (max-width: 860px) { .home-cols { grid-template-columns: 1fr; } }
.recent-item { display: flex; gap: .8rem; align-items: center; padding: .7rem .2rem; border-bottom: 1px solid var(--line); cursor: pointer; text-decoration: none; color: inherit; }
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover strong { color: var(--gold); }
.setup-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; font-size: .9rem; }
.setup-list li { display: flex; gap: .6rem; align-items: flex-start; }
.setup-list b { width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .75rem; color: #fff; background: var(--ok); }
.setup-list li.off b { background: var(--muted); }
.setup-list small { display: block; color: var(--muted); }
