:root {
  color-scheme: light;
  --bg: #f6f5f0;
  --surface: #fffdfa;
  --surface-strong: #ffffff;
  --line: #ded9cb;
  --line-strong: #c7bfae;
  --text: #1f2a2e;
  --muted: #687477;
  --soft: #edf0e8;
  --accent: #0f7b6c;
  --accent-strong: #0a5f55;
  --accent-soft: #d7efe7;
  --warn: #d97706;
  --danger: #b42318;
  --shadow: 0 24px 60px rgba(31, 42, 46, 0.12);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(15, 123, 108, 0.08), transparent 42%),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar,
.bottombar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-color: var(--line);
  background: rgba(255, 253, 250, 0.92);
  backdrop-filter: blur(18px);
}

.topbar {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.bottombar {
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #0f7b6c, #2f604f);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 123, 108, 0.22);
}

.brand h1,
.brand p,
.section-head h2,
.empty-state h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.05;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.bottombar {
  display: flex;
  align-items: center;
}

.privacy-pill {
  border: 1px solid rgba(15, 123, 108, 0.26);
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ghost-button,
.text-button,
.primary-button,
.segment {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  font-weight: 800;
}

.ghost-button {
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.ghost-button:not(:disabled):hover,
.text-button:hover {
  color: var(--danger);
  background: #fff2ef;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.control-panel {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.78);
}

.panel-section {
  padding: 18px 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-section.is-hidden,
.is-hidden {
  display: none !important;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 13px;
  letter-spacing: 0;
}

.section-head span,
.dropzone small,
.field span,
.slider-field label,
.slider-field output,
.empty-state p,
.canvas-meta {
  color: var(--muted);
}

.section-head span,
.dropzone small,
.field span,
.slider-field label,
.slider-field output {
  font-size: 12px;
  font-weight: 700;
}

.dropzone {
  min-height: 144px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dropzone.small {
  min-height: 116px;
}

.dropzone.is-over,
.dropzone:hover {
  border-color: var(--accent);
  background: #f0faf6;
}

.dropzone input {
  display: none;
}

.drop-icon,
.empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--soft);
}

.segment {
  color: var(--muted);
  background: transparent;
}

.segment.is-active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 123, 108, 0.2);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
  outline: 0;
}

textarea {
  resize: vertical;
  min-height: 98px;
  padding: 12px;
  line-height: 1.55;
}

select {
  min-height: 38px;
  padding: 0 10px;
}

textarea:focus,
select:focus,
input[type="range"]:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(15, 123, 108, 0.2);
  outline-offset: 2px;
}

.color-field {
  grid-template-columns: 1fr 48px;
  align-items: center;
}

input[type="color"] {
  width: 48px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 4px;
}

.slider-field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.slider-field:last-child {
  margin-bottom: 0;
}

.slider-field > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  accent-color: var(--accent);
  cursor: pointer;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
}

.switch-row input {
  width: 42px;
  height: 24px;
  appearance: none;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  transition: background 0.2s ease;
}

.switch-row input::before {
  content: "";
  width: 18px;
  height: 18px;
  position: absolute;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

.switch-row input:checked {
  background: var(--accent);
}

.switch-row input:checked::before {
  transform: translateX(18px);
}

.logo-preview-wrap {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.logo-preview-wrap img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 8px;
}

.text-button {
  justify-self: start;
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.position-grid button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  position: relative;
}

.position-grid button::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
  position: absolute;
  inset: 0;
  margin: auto;
}

.position-grid button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.position-grid button.is-active::after {
  background: var(--accent);
}

.preview-area {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(31, 42, 46, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(31, 42, 46, 0.04) 1px, transparent 1px),
    #ebe6dc;
  background-size: 22px 22px;
}

.empty-state {
  width: min(520px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
  padding: 34px 22px;
}

.empty-state h2 {
  font-size: clamp(22px, 4vw, 34px);
}

.empty-state p {
  margin: 0;
  max-width: 360px;
  line-height: 1.65;
}

.canvas-wrap {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 100%;
}

#previewCanvas {
  max-width: min(100%, 1180px);
  max-height: calc(100vh - 190px);
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: white;
}

.canvas-meta {
  min-height: 24px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 250, 0.82);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.bottombar {
  justify-content: flex-end;
}

.field.compact {
  display: grid;
  grid-template-columns: auto minmax(88px, 110px);
  align-items: center;
  gap: 8px;
  margin: 0;
}

.primary-button {
  min-width: 180px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(15, 123, 108, 0.2);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-area {
    min-height: 56vh;
    padding: 18px;
  }

  #previewCanvas {
    max-height: 62vh;
  }
}

@media (max-width: 640px) {
  .topbar,
  .bottombar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .bottombar {
    width: 100%;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .bottombar {
    align-items: stretch;
  }

  .field.compact {
    grid-template-columns: 1fr;
  }

  .primary-button {
    min-width: 0;
    width: 100%;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }
}
