/* VoxelYard — dark Minecraft-server HUD.
   Tokens: bg #090c1a (deep navy) · panel #151a2e · line #393d55
           ink #e4ebf3 · cream #e9d5aa (headings/brand) · muted #8a91ad
           green #398f59 (primary buttons) · gold #fbb039 (accent/active) */

@import url('https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&family=Montserrat:wght@400;600;700&display=swap');

:root {
  --bg: #090c1a;
  --panel: rgba(21, 26, 46, 0.94);
  --panel-solid: #151a2e;
  --well: #0d1122;
  --line: #393d55;
  --ink: #e4ebf3;
  --cream: #e9d5aa;
  --muted: #8a91ad;
  --accent: #fbb039;
  --accent-glow: rgba(251, 176, 57, 0.35);
  --green: #398f59;
  --green-deep: #2a6b43;
  --green-bright: #52c274;
  --checker: repeating-conic-gradient(#4a4f63 0% 25%, #23283a 0% 50%);
  --pixel: "Silkscreen", "Courier New", monospace;
  --hud: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --body: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% -20%, #161c38 0%, var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: var(--body);
}

button, .button-link, input {
  font-size: 13px;
}
input { font-family: var(--hud); }

/* Blocky Minecraft-style buttons: square corners, hard bevel, pixel type. */
button, .button-link {
  appearance: none;
  border: 2px solid #05070f;
  background: var(--panel-solid);
  color: var(--ink);
  padding: 7px 12px;
  border-radius: 0;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  font-family: var(--pixel);
  font-size: 12px;
  letter-spacing: 0.02em;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
button:hover, .button-link:hover {
  border-color: var(--accent);
  color: var(--cream);
}
button.primary, .button-link.primary {
  background: var(--green);
  border-color: #05070f;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18),
              inset 0 -3px 0 var(--green-deep);
}
button.primary:hover, .button-link.primary:hover {
  filter: brightness(1.12);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.spacer { flex: 1; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ editor HUD */

.editor-page { overflow: hidden; }

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.85;
}
#crosshair::before, #crosshair::after {
  content: "";
  position: absolute;
  background: var(--ink);
}
#crosshair::before { left: 7px; top: 0; width: 2px; height: 16px; }
#crosshair::after  { left: 0; top: 7px; width: 16px; height: 2px; }

#toolbar {
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--pixel);
}

#toolbar .toolbar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

/* Right-hand menu: model actions on top, the export stack below. */
#menuRight {
  position: fixed;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 10px 14px;
  font-family: var(--pixel);
}
#menuRight .menu-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

#menuBottomRight {
  position: fixed;
  bottom: 18px;
  right: 14px;
  display: flex;
  gap: 8px;
  font-family: var(--pixel);
}

.brand {
  font-family: var(--pixel);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cream);
  user-select: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.brand b { color: var(--green-bright); font-weight: 700; }

.model-label {
  padding: 4px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  font-family: var(--hud);
  font-size: 12px;
  max-width: 26ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vox-count { font-size: 9px; color: var(--muted); }

/* Signature element: the hotbar. Chunky game-HUD slots, gold active ring. */
#hotbar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line),
              0 6px 18px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

/* Animation frames bar, bottom left — same panel look as the hotbar. */
#framesBar {
  position: fixed;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 2px solid #05070f;
  box-shadow: inset 0 0 0 1px var(--line),
              0 6px 18px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  font-family: var(--pixel);
}
#framesBar .frames-title {
  font-size: 10px;
  color: var(--muted);
  padding: 0 4px 0 2px;
}
#framesBar .frame-label {
  min-width: 42px;
  text-align: center;
  font-size: 11px;
  color: var(--cream);
}
#framesBar button {
  min-width: 34px;
  padding: 7px 8px;
}
#framesBar button:disabled {
  opacity: 0.4;
  cursor: default;
}
#framesBar button:disabled:hover { border-color: #05070f; color: var(--ink); }
#framesBar .frame-play {
  border-left: 1px solid var(--line);
  margin-left: 2px;
}
#framesBar .frames-fps {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}
#framesBar .frames-fps input { width: 72px; }
#framesBar .frames-fps span { min-width: 44px; }

/* Name of the current palette, floating just above the hotbar. */
#hotbar .palette-label {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  background: var(--panel);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--cream);
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

/* The color currently in hand — bigger than the slots, may hold a color
   that isn't in the hotbar (Q / middle-click eyedropper). */
#hotbar .selected-color {
  width: 66px;
  height: 66px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 0;
  box-shadow: 0 0 0 2px var(--accent-glow),
              inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  flex: none;
  cursor: pointer;
}

#hotbar .slots {
  display: flex;
  gap: 6px;
  border-left: 1px solid var(--line);
  padding-left: 8px;
  margin-left: 2px;
}

