/* System fonts only: no Google Fonts request (avoids sending visitor IPs to Google, a GDPR issue in Germany). */
:root {
  --bg: #f7f7fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: #f0f0f6;
  --text: #0f1020;
  --muted: #62647a;
  --faint: #9a9cb0;
  --border: rgba(15, 16, 32, 0.08);
  --border-strong: rgba(15, 16, 32, 0.16);
  --grad: linear-gradient(135deg, #ff3d6e 0%, #ff8a3d 100%);
  --accent: #ff4d63;
  --accent-ring: rgba(255, 77, 99, 0.28);
  --chip-on-bg: rgba(255, 77, 99, 0.1);
  --chip-on-text: #e3264a;
  --direction-bg: rgba(99, 102, 241, 0.1);
  --direction-text: #4f46e5;
  --error: #d92d20;
  --error-bg: rgba(217, 45, 32, 0.08);
  --shadow: 0 1px 2px rgba(15, 16, 32, 0.04), 0 12px 40px -12px rgba(15, 16, 32, 0.12);
  --glow-1: rgba(255, 61, 110, 0.22);
  --glow-2: rgba(255, 138, 61, 0.18);
  --glow-3: rgba(99, 102, 241, 0.14);
  --r-lg: 20px;
  --r-md: 12px;
  --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c10;
    --surface: rgba(22, 23, 30, 0.72);
    --surface-solid: #16171e;
    --surface-2: #1d1f28;
    --text: #f1f1f6;
    --muted: #a1a3b8;
    --faint: #6c6e85;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #ff5a70;
    --accent-ring: rgba(255, 90, 112, 0.35);
    --chip-on-bg: rgba(255, 90, 112, 0.14);
    --chip-on-text: #ff8296;
    --direction-bg: rgba(129, 140, 248, 0.14);
    --direction-text: #a5b4fc;
    --error: #ff8a80;
    --error-bg: rgba(255, 138, 128, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 50px -20px rgba(0, 0, 0, 0.6);
    --glow-1: rgba(255, 61, 110, 0.2);
    --glow-2: rgba(255, 138, 61, 0.12);
    --glow-3: rgba(99, 102, 241, 0.16);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
svg { display: block; }
code { font: 0.9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* Ambient background */
.bg-glow {
  position: fixed; inset: -20vh -10vw auto; height: 80vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, var(--glow-1), transparent 70%),
    radial-gradient(35% 45% at 75% 20%, var(--glow-3), transparent 70%),
    radial-gradient(30% 40% at 55% 55%, var(--glow-2), transparent 70%);
  filter: blur(20px);
}

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 6px 16px -6px var(--accent); }
.logo svg { width: 16px; height: 16px; fill: #fff; }
.pill { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 8px; }

/* Hero */
.hero { max-width: 820px; margin: 0 auto; padding: 56px 16px 36px; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; backdrop-filter: blur(8px);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 4px var(--accent-ring); }
.hero h1 { font-size: clamp(30px, 5.2vw, 52px); line-height: 1.08; letter-spacing: -0.035em; margin: 20px 0 14px; font-weight: 800; }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: clamp(15px, 2vw, 18px); color: var(--muted); margin: 0 auto; max-width: 560px; }
@media (max-width: 640px) { .br-desk { display: none; } .hero { padding-top: 36px; } }

/* Layout */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 0 16px 40px;
  display: grid; gap: 20px; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 24px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.form-card { position: sticky; top: 76px; }
@media (max-width: 900px) { .form-card { position: static; } }
@media (max-width: 480px) { .card { padding: 18px; border-radius: 16px; } }

/* Form */
.field { margin-bottom: 20px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.opt { font-weight: 500; color: var(--faint); margin-left: 4px; }

input[type="text"], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 12px 14px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--faint); }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.textarea-wrap { position: relative; }
textarea { resize: vertical; min-height: 96px; padding-bottom: 28px; display: block; }
.counter { position: absolute; right: 12px; bottom: 8px; font-size: 12px; color: var(--faint); pointer-events: none; font-variant-numeric: tabular-nums; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; border: 1px solid var(--border); }
.segmented label { position: relative; }
.segmented input, .chips input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 10px; border-radius: 10px;
  font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s;
}
.segmented svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.segmented input:checked + span { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px -4px rgba(0,0,0,.12); }
.segmented input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips span {
  display: inline-block; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-solid);
  transition: border-color .15s, background .15s, color .15s; user-select: none;
}
.chips span:hover { color: var(--text); border-color: var(--faint); }
.chips input:checked + span { background: var(--chip-on-bg); border-color: var(--accent); color: var(--chip-on-text); font-weight: 600; }

