/* ZfStands editor, Catppuccin Mocha with Mauve as accent (like the ZfPerms editor) */
:root {
  --crust: #11111b;
  --mantle: #181825;
  --base: #1e1e2e;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --text: #cdd6f4;
  --mauve: #cba6f7;
  --lavender: #b4befe;
  --red: #f38ba8;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --peach: #fab387;
  --sky: #89dceb;
  --blue: #89b4fa;

  --radius: 10px;
  --topbar: 52px;
  --sans: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  overflow: hidden;
}
h1, h3 { margin: 0 0 .6em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.4rem; }
h3 { font-size: .78rem; color: var(--subtext0); text-transform: uppercase; letter-spacing: .07em; }
p { margin: .4em 0; }
.muted { color: var(--subtext0); }
.small { font-size: .82em; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; flex: none; }
.brand-zf { color: var(--sky); }
.brand-stands { color: var(--peach); margin-left: -8px; }
.brand-sub { color: var(--overlay1); font-weight: 500; font-size: .9rem; }
.where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--subtext1); white-space: nowrap; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--overlay0); }
.status.live .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status.away .dot { background: var(--yellow); }
.status.offline .dot, .status.closed .dot { background: var(--red); }
#done { flex: none; }

/* ---- message screen ---- */
.screen { display: grid; place-items: center; height: calc(100% - var(--topbar)); padding: 16px; }
.card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: var(--radius);
  padding: 16px;
}
.card.narrow { max-width: 480px; text-align: center; padding: 28px; }

/* ---- editor layout ---- */
.editor {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100% - var(--topbar));
}
.viewport { position: relative; min-width: 0; min-height: 0; background: radial-gradient(ellipse at 50% 40%, #262637, var(--crust)); }
.viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.panel {
  overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--base);
  border-left: 1px solid var(--surface0);
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .viewport { height: 58vh; }
  .panel { border-left: 0; border-top: 1px solid var(--surface0); }
  .topbar { gap: 10px; padding: 0 12px; }
  .where, .brand-sub { display: none; }
}

/* ---- toolbar over the 3D view ---- */
.toolbar {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 8px;
  pointer-events: none;
}
.toolbar .group {
  display: flex; gap: 2px; padding: 3px;
  background: color-mix(in srgb, var(--mantle) 88%, transparent);
  border: 1px solid var(--surface0); border-radius: 10px;
  pointer-events: auto;
  backdrop-filter: blur(6px);
}
.toolbar button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; color: var(--subtext1); }
.toolbar button:hover:not(:disabled) { background: var(--surface0); color: var(--text); }
.toolbar button.active { background: var(--surface0); color: var(--mauve); }
.toolbar button.on { color: var(--green); }
.hint {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  color: var(--overlay1); font-size: .8rem; pointer-events: none;
  text-shadow: 0 1px 2px var(--crust);
}
.toast {
  position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%);
  background: var(--surface0); border-left: 4px solid var(--yellow);
  padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  max-width: min(440px, 90%);
  animation: toast-in .15s ease-out;
}
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translate(-50%, 8px); opacity: 0; } }

/* ---- controls ---- */
button {
  font: inherit; font-weight: 500;
  border-radius: 8px; padding: 7px 12px;
  border: 1px solid var(--surface1);
  background: var(--surface0); color: var(--text);
  cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--surface1); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--mauve); color: var(--crust); border-color: var(--mauve); }
button.primary:hover:not(:disabled) { background: var(--lavender); border-color: var(--lavender); }
input[type=text], input[type=number] {
  width: 100%;
  background: var(--crust);
  color: var(--text);
  border: 1px solid var(--surface1);
  border-radius: 7px;
  padding: 6px 8px;
  font: inherit;
}
input[type=number] { font-family: var(--mono); font-size: .9em; padding: 4px 6px; }
input:focus { outline: 2px solid var(--mauve); outline-offset: -1px; border-color: transparent; }
input[type=range] { width: 100%; accent-color: var(--mauve); margin: 0; }
label, .label { display: block; color: var(--subtext0); font-size: .82rem; margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.row > button { flex: 1; }
.row > .muted { flex: 1; }
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

/* parts */
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.parts button { text-align: left; padding: 7px 10px; }
.parts button kbd { float: right; color: var(--overlay0); font-family: var(--mono); font-size: .75rem; margin-top: 2px; }
.parts button.selected { border-color: var(--mauve); background: color-mix(in srgb, var(--mauve) 16%, var(--mantle)); color: var(--mauve); }

.axes { display: flex; flex-direction: column; gap: 6px; }
.axis, .slider { display: grid; grid-template-columns: 1fr 72px; gap: 8px; align-items: center; }
.axis { grid-template-columns: 16px 1fr 72px; }
.axis .name { font-family: var(--mono); font-weight: 700; }
.axis.x .name { color: var(--red); }
.axis.y .name { color: var(--green); }
.axis.z .name { color: var(--blue); }
.axis.x input[type=range] { accent-color: var(--red); }
.axis.y input[type=range] { accent-color: var(--green); }
.axis.z input[type=range] { accent-color: var(--blue); }

/* presets */
.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.presets button { padding: 6px 4px; font-size: .88rem; }

/* stand */
.compass { display: flex; justify-content: space-between; color: var(--overlay1); font-size: .75rem; font-family: var(--mono); padding: 2px 0 0; }
.compass button { padding: 1px 6px; font-size: .75rem; border-color: transparent; background: none; color: var(--overlay1); }
.compass button:hover { color: var(--text); }
.offsets { display: flex; flex-direction: column; gap: 6px; }
.offset { display: grid; grid-template-columns: 16px 34px 1fr 34px; gap: 6px; align-items: center; }
.offset .name { font-family: var(--mono); font-weight: 700; }
.offset.x .name { color: var(--red); }
.offset.y .name { color: var(--green); }
.offset.z .name { color: var(--blue); }
.offset button { padding: 3px 0; }

/* flags */
.flags { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-bottom: 12px; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: .9rem; margin: 0; }
.switch input { appearance: none; width: 30px; height: 17px; border-radius: 999px; background: var(--surface1); position: relative; flex: none; cursor: pointer; margin: 0; transition: background .12s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--subtext1); transition: transform .12s; }
.switch input:checked { background: var(--mauve); }
.switch input:checked::after { transform: translateX(13px); background: var(--crust); }
.name-row { display: flex; gap: 6px; }
.name-row button { flex: none; }

/* equipment */
.equipment { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.equipment li { display: flex; gap: 10px; font-size: .9rem; }
.equipment .slot { color: var(--overlay1); width: 7.5em; flex: none; }
.equipment .item { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equipment .item.none { color: var(--overlay0); }
.equipment .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: 0; }
