/* Skritch — iOS/macOS system look: grouped lists, system font, one accent. */
:root {
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --card: #ffffff;          /* secondarySystemGroupedBackground */
  --label: #000000;
  --label2: rgba(60, 60, 67, 0.6);
  --sep: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.16);
  --accent: #c2410c;        /* one warm accent for the one action that matters */
  --accent-ink: #ffffff;
  --fabric: #ebe8e1;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, 0.6);
    --sep: rgba(84, 84, 88, 0.65); --fill: rgba(118, 118, 128, 0.24); --accent: #f97316; --accent-ink: #000; --fabric: #2a2926;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --label: #ffffff; --label2: rgba(235, 235, 245, 0.6);
  --sep: rgba(84, 84, 88, 0.65); --fill: rgba(118, 118, 128, 0.24); --accent: #f97316; --accent-ink: #000; --fabric: #2a2926;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--label);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: 0.35; cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--sep);
}
.bar h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.2px; }
.bar-actions { display: flex; gap: 8px; align-items: center; }

.filled { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 10px; padding: 8px 16px; min-height: 36px; }
.filled.large { font-size: 17px; padding: 14px 28px; border-radius: 14px; min-height: 50px; }
.plain { color: var(--accent); padding: 8px 6px; min-height: 36px; }

main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 32px; display: grid; gap: 16px; }

.stage { min-width: 0; }
.empty {
  min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  border: 2px dashed var(--sep); border-radius: 20px; text-align: center; padding: 24px; color: var(--label2);
}
.empty.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.empty-art { width: 140px; color: var(--accent); opacity: 0.9; }
.hint { color: var(--label2); font-size: 15px; margin: 0; }
.group-head .hint { font-size: 13px; }

.viewer { display: grid; gap: 10px; }
.canvas-wrap { position: relative; background: var(--fabric); border-radius: var(--radius); overflow: hidden; aspect-ratio: 1 / 1; max-height: 70vh; width: 100%; }
#canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; }
.busy { position: absolute; left: 0; top: 0; height: 3px; width: 100%; overflow: hidden; }
.busy::after { content: ""; position: absolute; inset: 0; width: 30%; background: var(--accent); animation: slide 0.9s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .busy::after { animation: none; width: 100%; opacity: 0.5; } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 9px; padding: 2px; }
.seg button { padding: 6px 8px; border-radius: 7px; font-size: 14px; font-weight: 500; min-height: 32px; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); font-weight: 600; }
.stats { margin: 0; text-align: center; color: var(--label2); font-size: 14px; font-variant-numeric: tabular-nums; min-height: 1.3em; }

.controls { display: grid; gap: 16px; align-content: start; }
.group { background: var(--card); border-radius: var(--radius); padding: 12px 16px 14px; display: grid; gap: 6px; }
.group h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.2px; color: var(--label2); margin: 0; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.row label, .row span { font-size: 17px; }
.row output { color: var(--label2); font-variant-numeric: tabular-nums; }
.row.sub { margin-top: 2px; }
.ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--label2); margin-top: -2px; }
.note { margin: 2px 0 0; font-size: 13px; color: var(--label2); }
.note.warn { color: #d70015; }

input[type="range"] { width: 100%; margin: 6px 0; accent-color: var(--accent); height: 28px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--fill); font-size: 14px; min-height: 36px; }
.chip .sw { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); flex: none; }
.chip[aria-pressed="false"] { opacity: 0.45; }
.chip[aria-pressed="false"] .sw { background-image: linear-gradient(135deg, transparent 45%, var(--label2) 45%, var(--label2) 55%, transparent 55%) !important; }
.chip small { color: var(--label2); }
.hoops { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { font-size: 14px; color: var(--accent); background: var(--fill); padding: 6px 12px; border-radius: 999px; min-height: 32px; }

.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desktop-only { display: inline; } }

/* Mac / iPad: preview left, controls right */
@media (min-width: 860px) {
  main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; padding-top: 20px; }
  .controls { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
  .canvas-wrap { max-height: calc(100vh - 170px); }
}
