/* ============ ATELIER — 3D editor chrome ============ */
:root {
  --bg: #0b0d11;
  --panel: rgba(15, 18, 23, 0.93);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e9ebf0;
  --dim: #8b93a1;
  --faint: #59616d;
  --accent: #f0a848;
  --accent-dim: rgba(240, 168, 72, 0.15);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; }
#viewport, #viewport canvas { position: fixed; inset: 0; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0,0,0,0.38) 100%); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar { position: fixed; top: 16px; left: 16px; z-index: 20; display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent); font-size: 15px; border: 1px solid rgba(240,168,72,.35); }
.brand-title { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }
.brand-title span { color: var(--faint); font-weight: 500; }
.brand-sub { font-size: 9.5px; color: var(--faint); letter-spacing: 0.12em; text-transform: uppercase; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.seed-box { display: flex; align-items: center; gap: 7px; padding-right: 10px; margin-right: 2px;
  border-right: 1px solid var(--line); font-size: 11px; }
.seed-label { color: var(--faint); font-size: 9px; letter-spacing: 0.14em; }
#seedVal { color: var(--accent); font-weight: 600; }
.btn { font-family: var(--sans); font-size: 11.5px; font-weight: 600; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: #171b22; color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s; white-space: nowrap; }
.btn:hover { background: #1e242e; border-color: rgba(255,255,255,.22); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #1c1206; }
.btn.primary:hover { background: #ffb95e; }
.btn.ghost { background: transparent; }

/* ---------- control panel ---------- */
#panel { position: fixed; top: 76px; right: 16px; bottom: 16px; width: 314px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow-y: auto; overscroll-behavior: contain; padding: 4px 16px 18px; }
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: #2a2f37; border-radius: 4px; }
#panel::-webkit-scrollbar-track { background: transparent; }

.section { border-top: 1px solid var(--line); padding: 9px 0 12px; margin-top: 9px; }
.section:first-child { border-top: none; margin-top: 2px; }
.sec-head { width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: none; border: none; cursor: pointer; padding: 2px 0 6px;
  font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--dim); }
.sec-head .chev { transition: transform .2s; color: var(--faint); font-size: 9px; }
.section.collapsed .chev { transform: rotate(-90deg); }
.section.collapsed .sec-body { display: none; }
.sec-body { padding-top: 2px; }

/* ---------- controls ---------- */
.ctl { display: block; margin: 11px 0 1px; }
.ctl-label { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11.5px; color: var(--dim); margin-bottom: 6px; }
.ctl-label .dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.ctl-val { font-family: var(--mono); font-size: 10.5px; color: var(--text); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--fill, 50%), #2a2f37 var(--fill, 50%)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #f5f6f8; border: 2px solid var(--accent); margin-top: -5px;
  box-shadow: 0 1px 6px rgba(0,0,0,.5); transition: transform .12s; }
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: #2a2f37; }
input[type="range"]::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%;
  background: #f5f6f8; border: 2px solid var(--accent); }

.select-wrap { position: relative; }
.select-wrap select { width: 100%; appearance: none; -webkit-appearance: none;
  background-color: #171b22; border: 1px solid var(--line-strong); color: var(--text);
  padding: 8px 30px 8px 11px; border-radius: 8px; font-family: var(--sans); font-size: 12px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b93a1' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.select-wrap select:hover { border-color: rgba(255,255,255,.25); }
.select-wrap select:focus { outline: none; border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--dim); font-family: var(--sans); font-size: 11px; font-weight: 500; cursor: pointer;
  transition: all .15s; }
.chip:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-card { padding: 9px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #141821; cursor: pointer; text-align: left; transition: all .15s; font-family: var(--sans); }
.style-card:hover { border-color: rgba(255,255,255,.25); }
.style-card.active { border-color: var(--accent); background: #1a1d24; box-shadow: 0 0 0 1px var(--accent) inset; }
.swatches { display: flex; gap: 3px; height: 9px; margin-bottom: 7px; }
.swatches span { flex: 1; border-radius: 2px; }
.style-name { font-size: 10.5px; color: var(--dim); font-weight: 600; line-height: 1.25; }
.style-card.active .style-name { color: var(--text); }

.view-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.view-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 11px 6px 9px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: #141821;
  color: var(--dim); font-family: var(--sans); font-size: 10.5px; font-weight: 600; cursor: pointer; transition: all .15s; }
.view-btn svg { width: 20px; height: 20px; }
.view-btn:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.view-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.ctl-row { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 1px; }
.ctl-row .row-label { font-size: 12px; color: var(--text); font-weight: 500; }
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #262c36;
  border: 1px solid var(--line-strong); cursor: pointer; transition: background .18s; flex: none; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #8b93a1; transition: all .18s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 18px; background: #1c1206; }

/* ---------- stats / hint / toast ---------- */
#stats { position: fixed; left: 16px; bottom: 16px; z-index: 15; display: flex; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; font-size: 10px; color: var(--faint); letter-spacing: 0.04em;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#stats b { color: var(--text); font-weight: 600; margin-left: 5px; }
#stats .acc { color: var(--accent); }
#hint { position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%); z-index: 18;
  background: #1d1710; border: 1px solid rgba(240,168,72,.4); color: #e8c98f;
  padding: 9px 16px; border-radius: 9px; font-size: 12px; }
#toast { position: fixed; top: 78px; left: 50%; transform: translateX(-50%) translateY(-6px); z-index: 30;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 14px; font-size: 11px; color: var(--text); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; backdrop-filter: blur(10px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  #topbar { top: 8px; left: 8px; right: 8px; gap: 10px; padding: 8px 10px; }
  .brand-sub { display: none; }
  .btn { padding: 6px 9px; font-size: 11px; }
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 46vh; }
  #stats { display: none; }
}
