:root {
  --bg: #121315; --panel: #18191c; --panel-2: #202125; --panel-3: #2a2b30; --line: #2a2c31;
  --ink: #ecebe6; --ink-2: #a5a49e; --ink-3: #6e6d69;
  --accent: #e8d35c; --accent-ink: #1b1a14;
  --canvas: #16171a; --dot: #2b2d33; --seam: rgba(255,255,255,.62); --grain: rgba(255,255,255,.22);
  --font: "Instrument Sans", system-ui, sans-serif;
  --r: 8px;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); overflow: hidden; display: grid; grid-template-rows: 52px 1fr; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { opacity: .35; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* top bar */
.top { display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; letter-spacing: -.01em; margin-right: 6px; }
.garment { display: flex; align-items: center; gap: 10px; padding: 5px 10px; border-radius: var(--r); text-align: left; }
.garment:hover { background: var(--panel-2); }
.garment b { display: block; font-weight: 600; font-size: 13px; line-height: 1.2; }
.garment small { display: block; color: var(--ink-2); font-size: 12px; line-height: 1.2; }
.seg { display: flex; background: var(--bg); border-radius: var(--r); padding: 3px; gap: 2px; }
.top .seg { margin: 0 auto; }
.seg button { padding: 5px 12px; border-radius: 6px; color: var(--ink-2); font-weight: 500; font-size: 13px; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--ink); }
.seg.small button { padding: 3px 10px; font-size: 12px; }
.tools-r { display: flex; align-items: center; gap: 6px; }
.note { color: var(--ink-3); font-size: 12px; margin: 0 6px; white-space: nowrap; }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.ic { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; color: var(--ink-2); transition: background .15s, color .15s; }
.ic:hover:not(:disabled) { background: var(--panel-2); color: var(--ink); }
.btn { padding: 7px 12px; border-radius: 6px; background: var(--panel-2); font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; justify-content: center; transition: background .15s, transform .1s; }
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #f2de6c; }
.btn.ghost { background: none; }
.btn.big { padding: 10px 14px; }
.menuwrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); width: 270px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 20; box-shadow: 0 16px 40px rgba(0,0,0,.45); }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--panel-3); }
.menu b { display: block; font-weight: 600; font-size: 13px; }
.menu small { color: var(--ink-2); font-size: 12px; }