/* Buttons */
.actions { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px; border-radius: var(--r-md); padding: 12px 18px; cursor: pointer;
  border: 1px solid transparent; transition: transform .1s, box-shadow .15s, opacity .15s, background .15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .7; }
.btn.primary { flex: 1; color: #fff; background: var(--grad); box-shadow: 0 10px 24px -10px var(--accent), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 14px 30px -10px var(--accent), inset 0 1px 0 rgba(255,255,255,.25); }
.btn.primary .ico { width: 18px; height: 18px; fill: #fff; }
a.btn.primary { flex: none; }
.btn.ghost { background: var(--surface-solid); color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { border-color: var(--faint); }
.btn.loading .ico { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.error { margin: 14px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--error-bg); color: var(--error); font-size: 14px; }

/* Output */
.output-card { min-height: 520px; display: flex; flex-direction: column; }
.output-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.output-head h2 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }
.stats { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.stat { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; cursor: pointer;
  background: var(--surface-solid); border: 1px solid var(--border-strong); color: var(--text); transition: border-color .15s, opacity .15s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover:not(:disabled) { border-color: var(--faint); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.output { flex: 1; overflow-wrap: anywhere; }
.output h1 { font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 12px; }
.output h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
  margin: 28px 0 10px;
}
.output h2::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.output h3 { font-size: 16px; margin: 18px 0 6px; }
.output p { margin: 0 0 12px; font-size: 16px; line-height: 1.7; }
.output ul { margin: 0 0 12px; padding-left: 20px; }
.output li { margin-bottom: 4px; }
.output .meta { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.output .meta strong { color: var(--text); }
.output .direction {
  display: inline-block; font-size: 13px; font-weight: 500; line-height: 1.5;
  background: var(--direction-bg); color: var(--direction-text); border-radius: 8px; padding: 2px 9px;
}
.output .notice { background: var(--chip-on-bg); color: var(--chip-on-text); border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; }
.output.streaming > :last-child::after { content: ""; display: inline-block; width: 8px; height: 1.1em; margin-left: 3px; vertical-align: -2px; border-radius: 2px; background: var(--grad); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Empty + skeleton */
.empty { height: 100%; min-height: 420px; display: grid; place-content: center; text-align: center; border: 1.5px dashed var(--border-strong); border-radius: 16px; padding: 32px; }
.empty-art { display: grid; gap: 8px; width: 160px; margin: 0 auto 20px; }
.empty-art span { height: 10px; border-radius: 99px; background: var(--surface-2); }
.empty-art span:nth-child(1) { width: 70%; background: var(--grad); opacity: .7; }
.empty-art span:nth-child(3) { width: 85%; }
.empty-title { font-weight: 600; font-size: 16px; margin: 0 0 4px; }
.empty-sub { color: var(--muted); margin: 0; font-size: 14px; max-width: 300px; }

.skeleton { display: grid; gap: 12px; }
.skeleton span { height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border-strong) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton span:first-child { height: 26px; width: 60%; margin-bottom: 8px; }
.skeleton span:nth-child(3) { width: 92%; }
.skeleton span:nth-child(4) { width: 78%; }
.skeleton span:nth-child(5) { width: 40%; margin-top: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Output head: title, rename, saved badge */
.head-main { min-width: 0; flex: 1; }
.title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.title-row h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 700; color: var(--text); background: var(--surface-solid); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 8px; box-shadow: 0 0 0 4px var(--accent-ring); outline: none; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { color: var(--text); background: var(--surface-2); }
.icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.danger:hover:not(:disabled) { color: var(--error); border-color: var(--error); }
.icon-btn.confirm { color: #fff !important; background: var(--error); border-color: var(--error) !important; width: auto; padding: 0 12px; font: 600 13px/1 inherit; }
.stat.saved { display: inline-flex; align-items: center; gap: 4px; color: #12a150; background: rgba(18, 161, 80, .1); }
.stat.saved svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Editor */
.editor { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.editor textarea {
  flex: 1; width: 100%; min-height: 480px; resize: vertical; font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 16px;
}
.editor textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-actions { display: flex; gap: 8px; }
.hint-text { font-size: 12px; color: var(--faint); }
.btn.sm { padding: 8px 14px; font-size: 14px; flex: none; }

/* Library */
.library { max-width: 1180px; margin: 0 auto; padding: 8px 16px 48px; }
.library-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.library-head h2 { font-size: 22px; letter-spacing: -0.02em; margin: 0; display: flex; align-items: center; gap: 10px; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 10px; }
.count:empty { display: none; }
.library-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.library-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search input, .library-tools select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 12px; height: 38px;
}
.search input { padding-left: 34px; width: 220px; }
.search input:focus, .library-tools select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
@media (max-width: 560px) { .library-tools, .search { width: 100%; } .search input { width: 100%; } .library-tools select { flex: 1; } }

.script-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.script-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow); backdrop-filter: blur(12px); transition: border-color .15s, transform .15s;
}
.script-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.script-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow); }
.script-card .open { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.script-card .open:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.card-title { font-weight: 650; font-size: 15px; line-height: 1.35; margin: 0; padding-right: 64px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title-input { font: inherit; font-weight: 650; font-size: 15px; width: 100%; color: var(--text); background: var(--surface-solid); border: 1px solid var(--accent); border-radius: 8px; padding: 4px 8px; box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.badge { font-weight: 600; border-radius: 999px; padding: 1px 8px; background: var(--surface-2); }
.badge.shorts { background: var(--chip-on-bg); color: var(--chip-on-text); }
.card-excerpt { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; }
.card-actions .icon-btn.sm { width: 28px; height: 28px; }

.library-empty { text-align: center; border: 1.5px dashed var(--border-strong); border-radius: 16px; padding: 40px 24px; }

/* Boot: hide everything until we know if the user is logged in */
body.booting #auth-view, body.booting #app-view, body.booting .footer { visibility: hidden; }

/* Nav account area */
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.credit-pill {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}
.credit-pill svg { width: 14px; height: 14px; fill: var(--accent); }
.brand, .credit-pill { white-space: nowrap; }
@media (max-width: 480px) { .pill-long, .nav .pill { display: none; } }
.credit-pill.is-out { color: var(--muted); }
.credit-pill.is-out svg { fill: var(--faint); }
.account { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer; font: 700 14px/1 inherit; color: #fff;
  background: var(--grad); text-transform: uppercase;
}
.avatar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; z-index: 30;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
}
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: grid; gap: 2px; }
.menu-email { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.menu-plan { font-size: 12px; color: var(--muted); }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--text); background: none; border: 0; border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }

/* Auth view */
.auth {
  max-width: 1080px; margin: 0 auto; padding: 64px 16px 48px;
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px); gap: 48px; align-items: center;
}
@media (max-width: 860px) { .auth { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 32px; } }
.auth-copy h1 { font-size: clamp(30px, 4.6vw, 48px); line-height: 1.08; letter-spacing: -0.035em; margin: 18px 0 20px; font-weight: 800; }
.benefits { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: var(--muted); font-size: 16px; }
.benefits li { display: flex; gap: 10px; align-items: baseline; }
.tick { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--chip-on-bg); color: var(--chip-on-text); font-size: 12px; font-weight: 800; }
.auth-card { padding: 28px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 24px; }
.tab { font: inherit; font-weight: 600; font-size: 14px; padding: 8px; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px -4px rgba(0,0,0,.12); }
.auth-step h2 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; overflow-wrap: anywhere; }
.auth-step input { margin-bottom: 14px; }
.auth-step input[type="email"], .code-input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 12px 14px;
}
.auth-step input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.code-input { font: 700 26px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; letter-spacing: 0.5em; text-align: center; padding-left: calc(14px + 0.5em) !important; }
.btn.block { width: 100%; }
.fine { font-size: 12px; color: var(--faint); margin: 12px 0 0; text-align: center; }
.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.link:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.back { font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0; padding: 0; margin-bottom: 14px; cursor: pointer; }
.back:hover { color: var(--text); }
.dev-code { font-size: 13px; border: 1px dashed #d4a017; background: rgba(212, 160, 23, .1); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.dev-code strong { font: 700 15px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; }
.dev-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #a87b00; margin-right: 4px; }

/* Generate button credit counter + exhausted state */
.btn-count { font-size: 12px; font-weight: 700; background: rgba(255,255,255,.22); border-radius: 999px; padding: 2px 9px; font-variant-numeric: tabular-nums; }
.btn-count:empty { display: none; }
.btn.primary.exhausted, .btn.primary.exhausted:hover {
  background: var(--surface-2); color: var(--faint); box-shadow: none; border-color: var(--border-strong); cursor: not-allowed; opacity: 1;
}
.btn.primary.exhausted .ico { fill: var(--faint); }
.btn.primary.exhausted .btn-count { background: var(--border-strong); color: var(--muted); }
.out-of-credits { margin: 12px 0 0; font-size: 14px; color: var(--muted); text-align: center; }

/* Upgrade modal */
.modal {
  width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  border: 1px solid var(--border-strong); border-radius: 22px; padding: 32px; color: var(--text);
  background: var(--surface-solid); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45);
}
.modal::backdrop { background: rgba(8, 8, 14, .55); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (max-width: 480px) { .modal { padding: 24px 18px; } }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.modal-head { text-align: center; margin-bottom: 24px; padding: 0 28px; }
.modal-icon { width: 48px; height: 48px; margin: 0 auto 14px; border-radius: 14px; background: var(--grad); display: grid; place-items: center; box-shadow: 0 10px 24px -10px var(--accent); }
.modal-icon svg { width: 24px; height: 24px; fill: #fff; }
.modal-head h2 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 6px; }
.modal-head p { margin: 0; color: var(--muted); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .plans { grid-template-columns: 1fr; } }
.plan {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: 16px;
  border: 1px solid var(--border-strong); background: var(--bg);
}
.plan.highlight { border: 2px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.plan-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--grad); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.plan-name { font-weight: 700; font-size: 16px; margin: 0; }
.plan-price { margin: 0; display: flex; align-items: baseline; gap: 4px; }
.plan-price strong { font-size: 36px; letter-spacing: -0.03em; }
.plan-price span { color: var(--muted); font-size: 14px; }
.plan-scripts { font-weight: 600; color: var(--chip-on-text); margin: -6px 0 0; font-size: 14px; }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; color: var(--muted); flex: 1; }
.plan li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-right: 8px; }
.plan .btn { width: 100%; text-decoration: none; }

