:root {
  color-scheme: light;
  --bg: #f5f0e8;
  --surface: #fffdfa;
  --surface-2: #ece7dd;
  --text: #191612;
  --muted: #6f6a62;
  --line: #d8d0c3;
  --accent: #1f7a69;
  --accent-2: #b2464e;
  --ink-soft: rgba(25, 22, 18, 0.08);
  --shadow: 0 18px 42px rgba(68, 52, 32, 0.1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11120f;
  --surface: #1b1d19;
  --surface-2: #272821;
  --text: #f7f2ea;
  --muted: #b2aa9d;
  --line: #3f4037;
  --accent: #63c7ad;
  --accent-2: #ef8a91;
  --ink-soft: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, select, input[type="color"] { cursor: pointer; }
textarea { resize: vertical; }
.wrap { width: min(1220px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner, .footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
}

.brand, .nav, .footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  color: var(--text);
  font-weight: 850;
  text-decoration: none;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.nav, .footer-links { flex-wrap: wrap; }
.nav a, .icon-button, .control-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  padding: 8px 11px;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.hero {
  padding: 30px 0 16px;
}

h1 {
  max-width: 930px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.lead {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
  gap: 16px;
  align-items: start;
}

.preview-panel, .controls-panel, .content section, .privacy-page {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-panel { overflow: hidden; }

.dropzone {
  display: grid;
  min-height: 158px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--accent) 13%, transparent), transparent 58%),
    linear-gradient(35deg, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 48%),
    var(--surface-2);
  text-align: center;
}

.dropzone.drag {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -8px;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 2rem;
  line-height: 1;
}

.upload-title {
  font-size: 1.12rem;
  font-weight: 850;
}

.upload-copy {
  max-width: 440px;
  color: var(--muted);
}

.preview-shell {
  display: grid;
  min-height: 360px;
  max-height: 74vh;
  place-items: center;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(45deg, var(--ink-soft) 25%, transparent 25%),
    linear-gradient(-45deg, var(--ink-soft) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--ink-soft) 75%),
    linear-gradient(-45deg, transparent 75%, var(--ink-soft) 75%),
    var(--surface-2);
  background-size: 26px 26px;
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
}

.preview-shell canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.preview-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.status {
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.status[data-tone="ok"] { color: var(--accent); }
.status[data-tone="error"] { color: var(--accent-2); }

.controls-panel {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.control-section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child { border-bottom: 0; }
.control-section h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.field, .range-field, .align-field, .choice-field {
  display: grid;
  gap: 7px;
}

.field span, .range-field span, .check-field span, .align-field legend, .choice-field legend {
  font-size: 0.88rem;
  font-weight: 780;
}

.field input:not([type="color"]), .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.field textarea {
  min-height: 82px;
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px;
}

.range-field input[type="range"] { width: 100%; }
.range-field.compact { align-content: end; }

.frame-style-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 10px;
  align-items: end;
}

.keyline-stack {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(86px, 1fr);
  gap: 10px;
  align-items: end;
}

.check-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.text-group {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-2) 42%, var(--surface));
}

.text-group legend {
  padding: 0 4px;
}

.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 4px 6px;
  font-size: 0.88rem;
  font-weight: 850;
  cursor: pointer;
}

.group-toggle input,
.row-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.text-group-body {
  display: grid;
  gap: 10px;
}

.text-group[data-enabled="false"] .text-group-body {
  opacity: 0.52;
}

.caption-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.caption-row[data-enabled="false"] .field {
  opacity: 0.5;
}

.row-toggle {
  display: grid;
  width: 42px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.row-toggle.top {
  align-self: start;
  margin-top: 27px;
}

.align-field,
.choice-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.align-field legend,
.choice-field legend {
  padding: 0;
}

.align-options,
.choice-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.align-option,
.choice-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 70px;
  align-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.align-option input,
.choice-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.align-option > span:last-child,
.choice-option > span:last-child {
  position: relative;
  z-index: 1;
  font-size: 0.76rem;
  font-weight: 800;
}

.align-preview {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 30px;
  align-content: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
}

.align-preview span {
  display: block;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.align-preview span:nth-child(1) { width: 78%; }
.align-preview span:nth-child(2) { width: 56%; }
.align-preview span:nth-child(3) { width: 68%; }
.align-left span { justify-self: start; }
.align-center span { justify-self: center; }
.align-right span { justify-self: end; }

.align-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.choice-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.align-option:has(input:focus-visible),
.choice-option:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, #ffffff);
  outline-offset: 2px;
}

.weight-preview {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  color: currentColor;
  font-size: 1.04rem;
  line-height: 1;
}

.weight-regular .weight-preview { font-weight: 500; }
.weight-medium .weight-preview { font-weight: 650; }
.weight-bold .weight-preview { font-weight: 800; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 800;
}

.control-button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.control-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button:focus-visible,
.control-button:focus-visible,
.nav a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, #ffffff);
  outline-offset: 2px;
}

.privacy-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

.content {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.content section, .privacy-page {
  padding: 18px;
}

.content h2, .privacy-page h1, .privacy-page h2 {
  margin-top: 0;
}

.site-footer {
  margin-top: 42px;
  border-top: 1px solid var(--line);
}

.muted { color: var(--muted); }

@media (max-width: 960px) {
  .workbench, .content {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: -1;
  }
}

@media (max-width: 680px) {
  .header-inner, .footer-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-footer, .two-col, .frame-style-row, .keyline-stack, .caption-row {
    grid-template-columns: 1fr;
  }

  .row-toggle {
    width: 100%;
  }

  .row-toggle.top {
    margin-top: 0;
  }

  .preview-shell {
    min-height: 280px;
    padding: 10px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }
}