/* work area */
main { display: grid; grid-template-columns: 1fr 1fr 300px; min-height: 0; }
body[data-view="pattern"] main { grid-template-columns: 1fr 0 300px; }
body[data-view="3d"] main { grid-template-columns: 0 1fr 300px; }
body[data-view="pattern"] .pane-3d, body[data-view="3d"] .pane-pattern { visibility: hidden; }
main.drop .pane { box-shadow: inset 0 0 0 2px var(--accent); }
.pane { position: relative; display: grid; grid-template-rows: 44px 1fr; min-width: 0; min-height: 0; overflow: hidden; }
.pane-pattern { border-right: 1px solid var(--line); }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.phead h2 { font-size: 13px; font-weight: 600; }
.phead h2 small { color: var(--ink-2); font-weight: 400; margin-left: 6px; font-size: 13px; }
.canvaswrap { position: relative; min-height: 0; }
#pattern { position: absolute; inset: 0; display: block; touch-action: none; }
.rail { position: absolute; left: 34px; top: 16px; display: flex; flex-direction: column; gap: 2px; background: var(--panel); border-radius: 10px; padding: 4px; }
.rail button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; color: var(--ink-2); transition: background .15s, color .15s; }
.rail button:hover { color: var(--ink); background: var(--panel-2); }
.rail button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.zoombar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; background: var(--panel); border-radius: 10px; padding: 4px; }
.zoombar output { width: 52px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
#stage { position: relative; min-height: 0; }
#stage canvas { display: block; touch-action: none; }
.hint { position: absolute; left: 14px; bottom: 12px; font-size: 12px; color: rgba(255,255,255,.85); background: rgba(0,0,0,.38); padding: 4px 9px; border-radius: 6px; pointer-events: none; }

/* right panel */
.panel { background: var(--panel); border-left: 1px solid var(--line); display: grid; grid-template-rows: 44px 1fr; min-height: 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.tabs button { color: var(--ink-2); font-weight: 500; font-size: 13px; }
.tabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px var(--accent); }
#panelBody { overflow: auto; padding: 4px 16px 24px; }
.group { padding: 16px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; }
.group h3 small { color: var(--ink-2); font-weight: 400; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty { color: var(--ink-2); font-size: 13px; margin-top: 12px; }
.layers { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 2px; }
.layer { display: grid; grid-template-columns: 26px 36px 1fr 26px 26px; align-items: center; gap: 6px; padding: 5px 4px; border-radius: 7px; cursor: pointer; }
.layer:hover { background: var(--panel-2); }
.layer.on { background: var(--panel-3); }
.layer .eye, .layer .ic { width: 26px; height: 26px; color: var(--ink-3); display: grid; place-items: center; border-radius: 5px; }
.layer .eye:hover, .layer .ic:hover { color: var(--ink); }
.thumb { width: 36px; height: 36px; border-radius: 5px; background: #fff center/contain no-repeat; display: grid; place-items: center; font-size: 15px; }
.lname { min-width: 0; }
.lname b { display: block; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lname small { color: var(--ink-2); font-size: 11.5px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field span { color: var(--ink-2); font-size: 12px; }
.field input, .field textarea, .field select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; }
.field textarea { resize: vertical; }
.field input[type=color] { height: 36px; padding: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sw { aspect-ratio: 1; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: transform .12s; position: relative; }
.sw:hover { transform: scale(1.08); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.sw.pick { display: grid; place-items: center; background: var(--panel-2); color: var(--ink-2); cursor: pointer; }
.sw.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.slider { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; color: var(--ink-2); }
.slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
input[type=range] { accent-color: var(--accent); width: 100%; }
.toggle { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; }
.toggle i { width: 34px; height: 20px; border-radius: 10px; background: var(--panel-3); position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(14px); background: var(--accent-ink); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme { display: grid; gap: 6px; text-align: left; font-size: 12px; color: var(--ink-2); padding: 4px; border-radius: 8px; }
.theme:hover { background: var(--panel-2); }
.theme.on { color: var(--ink); box-shadow: inset 0 0 0 2px var(--accent); }
.tprev { aspect-ratio: 4/3; border-radius: 5px; background: center/cover; }

/* launchpad */
.launchpad { position: fixed; inset: 0; background: rgba(8,8,10,.72); display: grid; place-items: center; z-index: 50; padding: 24px; }
.lp { width: min(1240px, 100%); height: min(780px, 100%); background: var(--panel); border-radius: 14px; display: grid; grid-template-columns: 1fr 1.05fr; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.lp-left { display: grid; grid-template-rows: auto auto 1fr; min-height: 0; padding: 22px 22px 0; }
.lp-head { display: flex; justify-content: space-between; align-items: center; }
.lp-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.015em; }
.lp-themes { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0; }
.chip { display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 5px; border-radius: 999px; background: var(--panel-2); font-size: 12.5px; color: var(--ink-2); }
.chip i { width: 20px; height: 20px; border-radius: 50%; background: center/cover; }
.chip.on { background: var(--ink); color: var(--bg); }
.lp-grid { overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding-bottom: 22px; align-content: start; }
.card { text-align: left; border-radius: 10px; padding: 6px; transition: background .15s; }
.card:hover { background: var(--panel-2); }
.card[aria-pressed="true"] { background: var(--panel-3); box-shadow: inset 0 0 0 2px var(--accent); }
.shot { display: block; aspect-ratio: 1; border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.card:hover .shot img { transform: scale(1.03); }
.cname { display: block; font-weight: 600; margin-top: 8px; font-size: 13.5px; }
.ccut { display: block; color: var(--ink-2); font-size: 12.5px; }
.lp-right { position: relative; background: var(--panel-2); min-height: 0; }
#lpPreview { width: 100%; height: 100%; object-fit: cover; display: block; }
.lp-foot { position: absolute; left: 18px; right: 18px; bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: rgba(18,19,21,.86); padding: 12px 12px 12px 16px; border-radius: 12px; }
.lp-foot b { display: block; font-size: 15px; }
.lp-foot span { color: var(--ink-2); font-size: 13px; }

@media (max-width: 900px) {
  body { overflow: auto; grid-template-rows: auto auto; }
  .top { flex-wrap: wrap; padding: 8px 12px; height: auto; }
  .top .seg { margin: 0; }
  .note { display: none; }
  main, body[data-view] main { grid-template-columns: 1fr; grid-template-rows: 60vh 60vh auto; }
  body[data-view] .pane { visibility: visible; }
  .pane-pattern { border-right: 0; border-bottom: 1px solid var(--line); }
  .lp { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
  .lp-right { order: -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
