/* Chronic Dunks — Design Studio.
   Layout: dark top bar · tool rail · tool panel · the shirt · selected item + price.
   On phones the rail becomes bottom tabs and the panel a bottom sheet. */
:root {
  --cds-ink: #121212;
  --cds-ink-2: #444444;
  --cds-ink-3: #5c5c57;
  --cds-paper: #FFFFFF;
  --cds-stage: #F2F2EE;
  --cds-line: #E4E4DF;
  --cds-line-2: #C9C9C2;
  --cds-accent: #FF5A1F;
  --cds-sel: #3EC7F0;
  --cds-ok: #1F6A2E;
  --cds-warn: #A2390E;
  --cds-mpesa: #1F7A33;
  --cds-display: Anton, Impact, "Arial Narrow", sans-serif;
  --cds-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.cds { margin: 0; background: var(--cds-stage); color: var(--cds-ink); font: 15px/1.5 var(--cds-body);
  display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--cds-accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.cds-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── top bar ───────────────────────────────────────────────────────────── */
.cds-top { flex: 0 0 auto; display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  background: var(--cds-ink); color: #fff; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.cds-logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.cds-logo span { font-family: var(--cds-display); font-size: 22px; letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; }
.cds-name { min-width: 0; flex: 0 1 240px; min-height: 40px; background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 0 10px; color: #fff; font-weight: 500; }
.cds-name:hover, .cds-name:focus { border-color: #4A4A45; }
.cds-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cds-icon { width: 44px; height: 44px; border-radius: 10px; border: 1px solid #3A3A36; background: transparent; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.cds-icon svg { width: 20px; height: 20px; }
.cds-icon:disabled { opacity: .35; cursor: default; }
.cds-icon-light { color: var(--cds-ink); border-color: var(--cds-line-2); }
.cds-price-pill { font-weight: 700; font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }

/* ── buttons ───────────────────────────────────────────────────────────── */
.cds-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--cds-line-2); background: #fff; color: var(--cds-ink); font-weight: 700;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.cds-btn:hover { background: #F7F7F4; }
.cds-btn:disabled { opacity: .5; cursor: default; }
.cds-btn-accent { background: var(--cds-accent); border-color: var(--cds-accent); color: var(--cds-ink); }
.cds-btn-accent:hover { background: var(--cds-accent); filter: brightness(.95); }
.cds-btn-dark { background: var(--cds-ink); border-color: var(--cds-ink); color: #fff; }
.cds-btn-dark:hover { background: #000; }
.cds-btn-mpesa { background: var(--cds-mpesa); border-color: var(--cds-mpesa); color: #fff; flex: 1 1 220px; }
.cds-btn-mpesa:hover { background: #17612A; }
.cds-btn-small { min-height: 38px; padding: 0 12px; font-size: 13px; }
.cds-btn-danger { color: #B3261E; }
.cds-wide { width: 100%; }

/* ── main layout ───────────────────────────────────────────────────────── */
.cds-main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 84px 0 minmax(0, 1fr) 320px; }
body.cds-panel-open .cds-main { grid-template-columns: 84px 330px minmax(0, 1fr) 320px; }

.cds-rail { background: #fff; border-right: 1px solid var(--cds-line); padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.cds-rail button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; min-height: 64px;
  border: 0; border-radius: 12px; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.cds-rail button svg { width: 22px; height: 22px; }
.cds-rail button:hover { background: var(--cds-stage); }
.cds-rail button[aria-pressed="true"] { background: var(--cds-accent); }

.cds-panel { background: #fff; border-right: 1px solid var(--cds-line); overflow-y: auto; position: relative; min-width: 0; }
.cds-panel section { padding: 22px 20px 28px; display: flex; flex-direction: column; gap: 12px; }
.cds-panel h2, .cds-props h2 { margin: 0; font-family: var(--cds-display); font-weight: 400; text-transform: uppercase; font-size: 28px; line-height: 1; letter-spacing: .3px; }
.cds-panel-close { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: none; }
.cds-panel-close svg { width: 20px; height: 20px; }
.cds-hint { margin: 0; font-size: 14px; color: var(--cds-ink-3); }
.cds-label { font-size: 13px; font-weight: 700; }
.cds-input { width: 100%; min-height: 44px; border: 1px solid var(--cds-line-2); border-radius: 12px; padding: 10px 12px; background: #fff; }
textarea.cds-input { resize: vertical; line-height: 1.45; }
.cds-input.cds-bad { border-color: #B3261E; box-shadow: 0 0 0 3px rgba(179,38,30,.15); }
.cds-row { display: flex; gap: 8px; }
.cds-row .cds-input { flex: 1 1 auto; min-width: 0; }
.cds-msg { margin: 0; font-size: 13px; min-height: 1em; }
.cds-msg-ok { color: var(--cds-ok); }
.cds-msg-warn { color: var(--cds-warn); }
.cds-msg-info { color: var(--cds-ink-2); }
.cds-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cds-chips button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--cds-line-2); background: #fff; font-size: 13px; font-weight: 600; cursor: pointer; }
.cds-chips button[aria-pressed="true"] { background: var(--cds-ink); border-color: var(--cds-ink); color: #fff; }

.cds-tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cds-tpl { display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 8px; border-radius: 14px; border: 1px solid var(--cds-line);
  background: var(--cds-stage); cursor: pointer; text-align: center; font-size: 12px; font-weight: 700; }
.cds-tpl img { width: 100%; height: auto; display: block; }
.cds-tpl:hover { border-color: var(--cds-ink); }
.cds-tpl.on { border: 2px solid var(--cds-ink); }

.cds-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 16px; border-radius: 16px;
  border: 2px dashed var(--cds-line-2); background: var(--cds-stage); cursor: pointer; }
.cds-drop svg { width: 30px; height: 30px; }
.cds-drop span { font-size: 13px; color: var(--cds-ink-3); }
.cds-drop.over { border-color: var(--cds-accent); background: #FFF1EA; }

.cds-result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.cds-result { aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--cds-line); background: #fff center/cover no-repeat; cursor: pointer; }
.cds-result.on { outline: 3px solid var(--cds-accent); }
.cds-result.dead { opacity: .3; }
.cds-pager { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.cds-pager button { min-width: 36px; min-height: 36px; border-radius: 8px; border: 1px solid var(--cds-line-2); background: #fff; cursor: pointer; }
.cds-pager button[aria-current="page"] { background: var(--cds-ink); color: #fff; }

.cds-layer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cds-layer { width: 100%; text-align: left; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--cds-line); background: #fff; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cds-layer.on { border: 2px solid var(--cds-ink); }

/* ── stage ─────────────────────────────────────────────────────────────── */
.cds-stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.cds-stage-top { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: center; }
.cds-seg { display: inline-flex; background: #fff; border: 1px solid var(--cds-line); border-radius: 999px; padding: 3px; flex-wrap: wrap; justify-content: center; }
.cds-seg button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; font-size: 14px; cursor: pointer; }
.cds-seg button[aria-pressed="true"] { background: var(--cds-ink); color: #fff; }
.cds-size-read { font-size: 13px; color: var(--cds-ink-3); font-variant-numeric: tabular-nums; }
.cds-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; background: var(--cds-ink); color: #fff; border-radius: 14px; padding: 8px 8px 8px 16px; font-size: 14px; }
.cds-banner span { flex: 1 1 220px; }
.cds-banner .cds-btn { min-height: 38px; }
.cds-banner-ask { background: #fff; color: var(--cds-ink); border: 2px solid var(--cds-ink); }
.cds-x { width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; color: inherit; font-size: 16px; cursor: pointer; }
.cds-canvas-wrap { flex: 1 1 auto; min-height: 260px; display: flex; align-items: center; justify-content: center; position: relative; }
#cdsCanvas { display: block; border-radius: 20px; background: #fff; box-shadow: 0 1px 0 var(--cds-line), 0 10px 30px rgba(0,0,0,.06); }
.cds-under { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: center; }
.cds-swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cds-sw { width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); cursor: pointer; }
.cds-sw[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cds-ink); }
.cds-colour-name { font-size: 13px; font-weight: 700; min-width: 70px; }

/* ── right column ──────────────────────────────────────────────────────── */
.cds-props { background: #fff; border-left: 1px solid var(--cds-line); overflow-y: auto; display: flex; flex-direction: column; }
.cds-props section { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.cds-edit { border-bottom: 1px solid var(--cds-line); }
.cds-empty { border-bottom: 1px solid var(--cds-line); }
.cds-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.cds-acts { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.cds-range { width: 100%; accent-color: var(--cds-ink); }
.cds-inks { display: flex; flex-wrap: wrap; gap: 6px; }
.cds-ink { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0,0,0,.25); cursor: pointer; padding: 0; }
.cds-ink[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cds-ink); }
.cds-ink-custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.cds-order { margin-top: auto; }
.cds-breakdown { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.cds-breakdown dt { color: var(--cds-ink-2); }
.cds-breakdown dd { margin: 0; text-align: right; font-weight: 600; }
.cds-breakdown .cds-total { color: var(--cds-ink); font-weight: 800; font-size: 16px; border-top: 1px solid var(--cds-line); padding-top: 8px; }
.cds-breakdown .cds-note { grid-column: 1 / -1; text-align: left; font-weight: 500; color: var(--cds-ok); font-size: 13px; }

/* ── checkout ──────────────────────────────────────────────────────────── */
.cds-modal { position: fixed; inset: 0; z-index: 50; background: rgba(18,18,18,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.cds-modal-card { width: min(560px, 100%); max-height: calc(100vh - 32px); background: #fff; border-radius: 22px; display: flex; flex-direction: column; overflow: hidden; }
.cds-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.cds-modal-head h2 { margin: 0; font-family: var(--cds-display); font-weight: 400; text-transform: uppercase; font-size: 28px; }
.cds-modal-body { padding: 4px 22px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.cds-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 700; color: var(--cds-ink-3); }
.cds-steps li { padding: 6px 12px; border-radius: 999px; background: var(--cds-stage); }
.cds-steps li.now { background: var(--cds-ink); color: #fff; }
.cds-steps li.done { color: var(--cds-ok); }
.cds-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cds-size-row { display: grid; grid-template-columns: 40px 40px 1fr 40px; align-items: center; gap: 4px; border: 1px solid var(--cds-line); border-radius: 12px; padding: 6px; }
.cds-size-row b { text-align: center; }
.cds-step { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--cds-line-2); background: #fff; font-size: 18px; cursor: pointer; }
.cds-qty { width: 100%; min-width: 0; height: 40px; text-align: center; border: 1px solid var(--cds-line-2); border-radius: 10px; font-weight: 700; }
.cds-form { display: flex; flex-direction: column; gap: 12px; }
.cds-field { display: flex; flex-direction: column; gap: 4px; }
.cds-del { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cds-del legend { font-weight: 800; margin-bottom: 4px; }
.cds-del-opt { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--cds-line-2); border-radius: 12px; cursor: pointer; }
.cds-del-opt:has(input:checked) { border: 2px solid var(--cds-ink); }
.cds-del-opt input { width: 18px; height: 18px; accent-color: var(--cds-ink); }
.cds-del-opt span { display: flex; flex-direction: column; min-width: 0; }
.cds-del-opt small { color: var(--cds-ink-3); }
.cds-del-opt em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.cds-paying { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 18px 0 6px; }
.cds-paying h3 { margin: 0; font-family: var(--cds-display); font-weight: 400; text-transform: uppercase; font-size: 30px; }
.cds-paying p { margin: 0; color: var(--cds-ink-2); max-width: 40ch; }
.cds-spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--cds-line); border-top-color: var(--cds-accent); animation: cds-spin 1s linear infinite; }
@keyframes cds-spin { to { transform: rotate(360deg); } }

/* ── phones ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body.cds { overflow: auto; height: auto; min-height: 100%; }
  .cds-logo span { display: none; }
  .cds-top { flex-wrap: nowrap; gap: 8px; padding-left: 12px; padding-right: 12px; }
  .cds-name { flex: 1 1 auto; width: 0; min-width: 0; padding: 0 6px; }
  .cds-top-actions { gap: 6px; }
  #cdsRedo { display: none; }
  .cds-price-pill { font-size: 14px; padding: 0; }
  #cdsCheckoutBtn { display: none; }
  .cds-main, body.cds-panel-open .cds-main { display: flex; flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .cds-stage { padding: 10px 12px; }
  .cds-canvas-wrap { min-height: 0; height: min(118vw, 62vh); }
  .cds-rail { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-direction: row; justify-content: space-around; border: 0;
    border-top: 1px solid var(--cds-line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); overflow: visible; }
  .cds-rail button { flex: 1 1 0; min-height: 56px; padding: 6px 0; font-size: 11px; }
  .cds-panel { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); z-index: 25; max-height: 62vh;
    border: 0; border-top: 1px solid var(--cds-line); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.15); display: none; }
  body.cds-panel-open .cds-panel { display: block; }
  .cds-panel-close { display: inline-flex; align-items: center; justify-content: center; }
  .cds-panel section { padding: 18px 16px 22px; }
  .cds-props { border: 0; border-top: 1px solid var(--cds-line); }
  .cds-props section { padding: 16px; }
  .cds-order { margin-top: 0; }
  .cds-modal { padding: 0; align-items: flex-end; }
  .cds-modal-card { border-radius: 20px 20px 0 0; max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) { .cds-spinner { animation: none; } }
