:root {
  --bg: #0b0a09;
  --bg-elev: #141210;
  --bg-card: #181512;
  --line: rgba(232, 213, 183, 0.12);
  --sand: #e8d5b7;
  --sand-dim: #b8a48a;
  --cream: #f5efe6;
  --muted: #8a7f72;
  --copper: #d4894a;
  --copper-deep: #b86f35;
  --ink: #0b0a09;
  --ok: #7dba8a;
  --radius: 16px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --bar-glass: rgba(11, 10, 9, 0.82);
  --frame-bg: #090807;
  --grain-opacity: 0.04;
}

html[data-theme="light"] {
  --bg: #f7f1e8;
  --bg-elev: #fffdf9;
  --bg-card: #ffffff;
  --line: rgba(40, 32, 24, 0.16);
  --sand: #1c1814;
  --sand-dim: #4a433a;
  --cream: #12100e;
  --muted: #524c44;
  --copper: #8b4a14;
  --copper-deep: #6e3a10;
  --ink: #0b0a09;
  --ok: #2d7a42;
  --bar-glass: rgba(247, 241, 232, 0.94);
  --frame-bg: #e8dfd0;
  --grain-opacity: 0.025;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--sand);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
.grain {
  pointer-events: none; position: fixed; inset: 0; z-index: 50; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.glow { pointer-events: none; position: fixed; border-radius: 50%; filter: blur(90px); z-index: 0; }
.glow-a {
  width: 50vw; height: 50vw; max-width: 640px; top: -10%; right: -5%;
  background: radial-gradient(circle, rgba(212,137,74,0.2), transparent 70%);
}
.tool-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--bar-glass); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 0.7rem; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #e2b07a, #b86f35 55%, #6b3d1c);
  box-shadow: 0 0 0 1px rgba(232,213,183,0.15), 0 8px 20px rgba(184,111,53,0.25);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text strong { font-weight: 650; font-size: 0.95rem; color: var(--cream); }
