/* Carousel Maker - one stylesheet, both themes, system fonts.
 * Scale: spacing 4/8/12/16/24/32, radii 8 (controls) / 14 (cards), controls 40px tall. */
:root {
  --bg: #f6f4ef; --panel: #ffffff; --panel2: #f0ede6; --ink: #17161a; --ink-dim: #5d5a63;
  --line: #e4e0d8; --line-strong: #cdc7bb; --accent: #b4532a; --accent-ink: #ffffff; --accent-soft: #f6e6dd;
  --ok: #18794e; --warn: #8a5a00; --bad: #b3261e; --shadow: 0 1px 2px rgba(22, 20, 16, 0.05), 0 4px 16px rgba(22, 20, 16, 0.05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --radius: 14px; --r-ctl: 8px; --h-ctl: 40px;
}
:root[data-theme="dark"] {
  --bg: #111013; --panel: #1a191d; --panel2: #232227; --ink: #efece6; --ink-dim: #a29ea8;
  --line: #2c2a30; --line-strong: #3d3a42; --accent: #f08a5d; --accent-ink: #1a0d06; --accent-soft: rgba(240, 138, 93, 0.16);
  --ok: #4cc38a; --warn: #e0a84a; --bad: #ff8a80; --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-dim); }
.small { font-size: 0.8125rem; }
.mono { font-family: var(--mono); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
h1, h2, h3 { line-height: 1.2; }
.h3 { font-size: 1.125rem; margin: 0 0 8px; }
.h4 { font-size: 0.9375rem; margin: 16px 0 6px; }

/* top bar */
.topbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 24px; min-height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 1.0625rem; letter-spacing: -0.01em; white-space: nowrap; }
.logo { color: var(--accent); flex: none; }
.topactions { display: flex; align-items: center; gap: 10px; flex: none; }
.backlink { text-decoration: none; font-size: 0.875rem; color: var(--ink-dim); padding: 8px 4px; }
.backlink:hover { color: var(--accent); }
.credits { font: 0.8125rem var(--mono); color: var(--ink-dim); }
.topup { font-size: 0.875rem; }

/* buttons */
button.ghost, button.primary, .chipbtn, select, label.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); border-radius: var(--r-ctl); padding: 0 14px; cursor: pointer; min-height: var(--h-ctl);
  font-size: 0.9375rem; font-weight: 500; line-height: 1.2; transition: background .12s, border-color .12s;
}
button.ghost:hover:not(:disabled), .chipbtn:hover, label.ghost:hover { border-color: var(--accent); background: var(--accent-soft); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.sq { width: var(--h-ctl); padding: 0; }
button.small, button.primary.small { min-height: 40px; font-size: 0.875rem; }
button.big { min-height: 48px; padding: 0 20px; font-size: 1rem; }
.quiet { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px 6px; min-height: 40px; font-size: 0.875rem; text-decoration: underline; text-underline-offset: 3px; }
.chipbtn[aria-pressed="true"], .segbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
main { max-width: 1080px; margin: 0 auto; padding: 24px 24px 48px; }
.hero h1 { font: 700 clamp(1.75rem, 5vw, 2.6rem)/1.1 var(--serif); letter-spacing: -0.01em; margin: 8px 0 8px; }
.lede { margin: 0 0 12px; color: var(--ink-dim); font-size: 1.0625rem; max-width: 60ch; }
.perks { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 16px; }
.perks li { font-size: 0.8125rem; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); }
.entry { padding: 12px; }
.hero.drag .entry { border-color: var(--accent); border-style: dashed; }
textarea#text { width: 100%; min-height: 150px; resize: vertical; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--panel2);
  padding: 12px; font: 16px/1.5 var(--sans); }
.entry-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 0; }
.msg { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--ink); }

