:root {
  --bg: #12151d;
  --panel: #1b2130;
  --panel-2: #232c3f;
  --line: #313c52;
  --text: #e7ecf5;
  --muted: #9aa6bd;
  --accent: #62b6ff;
  --accent-2: #4f9dff;
  --radius: 12px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
}

/* --------------------------------------------------------------------- */
/* Controls sidebar                                                       */
/* --------------------------------------------------------------------- */

.controls {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.masthead h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

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

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

select,
input[type="file"] {
  width: 100%;
}

select {
  appearance: none;
  background: #141a26;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}

select:focus,
.drop-zone:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.checkbox {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 9px;
  cursor: pointer;
}

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

.checkbox input {
  margin-top: 2px;
  accent-color: var(--accent);
}

/* Info grid + swatches */

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  font-size: 13px;
  margin: 0;
}

.info-grid dt {
  color: var(--muted);
}

.info-grid dd {
  margin: 0;
  text-align: right;
  color: var(--text);
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: flex-end;
}

.swatch {
  width: 15px;
  height: 15px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Drop zone */

.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 12px;
  background: #141a26;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: #17202f;
}

.drop-zone-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.drop-zone-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Buttons */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button-row button {
  flex: 1 1 auto;
  background: #141a26;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12px;
  cursor: pointer;
}

.button-row button:hover {
  border-color: var(--accent);
  color: #fff;
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  padding: 0;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

#reset-adjust {
  margin-top: 4px;
}

/* Sliders */

.slider {
  margin-bottom: 10px;
}

.slider label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.slider output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

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

/* --------------------------------------------------------------------- */
/* Stage                                                                  */
/* --------------------------------------------------------------------- */

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.stage-title {
  font-size: 15px;
  font-weight: 600;
}

.stage-actions {
  display: flex;
  gap: 10px;
}

.primary-button,
.ghost-button {
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--line);
}

.primary-button {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #04101d;
  font-weight: 600;
}

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

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

.ghost-button {
  background: transparent;
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--accent);
}

.viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: radial-gradient(circle at 50% 30%, #1a2030, #0d1017 75%);
}

.device {
  --substrate: #d4d3c8;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(145deg, #2b3141, #171b25);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid #0c0f16;
}

.device canvas {
  display: block;
  background: var(--substrate);
  border-radius: 4px;
  image-rendering: pixelated;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    0 2px 10px rgba(0, 0, 0, 0.4);
}

.empty-hint {
  color: var(--muted);
  font-size: 14px;
}

.stage-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.source-details {
  font-size: 12px;
  color: var(--muted);
  max-width: 60%;
}

.source-details summary {
  cursor: pointer;
}

.source-canvas {
  display: block;
  margin-top: 10px;
  max-width: 260px;
  max-height: 180px;
  width: auto;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.render-caption {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* --------------------------------------------------------------------- */
/* Responsive                                                            */
/* --------------------------------------------------------------------- */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
  }

  .controls {
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    height: auto;
    min-height: 70vh;
  }

  .viewport {
    min-height: 50vh;
  }

  .source-details {
    max-width: 100%;
  }
}
