:root {
  --bg: #0a0a0b;
  --bg-soft: #111113;
  --card: #141416;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --fg: #f4f1ea;
  --fg-dim: #8a8a92;
  --fg-faint: #7e7e88;
  --accent: #2f5fe0;
  --accent-soft: rgba(47, 95, 224, 0.16);
  --amber: #e0a857;

  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono: "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;

  --radius: 16px;
  --maxw: 980px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 35%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 35%, #000 30%, transparent 80%);
}

.nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(18px, 5vw, 48px);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
}
.brand-mark {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 0;
  color: var(--accent);
  position: relative;
  top: 6px;
}
.brand-name {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-dim { color: var(--fg-faint); font-weight: 400; }

.nav-actions { display: flex; align-items: center; gap: 14px; }

.lang-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.lang-btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.lang-btn.is-active { background: var(--fg); color: var(--bg); }

.nav-link {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg-dim);
  text-decoration: none;
  transition: color 0.15s;
}
.nav-link:hover { color: var(--fg); }

.wrap {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 56px) clamp(18px, 5vw, 24px) 64px;
}

.hero { text-align: center; margin-bottom: 36px; }
.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--fg-faint);
  margin-bottom: 16px;
}
.title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(52px, 11vw, 104px);
  line-height: 0.98;
  letter-spacing: -0.005em;
}
.title em {
  font-style: italic;
  color: var(--accent);
}
.subtitle {
  margin: 20px auto 0;
  max-width: 440px;
  color: var(--fg-dim);
  font-size: 15px;
  line-height: 1.6;
}

.picker { margin-bottom: 28px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.chip {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.chip:hover { color: var(--fg); border-color: var(--border-strong); }
.chip.is-active {
  color: var(--fg);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.chip.chip-all.is-active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.stage { display: flex; flex-direction: column; align-items: center; }

.card-frame {
  width: 100%;
  max-width: 820px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}
#quoteCanvas { display: block; width: 100%; height: 100%; }

.controls {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.theme-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.theme-btn.is-active { border-color: var(--accent); }
.sw {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.sw-dark { background: #16181d; }
.sw-cream { background: #efe7d6; }
.sw-blue { background: linear-gradient(135deg, #1d3a8f, #3b6dff); }

.buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-ico { font-size: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2552cc; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--fg); background: rgba(255, 255, 255, 0.04); }
.btn:active { transform: translateY(0); }
.btn.is-done { color: var(--accent); border-color: var(--accent); }

.customize-toggle {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--fg-dim);
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.15s;
}
.customize-toggle:hover { color: var(--fg); }
.customize-toggle .chevron { font-size: 10px; transition: transform 0.2s; }
.customize-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.custom-panel {
  width: 100%;
  max-width: 440px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.custom-panel[hidden] { display: none; }

.cust-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 12px;
}
.cust-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.cust-select,
.cust-input {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  width: 100%;
  cursor: pointer;
}
.cust-input { cursor: text; }
.cust-select:focus-visible,
.cust-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.cust-range { width: 100%; accent-color: var(--accent); cursor: pointer; }

.align-toggle { display: inline-flex; gap: 6px; }
.align-btn {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--fg-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  width: 38px;
  height: 34px;
  cursor: pointer;
  transition: all 0.15s;
}
.align-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.align-btn.is-active { color: var(--fg); background: var(--accent-soft); border-color: var(--accent); }

.cust-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
  cursor: pointer;
}
.cust-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.color-row { display: flex; flex-wrap: wrap; gap: 14px; }
.color-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-dim);
  cursor: pointer;
}
.color-pick input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.color-pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-pick input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }

.cust-reset {
  justify-self: start;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  background: transparent;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cust-reset:hover { color: var(--fg-dim); }

.foot {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 22px clamp(18px, 5vw, 48px);
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}
.foot-item { display: flex; flex-direction: column; gap: 4px; }
.foot-key {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--fg-faint);
}
.foot-val { font-family: var(--mono); font-size: 13px; color: var(--fg-dim); }
.foot-note {
  flex-basis: 100%;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--fg-faint);
}
.foot-link { text-decoration: none; transition: color 0.15s; }
.foot-link:hover { color: var(--fg); }

@media (max-width: 600px) {
  .nav { padding: 16px 18px; }
  .wrap { padding-top: 16px; }
  .subtitle { font-size: 14px; }
  .controls { width: 100%; }
  .buttons { width: 100%; flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
  .foot { gap: 16px 26px; padding: 20px 18px; }

  .custom-panel { max-width: 100%; padding: 18px 16px; gap: 16px; }
  .cust-row { grid-template-columns: 1fr; gap: 8px; align-items: start; }
  .cust-label { font-size: 10px; letter-spacing: 0.1em; }
  .color-row { justify-content: space-between; gap: 10px; }
  .color-pick { flex: 1; justify-content: center; }
  .align-toggle { width: 100%; }
  .align-btn { flex: 1; }
}

@media (max-width: 400px) {
  .nav-link { display: none; }              
  .chip { font-size: 11px; padding: 7px 10px; }
  .eyebrow { font-size: 11px; letter-spacing: 0.16em; }
  .brand-name { font-size: 13px; }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}
.chip:focus-visible,
.lang-btn:focus-visible,
.theme-btn:focus-visible { outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 20;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  text-decoration: none;
  transition: top 0.16s ease;
}
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover { transform: none; }
}
