:root {
  color-scheme: light;
  --bg: #eff4fb;
  --card: #ffffff;
  --card-soft: rgba(255,255,255,.92);
  --line: #d9e2ef;
  --text: #2f3c57;
  --muted: #6d7e9c;
  --accent: #14c7a0;
  --accent-dark: #129f82;
  --blue: #1f66df;
  --panel-input: #ffffff;
  --panel-strong: #303c59;
  --on-strong: #ffffff;
  --elev-shadow: 0 16px 40px rgba(26, 43, 76, .06);
  --checker-a: #f1f4f9;
  --checker-b: #e2e8f2;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f243f;
  --card: #131d2b;
  --card-soft: rgba(19, 29, 43, .92);
  --line: #2a3a53;
  --text: #e6eefc;
  --muted: #a6b7d2;
  --accent: #2ad4b2;
  --accent-dark: #22b89a;
  --blue: #4d8dff;
  --panel-input: #192638;
  --panel-strong: #223550;
  --on-strong: #eaf1ff;
  --elev-shadow: 0 18px 44px rgba(0, 0, 0, .35);
  --checker-a: #1a2739;
  --checker-b: #152133;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); background-image: repeating-linear-gradient(45deg, var(--checker-a), var(--checker-a) 10px, var(--bg) 10px, var(--bg) 20px); background-size: 20px 20px; background-clip: border-box; }
body[data-theme="dark"] { background-image: repeating-linear-gradient(45deg, var(--checker-a), var(--checker-a) 10px, var(--bg) 10px, var(--bg) 20px); background-size: 20px 20px; background-clip: border-box; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 18px 28px; background: var(--card-soft);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(16px);
}
.site-brand { display: flex; align-items: center; gap: 12px; font-size: 30px; }
.site-logo { width: 34px; height: 34px; object-fit: contain; }
.site-nav { display: flex; gap: 42px; color: var(--muted); font-size: 18px; }
.dashboard-button { background: var(--blue); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; min-height: 44px; padding: 0 14px; font-weight: 700;
}

.layout {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, .85fr); gap: 24px;
  padding: 24px; max-width: 1700px; margin: 0 auto;
}
.composer, .preview-column { display: grid; gap: 22px; align-content: start; }
.card {
  background: var(--card-soft); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--elev-shadow); padding: 24px;
}
.preview-card { position: static; }
.step-heading { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 700; margin-bottom: 18px; }
.step-heading span { width: 34px; height: 34px; border-radius: 8px; background: var(--panel-strong); color: var(--on-strong); display: inline-grid; place-items: center; }

.option-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px;
  background: var(--card-soft); border: 1px solid var(--line); border-radius: 22px; padding: 18px;
}
.type-btn {
  border: 1px solid var(--line); background: var(--panel-input); border-radius: 16px; min-height: 58px;
  font-weight: 700; color: var(--text);
}
.type-btn.active { border-color: #12c08f; background: #e7fbf4; color: #10936d; }

.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab-button { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 14px 22px; color: var(--muted); font-size: 18px; }
.tab-button.active { color: #19b37f; background: var(--panel-input); border-color: var(--line); border-top-left-radius: 14px; border-top-right-radius: 14px; margin-bottom: -1px; }

.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: 18px; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel-input); color: var(--text);
  padding: 14px 16px; outline: none;
}
.field textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.range-row { display: grid; grid-template-columns: 180px 1fr 60px; gap: 12px; align-items: center; margin-bottom: 16px; }
.range-row input[type="range"] { width: 100%; }
.range-value { font-weight: 700; color: var(--text); text-align: right; min-width: 50px; }

.frame-choices, .shape-choices, .logo-choices, .bg-choices { display: grid; gap: 12px; }
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-label[for="phraseColor"], label[for="phraseColor"] { font-size: 18px; font-weight: 700; }
.color-control label:not([for]) { font-size: 18px; font-weight: 700; }
.swatch {
  width: 80px; height: 80px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-input);
  display: grid; place-items: center; padding: 10px;
}
.swatch.active { border-color: #4d8df5; box-shadow: 0 0 0 2px rgba(77,141,245,.14) inset; }
.swatch svg, .swatch img { width: 100%; height: 100%; object-fit: contain; }
.shape-swatch span { font-size: 12px; font-weight: 700; letter-spacing: .02em; color: var(--text); text-transform: uppercase; }
.logo-swatch span { font-size: 11px; font-weight: 700; color: var(--muted); }
.logo-preview { justify-self: start; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 10px; }
.shape-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 10px; }

