/* Layout: fixed-width control rail on the left, large preview stage on the right;
   stacks to one column on narrow screens. Accent is aeronautical-chart magenta. */
:root {
  --paper: #EDF0EA;
  --panel: #F8F9F5;
  --stage: #DCE1D8;
  --ink: #1D2925;
  --muted: #5C6963;
  --line: #CDD4CA;
  --accent: #B5115C;
  --accent-ink: #FFFFFF;
  --focus: #1C6FB0;
  --check-a: #E4E7E1;
  --check-b: #F3F5F0;

  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111714; --panel: #171E1A; --stage: #0C100E; --ink: #E3EAE5; --muted: #97A49D;
    --line: #2B3530; --accent: #EE5B9B; --accent-ink: #1A0710; --focus: #6DB3EA;
    --check-a: #1C2420; --check-b: #232C27; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111714; --panel: #171E1A; --stage: #0C100E; --ink: #E3EAE5; --muted: #97A49D;
  --line: #2B3530; --accent: #EE5B9B; --accent-ink: #1A0710; --focus: #6DB3EA;
  --check-a: #1C2420; --check-b: #232C27; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-body);
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- top bar */
.topbar {
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
  padding-block: 14px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 38px; height: 30px; color: var(--ink); align-self: center; }
.panel-foot { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.panel-foot a, .credits a { color: var(--accent); text-underline-offset: 2px; }
.brand-name {
  font: 700 26px/1 var(--font-display);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tagline { margin: 0; color: var(--muted); }

/* ---- workspace */
.workspace {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
}
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding-block: 8px 32px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: 20px;
}
.group { display: grid; gap: 12px; padding-block: 18px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
h2 {
  margin: 0;
  font: 600 13px/1 var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
}

/* ---- upload */
.drop {
  position: relative;
  display: grid; gap: 4px; justify-items: center; text-align: center;
  padding: 22px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { font: 600 20px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: 0.03em; }
.drop-sub { color: var(--muted); font-size: 13px; }

.trackinfo {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  font: 400 12.5px/1.45 var(--font-mono);
}
.trackinfo dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 11.5px; padding-top: 1px; }
.trackinfo dd { margin: 0; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }

/* ---- style picker */
.styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-card {
  display: grid; gap: 6px; text-align: left;
  padding: 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: transparent; cursor: pointer;
}
.style-card:hover { border-color: var(--ink); }
.style-card[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.swatch { height: 34px; border-radius: 3px; position: relative; overflow: hidden; }
.swatch svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.style-name { font: 600 16px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.03em; }
.style-note { font-size: 11.5px; line-height: 1.3; color: var(--muted); }

/* ---- segmented */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  border: 0; background: transparent; padding: 8px 4px; cursor: pointer;
  border-right: 1px solid var(--line); font-size: 13px;
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--panel); }

/* ---- fields */
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.reset {
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 12px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.hint { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.field input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font-size: 14px;
}
.field input:focus, .field select:focus { border-color: var(--focus); outline: none; }
.field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font-size: 14px; width: 100%;
}
.field .check { color: var(--ink); margin-top: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 13px; }
.slider output { font: 500 12px/1.6 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input { grid-column: 1 / -1; accent-color: var(--accent); width: 100%; margin: 0; }

/* ---- actions */
.spec { margin: 0; font: 400 12px/1.5 var(--font-mono); color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--ink);
  background: transparent; cursor: pointer; font-weight: 600;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn:disabled { opacity: .55; cursor: progress; }
.note { margin: 0; font-size: 12.5px; color: var(--muted); }
.note code { font-family: var(--font-mono); font-size: 12px; }

/* ---- stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.stage-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 10px;
  padding-left: 20px;
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 500;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--panel); }
.garments { display: flex; gap: 6px; align-items: center; }
.garment {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); cursor: pointer; padding: 0;
}
.garment[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--stage), 0 0 0 4px var(--accent); }
.status { margin: 0 0 0 auto; font: 400 12.5px/1.4 var(--font-mono); color: var(--muted); min-width: 0; }
.status.error { color: var(--accent); }

.empty {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  max-width: 26rem; padding: 32px 24px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.empty svg { width: 120px; height: 60px; color: var(--accent); }
.empty-title { margin: 0; font: 700 28px/1.05 var(--font-display); text-transform: uppercase; letter-spacing: .03em; color: var(--ink); }
.empty-text { margin: 0; font-size: 14px; line-height: 1.5; }
.stage-view { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.sheet { display: grid; place-items: center; width: 100%; height: 100%; }
.sheet canvas {
  max-width: 100%; max-height: 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 10px 30px rgba(0,0,0,.14);
  background: var(--panel);
}
.sheet.transparent canvas {
  background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 18px 18px;
}
/* light-ink designs are previewed on a dark checkerboard so white artwork stays visible */
.sheet.transparent.dark-ink canvas {
  background: repeating-conic-gradient(#26302C 0 25%, #2E3934 0 50%) 0 0 / 18px 18px;
}
.tee { position: absolute; inset: 24px; }
.tee-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 12px 24px rgba(0,0,0,.18)); }

@media (max-width: 820px) {
  body { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .stage { order: -1; }
  .stage-view { height: 70vh; padding: 16px; }
  .panel { border-right: 0; overflow: visible; padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .stage-bar { padding-left: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