.work { display: grid; gap: 16px; margin-top: 24px; }
.result { padding: 16px; min-width: 0; }
.result-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.verdict { font-weight: 600; margin: 0 0 8px; }
.verdict.ok { color: var(--ok); }
.verdict.warn { color: var(--warn); }
.strip { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 10px; -webkit-overflow-scrolling: touch; }
.slide { margin: 0; flex: 0 0 auto; width: min(300px, 72vw); scroll-snap-align: start; }
.slide canvas { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
.slide figcaption { display: flex; justify-content: space-between; align-items: center; }
.exports { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.checks { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 0.875rem; }
.checks li { padding-left: 22px; position: relative; }
.checks li::before { position: absolute; left: 0; font-weight: 700; }
.checks li.ok::before { content: "\2713"; color: var(--ok); }
.checks li.warn::before { content: "!"; color: var(--warn); left: 5px; }
.checks li.bad::before { content: "\2717"; color: var(--bad); }
.checks li.info::before { content: "i"; color: var(--ink-dim); left: 5px; font-style: italic; }
.warnline { color: var(--warn); font-weight: 500; }

.options { padding: 16px; display: grid; gap: 14px; }
.ctl { display: grid; gap: 6px; }
.ctl-h { font-size: 0.8125rem; font-weight: 600; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.seg, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.segbtn { border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--r-ctl); padding: 0 14px; min-height: var(--h-ctl); cursor: pointer; font-size: 0.9375rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.15); }
.dot-cinematic { background: linear-gradient(180deg, #5b8cb6, #c95a30, #1b1e3a); }
.dot-paper { background: #f4ede0; }
.dot-ink { background: #111; }
.dot-bold { background: linear-gradient(135deg, #1f3fbf 50%, #d9480f 50%); }
.dot-pastel { background: linear-gradient(135deg, #fde2e4 50%, #e8e3f7 50%); }
input[type="text"] { min-height: var(--h-ctl); border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--panel); padding: 0 12px; width: 100%; max-width: 420px; font-size: 16px; }
select { padding: 0 10px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.check input { width: 18px; height: 18px; }
details.more > summary, details.ai > summary, details > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
details.more { display: grid; gap: 8px; }

.ai { padding: 16px; }
.ai .sum-t { font-size: 1.0625rem; }
.badge { font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--ink-dim); }
.hint { margin: 8px 0; color: var(--ink-dim); font-size: 0.9375rem; }
.hint.bad, #aiMsg.bad { color: var(--bad); }
.ai-fields { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.ai-fields .grow { flex: 1 1 240px; }
.ai-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; }
.progress { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--panel2); }
.progresshead { display: flex; justify-content: space-between; }
.steps { margin: 8px 0 0; padding-left: 20px; font-size: 0.875rem; color: var(--ink-dim); }
.steps li.done { color: var(--ok); }
.steps li.now { color: var(--ink); font-weight: 600; }
.ai-result { margin-top: 12px; }
.caption { background: var(--panel2); border-radius: var(--r-ctl); padding: 10px 12px; margin: 0 0 8px; }
.raw { white-space: pre-wrap; word-break: break-word; font: 0.8125rem/1.45 var(--mono); background: var(--panel2); padding: 10px; border-radius: var(--r-ctl); max-height: 320px; overflow: auto; }

.history { padding: 16px; margin-top: 16px; }
.histlist { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.histbtn { width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 10px 12px; min-height: 44px; cursor: pointer; }
.histbtn:hover { border-color: var(--accent); }

.explain, .faq { margin-top: 40px; }
.explain h2, .faq h2 { font: 700 1.5rem/1.2 var(--serif); }
.how { padding-left: 20px; display: grid; gap: 8px; max-width: 70ch; }
.faq details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.faq details p { margin: 0 0 12px; color: var(--ink-dim); max-width: 70ch; }
.foot { border-top: 1px solid var(--line); padding: 20px 24px; text-align: center; font-size: 0.875rem; color: var(--ink-dim); }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-ctl); font-size: 0.875rem; }

/* docs pages */
.doc { max-width: 900px; }
.doc pre { overflow-x: auto; background: var(--panel2); padding: 12px; border-radius: var(--r-ctl); font: 0.8125rem/1.5 var(--mono); }
.tablewrap { overflow-x: auto; }
.fr-table { border-collapse: collapse; font-size: 0.875rem; }
.fr-table th, .fr-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.codegroup { margin: 12px 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tab { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 0.8125rem; min-height: 36px; }
.tab.active { border-color: var(--accent); background: var(--accent-soft); }
.statebox, .tokenbox { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 12px; background: var(--panel); }
.tokenbox { font-family: var(--mono); word-break: break-all; }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
button.mini { border: 1px solid var(--line-strong); background: var(--panel); border-radius: var(--r-ctl); padding: 0 12px; min-height: 40px; cursor: pointer; }

@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .backlink { display: none; }
  main { padding: 16px 16px 40px; }
  .entry-row .small { flex-basis: 100%; }
}