#hotbar .slot {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--well);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.05),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
#hotbar .slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow),
              inset 0 2px 0 rgba(255, 255, 255, 0.05),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
#hotbar .swatch {
  position: absolute;
  inset: 7px;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
#hotbar .num {
  position: absolute;
  top: 2px;
  left: 5px;
  font-family: var(--pixel);
  font-size: 8px;
  color: rgba(233, 213, 170, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
/* Current-tool badge at the left end of the hotbar. */
#hotbar .tool-badge {
  align-self: stretch;
  width: 64px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--well);
  color: var(--green-bright);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.03em;
  word-break: break-word;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.05),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
#hotbar .tool-badge:hover { border-color: var(--green-bright); }

/* Tool menu (E) — pointer released, but the toolbar stays clickable:
   the overlay itself passes clicks through, only the panel catches them. */
.tool-menu {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.tool-menu-panel {
  pointer-events: auto;
  width: min(560px, calc(100vw - 32px));
  background: var(--panel);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line),
              0 10px 30px rgba(0, 0, 0, 0.55);
  padding: 20px 22px;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tool-menu-panel h2 {
  margin: 0;
  font-family: var(--pixel);
  font-size: 15px;
  color: var(--cream);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tool-menu-key {
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 2px 7px;
}
.tool-cards { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-card {
  flex: 1 1 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
}
.tool-card .tool-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--green-bright);
}
.tool-card .tool-icon {
  width: 96px;
  height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
}
.tool-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow),
              inset 0 2px 0 rgba(255, 255, 255, 0.08),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
.tool-options {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.tool-radio {
  font-family: var(--hud);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.tool-radio input { accent-color: var(--green); }
.tool-note {
  margin: 0;
  width: 100%;
  font-family: var(--body);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-slider {
  font-family: var(--hud);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.tool-slider input[type="range"] {
  width: 180px;
  accent-color: var(--green);
}
.tool-slider-val {
  min-width: 4ch;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* custom color picker — HSV square, hue bar, MC dye presets, hex field.
   Three columns: picker, my palettes, shared palettes. Bottom padding keeps
   the panels clear of the hotbar, which stays visible and clickable so a
   slot can be picked and recolored while the dialog is open. */
#colorDialog {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px 28px 150px;
}
.color-panel { width: min(324px, calc(100vw - 32px)); }

.picker-main { display: flex; gap: 10px; }
.sv-area {
  position: relative;
  flex: 1;
  height: 160px;
  border: 2px solid var(--line);
  border-radius: 0;
  cursor: crosshair;
  touch-action: none;
}
.sv-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hue-bar {
  position: relative;
  width: 22px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: linear-gradient(to bottom,
    #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
  touch-action: none;
}
.hue-cursor {
  position: absolute;
  left: -2px;
  right: -2px;
  height: 8px;
  border: 2px solid #fff;
  outline: 1px solid rgba(0, 0, 0, 0.8);
  transform: translateY(-50%);
  pointer-events: none;
}
/* opacity slider — current color fading to transparent over a checkerboard */
.alpha-bar {
  position: relative;
  width: 22px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--checker) 0 0 / 10px 10px;
  cursor: pointer;
  touch-action: none;
}
.alpha-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--swatch, #fff), transparent);
}

/* Any surface showing a palette color: the color rides in --swatch above a
   checkerboard, so translucent colors are visibly translucent. */
#hotbar .swatch, #hotbar .selected-color, .palette-strip .chip,
.color-preview, .picker-presets .preset {
  background:
    linear-gradient(var(--swatch, transparent), var(--swatch, transparent)),
    var(--checker) 0 0 / 10px 10px;
}

.picker-presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-top: 2px;
}
.picker-presets .preset {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.15),
              inset 0 -3px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.picker-presets .preset:hover { border-color: var(--accent); }

.picker-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.color-preview {
  width: 38px;
  height: 38px;
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  flex: none;
}
#hexInput { flex: 1; }

/* my / shared palettes side panels */
.palette-panel {
  width: min(300px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 200px));
  overflow-y: auto;
}
.palette-list { display: flex; flex-direction: column; gap: 6px; }
.palette-row { display: flex; gap: 6px; }
.palette-row .palette-apply {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
}
.palette-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
}
.palette-name {
  font-size: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-author {
  font-family: var(--body);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.palette-strip { display: flex; gap: 3px; }
.palette-strip .chip {
  width: 16px;
  height: 16px;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.palette-row .palette-delete { padding: 0 10px; color: var(--muted); }
.palette-row .palette-delete:hover { color: #ff6b5e; border-color: #ff6b5e; }
.palette-save { display: flex; gap: 6px; }
.palette-save input { flex: 1; min-width: 0; }

/* click-to-build hint */
#hint {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(9, 12, 26, 0.6);
  pointer-events: none;
}
.hint-panel {
  width: min(440px, calc(100vw - 32px));
  background: var(--panel);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line),
              0 10px 30px rgba(0, 0, 0, 0.55);
  padding: 22px 26px;
  backdrop-filter: blur(6px);
}
.hint-panel h1 {
  margin: 0 0 4px;
  font-family: var(--pixel);
  font-size: 18px;
  letter-spacing: 0.03em;
  color: var(--cream);
}
.hint-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-family: var(--body);
  font-size: 13px;
}
.controls {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  font-family: var(--hud);
  font-size: 12px;
}
.controls div { display: flex; gap: 8px; align-items: baseline; }
.controls dt {
  color: var(--green-bright);
  min-width: 9ch;
  font-weight: 700;
}
.controls dd { margin: 0; color: var(--muted); }
.hint-tip {
  margin: 16px 0 0;
  font-family: var(--body);
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

/* save dialog */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(9, 12, 26, 0.72);
}
/* While the color picker is open, the hotbar rises above the dialog so
   slots stay visible and clickable (click one to retarget the picker). */
body.picking #hotbar { z-index: 11; }
.dialog-panel {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel-solid);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line),
              0 10px 30px rgba(0, 0, 0, 0.55);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dialog-panel h2 {
  margin: 0;
  font-family: var(--pixel);
  font-size: 14px;
  color: var(--cream);
}
.dialog-sub {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--body);
  font-size: 12px;
}
.dialog-panel label {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--hud);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dialog-panel input[type="text"] {
  background: var(--well);
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  padding: 8px 10px;
}
.dialog-panel input[type="text"]:focus { border-color: var(--accent); outline: none; }
.dialog-path {
  margin: 0;
  padding: 8px 10px;
  background: var(--well);
  border: 2px solid var(--line);
  border-radius: 0;
  font-family: var(--hud);
  font-size: 12px;
  word-break: break-all;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* /give + /summon command dialog */
.give-panel { width: min(540px, calc(100vw - 32px)); }
.give-panel .cmd-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 8px;
}
.give-panel .cmd-row input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

