:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #61707d;
  --line: #d8e1e8;
  --panel: #ffffff;
  --surface: #f4f7f8;
  --field: #f9fbfc;
  --accent: #0b7a75;
  --accent-strong: #075c58;
  --accent-soft: #d9f1ef;
  --warm: #f4b860;
  --rose: #d75a6a;
  --shadow: 0 22px 55px rgba(16, 42, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(11, 122, 117, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(244, 184, 96, 0.2), transparent 36%),
    var(--surface);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.workspace {
  min-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 780px;
  font-size: clamp(1.85rem, 4vw, 4rem);
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

.editor-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: stretch;
}

.preview-pane,
.controls {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(216, 225, 232, 0.9);
  box-shadow: var(--shadow);
}

.preview-pane {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 14px;
  padding: 16px;
  border-radius: 8px;
}

.drop-zone {
  min-height: 96px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 18px;
  border: 1px dashed #9ab7c2;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.drop-zone small {
  color: var(--muted);
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.upload-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--accent);
  font-size: 1.35rem;
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 360px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #edf2f5 25%, transparent 25%),
    linear-gradient(-45deg, #edf2f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf2f5 75%),
    linear-gradient(-45deg, transparent 75%, #edf2f5 75%);
  background-color: #ffffff;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
}

.canvas-wrap:not(.is-empty) .empty-preview {
  display: none;
}

.preview-actions {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.segmented button {
  min-width: 82px;
  min-height: 38px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.is-active {
  color: white;
  background: var(--accent);
}

.file-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  border-radius: 8px;
}

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

.control-section:last-child {
  border-bottom: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
}

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

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

label b {
  color: var(--ink);
  font-size: 0.92rem;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
}

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

.primary-button,
.ghost-button,
.tiny-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  color: white;
  background: var(--accent);
}

.primary-button:hover,
.segmented button.is-active:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-button,
.tiny-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--line);
}

.ghost-button {
  min-width: 86px;
}

.tiny-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

  .workspace {
    min-height: calc(100vh - 32px);
  }

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

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-section {
    border-right: 1px solid var(--line);
  }
}

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

  .preview-pane {
    min-height: 540px;
    grid-template-rows: auto minmax(300px, 1fr) auto;
  }

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

  .control-section {
    border-right: 0;
  }

  .preview-actions {
    align-items: stretch;
  }

  .segmented,
  .file-stats {
    width: 100%;
  }

  .file-stats {
    display: grid;
    gap: 6px;
  }
}
