:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #62666f;
  --panel: #ffffff;
  --line: #dadce3;
  --surface: #f3f5f8;
  --accent: #256f64;
  --accent-strong: #15584f;
  --warn: #ab3a28;
  --focus: #3b82f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  min-width: 0;
}

.brand-row,
.action-row,
.nudge-row,
.toggle-row,
.folder-row {
  display: flex;
  align-items: center;
}

.brand-row {
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.field-group,
.slider-group {
  display: grid;
  gap: 7px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
}

input[type="file"],
input[type="text"],
input[type="color"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input[type="file"] {
  padding: 8px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  padding: 0 10px;
}

textarea {
  min-height: 112px;
  padding-top: 9px;
  resize: vertical;
}

input[type="color"] {
  padding: 4px;
}

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

.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: #fff;
  color: var(--ink);
  font-size: 18px;
}

.icon-button:hover,
.secondary-button:hover {
  border-color: #aeb3bd;
  background: #f8f9fb;
}

.nudge-row {
  gap: 8px;
}

.folder-row {
  gap: 10px;
}

.folder-row .secondary-button {
  flex: 0 0 auto;
}

#folderName {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.status-box {
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8f9fb;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.status-box.warning {
  border-color: #e7b3a9;
  background: #fff7f5;
  color: var(--warn);
}

.status-box.ready {
  border-color: #a6d7cb;
  background: #f0fbf8;
  color: var(--accent-strong);
}

.action-row {
  gap: 10px;
  margin-top: auto;
}

.compact-actions {
  margin-top: 0;
}

.compact-actions .secondary-button {
  flex: 1;
  min-width: 0;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 14px;
}

.primary-button {
  flex: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

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

.secondary-button {
  background: #fff;
  color: var(--ink);
}

.preview-area {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 24px;
  overflow: auto;
}

.canvas-frame {
  display: grid;
  place-items: center;
  width: min(100%, 760px);
  min-height: min(88vh, 980px);
}

#previewCanvas {
  max-width: 100%;
  max-height: 90vh;
  width: auto;
  height: auto;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  border: 1px solid #c9cdd5;
  box-shadow: 0 18px 50px rgba(31, 35, 40, 0.16);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.35);
  outline-offset: 2px;
}

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

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

  .action-row {
    margin-top: 4px;
  }

  .preview-area {
    padding: 16px;
  }
}