/* Monthly / Yearly switch + yearly savings */
.billing-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: min(340px, 100%); margin: 0 auto 26px;
  padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.billing-switch label { position: relative; }
.billing-switch input { position: absolute; opacity: 0; pointer-events: none; }
.billing-switch span {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border-radius: 9px;
  font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.billing-switch input:checked + span { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px -4px rgba(0,0,0,.12); }
.billing-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.save-pill { font-style: normal; font-size: 11px; font-weight: 700; color: #12a150; background: rgba(18, 161, 80, .12); border-radius: 999px; padding: 1px 7px; }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.save-tag { font-size: 12px; font-weight: 700; color: #12a150; background: rgba(18, 161, 80, .12); border-radius: 999px; padding: 2px 9px; }
.plan-sub { margin: -10px 0 0; font-size: 13px; color: var(--muted); }
.plan-sub s { color: var(--faint); margin-left: 4px; }

/* Token cost on length chips */
.chip-cost {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px;
  font-size: 11px; font-weight: 700; border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: 1px;
}
.chips input:checked + span .chip-cost { background: var(--accent); color: #fff; }
.chips span.over { opacity: .45; text-decoration: line-through; text-decoration-color: var(--faint); }
.chips span.over .chip-cost { text-decoration: none; }

/* Cost table in upgrade popup */
.cost-table { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); text-align: center; }
.cost-title { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cost-list { display: grid; gap: 8px; }
.cost-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.cost-list .cost-fmt { background: none; font-weight: 600; color: var(--text); padding-left: 0; min-width: 84px; text-align: right; }
@media (max-width: 560px) { .cost-list .cost-fmt { min-width: 0; width: 100%; text-align: center; } }
.cost-list span { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; }
.cost-list b { color: var(--text); margin-left: 2px; }
.cost-list b::after { content: " tk"; font-weight: 500; color: var(--faint); }

/* Checkout placeholder */
.checkout { max-width: 520px; margin: 0 auto; padding: 40px 16px 64px; }
.checkout .back { display: inline-block; margin-bottom: 16px; text-decoration: none; }
.checkout-card h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0 0 4px; }
.summary { border: 1px solid var(--border-strong); border-radius: 14px; margin: 8px 0 18px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; }
.summary-row + .summary-row { border-top: 1px solid var(--border); }
.summary-row .plan-scripts { margin: 2px 0 0; }
.summary-row .plan-price strong { font-size: 26px; }
.summary-row.total { font-size: 15px; }
.pay-placeholder { font-size: 14px; color: var(--muted); background: var(--surface-2); border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.pay-placeholder strong { display: block; color: var(--text); margin-bottom: 4px; }

/* Legal pages (German drafts) */
.legal { max-width: 820px; margin: 0 auto; padding: 32px 16px 48px; }
.legal .back { display: inline-block; margin-bottom: 16px; text-decoration: none; }
.legal-card { background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-lg); padding: clamp(20px, 4vw, 40px); box-shadow: var(--shadow); }
.legal h1 { font-size: clamp(26px, 4vw, 34px); letter-spacing: -0.02em; margin: 0 0 6px; }
.legal h2 { font-size: 19px; margin: 32px 0 10px; letter-spacing: -0.01em; }
.legal h3 { font-size: 16px; margin: 22px 0 8px; }
.legal p, .legal li { font-size: 15px; line-height: 1.7; }
.legal ul, .legal ol { padding-left: 22px; }
.legal .stand { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.legal mark { background: rgba(250, 204, 21, .35); color: inherit; border-radius: 4px; padding: 0 4px; }
.draft-banner {
  border: 2px solid #d97706; background: rgba(217, 119, 6, .1); color: var(--text);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 24px; font-size: 14px; line-height: 1.55;
}
.draft-banner strong { color: #b45309; }
@media (prefers-color-scheme: dark) { .draft-banner strong { color: #fbbf24; } }
.legal .box { background: var(--surface-2); border-radius: 12px; padding: 16px 18px; margin: 14px 0; }
.legal table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.legal th, .legal td { text-align: left; border-bottom: 1px solid var(--border); padding: 8px 6px; vertical-align: top; }

/* Footer legal links + Kündigungsbutton (§312k BGB) */
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 10px 0 0; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.cancel-link { font-weight: 700; color: var(--text) !important; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px 12px; }

/* Cancellation form */
.cancel-form .field { margin-bottom: 16px; }
.cancel-form input[type="text"], .cancel-form input[type="email"], .cancel-form input[type="date"], .cancel-form select, .cancel-form textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-solid);
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 11px 13px;
}
.cancel-form input:focus, .cancel-form select:focus, .cancel-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.radio-row { display: grid; gap: 8px; }
.radio-row label { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.55; color: var(--text); margin: 14px 0; text-align: left; }
.consent input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.consent a { color: var(--accent); }
.confirm-box { border: 2px solid #12a150; background: rgba(18, 161, 80, .08); border-radius: 14px; padding: 18px 20px; }
.confirm-box h2 { margin-top: 0; }

/* Footer + toast */
.footer { max-width: 1180px; margin: 0 auto; padding: 8px 16px 40px; color: var(--faint); font-size: 13px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; padding: 10px 16px; border-radius: 999px;
  box-shadow: var(--shadow); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
