:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #68727f;
  --line: #dfe4ea;
  --surface: #ffffff;
  --surface-soft: #f3f5f7;
  --brand: #14517c;
  --accent: #f5d31c;
  --shadow: 0 18px 45px rgba(18, 29, 41, 0.12);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #e9edf1; }

body {
  margin: 0;
  color: var(--ink);
  background: #e9edf1;
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button, select, input[type="color"], input[type="range"] { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 14px 24px;
  color: white;
  background: #111922;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.topbar h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.eyebrow { margin-bottom: 3px; color: #93c9e8; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.privacy-pill { padding: 7px 10px; color: #bcd0dd; background: rgba(255,255,255,.07); border-radius: 999px; font-size: 12px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 410px) minmax(520px, 1fr);
  align-items: start;
  min-height: calc(100vh - 78px);
}

.controls {
  height: calc(100vh - 78px);
  padding: 18px;
  overflow: auto;
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
}

.panel {
  margin-bottom: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(18, 29, 41, .035);
}

.panel-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 14px; }
.step { display: grid; place-items: center; width: 26px; height: 26px; color: white; background: var(--brand); border-radius: 8px; font-size: 10px; font-weight: 800; }

.field { display: grid; gap: 6px; min-width: 0; margin-bottom: 12px; }
.field > span, .color-field > span { color: #4f5b66; font-size: 11px; font-weight: 750; letter-spacing: .02em; }
.field small { justify-self: end; margin-top: -3px; color: #8a929b; font-size: 10px; }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 39px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid #d7dde3;
  border-radius: 9px;
  outline: none;
  resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: #4187b4; box-shadow: 0 0 0 3px rgba(20,81,124,.1); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-grid-four { grid-template-columns: repeat(4, 1fr); }
.color-field { display: grid; gap: 6px; }
.color-field input { width: 100%; height: 38px; padding: 3px; background: white; border: 1px solid #d7dde3; border-radius: 9px; }

.range-field { display: grid; gap: 7px; margin: 12px 0; }
.range-field > span { display: flex; justify-content: space-between; gap: 12px; color: #4f5b66; font-size: 11px; }
.range-field output { color: #78838d; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="range"]:disabled { cursor: not-allowed; opacity: .35; }
.compact-range { display: flex; align-items: center; gap: 7px; min-height: 39px; padding: 0 8px; background: #fbfcfd; border: 1px solid #d7dde3; border-radius: 9px; }
.compact-range input { min-width: 0; }
.compact-range output { min-width: 34px; color: #78838d; font-size: 10px; text-align: right; }

.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { display: flex; align-items: center; gap: 6px; padding: 7px 9px; background: #f5f7f9; border: 1px solid #e0e5ea; border-radius: 8px; font-size: 11px; cursor: pointer; }
.toggle input { margin: 0; accent-color: var(--brand); }
.field-help { margin: -4px 0 12px; color: #7b8791; font-size: 11px; }
.field-help code { padding: 1px 4px; color: #31536a; background: #edf3f6; border-radius: 4px; }
.safe-note { margin: 9px 0 0; }

.dropzone {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 126px;
  padding: 15px;
  text-align: center;
  background: #f6f9fb;
  border: 1.5px dashed #9eafbc;
  border-radius: 12px;
  transition: .18s ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { color: var(--brand); background: #edf6fb; border-color: var(--brand); }
.dropzone input { display: none; }
.dropzone-icon { display: grid; place-items: center; width: 32px; height: 32px; color: white; background: var(--brand); border-radius: 50%; font-size: 22px; line-height: 1; }
.dropzone small { color: #84909a; }
.dropzone-compact { min-height: 98px; grid-template-columns: auto 1fr; justify-items: start; align-content: center; column-gap: 10px; text-align: left; }
.dropzone-compact .dropzone-icon { grid-row: span 2; }
.photo-meta { margin-top: 9px; color: #7b8791; font-size: 11px; }
.photo-meta.warning { color: #a8660b; }
.background-removal { margin-top: 12px; padding: 11px; background: #f7faf8; border: 1px solid #dce8df; border-radius: 10px; }
.background-removal .field { margin-bottom: 8px; }
.removal-sensitivity { margin: 8px 0; }
.removal-note { margin: 6px 0 0; }
.removal-note.processing { color: #17648f; }
.removal-note.success { color: #277449; }
.removal-note.warning { color: #a8660b; }

.button {
  min-height: 38px;
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  font-weight: 750;
  transition: transform .15s ease, filter .15s ease;
}
.button:hover { filter: brightness(1.07); transform: translateY(-1px); }
.button-primary { color: white; background: var(--brand); }
.button-secondary { color: #17202a; background: var(--accent); }
.button-dark { color: white; background: #20272d; }
.button-ghost { color: white; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); }
.export-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.export-buttons-three { grid-template-columns: repeat(3, 1fr); }
.button-set { width: 100%; margin-top: 9px; color: #173044; background: #e5f0f7; border: 1px solid #c8dae7; }
.project-divider { height: 1px; margin: 14px 0; background: var(--line); }
.project-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.button-project { display: grid; place-items: center; color: #44515c; background: #f4f6f8; border: 1px solid #dce2e7; font-size: 11px; cursor: pointer; }
.project-file-button input { display: none; }
.export-size { margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: center; }

.preview-area {
  position: sticky;
  top: 78px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100vh - 78px);
  min-height: 520px;
  padding: 20px 26px 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 12%, rgba(20,81,124,.12), transparent 26%),
    #dfe4e8;
}

.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.preview-label { font-weight: 800; }
.preview-status { margin-left: 8px; color: #277449; font-size: 11px; }
.preview-status.warning { color: #a8660b; }
.drag-hint { color: #69747d; font-size: 11px; }

.canvas-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

#creativeCanvas {
  display: block;
  width: 1px;
  height: 1px;
  max-width: none;
  max-height: none;
  background: white;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
  cursor: grab;
}
#creativeCanvas.is-dragging { cursor: grabbing; }

.validation {
  max-width: 720px;
  margin: 12px auto 0;
  padding: 10px 12px;
  color: #80500b;
  background: #fff7df;
  border: 1px solid #ecd898;
  border-radius: 9px;
  font-size: 11px;
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 350px minmax(420px, 1fr); }
  .privacy-pill { display: none; }
}

@media (max-width: 760px) {
  .topbar { position: relative; align-items: flex-start; padding: 12px 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar-actions .button-ghost { display: none; }
  .workspace { display: flex; flex-direction: column-reverse; }
  .controls { width: 100%; height: auto; overflow: visible; border: 0; }
  .preview-area { position: relative; top: 0; width: 100%; height: min(66vh, 620px); min-height: 430px; padding: 13px; }
  .drag-hint { display: none; }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .topbar-actions #exportJpgButton { padding-inline: 10px; font-size: 12px; }
  .preview-status { display: block; margin: 2px 0 0; }
  .controls { padding: 10px; }
  .panel { padding: 14px; }
}