/* display settings dialog — controls on the left, live preview on the right */
#displayDialog {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px 28px;
  flex-wrap: wrap;
  overflow-y: auto;
}
.display-panel { width: min(400px, calc(100vw - 32px)); }

.preview-panel { width: min(420px, calc(100vw - 32px)); }
#displayPreview {
  width: 100%;
  height: auto;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--well);
  cursor: grab;
  touch-action: none;
}
#displayPreview:active { cursor: grabbing; }

.preset-row { display: flex; gap: 6px; }
.preset-row button { flex: 1; }
.preset-row button.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow),
              inset 0 2px 0 rgba(255, 255, 255, 0.08),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}

.dialog-panel select {
  background: var(--well);
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  padding: 8px 10px;
  font-family: var(--hud);
  font-size: 13px;
}
.dialog-panel select:focus { border-color: var(--accent); outline: none; }

.display-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr;
  gap: 6px 8px;
  align-items: center;
  margin-top: 4px;
}
.display-grid .display-head {
  text-align: center;
  font-family: var(--hud);
  font-size: 11px;
  color: var(--muted);
}
.display-grid .display-label {
  font-family: var(--hud);
  font-size: 12px;
  color: var(--muted);
}
.display-grid input[type="number"] {
  width: 100%;
  background: var(--well);
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  padding: 7px 8px;
}
.display-grid input[type="number"]:focus { border-color: var(--accent); outline: none; }

/* canvas manager dialog */
.canvas-panel { width: min(460px, 92vw); }
.canvas-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.canvas-list .canvas-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
}
.canvas-list .canvas-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow),
              inset 0 2px 0 rgba(255, 255, 255, 0.08),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
.canvas-list .canvas-name { font-family: var(--pixel); font-size: 12px; }
.canvas-list .canvas-info {
  font-family: var(--body);
  font-size: 11px;
  color: var(--muted);
}
.canvas-add-row { display: flex; }
.canvas-add-row button { flex: 1; }
.canvas-rot-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.canvas-rot-row .preset-row { flex: 1; }
.canvas-rot-row input[type="number"] {
  width: 90px;
  background: var(--well);
  border: 2px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  padding: 7px 8px;
}
.canvas-rot-row input[type="number"]:focus { border-color: var(--accent); outline: none; }
.canvas-angle-unit { color: var(--muted); }
.canvas-warn {
  margin: 4px 0 0;
  font-family: var(--body);
  font-size: 12px;
  line-height: 1.45;
  color: var(--accent);
}
.canvas-panel button:disabled,
.canvas-panel input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* toast */
#toast {
  position: fixed;
  bottom: 84px; /* clears the frames bar (bottom: 18px + its height) */
  left: 18px;
  transform: translateY(6px);
  background: var(--panel-solid);
  border: 2px solid #05070f;
  border-left: 3px solid var(--green-bright);
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line),
              0 6px 18px rgba(0, 0, 0, 0.5);
  padding: 9px 14px;
  font-family: var(--body);
  font-size: 12.5px;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 32px));
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}

