/* Theme: dark charcoal dashboard with teal + orange glow accents. */
:root {
  --bg: #131619;
  --bg-deep: #0e1013;
  --panel: #1a1e22;
  --panel-2: #22272c;
  --panel-3: #2b3137;
  --line: #2a3036;
  --line-2: #363e45;
  --text: #e6ecef;
  --muted: #8e99a2;
  --accent: #2ee6d6;
  --accent-strong: #19cbbd;
  --accent-soft: rgba(46,230,214, 0.13);
  --accent-2: #8ff5ec;
  --on-accent: #052421;
  --orange: #ff9f43;
  --orange-soft: rgba(255,159,67, 0.14);
  --fabric: #ff9f43;
  --fabric-soft: rgba(255,159,67, 0.14);
  --ok: #3ad69a;
  --warn: #ffb547;
  --danger: #ff5f6d;
  --radius: 8px;
  --card-radius: 16px;
  --card-bg: linear-gradient(180deg, #23292e 0%, #1c2125 100%);
  --card-border: rgba(255,255,255,.06);
  --card-shadow: 0 12px 30px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
  --glow: 0 0 0 1px rgba(46,230,214,.35), 0 0 18px rgba(46,230,214,.35);
  --glow-orange: 0 0 0 1px rgba(255,159,67,.4), 0 0 18px rgba(255,159,67,.35);
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tag { display: inline-block; font-size: 10.5px; padding: 1px 6px; border-radius: 99px; background: var(--fabric-soft); color: var(--fabric); margin-left: 6px; font-weight: 600; vertical-align: middle; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: #444b59; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: #5cefe2; }
.btn.primary.glow { box-shadow: 0 0 16px rgba(46,230,214,.35); border-radius: 99px; padding: 0 16px; }
.btn.wide { width: 100%; justify-content: center; }
.btn.accent-ghost { border-color: rgba(46,230,214,.45); color: var(--accent-2); background: var(--accent-soft); }
.btn.accent-ghost:hover:not(:disabled) { background: rgba(46,230,214,.2); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); background: rgba(239, 91, 107, 0.1); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.tiny { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn.teach { width: 100%; justify-content: center; background: linear-gradient(90deg, rgba(46,230,214,.18), rgba(255,159,67,.18)); border-color: #2c4a48; font-weight: 600; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text);
}
.icon-btn:hover:not(:disabled) { background: var(--panel-3); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.tiny { width: 22px; height: 22px; border-radius: 5px; color: var(--muted); }
.btn-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.btn-row.wrap { flex-wrap: wrap; }
.btn-row.tight { gap: 0; }
input[type="text"], input[type="number"], select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; line-height: 1.5; }
input[type="color"] { width: 34px; height: 28px; padding: 2px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer; }
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.field-hint { font-size: 11px; color: var(--muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.snapshot { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 11.5px; max-height: 220px; overflow: auto; white-space: pre-wrap; color: #b9c2d3; margin: 0; }

/* ---------- app pages ---------- */
.page { min-height: 100%; display: flex; flex-direction: column; }
.app-header { display: flex; align-items: center; gap: 22px; padding: 0 24px; height: 56px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 14px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2ee6d6, #ff9f43); color: var(--on-accent); }
.nav { display: flex; gap: 4px; }
.nav a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 7px; color: var(--muted); text-decoration: none; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-2); }
.page-main { padding: 28px 24px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }
.hero { margin-bottom: 26px; }
.hero h1 { font-size: 26px; margin-bottom: 6px; }
.hero p { max-width: 760px; margin: 0; }
.hero.row { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.section-title { font-size: 15px; margin: 26px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-align: left; }
.card.pad { padding: 16px; overflow: visible; }
.new-card { cursor: pointer; padding: 0; display: flex; flex-direction: column; }
.new-card:hover:not(.disabled) { border-color: var(--accent); }
.new-card.disabled { opacity: 0.6; cursor: default; }
.thumb { display: block; width: 100%; height: 170px; background: var(--panel-2); }
.thumb.blank { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-weight: 650; font-size: 14px; }
.design-card .btn-row { margin-top: 8px; }
.card-open { display: block; padding: 0; border: 0; background: none; cursor: pointer; width: 100%; }

/* ---------- editor layout ----------
   [rail] [chat] [resizer] [stage: work (tiles / design / player) + side]
   The chat stays on the left at every width; below 1000 px the side panel moves under the design.   */
.editor {
  --rail-w: 60px; --chat-w: 320px; --side-w: 316px;
  height: 100vh; display: grid;
  grid-template-columns: var(--rail-w) clamp(220px, var(--chat-w), 42vw) 6px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas: "rail top top top" "rail chat rz stage";
  background: radial-gradient(1100px 520px at 62% -12%, rgba(46,230,214,.07), transparent 60%), var(--bg);
}
.stage { grid-area: stage; display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); min-width: 0; min-height: 0; }
.editor.mode-adv { --side-w: 340px; }
.editor.mode-ai [data-adv] { display: none !important; }
.editor.mode-adv [data-ai] { display: none !important; }

/* icon rail */
.rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 14px; background: var(--bg-deep); border-right: 1px solid var(--line); min-height: 0; }
.rail-brand {
  width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
  color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--orange)); box-shadow: 0 0 18px rgba(46,230,214,.35);
}
.rail-group { display: flex; flex-direction: column; gap: 6px; }
.rail-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: color .15s, background .15s, box-shadow .15s;
}
.rail-btn:hover, .rail-btn.open { color: var(--accent); background: var(--panel-2); border-color: var(--line-2); }
.rail-btn.open { box-shadow: var(--glow); }
.rail-btn[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge); position: absolute; top: 1px; right: 0; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 99px;
  background: var(--orange); color: #2a1600; font-size: 9.5px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}

/* top bar */
.topbar {
  grid-area: top; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 0 14px 0 12px; border-bottom: 1px solid var(--line); background: rgba(14,16,19,.55); min-width: 0;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-right { justify-content: flex-end; }
.tb-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; flex: none; }
.design-name { width: 220px !important; background: transparent !important; border-color: transparent !important; font-weight: 650; font-size: 14px; }
.design-name:hover, .design-name:focus { border-color: var(--line-2) !important; background: var(--bg) !important; }
.fabric-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border-radius: 99px; cursor: pointer; min-width: 0; white-space: nowrap;
  border: 1px solid rgba(255,159,67,.45); background: var(--fabric-soft); color: var(--fabric); font-weight: 600; font-size: 12px;
}
.fabric-chip:hover { background: rgba(255,159,67,.24); }
.chip-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4); }
.mode-switch { display: inline-flex; padding: 4px; border-radius: 99px; background: var(--bg-deep); border: 1px solid var(--line-2); box-shadow: inset 0 1px 4px rgba(0,0,0,.55); }
.mode-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 18px; border-radius: 99px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; font-weight: 650; font-size: 13px; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active:first-child { background: linear-gradient(180deg, #4af1e3, var(--accent-strong)); color: var(--on-accent); box-shadow: 0 0 18px rgba(46,230,214,.45); }
.mode-btn.active:last-child { background: linear-gradient(180deg, #ffb46a, #f58a2a); color: #2a1600; box-shadow: 0 0 18px rgba(255,159,67,.4); }

/* chat column */
.chat-col { grid-area: chat; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.col-resizer { grid-area: rz; cursor: col-resize; position: relative; touch-action: none; }
.col-resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.col-resizer:hover::after { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.chat-head { display: flex; align-items: center; gap: 9px; height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.chat-head strong { font-size: 13.5px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-orb {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; color: var(--accent);
  background: radial-gradient(circle at 35% 30%, rgba(46,230,214,.38), rgba(46,230,214,.06) 70%);
  box-shadow: 0 0 12px rgba(46,230,214,.3), inset 0 0 0 1px rgba(46,230,214,.5);
}
.ai-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); flex: none; cursor: help; }
.ai-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #5b656e; }
.ai-dot.on { color: var(--ok); }
.ai-dot.on::before { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; scrollbar-width: thin; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }
.msg-meta { display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.msg-undo { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: var(--muted); font-size: 11px; cursor: pointer; }
.msg-undo:hover:not(:disabled) { color: var(--accent-2); }
.msg-undo:disabled { opacity: .45; cursor: default; }
.bubble { padding: 8px 12px; border-radius: 14px; background: var(--panel-2); overflow-wrap: anywhere; line-height: 1.5; }
.msg.assistant .bubble { border-bottom-left-radius: 4px; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; font-weight: 500; }
.bubble-more { margin-top: 4px; }
.bubble-more summary { color: var(--accent-2); font-size: 12px; cursor: pointer; margin: 0; list-style: none; }
.bubble-more summary::-webkit-details-marker { display: none; }
.bubble-more summary::before { content: '▸ '; }
.bubble-more[open] summary::before { content: '▾ '; }
.bubble-more ul { margin: 6px 0 0; padding-left: 16px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #c4cdd4; }
.starters { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.starter { text-align: left; padding: 6px 11px; border-radius: 12px; border: 1px solid var(--line-2); background: transparent; color: var(--accent-2); cursor: pointer; font-size: 12px; }
.starter:hover:not(:disabled) { border-color: rgba(46,230,214,.6); background: var(--accent-soft); }
.starter:disabled { opacity: .45; cursor: not-allowed; }
.switch.small { width: 30px; height: 18px; }
.switch.small .slider::before { width: 12px; height: 12px; }
.switch.small input:checked + .slider::before { transform: translateX(12px); }
.via { font-size: 10.5px; color: var(--muted); }
.bubble.thinking { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .7; } }
.chat-compose { flex: none; display: flex; align-items: flex-end; gap: 8px; margin: 0 12px 12px; padding: 4px 4px 4px 12px; border-radius: 16px; background: var(--bg-deep); border: 1px solid var(--line-2); }
.chat-compose:focus-within { border-color: rgba(46,230,214,.6); box-shadow: 0 0 0 3px rgba(46,230,214,.12); }
.chat-input { border: 0 !important; background: transparent !important; padding: 7px 0 !important; min-height: 34px; height: 34px; max-height: 140px; resize: none; overflow-y: hidden; }
.chat-input:focus-visible { outline: none; }
.send-btn {
  flex: none; width: 34px; height: 34px; border-radius: 12px; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--on-accent); background: var(--accent); box-shadow: 0 0 14px rgba(46,230,214,.4);
}
.send-btn:hover:not(:disabled) { background: #5cefe2; }
.send-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* work area: design in the middle */
.work { display: flex; flex-direction: column; gap: 12px; padding: 12px; min-width: 0; min-height: 0; }
.editor.mode-adv .work { gap: 0; padding: 0; }
.work-top:empty, .work-bottom:empty { display: none; }
.canvas-frame { position: relative; flex: 1; min-height: 160px; display: flex; overflow: hidden; background: #0b0d10; }
.editor.mode-ai .canvas-frame { border-radius: var(--card-radius); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); }
.canvas-host { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.stitch-canvas { display: block; position: absolute; inset: 0; touch-action: none; outline: none; }
.stitch-canvas.layer { pointer-events: none; }
.canvas-toolbar {
  position: absolute; top: 10px; left: 10px; right: 170px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  pointer-events: none;
}
.canvas-toolbar > * { pointer-events: auto; }
.canvas-toolbar .tb-sep { background: rgba(255,255,255,.15); }
.canvas-toolbar .btn.primary { border-radius: 99px; }
.seg { display: inline-flex; background: rgba(14,16,19,.86); border: 1px solid var(--line-2); border-radius: 99px; padding: 2px; backdrop-filter: blur(6px); }
.seg-btn { border: 0; background: transparent; padding: 4px 11px; border-radius: 99px; cursor: pointer; color: var(--muted); font-size: 12px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--panel-3); color: var(--accent-2); box-shadow: inset 0 0 0 1px rgba(46,230,214,.45); }
.tool-toggle {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 99px; cursor: pointer; font-size: 12px;
  background: rgba(14,16,19,.86); border: 1px solid var(--line-2); color: var(--muted); backdrop-filter: blur(6px);
}
.tool-toggle.active { color: #c4faf4; border-color: rgba(46,230,214,.6); background: rgba(16,58,55,.92); }
.zoom-box {
  position: absolute; top: 10px; right: 10px; display: flex; align-items: center; gap: 2px; padding: 2px;
  background: rgba(14,16,19,.86); border: 1px solid var(--line-2); border-radius: 99px; backdrop-filter: blur(6px);
}
.zoom-box .icon-btn { border-radius: 99px; }
.zoom-label { min-width: 46px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.canvas-hint {
  position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: #c3cbd2; background: rgba(14,16,19,.75); padding: 3px 9px; border-radius: 99px; pointer-events: none;
}

/* AI mode: stat tiles above the design */
.work-top { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; flex: none; }
.stat-tile {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; min-width: 0;
  background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow);
}
.tile-ico {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; color: var(--accent);
  background: rgba(46,230,214,.1); box-shadow: inset 0 0 0 1px rgba(46,230,214,.35), 0 0 12px rgba(46,230,214,.2);
}
.stat-tile.orange .tile-ico { color: var(--orange); background: rgba(255,159,67,.1); box-shadow: inset 0 0 0 1px rgba(255,159,67,.4), 0 0 12px rgba(255,159,67,.2); }
.tile-body { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 6px; min-width: 0; }
.tile-label { grid-column: 1 / -1; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
.tile-value { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-shadow: 0 0 12px rgba(46,230,214,.25); }
.stat-tile.orange .tile-value { text-shadow: 0 0 12px rgba(255,159,67,.25); }
.tile-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-unit { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 3px; text-shadow: none; }

/* AI mode: player pill under the design */
.ai-bottom {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 6px 6px; border-radius: 99px;
  background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow);
}
.pill-player { flex: 1; min-width: 0; }
.pill-player .player-range { flex: 1; width: auto; min-width: 60px; }
.play-btn { width: 44px; height: 32px; border-radius: 99px; color: var(--accent); }
.ai-bottom .play-btn { background: linear-gradient(180deg, #ffb46a, #f58a2a); color: #2a1600; box-shadow: 0 0 14px rgba(255,159,67,.4); }
.ai-bottom .play-btn:hover:not(:disabled) { background: linear-gradient(180deg, #ffc285, #ff9a3f); }
.ai-bottom .speed { border-radius: 99px; }

/* Advanced mode: full status bar */
.statusbar { flex: none; height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 12px; background: var(--panel); border-top: 1px solid var(--line); min-width: 0; }
.stats { display: flex; align-items: center; gap: 16px; overflow: hidden; white-space: nowrap; }
.stat { display: inline-flex; gap: 6px; font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 99px; font-weight: 650; white-space: nowrap; }
.badge.ok { background: rgba(58,214,154,.14); color: var(--ok); }
.badge.warn { background: rgba(255,159,67,.16); color: var(--warn); }
.player { display: flex; align-items: center; gap: 6px; flex: none; }
.player-range { width: 220px; accent-color: var(--accent); }
.player-count { min-width: 140px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.speed { width: auto; padding: 3px 6px; }
/* the status bar fits what the design area has room for */
.work { container: work / inline-size; }
@container work (max-width: 1000px) {
  .stats .stat:nth-child(n+4) { display: none; }
  .statusbar .player-range { width: 150px; }
}
@container work (max-width: 720px) {
  .stats .stat:nth-child(n+3) { display: none; }
  .player-count { display: none; }
}

/* right side */
.side { min-height: 0; min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); }
.editor.mode-ai .side { background: transparent; border-left: 0; }
.ai-side { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 20px 0; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.side-tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.side-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; border: 0; border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 650; font-size: 12.5px; white-space: nowrap;
}
.side-tab:hover { color: var(--text); }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: linear-gradient(180deg, transparent, rgba(46,230,214,.08)); }
.adv-panels { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.adv-panels > .panel { min-height: 0; }
.side[data-tab="props"] .panel.seq, .side[data-tab="seq"] .panel.props { display: none; }
.panel { background: var(--panel); overflow-y: auto; overflow-x: hidden; min-height: 0; }
.panel.props { padding-bottom: 24px; }
@media (min-width: 1700px) {
  .editor.mode-adv { --side-w: 610px; }
  .editor.mode-adv .side-tabs { display: none; }
  .editor.mode-adv .adv-panels { grid-template-columns: 270px minmax(0, 1fr); }
  .editor.mode-adv .adv-panels > .panel { display: block !important; }
  .editor.mode-adv .panel.seq { border-right: 1px solid var(--line); }
}

/* AI cards */
.ai-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: none;
}
.ai-card-head { display: flex; align-items: center; gap: 8px; }
.ai-card-ico { width: 24px; height: 24px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--accent); background: var(--accent-soft); }
.ai-card-title { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; font-weight: 750; color: #b8c3cb; }
.check-top { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; align-items: center; }
.check-summary { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.check-summary strong { font-size: 14px; }
.check-summary .btn { margin-top: 7px; }
.dial svg { width: 92px; height: 92px; display: block; overflow: visible; }
.dial .tk { stroke: #39424a; stroke-width: 1.6; }
.dial .tk.on { stroke: var(--accent); }
.dial-track { fill: none; stroke: #2a3137; stroke-width: 9; }
.dial-arc { fill: none; stroke: url(#dialGrad); stroke-width: 9; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(46,230,214,.55)); }
.dial-big { fill: var(--text); font-size: 30px; font-weight: 750; text-anchor: middle; font-family: var(--font); }
.dial-small { fill: var(--muted); font-size: 10.5px; text-anchor: middle; letter-spacing: .06em; font-family: var(--font); text-transform: uppercase; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.check-list li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; column-gap: 8px; font-size: 12px; line-height: 1.35; min-height: 24px; }
.check-dot { width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.check-list li.ok .check-dot { color: var(--on-accent); background: var(--accent); box-shadow: 0 0 8px rgba(46,230,214,.5); }
.check-list li.todo .check-dot { color: #2a1600; background: var(--orange); box-shadow: 0 0 8px rgba(255,159,67,.5); }
.check-list li.ok .check-label { color: #c2ccd3; }
.fabric-pick {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--bg-deep); cursor: pointer; text-align: left; color: var(--text);
}
.fabric-pick:hover { border-color: rgba(255,159,67,.6); box-shadow: var(--glow-orange); }
.fabric-dot { width: 34px; height: 34px; border-radius: 50%; flex: none; border: 2px solid rgba(255,159,67,.75); box-shadow: 0 0 12px rgba(255,159,67,.35); }
.fabric-pick-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fabric-pick-body .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.garment-swatch.sm { width: 22px; height: 22px; border-radius: 50%; }
.inline-field { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 8px; color: var(--muted); }
.inline-field select { padding: 5px 8px; border-radius: 9px; }
.adj-target { margin: -4px 0 0; }
.adj-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.adj-label { font-size: 12.5px; color: #c7d0d6; min-width: 0; }
.adj-btns { display: inline-flex; flex: none; border-radius: 99px; background: var(--bg-deep); border: 1px solid var(--line-2); padding: 3px; }
.adj-btn { height: 26px; padding: 0 11px; border-radius: 99px; border: 0; cursor: pointer; font-size: 12px; font-weight: 650; background: transparent; color: var(--muted); }
.adj-btn.minus:hover:not(:disabled) { background: rgba(255,159,67,.16); color: var(--orange); }
.adj-btn.plus:hover:not(:disabled) { background: rgba(46,230,214,.16); color: var(--accent); }
.adj-btn:disabled { opacity: .45; cursor: not-allowed; }
.thread-list { display: flex; flex-direction: column; gap: 2px; margin: -4px -6px; }
.thread-row {
  display: grid; grid-template-columns: 18px 14px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px;
  border: 0; background: transparent; color: var(--text); cursor: pointer; text-align: left;
}
.thread-row:hover { background: var(--panel-3); }
.thread-num { font-size: 10.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.thread-row .swatch { border-radius: 50%; }
.thread-row-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.thread-row-count { font-size: 11.5px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.sel-card { border-color: rgba(46,230,214,.45); box-shadow: var(--card-shadow), 0 0 22px rgba(46,230,214,.12); }
.sel-head { display: flex; align-items: center; gap: 10px; }
.sel-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sel-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 99px; border: 1px solid var(--line-2);
  background: var(--bg-deep); color: var(--muted); cursor: pointer; font-size: 12px;
}
.pill:hover { color: var(--text); }
.pill.on { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: 0 0 12px rgba(46,230,214,.4); font-weight: 650; }
.thread-grid.compact { gap: 6px; align-items: center; }
.thread-grid.compact .thread { width: 20px; height: 20px; border-radius: 50%; }
.thread-grid.compact input[type="color"] { width: 30px; height: 22px; border-radius: 99px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--accent-2); cursor: pointer; padding: 0; font-size: 12px; align-self: flex-start; }
.link-btn:hover { text-decoration: underline; }

/* rail flyout menus */
.menu.flyout { border-radius: 14px; padding: 6px; background: linear-gradient(180deg, #252b31, #1d2227); box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(46,230,214,.14); }
.menu-title { padding: 8px 10px 8px; font-weight: 700; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item.active { color: var(--accent); background: var(--accent-soft); }
.menu-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; margin: 0 3px; }
.menu-dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.menu-note { margin: 4px 10px 8px; color: var(--muted); font-size: 12px; line-height: 1.5; max-width: 300px; }
.menu-swatches { display: flex; flex-wrap: wrap; gap: 7px; padding: 4px 10px 8px; }
.menu-toggle { display: flex; align-items: center; gap: 10px; padding: 7px 9px; cursor: pointer; border-radius: 6px; }
.menu-toggle:hover { background: var(--panel-3); }
.menu-toggle .menu-label { display: flex; flex-direction: column; gap: 1px; }
.menu-toggle small { font-size: 11px; }

/* ---------- sequence panel ---------- */
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 12px; position: sticky; top: 0; background: var(--panel); z-index: 1; border-bottom: 1px solid var(--line); }
.panel-head.sub { position: static; border-top: 1px solid var(--line); margin-top: 8px; }
.panel-title { display: flex; align-items: center; gap: 7px; font-weight: 650; }
.count { font-size: 11px; color: var(--muted); background: var(--panel-3); border-radius: 99px; padding: 0 7px; font-weight: 600; }
.seq-list { padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.seq-row {
  display: grid; grid-template-columns: 18px 14px 16px minmax(0, 1fr) auto 22px; align-items: center; gap: 7px;
  padding: 6px 6px; border-radius: 7px; cursor: pointer; border: 1px solid transparent;
}
.seq-row:hover, .seq-row.is-hover { background: var(--panel-2); }
.seq-row.is-linked { background: rgba(46,230,214,.09); border-color: rgba(46,230,214,.28); }
.seq-row.is-primary { background: var(--accent-soft); border-color: var(--accent); }
.seq-row.is-hidden { opacity: 0.45; }
.seq-row.color-break { margin-top: 6px; }
.seq-row.virtual { cursor: default; opacity: .75; border-style: dashed; border-color: var(--line-2); }
.seq-num { font-size: 10.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.25); display: inline-block; flex: none; }
.swatch.lg { width: 26px; height: 26px; border-radius: 7px; }
.swatch.xs { width: 10px; height: 10px; border-radius: 3px; }
.seq-main { min-width: 0; }
.seq-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.seq-style { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seq-row.is-linked .seq-style, .seq-row.is-primary .seq-style { color: var(--accent-2); }
.seq-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.style-list, .color-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.style-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto 8px; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 7px; border: 1px solid transparent; background: none; cursor: pointer; text-align: left; }
.style-row:hover { background: var(--panel-2); }
.style-row.active { background: var(--accent-soft); border-color: rgba(46,230,214,.4); }
.style-name-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot-custom { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.color-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; }

/* ---------- properties ---------- */
.prop-header { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.prop-header-main { display: flex; align-items: center; gap: 10px; }
.prop-name { font-weight: 650; font-size: 14.5px; }
.linkbox { margin: 12px 12px 4px; padding: 10px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.linkbox.linked { border-color: rgba(46,230,214,.5); background: linear-gradient(180deg, rgba(46,230,214,.12), rgba(46,230,214,.04)); }
.linkbox p { margin: 0; }
.linkbox .btn-row { flex-wrap: wrap; }
.linkbox-head { display: flex; align-items: center; gap: 8px; color: var(--accent-2); }
.style-name { font-weight: 650; background: transparent !important; border-color: transparent !important; padding: 3px 6px !important; }
.style-name:hover, .style-name:focus { border-color: var(--line-2) !important; background: var(--bg) !important; }
.members { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-sm { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; }
.chip-sm.on { border-color: var(--accent); color: var(--accent-2); }
.prop-section { padding: 10px 14px 6px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.prop-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.type-btn { display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; font-size: 12px; }
.type-btn:hover { border-color: #4a5262; }
.type-btn.active { border-color: var(--accent); background: var(--accent-soft); color: #c9faf5; }
.p-row { display: flex; flex-direction: column; gap: 5px; }
.p-head { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.p-label { font-size: 12px; color: #c4cad5; cursor: help; }
.src { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; letter-spacing: .02em; }
.src-custom { background: var(--accent-soft); color: var(--accent-2); }
.src-fabric { background: var(--fabric-soft); color: var(--fabric); }
.src-default { background: var(--panel-3); color: var(--muted); }
.src-mixed { background: rgba(240,163,58,.14); color: var(--warn); }
.p-note { font-size: 11px; color: var(--muted); }
.stepper { display: flex; align-items: stretch; height: 30px; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; background: var(--bg); }
.stepper.compact { height: 28px; }
.stepper.disabled { opacity: .5; }
.stepper .num { border: 0; border-radius: 0; text-align: center; background: transparent; padding: 0 4px; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
.stepper .num::-webkit-outer-spin-button, .stepper .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { display: flex; align-items: center; padding: 0 8px 0 2px; color: var(--muted); font-size: 11.5px; }
.step { width: 32px; border: 0; background: var(--panel-2); cursor: pointer; font-size: 15px; color: var(--text); flex: none; }
.step:hover:not(:disabled) { background: var(--panel-3); color: var(--accent-2); }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--panel-3); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch .slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.thread-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.thread { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(255,255,255,.22); cursor: pointer; padding: 0; }
.thread:hover { transform: scale(1.1); }
.thread.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.teach-box { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.fabric-card { background: var(--panel-2); border: 1px solid rgba(255,159,67,.3); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.fabric-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fabric-name { font-weight: 650; display: flex; align-items: center; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.tips { margin: 0; padding-left: 16px; color: #c4cad5; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }

/* ---------- menus, modals, toasts ---------- */
.menu { position: fixed; z-index: 100; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px; padding: 5px; box-shadow: 0 14px 40px rgba(0,0,0,.5); max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 9px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.menu-item:hover:not(:disabled) { background: var(--panel-3); }
.menu-item:disabled { opacity: .4; }
.menu-label { flex: 1; }
.menu-hint { font-size: 11px; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line-2); margin: 4px 2px; }
.menu-header { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 7px 9px 3px; font-weight: 700; }
.modal-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(5,7,10,.66); display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.6); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
.modal-head h2 { font-size: 18px; }
.modal-head p { margin: 4px 0 0; max-width: 720px; }
.modal-body { padding: 6px 20px 12px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 56px; transform: translate(-50%, 20px); opacity: 0; z-index: 120; background: #163634; border: 1px solid var(--accent); color: #fff; padding: 9px 16px; border-radius: 9px; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #4a1f26; border-color: var(--danger); }

/* ---------- fabric picker ---------- */
.fabric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.fabric-option { display: flex; gap: 10px; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; }
.fabric-option:hover { border-color: #4a5262; }
.fabric-option.on { border-color: var(--fabric); background: linear-gradient(180deg, rgba(255,159,67,.14), rgba(255,159,67,.04)); box-shadow: 0 0 0 1px var(--fabric) inset; }
.fabric-swatch { width: 54px; height: 54px; border-radius: 8px; flex: none; border: 1px solid rgba(255,255,255,.15); }
.fabric-option-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mini-facts { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; margin: 4px 0 0; font-size: 11px; }
.mini-facts dt { color: var(--muted); }
.mini-facts dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fabric-foot { display: grid; grid-template-columns: 1fr 260px; gap: 16px; margin-top: 16px; align-items: end; }
.fabric-picker .check { margin-top: 12px; }

/* ---------- training studio ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.split { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 18px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 3px; position: sticky; top: 72px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: none; cursor: pointer; text-align: left; }
.list-item:hover { background: var(--panel-2); }
.list-item.active { background: var(--accent-soft); border-color: rgba(46,230,214,.45); }
.list-item.off { opacity: .55; }
.list .btn { margin-top: 8px; align-self: flex-start; }
.mini-swatch { width: 28px; height: 28px; border-radius: 6px; flex: none; border: 1px solid rgba(255,255,255,.15); }
.editor-pane { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.editor-pane h3 { margin: 10px 0 0; }
.param-matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.matrix-col { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.matrix-head { display: flex; align-items: center; gap: 7px; font-weight: 650; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.matrix-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px; align-items: center; gap: 8px; }
.matrix-row select { padding: 4px 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stitch-card-head { display: flex; align-items: center; gap: 10px; }
.stitch-card-head h3 { margin: 0; }
.stitch-card-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 10px; }
.defaults-grid { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.cond-list { display: flex; flex-direction: column; gap: 6px; }
.cond-row { display: grid; grid-template-columns: 200px 72px minmax(0, 1fr) 30px; gap: 6px; align-items: center; }
.lesson { display: flex; flex-direction: column; gap: 8px; }
.lesson-head { display: flex; align-items: center; gap: 10px; }
.lesson-title { font-weight: 650; background: transparent !important; border-color: transparent !important; padding-left: 0 !important; }
.lesson-title:hover, .lesson-title:focus { border-color: var(--line-2) !important; padding-left: 8px !important; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 6px; }

/* ---------- artwork import ---------- */
.upload-card .thumb.blank { flex-direction: column; gap: 8px; background: linear-gradient(135deg, rgba(46,230,214,.12), rgba(255,159,67,.12)); color: var(--accent-2); }
.page.dragging { outline: 3px dashed var(--accent); outline-offset: -8px; }
.tool-toggle.narrow { padding: 0 6px; margin-left: -3px; }
.art-group { display: inline-flex; align-items: center; gap: 4px; }
.import-page { height: 100vh; min-height: 0; }
.import-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 350px; }
.import-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #0b0d10; }
.import-stage.dragging::after { content: 'Drop to open'; position: absolute; inset: 12px; border: 3px dashed var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 650; color: var(--accent-2); background: rgba(46,230,214,.08); pointer-events: none; }
.import-side { border-left: 1px solid var(--line); padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.import-side h3 { margin: 8px 0 0; }
.side-title { font-size: 17px; }
.howto { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.howto b { color: var(--text); }
.import-steps { display: flex; gap: 4px; margin-bottom: 4px; }
.import-step { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); padding: 6px 7px; border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.import-step.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.import-step.done { color: var(--ok); }
.step-num { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--panel-3); font-size: 11px; font-weight: 700; flex: none; }
.import-step.on .step-num { background: var(--accent); color: var(--on-accent); }
.import-step.done .step-num { background: rgba(63,191,127,.18); }
.drop-zone { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.drop-card { width: min(520px, 100%); text-align: center; padding: 40px 28px; border: 2px dashed var(--line-2); border-radius: 16px; background: rgba(23,26,32,.7); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop-card h2 { font-size: 20px; }
.drop-card p { margin: 2px 0; }
.drop-icon { width: 66px; height: 66px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-2); margin-bottom: 6px; }
.drop-convert { max-width: 420px; }
.busy-overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(8,10,13,.5); z-index: 5; }
.busy-overlay.show { display: flex; }
.busy-card { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-2); box-shadow: 0 14px 40px rgba(0,0,0,.5); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.file-card { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.file-card .btn { align-self: flex-start; }
.file-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); border: 1px solid rgba(46,230,214,.3); color: #c4faf4; }
.note.warn { background: var(--fabric-soft); border-color: rgba(255,159,67,.35); color: #f0d3a2; }
.note.error { background: rgba(239,91,107,.12); border-color: rgba(239,91,107,.4); color: #ffc4cb; }
.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; font-size: 12px; color: var(--muted); }
.tool-btn:hover { color: var(--text); border-color: #4a5262; }
.tool-btn.on { color: #c4faf4; border-color: var(--accent); background: var(--accent-soft); }
.seg.wide { display: flex; backdrop-filter: none; background: var(--bg); }
.seg.wide .seg-btn { flex: 1; padding: 5px 6px; }
.sel-stats { font-size: 12px; color: var(--muted); padding: 6px 0; border-top: 1px solid var(--line); }
.side-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.color-list { display: flex; flex-direction: column; gap: 4px; }
.color-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.color-row.off { opacity: .55; }
.color-row .pct { margin-left: auto; font-variant-numeric: tabular-nums; }
.thread-btn { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; min-width: 0; max-width: 150px; }
.thread-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.garment-row { display: flex; flex-wrap: wrap; gap: 6px; }
.garment-swatch { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(255,255,255,.25); cursor: pointer; }
.garment-swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.result-card { padding: 10px 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.result-grid b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.result-grid span { font-size: 11px; color: var(--muted); }
@media (max-width: 860px) {
  .import-page { height: auto; }
  .import-body { grid-template-columns: 1fr; }
  .import-stage { height: 62vh; }
  .import-side { border-left: 0; border-top: 1px solid var(--line); }
  .import-step { font-size: 11px; }
}

/* editor at smaller widths: the chat always stays on the left */
@media (max-width: 1480px) {
  .editor { --chat-w: 296px; --side-w: 294px; }
  .editor.mode-adv { --side-w: 318px; }
  .tile-sub { display: none; }
  .canvas-hint { display: none; }
}
@media (max-width: 1240px) {
  .editor { --chat-w: 270px; --side-w: 276px; }
  .editor.mode-adv { --side-w: 300px; }
  .mode-btn { padding: 0 12px; }
  .player-range { width: 140px; }
  .player-count { min-width: 0; }
}
@media (max-width: 1000px) {
  .editor { --rail-w: 52px; --chat-w: 250px; }
  .rail-btn { width: 36px; height: 36px; }
  .rail-brand { width: 34px; height: 34px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .fabric-chip { display: none; }
  .design-name { width: 100% !important; max-width: 200px; }
  /* the side panel goes under the design and the whole stage scrolls */
  .stage { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
  .work { flex: none; height: calc(100vh - 56px); min-height: 420px; }
  .side { flex: none; min-height: auto; }
  .editor.mode-ai .side { background: transparent; }
  .ai-side { overflow: visible; padding: 0 12px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); align-items: start; }
  .editor.mode-adv .side { border-left: 0; border-top: 1px solid var(--line); }
  .adv-panels > .panel { overflow: visible; }
}
@media (max-width: 760px) {
  .editor { --chat-w: 230px; }
  .mode-btn { padding: 0 10px; gap: 5px; font-size: 12px; height: 30px; }
  .mode-btn .ico { display: none; }
  .tb-right .icon-btn { width: 26px; }
  .tb-right .btn.primary.glow { padding: 0 10px; }
  .tb-sep { display: none; }
}
/* inside the design area: depends on its own width, not the window */
@container work (max-width: 700px) {
  .work-top { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  .work-top::-webkit-scrollbar { display: none; }
  .stat-tile { flex: none; padding: 7px 12px 7px 8px; gap: 8px; border-radius: 12px; }
  .tile-ico { width: 26px; height: 26px; }
  .tile-value { font-size: 15px; }
  .tile-sub { display: none; }
}
@container work (max-width: 560px) {
  .canvas-toolbar { right: 10px; }
  .zoom-box { top: auto; bottom: 10px; }
  .seg-btn { padding: 4px 8px; }
  .ai-bottom .badge { display: none; }
  .statusbar .stats { display: none; }
  .statusbar .player { flex: 1; min-width: 0; }
  .statusbar .player-range { flex: 1; width: auto; min-width: 60px; }
}
@media (max-width: 860px) {
  .split, .stitch-card-body, .row-4 { grid-template-columns: 1fr; }
  .list { position: static; }
  .fabric-foot { grid-template-columns: 1fr; }
  .app-header { gap: 10px; padding: 0 16px; }
  .app-header > .muted { display: none; }
  .page-main { padding: 20px 16px 40px; }
}
