:root {
  color-scheme: light;
  --page: #f8fafc;
  --surface: #fff;
  --surface-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #14b8a6;
  --brand-strong: #0d9488;
  --brand-deep: #0f766e;
  --brand-soft: rgba(20, 184, 166, .09);
  --on-brand: #fff;
  --placeholder: #94a3b8;
  --danger-border: #fecaca;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --shadow: 0 8px 26px rgba(15, 23, 42, .06);
  --brand-glow: rgba(20, 184, 166, .2);
  --stage-bg: #0f172a;
  --stage-text: #5eead4;
  --radius: 18px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1120;
  --surface: #101a2e;
  --surface-soft: #16223a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #26354a;
  --brand: #2dd4bf;
  --brand-strong: #14b8a6;
  --brand-deep: #2dd4bf;
  --brand-soft: rgba(45, 212, 191, .1);
  --on-brand: #fff;
  --placeholder: #64748b;
  --danger-border: #7f1d1d;
  --danger-bg: #351c27;
  --danger-text: #fecaca;
  --shadow: 0 12px 30px rgba(0, 0, 0, .2);
  --brand-glow: rgba(45, 212, 191, .24);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--brand-strong); outline-offset: 3px; }

.page-shell {
  width: min(100% - 48px, 1180px);
  margin: 0 auto;
  padding: 44px 0 64px;
  flex: 1;
}
.hero { max-width: 780px; margin: 0 auto 30px; text-align: center; }
.eyebrow { margin: 0 0 7px; color: var(--brand-deep); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.hero h1 { margin: 0; font-size: clamp(1.75rem, 3.4vw, 2.4rem); line-height: 1.15; letter-spacing: -.035em; text-wrap: balance; }
.hero > p:not(.eyebrow) { max-width: 680px; margin: 10px auto 0; color: var(--muted); font-size: 1rem; text-wrap: balance; }
.privacy-note {
  width: fit-content;
  max-width: 100%;
  margin: 18px auto 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .82rem;
}
.privacy-note svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: var(--brand-deep);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, .96fr);
  align-items: start;
  gap: 20px;
}
.controls-column { display: grid; gap: 16px; min-width: 0; }
.panel,
.preview-panel,
.content-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: clamp(18px, 2.8vw, 24px); }
.panel-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 19px; }
.step-number {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: .75rem;
  font-weight: 800;
}
.panel-heading h2,
.preview-heading h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.field { min-width: 0; }
.field-label { display: block; margin-bottom: 7px; font-size: .84rem; font-weight: 700; }
.field-help { margin: 6px 0 0; color: var(--muted); font-size: .74rem; }
.field-value { color: var(--brand-deep); font-weight: 800; }
input,
select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--page);
  color: var(--text);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: var(--placeholder); opacity: .8; }
input:hover,
select:hover { border-color: var(--brand); }
input:focus,
select:focus {
  border-color: var(--brand-strong);
  outline: 0;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input[aria-invalid="true"] { border-color: var(--danger-text); }
select { cursor: pointer; }
input[type="range"] {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--brand-strong);
  cursor: pointer;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: none;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--brand-strong);
}
input[type="color"] {
  width: 52px;
  height: 48px;
  min-height: 48px;
  padding: 4px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }

.preset-block { margin: -2px 0 16px; }
.preset-label { margin: 0 0 7px; color: var(--muted); font-size: .74rem; font-weight: 600; }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; }
.preset-btn {
  min-height: 36px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 750;
  transition: border-color .16s ease, color .16s ease, background-color .16s ease;
}
.preset-btn:hover { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }

.end-options { display: grid; gap: 9px; margin-top: 10px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.check-row input[type="checkbox"] { flex: none; }
.check-row strong { display: block; color: var(--text); font-size: .84rem; }
.check-row small { display: block; color: var(--muted); font-size: .73rem; line-height: 1.45; }
.sound-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.color-line { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; }
.hex-input { text-transform: lowercase; }

.input-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger-border);
  border-radius: 11px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: .84rem;
}
.input-error svg { width: 17px; height: 17px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 750;
  transition: transform .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 7px 17px var(--brand-glow); }
.btn-outline { border-color: var(--line); background: var(--surface); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-deep); }

.preview-panel {
  position: sticky;
  top: 18px;
  min-width: 0;
  padding: clamp(18px, 2.8vw, 25px);
}
.preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.preview-heading .eyebrow { margin-bottom: 3px; }
.ratio-chip {
  flex: none;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--page);
  color: var(--muted);
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .04em;
}
.stage-shell {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}
.preview-box {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  background: var(--stage-bg);
}
.counter-text {
  display: block;
  max-width: none;
  margin: 0;
  color: var(--stage-text);
  font-size: 80px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.045em;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color .2s ease;
}
.counter-text.is-done { animation: counter-settle .45s ease-out; }
@keyframes counter-settle {
  from { opacity: .55; transform: scale(.94); }
  to { opacity: 1; transform: scale(1); }
}

.preview-caption { min-height: 1.4em; margin: 11px 1px 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.preview-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.download-btn { width: 100%; margin-top: 8px; }
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--page);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}
.status::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.status.running { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.status.done { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-deep); }
.status.error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger-text); }
.preview-note { margin: 10px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.5; text-align: center; }

.content-section { margin-top: 24px; padding: clamp(20px, 3vw, 28px); }
.section-heading { margin-bottom: 17px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.6rem); letter-spacing: -.03em; }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.steps-grid li { display: flex; gap: 11px; padding: 14px; border-radius: 13px; background: var(--page); }
.steps-grid li > span { color: var(--brand-deep); font-size: .74rem; font-weight: 800; }
.steps-grid h3 { margin: 0 0 4px; font-size: .89rem; }
.steps-grid p, .faq-section details p { margin: 0; color: var(--muted); font-size: .83rem; }
.faq-section details { border-top: 1px solid var(--line); }
.faq-section summary { padding: 13px 2px; cursor: pointer; font-weight: 700; }
.faq-section details p { padding: 0 2px 14px; }
.faq-section summary::marker { color: var(--brand-deep); }
.noscript-note { margin: 0 0 20px; padding: 11px 13px; border: 1px solid var(--danger-border); border-radius: 11px; background: var(--danger-bg); color: var(--danger-text); font-size: .85rem; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(320px, .86fr); gap: 14px; }
  .preview-panel { top: 12px; }
  .steps-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .page-shell { width: min(100% - 32px, 560px); padding-top: 32px; }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}
@media (max-width: 440px) {
  .page-shell { width: min(100% - 24px, 400px); padding-top: 25px; }
  .hero { margin-bottom: 22px; }
  .hero > p:not(.eyebrow) { font-size: .96rem; }
  .privacy-note { align-items: flex-start; border-radius: 12px; font-size: .76rem; }
  .panel, .preview-panel { padding: 17px; }
  .field-grid { grid-template-columns: 1fr; }
  .preview-actions { grid-template-columns: 1fr; }
  .preview-actions .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
