:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1b2130;
  --muted: #5d6475;
  --line: #e3e6ee;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --ok: #059669;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 800; font-size: 20px; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--brand); font-weight: 600; }
#nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
#nav a { color: var(--ink); font-weight: 500; white-space: nowrap; }
#nav a.btn { color: #fff; padding: 8px 14px; }

main { max-width: 1100px; margin: 0 auto; padding: 32px 20px 60px; min-height: 70vh; }
.footer { display: flex; gap: 20px; justify-content: center; padding: 24px; color: var(--muted); border-top: 1px solid var(--line); font-size: 14px; flex-wrap: wrap; }

h1 { font-size: 40px; line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 26px; margin: 32px 0 12px; }
h3 { margin: 0 0 6px; }
.lead { font-size: 19px; color: var(--muted); max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.hero { text-align: center; padding: 40px 0 24px; }
.hero .lead { margin: 0 auto 24px; }

.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #e8e9f3; color: var(--ink); }
.btn.secondary:hover { background: #d9dbea; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #fee2e2; color: var(--err); }
.btn.ok { background: var(--ok); }
.btn[disabled] { opacity: .6; cursor: progress; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.card.highlight { border: 2px solid var(--brand); }

.price { font-size: 36px; font-weight: 800; margin: 8px 0; }
.price small { font-size: 15px; font-weight: 500; color: var(--muted); }
.features { list-style: none; padding: 0; margin: 14px 0 20px; }
.features li { padding: 4px 0 4px 22px; position: relative; }
.features li::before { content: "\2713"; color: var(--ok); position: absolute; left: 0; font-weight: 700; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toggle button { border: 0; background: var(--card); padding: 6px 14px; cursor: pointer; font: inherit; }
.toggle button.active { background: var(--brand); color: #fff; }

.auth { max-width: 420px; margin: 20px auto; }
label { display: block; font-weight: 600; margin: 14px 0 4px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
textarea { min-height: 110px; }
input[type=file] { padding: 8px; background: #fafbff; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

.alert { padding: 12px 14px; border-radius: 8px; margin: 14px 0; }
.alert.ok { background: #ecfdf5; color: var(--ok); }
.alert.err { background: #fef2f2; color: var(--err); }
.alert.info { background: #eef2ff; color: var(--brand-dark); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0 22px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }

.studio-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 12px; }
.studio-tabs button { flex: 1; min-width: min(100%, 150px); border: 1px solid var(--line); border-radius: 8px; padding: 12px 18px; background: var(--card); color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.studio-tabs button[aria-selected=true] { background: var(--brand); border-color: var(--brand); color: #fff; }
.studio-tabs button:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 3px; }
.studio-tab-group { flex-basis: 100%; margin: 8px 0 -2px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.studio-tab-group:first-child { margin-top: 0; }
.color-picker { display: flex; align-items: center; gap: 8px; }
.color-picker select { flex: 1; min-width: 0; }
.color-picker input[type=color] { width: 48px; height: 40px; padding: 2px; flex: none; }
.color-swatch { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1px solid var(--line); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.frame-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; margin: 8px 0 16px; }
.frame-choice { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 2px solid var(--line); border-radius: 8px; background: var(--card); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.frame-choice img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 5px; background: #111827; }
.frame-choice[aria-checked=true] { border-color: var(--brand); color: var(--brand-dark); font-weight: 700; }
.frame-choice:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.thumbnail-maker { margin-top: 8px; }
.compression-table tr.compression-best td { background: #ecfdf5; }
.compression-table td { vertical-align: top; }
.video-studio [role=tabpanel][hidden] { display: none; }
.video-studio [role=tabpanel] > .tool-card { width: 100%; min-width: 0; }

.usage { margin: 6px 0 0; }
.bar { height: 10px; background: #e8e9f3; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--brand); }
.bar.full > div { background: var(--err); }

/* Rewards and Free-plan tool tokens */
.rewards { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: linear-gradient(90deg, #fff7ed, #fef3c7); color: #78350f; display: grid; gap: 8px; }
.rewards .row { gap: 8px; align-items: center; flex-wrap: wrap; }
.rewards .muted { color: #92400e; }
.btn.reward { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.btn.reward:hover { background: #c2410c; }
.chip { border: 1px solid #fcd34d; background: #fff; color: #78350f; border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chip:hover { background: #fffbeb; }
.tool-tokens { margin: -4px 0 8px; }
.badge.tokens { background: #fef3c7; color: #92400e; }
.alert.locked { background: #fff7ed; color: #7c2d12; border: 1px solid #fdba74; }
.alert.locked p { margin: 6px 0 10px; }
.badge.locked-badge { background: #ffedd5; color: #9a3412; }

.tool-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tool-card.storyboard-target { border-color: #0e7490; box-shadow: 0 0 0 2px rgba(14, 116, 144, .16); }
.badge { font-size: 12px; background: #eef2ff; color: var(--brand-dark); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.result { margin-top: 14px; }
.result pre { white-space: pre-wrap; background: #f3f4f8; padding: 12px; border-radius: 8px; max-height: 260px; overflow: auto; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #fafbff; color: var(--muted); font-weight: 600; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre.code { background: #111827; color: #e5e7eb; padding: 14px; border-radius: 8px; overflow: auto; }

.ledger td { padding: 4px; border: 0; }
.ledger input { padding: 6px 8px; min-width: 70px; }
.ledger-wrap { overflow-x: auto; max-width: 100%; }
.grid > * { min-width: 0; }

@media (max-width: 640px) {
  h1 { font-size: 30px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .brand { font-size: 18px; }
  #nav { gap: 12px; font-size: 14px; }
  .stats { gap: 18px; }
}

/* ---- Visual polish ---- */
body { background: radial-gradient(1200px 500px at 10% -10%, #eef0ff 0%, transparent 60%), radial-gradient(900px 400px at 100% 0%, #fdf2ff 0%, transparent 55%), var(--bg); }
.topbar { backdrop-filter: saturate(180%) blur(8px); background: rgba(255, 255, 255, .85); }

.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 16px; height: 16px; vertical-align: -3px; }

.hero-bg { position: relative; margin: 0 -8px 26px; padding: 56px 24px 40px; border-radius: 24px;
  background: linear-gradient(135deg, #1e1b4b 0%, #4338ca 45%, #7c3aed 100%); color: #fff; box-shadow: 0 20px 50px -20px rgba(67, 56, 202, .55); overflow: hidden; }
.hero-bg::after { content: ""; position: absolute; inset: auto -80px -120px auto; width: 340px; height: 340px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.hero-bg .lead { color: #e0e7ff; }
.hero-bg .btn { background: #fff; color: var(--brand-dark); }
.hero-bg .btn:hover { background: #eef2ff; }
.hero-bg .btn.secondary { background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .35); }
.grad { background: linear-gradient(90deg, #a5b4fc, #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); margin-bottom: 18px; }
.btn.lg { padding: 13px 24px; font-size: 16px; }
.stats { display: flex; gap: 40px; justify-content: center; margin-top: 34px; flex-wrap: wrap; position: relative; z-index: 1; }
.stats div { display: flex; flex-direction: column; }
.stats strong { font-size: 28px; }
.stats span { font-size: 13px; color: #c7d2fe; }

.card { box-shadow: 0 1px 2px rgba(16, 24, 40, .04); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.tool-tile:hover, .feature:hover, .tool-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -12px rgba(30, 27, 75, .25); border-color: #c7d2fe; }
.card.highlight { background: linear-gradient(#fff, #fff) padding-box, linear-gradient(135deg, #6366f1, #a855f7) border-box; border: 2px solid transparent; }

.tool-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 12px; flex: none; }
.tool-icon.c0 { background: #eef2ff; color: #4f46e5; }
.tool-icon.c1 { background: #ecfeff; color: #0e7490; }
.tool-icon.c2 { background: #fdf2f8; color: #be185d; }
.tool-icon.c3 { background: #f0fdf4; color: #15803d; }
.tool-icon.c4 { background: #fff7ed; color: #c2410c; }
.tool-head { justify-content: flex-start; gap: 14px; align-items: center; }
.tool-head .tool-icon { margin-bottom: 0; }
.tool-title h3 { margin: 0 0 4px; }
.badge.ai { background: linear-gradient(90deg, #6366f1, #a855f7); color: #fff; margin-left: 6px; vertical-align: 2px; }
.tool-title .badge.ai { margin-left: 0; }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px; border: 2px dashed #c7d2fe; border-radius: 12px;
  background: #fafbff; color: var(--muted); font-weight: 400; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; margin: 4px 0 0; }
.dropzone .icon { color: var(--brand); }
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: #eef2ff; }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: #f0fdf4; }
.dropzone.has-file .icon { color: var(--ok); }
.dz-file { font-size: 13px; color: var(--ink); word-break: break-all; }
.dz-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.alert.loading { display: flex; align-items: center; gap: 10px; }
.alert.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #c7d2fe; border-top-color: var(--brand); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.transcript { background: #f8fafc; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 14px 16px; margin: 10px 0 12px;
  max-height: 320px; overflow: auto; white-space: pre-wrap; line-height: 1.65; font-size: 15px; }
video.preview, .result audio { width: 100%; border-radius: 10px; margin-top: 6px; background: #000; }
.result audio { background: transparent; }
.media-comparison { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; margin: 12px 0; }
.preview-panel { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.preview-panel h4 { margin: 0 0 6px; font-size: 14px; }
.project-video-item.selected-project-video { border-color: var(--brand); box-shadow: 0 0 0 2px #e0e7ff; }
.media-image-preview { display: block; max-width: 100%; max-height: 440px; object-fit: contain; background: #111827; border-radius: 6px; margin: 10px 0; }
.pdf-preview { width: 100%; height: min(78vh, 840px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.metadata-comparison { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 12px; margin: 12px 0; }
.metadata-panel { min-width: 0; }
.metadata-panel h4 { margin: 4px 0 8px; }
.metadata-panel table { table-layout: fixed; }
.metadata-panel td { overflow-wrap: anywhere; }
.metadata-actions { margin: 0 0 8px; gap: 6px; }
.metadata-checklist .metadata-check { width: 72px; text-align: center; }
.metadata-checklist .metadata-check input { width: 18px; height: 18px; }
.metadata-panel tr.metadata-group th { background: #eef0f7; color: var(--ink); }
.metadata-fixed td { color: var(--muted); }
.metadata-report th:first-child { width: 34%; }
.metadata-report tr.metadata-removed td { background: #ecfdf5; }
.metadata-report tr.metadata-removed .metadata-value { text-decoration: line-through; color: var(--muted); }
.metadata-report tr.metadata-failed td { background: #fef2f2; }
.metadata-report tr.metadata-dropped td, .metadata-report tr.metadata-added td { background: #fffbeb; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line); color: var(--ink); }
.pill.removed { background: var(--ok); color: #fff; }
.pill.failed { background: var(--err); color: #fff; }
.pill.dropped, .pill.added { background: #fde68a; color: #78350f; }
.storyboard-result { margin: 12px 0; overflow-wrap: anywhere; }
.storyboard-result h4 { margin: 0 0 6px; }
.scene-list { display: grid; gap: 8px; margin-top: 12px; }
.scene-item { padding: 10px 12px; border-left: 3px solid #0e7490; background: #fff; }
.scene-item h5 { margin: 0 0 4px; font-size: 14px; }
.scene-item p { margin: 3px 0; }
.scene-timing { color: #0e7490; font-variant-numeric: tabular-nums; }
.storyboard-video-result { margin-top: 14px; }
.demo { margin: 0 0 10px; background: linear-gradient(135deg, #fff, #f5f3ff); }
.ai-pick { margin: 10px 0 12px; padding: 12px 14px; border-radius: 10px; background: linear-gradient(135deg, #eef2ff, #faf5ff); border: 1px solid #ddd6fe; }
.ai-pick h4 { margin: 0 0 4px; color: #4c1d95; }
.ai-pick p { margin: 2px 0; }
.demo-head { display: flex; gap: 14px; align-items: center; }
.demo-head .tool-icon { margin: 0; }
.demo blockquote { margin: 16px 0; padding: 14px 18px; border-left: 4px solid #a855f7; background: #fff; border-radius: 8px; font-size: 17px; font-style: italic; color: #312e81; }

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; counter-reset: s; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #6366f1, #a855f7); margin-bottom: 10px; }

/* ---- Grouped tool forms, visual finder and suggestion tables ---- */
.field-group { border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px 18px; margin: 16px 0; background: linear-gradient(#fcfcff, #fff); }
.field-group > h4 { margin: 0; font-size: 15px; color: var(--brand-dark); }
.field-group > h4 + p { margin: 2px 0 0; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 0 18px; }
.field-grid > .field { min-width: 0; }
.field-grid > .field.wide { grid-column: 1 / -1; }
.field-grid > .field > textarea { min-height: 84px; }
.field-group .dropzone { padding: 12px; }
.visual-finder > .result { margin-top: 10px; }
.run-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }


.suggestion-table { overflow-x: auto; margin: 12px 0 4px; }
.suggestion-table table { table-layout: auto; }
.suggestion-table th:first-child, .suggestion-table td:first-child { width: 120px; }
.suggestion-table td { vertical-align: middle; }
.suggestion-table tbody tr:hover { background: #f8fafc; }
.suggestion-table tbody tr:last-child td { border-bottom: 0; }
.suggestion-table p { margin: 2px 0 0; }
.suggestion-preview img { display: block; width: 104px; height: 72px; object-fit: cover; border-radius: 6px; background: #111827; }

@media (max-width: 520px) {
  .suggestion-table th:first-child, .suggestion-table td:first-child { width: 86px; }
  .suggestion-preview img { width: 72px; height: 54px; }
}

/* End-user / developer view switch and the Developer tab */
.app-head { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.mode-switch { display: inline-flex; border: 1px solid #c7d2fe; border-radius: 999px; overflow: hidden; }
.mode-option { border: 0; background: #fff; color: var(--brand-dark); padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.mode-option[aria-pressed=true] { background: var(--brand); color: #fff; }
.mode-option:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: -3px; }
.dev-toolbar { align-items: center; gap: 12px; flex-wrap: wrap; }
.dev-grid { display: grid; gap: 16px; margin-top: 12px; }
.dev-card h4 { margin: 14px 0 6px; }
.dev-table td, .dev-table th { font-size: 13px; vertical-align: top; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }
.dev-logs { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; max-height: 420px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.badge.ok-badge { background: #ecfdf5; color: var(--ok); }
.badge.bad-badge { background: #fef2f2; color: var(--err); }
.raw-debug { margin-top: 10px; }
.raw-debug pre { background: #f3f4f8; padding: 10px; border-radius: 8px; max-height: 320px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.dev-table tr.clickable { cursor: pointer; }
.dev-table tr.clickable:hover, .dev-table tr.clickable:focus-visible { background: #eef2ff; outline: none; }
.dev-customer { margin-top: 12px; }
.dev-customer .row { gap: 8px; margin: 8px 0; flex-wrap: wrap; align-items: center; }
.dev-customer input[type=text] { min-width: 240px; flex: 1; }
.dev-fix-form { gap: 8px; align-items: stretch; flex-wrap: wrap; }
.dev-fix-form textarea { flex: 1; min-width: 220px; }
.preset-preview { display: block; width: 120px; height: 120px; object-fit: cover; border-radius: 10px; margin: 6px 0 4px; border: 1px solid #e5e7eb; }
.preset-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.preset-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid #e5e7eb; border-radius: 10px; background: #fff; cursor: pointer; font: inherit; font-size: 12px; color: inherit; }
.preset-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #f3f4f6; }
.preset-tile[aria-checked=true] { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(79, 70, 229, .25); font-weight: 600; }
.preset-tile:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }
.upload-tile .upload-icon { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-size: 32px; color: var(--brand-dark); background: #eef2ff; border-radius: 6px; }