.logo-text span { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.bar-right { display: flex; align-items: center; gap: 0.75rem; }
.bar-links { display: flex; gap: 1rem; font-size: 0.88rem; color: var(--sand-dim); }
.bar-links a:hover { color: var(--cream); }
.tool-layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 1.25rem; padding: 1.25rem 1.5rem 2rem;
  min-height: calc(100vh - 64px);
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.35rem 1.4rem 1.5rem;
}
.eyebrow {
  margin: 0 0 0.55rem; font-size: 0.72rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--copper); font-weight: 600;
}
h1 {
  margin: 0 0 0.65rem; font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.7rem, 2.4vw, 2.15rem); line-height: 1.15; color: var(--cream);
  letter-spacing: -0.02em;
}
h1 em { font-style: italic; color: var(--copper); }
.lede { margin: 0 0 1.25rem; color: var(--sand-dim); font-size: 0.95rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; }
.field > span { font-size: 0.8rem; color: var(--sand-dim); font-weight: 500; }
.field .opt { color: var(--muted); font-weight: 400; text-transform: lowercase; letter-spacing: 0; }
.field abbr { color: var(--copper); text-decoration: none; }
.field input, .field select {
  width: 100%; padding: 0.7rem 0.85rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--cream);
  outline: none; transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus, .field select:focus {
  border-color: rgba(212,137,74,0.55);
  box-shadow: 0 0 0 3px rgba(212,137,74,0.15);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.check {
  display: flex; align-items: center; gap: 0.55rem; margin: 0.25rem 0 1rem;
  font-size: 0.85rem; color: var(--sand-dim); cursor: pointer;
}
.check input { accent-color: var(--copper); width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.btn-copper, .btn-ghost, .btn-ghost-sm {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.7rem 1.15rem; border-radius: 999px; font-weight: 600; font-size: 0.92rem;
  transition: transform .2s var(--ease), background .2s, border-color .2s;
}
.btn-copper { background: linear-gradient(135deg, #e2b07a, var(--copper-deep)); color: var(--ink); }
.btn-copper:hover { transform: translateY(-1px); }
.btn-copper:disabled { opacity: 0.55; cursor: wait; transform: none; }
.btn-ghost, .btn-ghost-sm {
  border: 1px solid var(--line); color: var(--sand); background: transparent;
}
.btn-ghost-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.status { min-height: 1.3em; margin: 0.85rem 0 0; font-size: 0.88rem; color: var(--sand-dim); }
.status.is-error { color: #e8a0a0; }
.status.is-ok { color: var(--ok); }
.tips { margin-top: 1.5rem; padding-top: 1.15rem; border-top: 1px solid var(--line); }
.tips h2 { margin: 0 0 0.55rem; font-size: 0.95rem; color: var(--cream); font-weight: 600; }
.tips ol { margin: 0; padding-left: 1.15rem; color: var(--sand-dim); font-size: 0.88rem; }
.tips li { margin-bottom: 0.35rem; }
.preview-panel { display: flex; flex-direction: column; min-height: 70vh; }
.preview-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: 0.85rem;
}
.preview-head h2 { margin: 0; font-size: 1.05rem; color: var(--cream); font-weight: 600; }
.preview-meta { display: flex; align-items: center; gap: 0.5rem; }
.badge {
  font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.25rem 0.55rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--copper); background: rgba(212,137,74,0.08);
}
.frame-wrap {
  flex: 1; min-height: 520px; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--frame-bg); position: relative;
}
.frame-empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  color: var(--muted); padding: 2rem; gap: 0.35rem;
}
.frame-empty p { margin: 0; }
.tiny { font-size: 0.78rem; color: var(--muted); }
iframe { width: 100%; height: 100%; border: 0; background: #fff; min-height: 520px; }
.watermark-note { margin: 0.75rem 0 0; }
.watermark-note strong { color: var(--sand-dim); font-weight: 500; }
@media (max-width: 980px) {
  .tool-layout { grid-template-columns: 1fr; }
  .preview-panel { min-height: 60vh; }
  .bar-links { display: none; }
}
@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
  .tool-layout { padding: 1rem; }
}


/* Theme toggle */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line);
  display: inline-grid; place-content: center;
  color: var(--sand-dim); background: transparent;
  transition: color .2s var(--ease), border-color .2s, background .2s;
  flex-shrink: 0; cursor: pointer; margin-left: 0.35rem;
}
.theme-toggle:hover { color: var(--cream); border-color: var(--copper); background: rgba(212,137,74,0.12); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }
html[data-theme="light"] .theme-toggle {
  color: var(--sand-dim);
  border-color: rgba(40,32,24,0.28);
  background: rgba(26,22,18,0.05);
}
html[data-theme="light"] .theme-toggle:hover {
  color: var(--cream);
  border-color: var(--copper);
  background: rgba(139,74,20,0.12);
}
html[data-theme="light"] .glow-a {
  background: radial-gradient(circle, rgba(196,120,58,0.16), transparent 70%);
}


/* Soft-gate / sales banner — does not block the tool */
.sales-banner {
  position: relative; z-index: 35;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(212,137,74,0.14), rgba(212,137,74,0.04));
}
.sales-banner-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.7rem 1.5rem;
  max-width: 1400px; margin: 0 auto;
}
.sales-banner p {
  margin: 0; font-size: 0.84rem; color: var(--sand-dim); max-width: 58rem; line-height: 1.45;
}
.sales-banner strong { color: var(--cream); font-weight: 600; }
.sales-banner code {
  font-size: 0.78rem; color: var(--copper);
  background: rgba(245,239,230,0.06); padding: 0.1rem 0.35rem; border-radius: 4px;
}
.sales-banner em { font-style: normal; color: var(--ok); }
.sales-banner-cta {
  flex-shrink: 0;
  display: inline-flex; align-items: center;
  padding: 0.5rem 0.95rem; border-radius: 999px;
  background: linear-gradient(180deg, #e2a86a, var(--copper-deep));
  color: var(--ink); font-weight: 600; font-size: 0.85rem;
}
.sales-banner.is-keyed {
  background: linear-gradient(90deg, rgba(125,186,138,0.12), rgba(212,137,74,0.06));
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
  border-color: rgba(40,32,24,0.28);
  color: var(--cream);
  background: var(--bg-elev);
}
html[data-theme="light"] .btn-ghost,
html[data-theme="light"] .btn-secondary {
  border-color: rgba(40,32,24,0.28);
  color: var(--cream);
}
