/* Sculpt Studio — dark-tech theme (Pencil ui.pen design spec, 2026-08-20).
   Tokens: bg #0d1220 · panel #141b2e · well #0d1220 · blue #3b82f6 · text #f1f5f9 · sub #94a3b8 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; background: #0d1220; color: #f1f5f9; }
button { font-family: inherit; cursor: pointer; user-select: none; touch-action: manipulation; }

/* ---- PLAY splash (dark-tech) ---- */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 22%, rgba(59,130,246,.22) 0%, rgba(13,18,32,0) 55%), #0d1220;
  transition: opacity .5s;
}
#splash.hidden { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; padding: 24px; }
.splash-title { font-size: clamp(40px, 8vw, 68px); font-weight: 800; letter-spacing: 4px; color: #f1f5f9; text-shadow: 0 0 30px rgba(59,130,246,.55); }
.splash-sub { font-size: clamp(15px, 2.6vw, 22px); opacity: .75; margin-top: 10px; letter-spacing: 8px; color: #94a3b8; }
.splash-tap {
  margin: 26px auto 0; display: inline-block; padding: 14px 34px; border-radius: 999px;
  font-size: clamp(17px, 2.6vw, 22px); font-weight: 700; color: #f1f5f9;
  background: rgba(20,27,46,.85); border: 1px solid rgba(148,163,184,.3);
}
.role-cards { display: flex; gap: 18px; justify-content: center; margin-top: 30px; flex-wrap: wrap; }
.role-card {
  width: 220px; min-height: 210px; border: 1px solid rgba(148,163,184,.22); border-radius: 16px; cursor: pointer;
  background: #141b2e; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 18px; transition: transform .12s, border-color .12s, box-shadow .12s;
}
.role-card:active { transform: scale(.95); }
.role-card:hover { border-color: #3b82f6; box-shadow: 0 0 18px rgba(59,130,246,.35); }
.role-card .role-emoji { font-size: 62px; }
.role-card .role-name { font-size: 24px; font-weight: 800; color: #f1f5f9; }
.role-card .role-desc { font-size: 13px; color: #94a3b8; }
.role-card.loading { opacity: .7; }
.role-card .role-load { min-height: 18px; font-size: 13px; color: #60a5fa; font-weight: 700; }
.debug-opt {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 24px;
  padding: 10px 18px; border-radius: 999px; background: #141b2e;
  border: 1px solid rgba(148,163,184,.25);
  font-size: 15px; font-weight: 700; color: #f1f5f9; cursor: pointer;
}
.debug-opt input { width: 20px; height: 20px; accent-color: #3b82f6; cursor: pointer; }

/* ---- studio canvas (right of the left UI columns — never covered) ---- */
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 286px; background: #0b1020; }
#app canvas { display: block; }

/* ---- top-right gear ---- */
#gear {
  position: fixed; top: 16px; right: 16px; z-index: 40;
  width: 56px; height: 56px; border-radius: 50%;
  background: #141b2e; border: 1px solid rgba(148,163,184,.25);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
#gear.active { background: #3b82f6; }

/* ---- toolbar / mode panels (LEFT vertical panel next to the tab column) ---- */
#toolbar {
  position: fixed; left: 116px; top: 12px; bottom: 12px; width: 170px; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch;
  pointer-events: none;
}
#toolbar > div { pointer-events: auto; }

.palette {
  display: grid; grid-template-columns: repeat(3, 46px);
  justify-content: center; gap: 6px; padding: 10px 8px 8px;
  background: #141b2e; border: 1px solid rgba(148,163,184,.18); border-radius: 12px;
}
.swatch {
  width: 46px; height: 46px; border-radius: 10px; border: 2px solid rgba(255,255,255,.14);
  box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .1s;
}
.swatch:active { transform: scale(.92); }
.swatch.active { outline: 3px solid #3b82f6; border-color: #f1f5f9; }
.swatch.rnd { background: #0d1220; font-size: 22px; border-color: rgba(148,163,184,.35); }

.paintrow {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 4px 8px 10px;
}
.paintrow .tool {
  min-width: 0; width: 100%; height: 46px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
  font-size: 13px; font-weight: 700; padding: 0 6px; overflow: hidden; white-space: nowrap;
}
.paintrow .tool.active { background: #3b82f6; border-color: #60a5fa; color: #fff; box-shadow: 0 0 12px rgba(59,130,246,.5); }
.paintrow .tool.dim { opacity: .45; }

/* tool row: 3 tools, exactly one lit */
.toolrow { grid-template-columns: 1fr 1fr 1fr; }
.toolrow .tool { height: 48px; font-size: 12px; }

/* thickness row: label + 3 size buttons with real brush dots + text labels */
.sizerow {
  display: grid; grid-template-columns: 46px 1fr 1fr 1fr; gap: 6px; align-items: center;
  padding: 2px 8px 8px;
  background: #141b2e; border: 1px solid rgba(148,163,184,.18); border-radius: 12px;
}
.sizerow .sizelabel { font-size: 11px; font-weight: 700; color: #94a3b8; text-align: center; }
.sizerow .tool {
  min-width: 0; width: 100%; height: 46px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.sizerow .tool.active { background: #3b82f6; border-color: #60a5fa; box-shadow: 0 0 12px rgba(59,130,246,.5); }
.sizerow .brushdot { display: inline-block; border-radius: 50%; background: #f1f5f9; }
.sizerow .brushdot.d-s { width: 8px; height: 8px; }
.sizerow .brushdot.d-m { width: 14px; height: 14px; }
.sizerow .brushdot.d-l { width: 22px; height: 22px; }
.sizerow .sizetxt { font-size: 10px; font-weight: 700; line-height: 1; color: #f1f5f9; }
.actionrow { padding: 2px 8px 10px; }
/* view row: fine orbit around the focused part (select mode only) */
.viewrow {
  display: none; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 8px 8px;
}
.viewrow .tool {
  min-width: 0; width: 100%; height: 40px; border-radius: 10px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  font-size: 15px; font-weight: 700;
}
.viewrow .vhome { grid-column: 1 / -1; font-size: 13px; }
.paintinfo, .hint {
  text-align: center; color: #94a3b8; font-size: 11.5px; font-weight: 600;
  padding: 4px 6px; line-height: 1.35; background: #141b2e; border: 1px solid rgba(148,163,184,.18); border-radius: 8px;
}

.presets {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 8px 8px;
}
.presets .preset {
  min-width: 0; width: 100%; height: 44px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  font-size: 12px; font-weight: 700; padding: 0 4px;
}
.presets .preset.active { background: #3b82f6; border-color: #60a5fa; color: #fff; box-shadow: 0 0 12px rgba(59,130,246,.5); }
.presets .preset:active { transform: scale(.94); }
#jointui .delete {
  display: block; margin: 8px auto; width: calc(100% - 16px); height: 48px;
  border-radius: 12px; border: none; background: #ef4444; color: #fff;
  font-size: 15px; font-weight: 700; box-shadow: 0 3px 10px rgba(239,68,68,.35);
}

.preview-row {
  display: flex; flex-direction: column; gap: 6px; padding: 6px 8px;
}
.preview-row .pv {
  min-width: 0; width: 100%; height: 46px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  font-size: 14px; font-weight: 700;
}
.preview-row .pv.active { background: #3b82f6; color: #fff; border-color: #60a5fa; }

/* ---- gear shelf (left panel) ---- */
.gearshelf {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px 8px 6px;
  background: #141b2e; border: 1px solid rgba(148,163,184,.18); border-radius: 12px;
}
.gearshelf .gearbtn {
  min-width: 0; width: 100%; height: 58px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 700; padding: 2px;
}
.gearshelf .gearbtn .g-ico { font-size: 20px; }
.gearshelf .gearbtn:active { transform: scale(.94); }
.gearshelf .gearbtn.on { background: #3b82f6; border-color: #60a5fa; color: #fff; box-shadow: 0 0 12px rgba(59,130,246,.5); }
.geartune {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 2px 8px 8px;
}
.geartune .tool {
  min-width: 0; width: 100%; height: 44px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35); font-size: 14px; font-weight: 700;
}

/* ---- preview clip row (champion mode, left panel) ---- */
.cliprow { display: none; grid-template-columns: 1fr 1fr; gap: 6px; padding: 2px 8px 8px; }
.cliprow .clipbtn {
  min-width: 0; width: 100%; height: 46px; border-radius: 12px; border: 1px solid rgba(148,163,184,.2);
  background: #0d1220; color: #f1f5f9; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 10.5px; font-weight: 700; padding: 2px;
}
.cliprow .clipbtn .c-ico { font-size: 18px; }
.cliprow .clipbtn.on { background: #3b82f6; color: #fff; border-color: #60a5fa; }

/* finish (centered overlay — deliberate done-screen, not work UI) */
#finishui {
  position: fixed; inset: 0; z-index: 45;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px;
  background: rgba(5,8,16,.72);
}
#finishui .ftitle { font-size: 40px; font-weight: 800; color: #f1f5f9; text-shadow: 0 0 24px rgba(59,130,246,.5); }
#finishui .fsub { color: #94a3b8; font-size: 16px; }
#finishui button {
  width: min(420px, 70vw); height: 64px; border-radius: 14px; border: none;
  font-size: 22px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
#finishui .save { background: #3b82f6; color: #fff; box-shadow: 0 0 18px rgba(59,130,246,.4); }
#finishui .glb { background: #0d1220; color: #f1f5f9; border: 1px solid rgba(148,163,184,.3); }
#finishui .back { background: #1f2a44; color: #94a3b8; }
#finishui .fstatus { font-size: 16px; min-height: 24px; color: #f1f5f9; }

/* ---- caption (bottom-right, out of the painting area) ---- */
#caption {
  position: fixed; right: 16px; bottom: 16px; z-index: 25;
  max-width: min(60vw, 420px); background: rgba(13,18,32,.82); color: #f1f5f9; padding: 8px 16px;
  border: 1px solid rgba(148,163,184,.25); border-radius: 999px;
  font-size: 16px; font-weight: 700; text-align: center;
  display: none;
}
#caption:not(:empty) { display: block; }

/* ---- settings overlay ---- */
#settings {
  position: fixed; inset: 0; z-index: 60; background: rgba(5,8,16,.72);
  align-items: center; justify-content: center; flex-direction: column;
}
#settings .settings {
  background: #141b2e; border: 1px solid rgba(148,163,184,.25); border-radius: 16px; padding: 24px; width: min(560px, 92vw);
  display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
#settings .srow { display: flex; align-items: center; justify-content: space-between; font-size: 19px; font-weight: 700; color: #f1f5f9; }
#settings select { font-size: 17px; padding: 8px 10px; background: #0d1220; color: #f1f5f9; border: 1px solid rgba(148,163,184,.3); border-radius: 8px; }
#settings input[type=range] { width: 60%; accent-color: #3b82f6; }
#settings .sample { height: 52px; border-radius: 14px; border: none; background: #3b82f6; color: #fff; font-size: 18px; font-weight: 700; }

/* ---- celebration ---- */
#celebration { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 12px; height: 20px; opacity: .0; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 1; } }
.celebrate-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(32px,7vw,60px); font-weight: 900; color: #f1f5f9; text-shadow: 0 0 30px rgba(59,130,246,.7);
  animation: pop .4s; background: radial-gradient(circle, rgba(59,130,246,.3), rgba(5,8,16,.4));
}

/* ---- bottom tab bar (left vertical column, dark-tech) ---- */
#tabbar {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 35;
  width: 104px;
  display: flex; flex-direction: column;
  background: #141b2e; border-right: 1px solid rgba(148,163,184,.18);
  box-shadow: 3px 0 14px rgba(0,0,0,.4);
}
#tabbar .tab {
  flex: 1; min-height: 0; width: 100%; border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 13px; font-weight: 700; color: #94a3b8;
}
#tabbar .tab .tab-ico { font-size: 26px; }
#tabbar .tab.active { color: #fff; background: #3b82f6; box-shadow: inset 0 0 18px rgba(59,130,246,.6); }
#tabbar .tab.active .tab-ico { transform: scale(1.12); }
#tabbar .tab.disabled { opacity: .35; pointer-events: none; }

/* ---- version badge ---- */
#vbadge {
  position: fixed; left: 6px; bottom: 4px; z-index: 5;
  font-size: 10px; color: rgba(148,163,184,.5); pointer-events: none;
}

/* ---- orbit arrows: diamond cluster on the RIGHT edge, all modes (v27) ---- */
.orbitarrows {
  position: absolute; top: 50%; right: 12px;
  transform: translateY(-50%);
  display: grid; gap: 8px; z-index: 45; pointer-events: none;
  grid-template-columns: 64px 64px 64px;
  grid-template-rows: 64px 64px 64px;
  grid-template-areas:
    ".  up ."
    "left . right"
    ". down .";
}
.orb-arrow {
  pointer-events: auto;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(148,163,184,.28);
  background: rgba(13,18,32,.55);
  color: #e2e8f0;
  font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.orb-arrow:active { background: rgba(59,130,246,.65); color: #fff; box-shadow: 0 0 16px rgba(59,130,246,.6); }
.orb-up::before    { content: '\25B2'; } /* ▲ */
.orb-down::before  { content: '\25BC'; } /* ▼ */
.orb-left::before  { content: '\25C0'; } /* ◀ */
.orb-right::before { content: '\25B6'; } /* ▶ */
.orb-up    { grid-area: up; }
.orb-down  { grid-area: down; }
.orb-left  { grid-area: left; }
.orb-right { grid-area: right; }

/* ---- narrow tablets: tighter panel ---- */
@media (max-width: 900px) {
  #app { left: 256px; }
  #toolbar { width: 140px; }
  .palette { grid-template-columns: repeat(3, 38px); gap: 5px; padding: 8px 6px 6px; }
  .swatch { width: 38px; height: 38px; }
  .paintrow .tool { font-size: 12px; }
  .presets .preset { font-size: 11px; }
  .gearshelf .gearbtn { font-size: 10px; }
  .cliprow .clipbtn { font-size: 9.5px; }
}
