:root {
  --bg: #0b0a09; --surface: #151311; --line: #2b2622; --ink: #f4efe8; --muted: #9b9188;
  --accent: #d8ad62; --accent-ink: #171006; --ok: #9bd0a4; --bad: #f0a08f;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--sans); padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app { width: min(100%, 520px); margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .02em; }

.segmented { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.segmented label, .look, .chip { position: relative; }
.segmented input, .look input, .chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.segmented span { display: grid; place-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.segmented input:checked + span { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span, .look input:focus-visible + .look-card, .chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tt-stage { position: relative; width: min(100%, calc((100vh - 370px) * 9 / 16)); min-width: 220px; aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border-radius: 18px; background: var(--surface); touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
@supports (height: 100svh) { .tt-stage { width: min(100%, calc((100svh - 370px) * 9 / 16)); } }
.tt-stage.tt-dragging { cursor: grabbing; }
.tt-stage.tt-empty { cursor: default; }
.tt-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tt-msg { position: absolute; inset: 0; display: grid; place-content: center; margin: 0; padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
.tt-msg:empty { display: none; }
.tt-bar-progress { position: absolute; left: 0; bottom: 0; width: var(--tt-p, 0%); height: 2px; background: var(--accent); opacity: 0; transition: opacity .3s; }
.tt-stage.tt-loading .tt-bar-progress { opacity: 1; }
.tt-bar { display: flex; justify-content: center; gap: 10px; margin: 8px 0 16px; }
.tt-btn { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); font-size: 19px; line-height: 1; cursor: pointer; }
.tt-btn[disabled] { opacity: .35; cursor: default; }
.tt-note { margin: -8px 0 14px; color: var(--muted); font-size: 12px; text-align: center; }
.tt-note:empty { display: none; }

fieldset { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
legend { margin-bottom: 8px; padding: 0; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; }
.looks, .chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.looks::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.look { flex: 0 0 auto; }
.look-card { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 74px; padding: 8px 5px; border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.look input:checked + .look-card { border-color: var(--accent); background: var(--surface); }
.look-text { display: block; width: 64px; overflow: hidden; text-align: center; }
.look-name { display: block; overflow: hidden; font-size: 11px; line-height: 1.2; white-space: nowrap; text-overflow: ellipsis; }
.look-detail { display: none; }
.swatch { flex: none; width: 36px; height: 46px; display: grid; grid-template-rows: 1fr 1fr; overflow: hidden; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; }
.swatch > span { position: relative; background: var(--c); }
.sw-one { grid-row: 1 / -1; }
.sw-inner { position: absolute; left: 50%; top: 0; width: 12px; height: 70%; transform: translateX(-50%); background: var(--c); clip-path: polygon(0 0,100% 0,50% 100%); }

.shoes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.shoe-group { min-width: 0; }
.shoe-type { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.chip > span { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px 0 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.chip input:checked + span { border-color: var(--accent); background: var(--surface); }
.dot { width: 16px; height: 16px; flex: none; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; background: var(--c); }

.result { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent); }
.ticket { width: min(100%, 520px); margin: 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 9px 9px 14px; border: 1px solid var(--line); border-radius: 18px; background: #11100e; box-shadow: 0 -12px 40px rgba(0,0,0,.45); }
.code { color: var(--accent); font: 750 clamp(22px, 7vw, 28px)/1.1 var(--mono); letter-spacing: .07em; white-space: nowrap; user-select: all; }
.copy { min-height: 42px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 750; cursor: pointer; }
.summary { grid-column: 1 / -1; margin: 0; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.hint { grid-column: 1 / -1; margin: 0; color: var(--ink); font-size: 12px; }
.toast { grid-column: 1 / -1; margin: 0; color: var(--ok); font-size: 12px; }
.toast:empty { display: none; }
.noscript { color: var(--bad); text-align: center; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { .look input:checked + .look-card, .chip input:checked + span, .segmented input:checked + span { outline: 3px solid Highlight; } }