.section-title { font-size: 16px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }
.section-title:first-child { margin-top: 0; }

.upload-area {
  border: 2px dashed var(--line); border-radius: 16px; background: var(--panel-input);
  padding: 32px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-area:hover, .upload-area.drag-over { border-color: var(--accent); background: rgba(20, 199, 160, .06); }
.upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.upload-placeholder svg { color: var(--accent); }
.upload-placeholder small { font-size: 14px; color: var(--muted); }

.no-logo { color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: center; height: 100%; }

.color-count-row { display: flex; gap: 10px; }
.color-count-btn {
  width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-input); color: var(--text); font-weight: 700; font-size: 18px;
}
.color-count-btn.active { border-color: #4d8df5; background: #e8f0ff; color: #1f66df; }

.logo-shape-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 10px; }
.logo-shape-grid .swatch { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px 8px; }
.logo-shape-grid .swatch svg { width: 40px; height: 40px; }
.logo-shape-grid .swatch span { font-size: 11px; font-weight: 700; color: var(--text); text-align: center; }
.color-control { display: grid; grid-template-columns: 1fr 110px; gap: 12px; align-items: center; }
.hex-input { min-height: 56px; }
.color-chip {
  width: 100%; min-height: 56px; padding: 6px; border-radius: 14px;
  background: var(--panel-input); border: 1px solid var(--line);
}
.color-chip::-webkit-color-swatch-wrapper { padding: 0; }
.color-chip::-webkit-color-swatch { border: 0; border-radius: 10px; }
.color-chip::-moz-color-swatch { border: 0; border-radius: 10px; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin: 6px 0 8px; }
.switch-row { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; color: var(--text); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 52px; height: 32px; border-radius: 999px; background: #d0d7e3; position: relative; flex: 0 0 auto; transition: background .15s ease;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(15, 23, 42, .18); transition: transform .15s ease;
}
.switch-row input:checked + .switch { background: #34c759; }
.switch-row input:checked + .switch::after { transform: translateX(20px); }

.preview-shell {
  border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; place-items: center;
  background: transparent;
}
.preview { width: 100%; display: grid; place-items: center; }
.preview svg { width: 100%; height: auto; display: block; }
.primary-download {
  width: 100%; margin-top: 18px; min-height: 62px; border: 0; border-radius: 14px; background: var(--accent);
  color: #fff; font-size: 20px; font-weight: 800;
}
.downloads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.secondary-download {
  border: 1px solid var(--line); background: var(--panel-input); border-radius: 14px; min-height: 48px; font-weight: 800;
}
.icon-downloads { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.icon-download { font-size: 13px; letter-spacing: .01em; }

body[data-theme="dark"] .type-btn.active {
  background: #17392f;
  border-color: #2ad4b2;
  color: #79f0d8;
}

.history-item span,
.history-note,
.site-nav,
.empty-state {
  color: var(--muted);
}

.history-note { color: var(--muted); margin-bottom: 12px; }
.empty-state { border: 1px dashed var(--line); border-radius: 14px; padding: 16px; color: var(--muted); }
.history-list { display: grid; gap: 12px; margin-top: 12px; }
.history-item {
  border: 1px solid var(--line); background: var(--panel-input); border-radius: 14px; padding: 12px;
  display: grid; gap: 10px;
}
.history-item img { width: 100%; border-radius: 10px; display: block; }
.history-item span { color: var(--muted); font-size: 14px; }

.dashboard-layout { max-width: 1200px; margin: 20px auto; padding: 0 20px 30px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.dashboard-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--card); display: flex; flex-direction: column; gap: 6px; min-height: 220px; }
.dashboard-card img { width: 100%; border-radius: 10px; margin-bottom: 8px; }
.dashboard-grid > article > div:nth-of-type(2) { color: var(--muted); font-size: 14px; text-align: center; width: 100%; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
.preview-card { position: static; }
.preview svg { max-width: 100%; }
}

@media (max-width: 760px) {
  .site-header { flex-wrap: wrap; }
  .site-nav { gap: 18px; flex-wrap: wrap; }
  .layout { padding: 14px; }
  .grid-2, .mini-row, .downloads, .range-row { grid-template-columns: 1fr; }
}