/* --------------------------------------------------------------- gallery */

.gallery-page {
  min-height: 100%;
}

.gallery-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-bottom: 2px solid var(--line);
  background: rgba(9, 12, 26, 0.6);
}

.gallery-main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 30px 22px 60px;
}
.gallery-main h1 {
  font-family: var(--pixel);
  font-size: 20px;
  letter-spacing: 0.03em;
  color: var(--cream);
  margin: 0 0 6px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}
.gallery-sub {
  color: var(--muted);
  font-family: var(--body);
  font-size: 14px;
  margin: 0 0 26px;
  max-width: 60ch;
}
#status { color: var(--muted); font-family: var(--hud); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.card {
  display: block;
  background: var(--panel-solid);
  border: 2px solid #05070f;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--line),
              0 0 0 1px var(--accent-glow);
  transform: translateY(-2px);
}

.card .preview {
  aspect-ratio: 16 / 10;
  background: var(--well);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--hud);
  font-size: 12px;
}
.card .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-name {
  padding: 10px 12px 2px;
  font-family: var(--pixel);
  font-size: 11px;
  font-weight: 700;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta {
  padding: 0 12px 12px;
  color: var(--muted);
  font-family: var(--body);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- server-pack gallery ---- */

.pack-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
.pack-controls input[type="text"] {
  flex: 1;
  min-width: 120px;
  max-width: 460px;
}
.pack-count {
  color: var(--muted);
  font-family: var(--hud);
  font-size: 12px;
}

.pack-card {
  position: relative;
  cursor: pointer;
  user-select: none;
}
.pack-card.unchecked {
  opacity: 0.45;
}
.pack-card.unchecked:hover {
  opacity: 0.8;
}
.pack-pick {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.pack-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 10px 10px;
}
.pack-actions .button-link {
  font-size: 11px;
  padding: 4px 10px;
}
.card .preview img.sprite {
  object-fit: contain;
  image-rendering: pixelated;
  padding: 16%;
  box-sizing: border-box;
}

/* ---- category tabs and badges (gallery + server pack) ---- */

.cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}
.cat-tab {
  font-family: var(--hud);
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  padding: 5px 12px;
  cursor: pointer;
}
.cat-tab:hover { color: var(--cream); border-color: var(--accent); }
.cat-tab.active {
  color: var(--cream);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.card-badge {
  float: right;
  margin-left: 8px;
  font-family: var(--hud);
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 1px 6px;
}

.canvas-list .import-category {
  font-family: var(--hud);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 10px 0 4px;
}
.canvas-list .import-category:first-child { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}

/* ------------------------------------------------- build together (live) */

.live-badge {
  font-family: var(--hud);
  font-size: 10px;
  color: var(--green-bright);
  border: 1px solid var(--green-deep);
  padding: 2px 7px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.live-badge::before {
  content: "●";
  margin-right: 5px;
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#btnShare.live-on {
  border-color: var(--green-bright);
  color: var(--green-bright);
}

.share-link-row { display: flex; gap: 6px; margin-bottom: 10px; }
.share-link-row input {
  flex: 1;
  font-family: var(--hud);
  font-size: 12px;
}

.share-roster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.share-roster .roster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--well);
  border: 1px solid var(--line);
  font-family: var(--body);
  font-size: 12px;
}
.share-roster .roster-dot {
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--dot, #fff);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.share-roster .roster-you { color: var(--muted); }

button.danger {
  border-color: #7a2f34;
  color: #f2a0a4;
}
button.danger:hover { border-color: #c24a51; color: #ffc4c7; }

/* ------------------------------------------------------- signed-in chip */

.auth-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 5px 3px 4px;
  border: 2px solid #05070f;
  background: var(--panel-solid);
  font-family: var(--hud);
  font-size: 12px;
  color: var(--muted);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08),
              inset 0 -3px 0 rgba(0, 0, 0, 0.45);
}
.auth-chip img {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.auth-chip .auth-signout {
  padding: 4px 8px;
  font-size: 10px;
}
a.auth-signin {
  padding: 6px 12px;
  color: var(--cream);
  text-decoration: none;
}
a.auth-signin:hover { color: var(--accent); }

.load-more {
  display: block;
  margin: 18px auto 0;
  padding: 10px 22px;
}
.load-more.hidden { display: none; }

.card-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
}
.card-actions button {
  padding: 4px 9px;
  font-size: 10px;
}
