:root {
  --desk: #22262b;
  --panel: #2c3138;
  --panel-2: #383f48;
  --line: rgba(255, 255, 255, 0.09);
  --ink: #e8eaed;
  --muted: #9aa3ad;
  --accent: #f4b23e;
  --accent-ink: #241a05;
  --select: #37a4e8;
  --danger: #e05252;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--desk);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.35; pointer-events: none; }
button svg { width: 22px; height: 22px; flex: none; }

select {
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 44px;
  padding: 0 8px;
}

/* ---------- top bar ---------- */
#topbar, #bottombar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
#topbar::-webkit-scrollbar, #bottombar::-webkit-scrollbar { display: none; }
#topbar { border-bottom: 1px solid var(--line); }
#bottombar { border-top: 1px solid var(--line); }

.brand {
  flex: none;
  font-weight: 650;
  letter-spacing: 0.06em;
  color: var(--accent);
  padding: 0 4px;
  white-space: nowrap;
}
.brand small { display: block; letter-spacing: 0.02em; font-weight: 400; color: var(--muted); font-size: 11px; }

.group {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-left: 1px solid var(--line);
}

.tbtn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* color swatches */
#colors { max-width: 360px; flex-wrap: wrap; row-gap: 4px; }
.swatch {
  min-width: 30px; min-height: 30px; width: 30px; height: 30px;
  padding: 0; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244, 178, 62, 0.35); }
.customColor {
  position: relative; width: 30px; height: 30px; min-width: 30px; min-height: 30px;
  border-radius: 50%; overflow: hidden; border: 2px dashed rgba(255, 255, 255, 0.4);
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}
.customColor input { position: absolute; inset: -8px; width: 46px; height: 46px; opacity: 0; }
.customColor.active { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(244, 178, 62, 0.35); }

/* stroke widths */
.wbtn { min-width: 40px; padding: 0 6px; }
.wbtn .dot { border-radius: 50%; background: var(--ink); }
.wbtn.active { background: var(--accent); border-color: var(--accent); }
.wbtn.active .dot { background: var(--accent-ink); }

/* ---------- stage ---------- */
#stageWrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
#stage {
  background: #ffffff;
  border-radius: 4px;
  touch-action: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08),
              0 10px 40px rgba(0, 0, 0, 0.55),
              0 0 90px rgba(244, 178, 62, 0.10);
}

/* ---------- bottom bar / filmstrip ---------- */
#strip {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 2px;
  min-width: 60px;
  scrollbar-width: none;
}
#strip::-webkit-scrollbar { display: none; }
.cell {
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--panel-2);
}
.cell.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }

#playBtn.playing { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#onionBtn.active { background: var(--panel-2); border-color: var(--accent); color: var(--accent); }
#delBtn:not(:disabled) { color: #f1a0a0; }

.lbl { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- banner ---------- */
#restoreBanner {
  position: absolute;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  max-width: 92vw;
}

/* ---------- menu sheet ---------- */
#menuOverlay, #busyOverlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
  padding: 16px;
}
[hidden] { display: none !important; }
.sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  width: min(440px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet h3 {
  margin: 18px 0 8px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted);
}
.sheet section { border-top: 1px solid var(--line); }
.sheet button { width: 100%; justify-content: flex-start; margin-bottom: 8px; }
.sheet .row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sheet .row button { flex: 1 1 auto; margin-bottom: 0; }
.sheet .row select { flex: none; }
.hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
#closeMenu { justify-content: center; margin-top: 14px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- busy / progress ---------- */
#busyOverlay { flex-direction: column; gap: 14px; }
#busyText { font-size: 16px; }
#busyBar { width: min(360px, 80vw); height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
#busyFill { height: 100%; width: 0%; background: var(--accent); transition: width 0.15s; }
#busyCancel { background: var(--panel-2); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 84px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  text-align: center;
}

@media (max-width: 760px) {
  .brand small { display: none; }
  #colors { max-width: 240px; }
}
