/*
 * Minecraft manager - design system.
 *
 * Base: the "Command" template from the Oversight library (dark dev-tool
 * dashboard, near-black surfaces, hairline cards, one burnt-orange accent,
 * sidebar shell), held to the house playbook:
 *   - neutrals + ONE accent, used for the primary action, active state, eyebrows
 *   - Poppins only; hierarchy from weight (300/500/600) and tracking
 *   - sentence case; uppercase only for small tracked labels
 *   - hairlines instead of shadows, one radius token
 *   - motion budget: one fade/rise, one hover; prefers-reduced-motion honoured
 *   - muted text never below #a1a1aa on near-black (contrast >= 4.5:1)
 * Status colours (running/crashed) are kept to small dots and text.
 */

@font-face { font-family: Poppins; font-weight: 300; font-display: swap; src: url(fonts/poppins-300.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 400; font-display: swap; src: url(fonts/poppins-400.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 500; font-display: swap; src: url(fonts/poppins-500.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 600; font-display: swap; src: url(fonts/poppins-600.woff2) format('woff2'); }
@font-face { font-family: Poppins; font-weight: 700; font-display: swap; src: url(fonts/poppins-700.woff2) format('woff2'); }

:root {
  color-scheme: light;
  /* neutrals - white page, near-black ink */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f6f7;
  --surface-3: #eeeef0;
  --line: rgb(0 0 0 / .08);
  --line-strong: rgb(0 0 0 / .14);
  --text: #111114;
  --text-2: #3f3f46;
  --muted: #6b6b74;
  /* the one accent, darkened from Command's orange so text on white passes 4.5:1 */
  --accent: #c9501a;
  --accent-hover: #b1440f;
  --accent-ink: #ffffff;
  --accent-soft: rgb(201 80 26 / .08);
  --accent-line: rgb(201 80 26 / .35);
  /* status, small doses only */
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #b45309;
  /* type scale */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 17px;
  --fs-xl: 24px;
  --fs-display: clamp(1.75rem, 3vw, 2.25rem);
  /* one radius for the whole UI */
  --r: 8px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.6 Poppins, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: var(--fs-sm); }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: var(--fs-display); line-height: 1.05; letter-spacing: -.03em; }
h2 { font-size: var(--fs-lg); margin-bottom: 14px; }
h3 {
  /* the tracked small label - the only uppercase in the UI */
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--muted); margin: 22px 0 10px;
}
.eyebrow {
  display: inline-block; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--accent);
}

/* ------------------------------------------------------------------ login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box {
  width: 100%; max-width: 380px; padding: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.login-box .brandmark { margin-bottom: 22px; }
.login-box h1 { font-size: var(--fs-xl); margin-bottom: 6px; }
.login-box input { width: 100%; margin: 22px 0 12px; }
.login-box button { width: 100%; }
.error { color: var(--bad); font-size: var(--fs-sm); min-height: 20px; margin-top: 10px; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs-lg); padding: 2px 8px 18px; }
.brandmark .mark {
  width: 30px; height: 30px; border-radius: var(--r); display: grid; place-items: center;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 15px;
}
.nav-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r);
  color: var(--text-2); font-size: var(--fs-sm); cursor: pointer; border: 1px solid transparent;
  background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }
.nav-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: var(--fs-xs); color: var(--muted); }
.side .foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px clamp(16px, 3vw, 32px); background: rgb(255 255 255 / .88);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .crumbs { font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumbs b { color: var(--text); font-weight: 500; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }

.page { padding: clamp(18px, 3vw, 32px); max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head .lead { color: var(--muted); max-width: 62ch; margin: 10px 0 0; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------- stat strip (KPI) */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  margin-bottom: 22px; overflow: hidden;
}
.stat { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: none; }
.stat .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .16em; color: var(--muted); font-weight: 600; }
.stat .v { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v small { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); letter-spacing: 0; }
.stat .s { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------------- meters */
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; position: relative; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.meter i.cap { background: rgb(0 0 0 / .12); }
.meter.big { height: 10px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); margin-top: 8px; }
.legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--accent); vertical-align: 0; }
.legend span.cap::before { background: rgb(0 0 0 / .12); }
.legend span.free::before { background: var(--surface-3); border: 1px solid var(--line-strong); }

/* --------------------------------------------------------------- tabs */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 22px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 7px 14px; font-size: var(--fs-sm); white-space: nowrap; border-radius: calc(var(--r) - 2px);
}
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.tab { display: none; }
.tab.active { display: block; animation: rise .5s var(--ease) both; }

/* -------------------------------------------------------------- surfaces */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.grid + .card, .card + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; min-width: 0;
}
.card > h2:first-child, .card > .row:first-child h2 { margin-bottom: 14px; }
.card .row.between > h2 { margin-bottom: 0; }

/* ---------------------------------------------------------------- inputs */
button, input, select, textarea {
  font: inherit; font-size: var(--fs-sm); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 8px 13px;
}
button { cursor: pointer; font-weight: 500; transition: background-color .15s, border-color .15s, color .15s; }
button:hover { background: var(--surface-3); border-color: rgb(0 0 0 / .24); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button.danger { color: var(--bad); border-color: rgb(220 38 38 / .3); background: none; }
button.danger:hover { background: rgb(220 38 38 / .08); border-color: rgb(220 38 38 / .5); }
button.small { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .4; cursor: not-allowed; }
input, select, textarea { min-width: 0; }
input::placeholder { color: #8b8b94; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; padding: 0; }
input[type=range] { accent-color: var(--accent); padding: 0; border: none; background: none; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row + .row { margin-top: 10px; }
.row input:not([type=checkbox]):not([type=number]) { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: var(--fs-sm); }
.check input { width: auto; }
.sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.field input, .field select { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px 16px; }

dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: var(--fs-sm); }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }

/* -------------------------------------------------------- status & pills */
.pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  border: 1px solid var(--line-strong); border-radius: 99px; padding: 3px 11px;
  font-size: 12px; color: var(--text-2); background: var(--surface-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #a1a1aa; flex: none; }
.dot.on, [data-phase=running] .dot { background: var(--ok); }
[data-phase=starting] .dot, [data-phase=stopping] .dot, [data-phase=waiting] .dot,
[data-phase=creating] .dot, [data-phase=cloning] .dot, [data-phase=backing-up] .dot, [data-phase=restoring] .dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
[data-phase=crashed] .dot { background: var(--bad); }
[data-phase=sleeping] .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.tag.bedrock, .tag.java, .tag.good { color: var(--text-2); }
.tag.accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.notice { border: 1px solid var(--line-strong); border-left: 2px solid var(--accent); border-radius: var(--r); padding: 10px 14px; font-size: var(--fs-sm); color: var(--text-2); background: var(--surface-2); }
.notice.bad { border-left-color: var(--bad); }
.warn-line { margin-top: 8px; font-size: 12px; color: var(--warn); border: 1px solid rgb(180 83 9 / .25); border-radius: var(--r); padding: 6px 10px; background: rgb(180 83 9 / .05); }

/* ------------------------------------------------------- server cards */
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.srv {
  display: flex; flex-direction: column; gap: 16px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .2s;
}
.srv:hover { border-color: var(--line-strong); }
.srv-head { display: flex; align-items: flex-start; gap: 12px; }
.srv-head .t { min-width: 0; flex: 1; }
.srv-name { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.srv-name:hover { color: var(--accent); }
.srv-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.srv-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.srv-nums .k { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 600; }
.srv-nums .v { font-size: var(--fs-lg); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.srv-nums .v small { font-size: 12px; color: var(--muted); font-weight: 400; }
.srv-msg { font-size: 12px; color: var(--muted); min-height: 0; }
.srv-msg.bad { color: var(--bad); }
.srv-actions { display: flex; gap: 6px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.srv-actions .push { margin-left: auto; }
.srv.new {
  align-items: center; justify-content: center; text-align: center; min-height: 230px;
  border-style: dashed; border-color: var(--line-strong); background: none; cursor: pointer; color: var(--muted);
}
.srv.new:hover { border-color: var(--accent-line); color: var(--text); }
.srv.new .plus { width: 40px; height: 40px; border-radius: var(--r); border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 22px; font-weight: 300; color: var(--accent); }

/* ---------------------------------------------------------- choice tiles */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.choice {
  display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 14px; height: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); cursor: pointer;
}
.choice b { font-weight: 500; font-size: var(--fs-sm); color: var(--text); }
.choice span { font-size: 12px; color: var(--muted); font-weight: 400; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice.on b { color: var(--accent); }

/* -------------------------------------------------------------- players */
.playerlist { display: flex; flex-direction: column; gap: 6px; }
.player {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.player .name { font-weight: 500; }
.pos { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.pcard { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; background: var(--surface-2); }
.pcard h3 { margin-top: 0; color: var(--text); text-transform: none; font-size: var(--fs-md); letter-spacing: 0; font-weight: 600; }

/* ------------------------------------------------------------ inventory */
.inv-section { margin-top: 18px; }
.inv-label { display: block; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .16em; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.slots { display: flex; gap: 4px; flex-wrap: wrap; }
.slots.grid9 { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); max-width: 580px; }
.slot {
  aspect-ratio: 1; min-height: 52px; background: var(--bg); border: 1px solid var(--line);
  border-radius: calc(var(--r) - 2px); padding: 4px; cursor: pointer; position: relative;
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
}
.slot:hover { border-color: var(--accent-line); }
.slot.filled { background: var(--surface-3); }
.slot.ench { box-shadow: inset 0 0 0 1px rgb(124 58 237 / .4); }
.slot .iname { font-size: 9px; line-height: 1.15; color: var(--text-2); word-break: break-word; max-height: 34px; overflow: hidden; }
/* Item icons: background-size 100% auto shows frame 1 of animated strips without cropping. */
.icon { position: absolute; inset: 5px; background-repeat: no-repeat; background-position: top center; background-size: 100% auto; image-rendering: pixelated; }
.icon.noicon { position: static; inset: auto; display: flex; align-items: flex-end; font-size: 9px; line-height: 1.1; color: var(--muted); word-break: break-word; overflow: hidden; height: 100%; }
.icon.small { position: static; inset: auto; width: 22px; height: 22px; flex: none; }
.icon.small.noicon { font-size: 0; }
.slot .icount { position: absolute; top: 3px; right: 5px; font-size: 11px; font-weight: 700; color: var(--text); text-shadow: 0 0 2px #fff; }
.slot .estar { position: absolute; top: 3px; left: 5px; font-size: 10px; color: #7c3aed; }
.slots.grid9 .slot { min-height: 56px; }
.slot .durbar { position: absolute; left: 4px; bottom: 3px; height: 3px; border-radius: 2px; }
.slot.dragging { opacity: .35; }
/* Changed locally, waiting for the server to confirm. */
.slot.pending { box-shadow: inset 0 0 0 1px var(--accent-line); }
.slot.pending::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.slot.dropto { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.slot[draggable="true"] { cursor: grab; }
.slot[draggable="true"]:active { cursor: grabbing; }
.trash { margin-top: 4px; padding: 12px; text-align: center; font-size: 12px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r); max-width: 580px; }
.trash.over { border-color: var(--bad); color: var(--bad); background: rgb(220 38 38 / .06); }

.quickadd { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.qa-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.qa-count { margin-left: auto; }
.qa-count input { width: 80px; }
#qa-search { width: 100%; }
.qa-results, .qa-recent { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.qa-recent:empty { margin: 0; }
.qa-lab { align-self: center; margin-right: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 5px; border-radius: 99px;
  font-size: 12px; background: var(--surface-3); border: 1px solid var(--line-strong); cursor: grab;
}
.chip:hover { border-color: var(--accent-line); }
.chip:active { cursor: grabbing; }
.chip.dragging { opacity: .4; }
.chip .icon.small { width: 18px; height: 18px; }

/* --------------------------------------------------------- slot editor */
.ed-info { display: flex; gap: 14px; align-items: flex-start; padding: 14px; margin-bottom: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.ed-info.empty { color: var(--muted); font-size: var(--fs-sm); display: block; }
.icon.big { position: static; inset: auto; width: 52px; height: 52px; flex: none; background-color: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 5px; background-clip: content-box; }
.icon.big.noicon { font-size: 9px; align-items: center; justify-content: center; text-align: center; }
.ed-meta { min-width: 0; flex: 1; }
.ed-name { font-size: var(--fs-md); font-weight: 600; text-transform: capitalize; }
.ed-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.ed-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.ed-tags .tag { text-transform: capitalize; }
.ed-tags .tag.ench { color: #7c3aed; border-color: rgb(124 58 237 / .35); }
.dur { margin-top: 8px; font-size: 12px; }
.dur .bar { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-bottom: 4px; max-width: 320px; }
.dur .bar i { display: block; height: 100%; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ed-col { min-width: 0; display: flex; flex-direction: column; }
.ed-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ed-title { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .16em; font-weight: 600; color: var(--muted); }
.badge { margin-left: auto; min-width: 22px; text-align: center; background: var(--accent); color: #fff; font-weight: 600; border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.badge.zero { background: var(--surface-3); color: var(--muted); font-weight: 500; }
.ench-list { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); max-height: 300px; overflow-y: auto; }
.ench { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); }
.ench:last-child { border-bottom: none; }
.ench.on { background: var(--accent-soft); }
.ench-name { flex: 1; font-size: var(--fs-sm); text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ench.on .ench-name { color: var(--accent); font-weight: 500; }
.steps { display: flex; gap: 2px; flex: none; }
.step { width: 24px; height: 24px; padding: 0; font-size: 11px; line-height: 1; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.step:hover { background: var(--surface-3); color: var(--text); }
.step.sel { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ench .step:first-child.sel { background: var(--surface-3); border-color: var(--line); color: var(--muted); }
.ench-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.ench-row label { flex: 1; font-size: var(--fs-sm); }
.ench-row input { width: 68px; }

/* --------------------------------------------------------------- picker */
/* Picker: searchable grid of tiles - icon on top, name below. */
.picker { margin-top: 12px; }
.picker-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.picker-bar input { flex: 1; min-width: 180px; }
.picker-sel { font-size: 12px; color: var(--accent); font-weight: 500; }
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px;
  max-height: 480px; overflow-y: auto; padding: 8px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
}
.picker-grid.compact { max-height: 250px; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  padding: 10px 6px 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); cursor: pointer; font-weight: 400; text-align: center;
}
.tile:hover { border-color: var(--accent-line); background: var(--surface); }
.tile.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
/* Animated textures are vertical frame strips: width-fit and clip, so frame 1 shows. */
.tile-icon { width: 32px; height: 32px; display: flex; justify-content: center; align-items: flex-start; overflow: hidden; flex: none; margin-top: 2px; }
.tile-icon img { width: 32px; height: auto; image-rendering: pixelated; }
.tile-glyph { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-3); color: var(--muted); }
.tile-glyph svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tile-name {
  font-size: 11.5px; line-height: 1.3; color: var(--text-2); text-transform: capitalize; width: 100%;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.tile.sel .tile-name { color: var(--accent); font-weight: 500; }
.picker-empty { grid-column: 1 / -1; padding: 16px; text-align: center; }
/* Off-screen tiles skip layout and paint, so showing every item stays smooth. */
.picker-grid .tile { content-visibility: auto; contain-intrinsic-size: auto 84px; }

/* Creative-style category tabs */
.picker-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.ptab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; flex: none;
  padding: 5px 10px 5px 7px; font-size: 12px; font-weight: 500; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
}
.ptab:hover { border-color: var(--accent-line); background: var(--surface); }
.ptab.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.ptab small { font-size: 11px; color: var(--muted); font-weight: 400; }
.ptab .tile-icon { width: 20px; height: 20px; margin: 0; }
.ptab .tile-icon img { width: 20px; }
.ptab .tile-glyph { width: 20px; height: 20px; }
.ptab .tile-glyph svg { width: 14px; height: 14px; }
.ptab:first-child { padding-left: 10px; }

/* ---------------------------------------------------------------- rules */
.rules { display: flex; flex-direction: column; gap: 2px; max-height: 400px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); padding: 4px; }
.rule { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; }
.rule:hover { background: var(--surface-2); }
.rule > span:first-child { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch { display: flex; gap: 3px; flex: none; }
.switch button { padding: 3px 10px; font-size: 12px; }
.switch input { padding: 3px 8px; font-size: 12px; width: 90px; }
.switch button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.switch button.get { color: var(--muted); padding: 3px 8px; }

/* -------------------------------------------------------------- console */
.console {
  margin: 14px 0 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; height: 480px; overflow-y: auto; font: 12px/1.6 var(--mono);
  white-space: pre-wrap; word-break: break-word; color: var(--text-2);
}
.console .warn { color: var(--warn); }
.console .err { color: var(--bad); }
.console .me { color: var(--accent); }

/* ------------------------------------------------------------ build tab */
.readout { margin-top: 12px; padding: 10px 14px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); font: 12.5px/1.6 var(--mono); color: var(--muted); }
.readout.has { color: var(--text); border-color: var(--accent-line); }
.lm-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.lm { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); flex-wrap: wrap; }
.lm-name { font-weight: 500; flex: 1; min-width: 140px; }
.lm-actions { display: flex; gap: 5px; margin-left: auto; flex-wrap: wrap; }
.lm-actions button { padding: 4px 10px; font-size: 12px; }
#radar { width: 100%; height: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.bm-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.bm-tab { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 14px; }
.bm-tab:hover { color: var(--text); background: none; }
.bm-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.bm-pane .picker-list { max-height: 240px; }

/* ------------------------------------------------------------- map */
#map-canvas { border: 1px solid var(--line) !important; border-radius: var(--r) !important; background: var(--bg) !important; }
.map-menu { position: absolute; min-width: 210px; z-index: 30; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; padding: 4px; }
.map-menu-item { padding: 7px 10px; font-size: var(--fs-sm); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.map-menu-item:hover { background: var(--surface-2); color: var(--accent); }
.map-menu-item.head { cursor: default; color: var(--muted); font-family: var(--mono); font-size: 12px; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 4px; padding-bottom: 8px; }
.map-menu-item.head:hover { background: none; color: var(--muted); }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; background: rgb(17 17 20 / .4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; animation: fade .2s ease both; }
.modal-box { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 22px; width: 100%; max-width: 860px; max-height: 90vh; overflow-y: auto; animation: rise .4s var(--ease) both; }
.modal-box.narrow { max-width: 620px; }
.modal-box > .row.between:first-child { margin-bottom: 16px; }
.modal-box > .row.between:first-child h2 { margin: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; max-width: min(92vw, 640px);
  background: var(--surface-3); border: 1px solid var(--line-strong); border-left: 2px solid var(--accent);
  padding: 10px 16px; border-radius: var(--r); font-size: var(--fs-sm); white-space: pre-wrap;
}
.toast.bad { border-left-color: var(--bad); }

/* ---------------------------------------------------------------- motion */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60; transform: translateX(-100%); transition: transform .3s var(--ease); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 55; }
  .menu-btn { display: inline-flex; padding: 6px 9px; }
  .editor { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .stat { border-right: none; border-bottom: 1px solid var(--line); }
  .slot { min-height: 34px; }
  .slot .iname { display: none; }
  .srv-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head .actions { margin-left: 0; }
}

/* ============================================================ users page */
.ua-layout { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.ua-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ua-main > .card + .card { margin-top: 0; }
.ua-user {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 400;
}
.ua-user.on { border-color: var(--accent); background: var(--accent-soft); }
.ua-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 600; flex: none; }
.ua-user.on .ua-avatar { background: var(--accent); color: #fff; }
.ua-uname { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ua-uname small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ua-board, .ua-library { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.ua-board { min-height: 90px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); }
.ua-board.over { border-color: var(--accent); background: var(--accent-soft); }
.ua-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; font-weight: 400; width: 100%;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); cursor: grab; position: relative;
}
.ua-card:hover { border-color: var(--accent-line); }
.ua-card.dragging { opacity: .4; }
.ua-card.over { box-shadow: inset 3px 0 0 var(--accent); }
.ua-ctext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ua-ctext b { font-weight: 500; font-size: var(--fs-sm); }
.ua-ctext small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ua-ico { width: 28px; height: 28px; image-rendering: pixelated; object-fit: contain; flex: none; }
.ua-ico-blank { display: inline-block; border-radius: 6px; background: var(--surface-3); }
.ua-x { padding: 0 8px; font-size: 18px; line-height: 1; border: none; background: none; color: var(--muted); }
.ua-x:hover { color: var(--bad); background: none; }
.ua-drop { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12px; padding: 10px; }
textarea { width: 100%; resize: vertical; }
@media (max-width: 900px) { .ua-layout { grid-template-columns: 1fr; } }

/* ============================================================ player page */
body.portal { background: var(--surface-2); }
.pt-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(16px, env(safe-area-inset-left)); background: rgb(255 255 255 / .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.pt-main { max-width: 1100px; margin: 0 auto; padding: 22px 16px calc(40px + env(safe-area-inset-bottom)); }
.pt-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.pt-card {
  display: flex; flex-direction: column; gap: 14px; padding: 18px; margin: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.pt-head { display: flex; align-items: center; gap: 12px; }
.pt-ico { width: 36px; height: 36px; image-rendering: pixelated; object-fit: contain; flex: none; }
.pt-ico-blank { display: inline-block; border-radius: var(--r); background: var(--surface-3); }
.pt-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pt-title b { font-weight: 600; font-size: var(--fs-md); }
.pt-title small { color: var(--muted); font-size: 12.5px; }
.pt-fields { display: flex; flex-direction: column; gap: 12px; }
.pt-field { display: flex; flex-direction: column; gap: 6px; }
.pt-field > span { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.pt-field input, .pt-field select { width: 100%; font-size: 15px; padding: 10px 13px; }
.pt-stepper { display: flex; gap: 6px; }
.pt-stepper input { text-align: center; }
.pt-stepper button { width: 44px; flex: none; font-size: 18px; padding: 0; }
.pt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pt-chip span {
  display: inline-block; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); cursor: pointer; font-size: var(--fs-sm); font-weight: 500;
}
.pt-chip input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pt-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.pt-quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.pt-chip-btn { padding: 12px 10px; font-size: var(--fs-sm); }
.pt-chip-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pt-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); }
.pt-switch input { position: absolute; opacity: 0; }
.pt-switch i { width: 40px; height: 24px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; flex: none; transition: background .15s; }
.pt-switch i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .15s var(--ease); }
.pt-switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.pt-switch input:checked + i::after { transform: translateX(16px); }
.pt-run { width: 100%; padding: 12px; font-size: 15px; }
.pt-out { font-size: 12.5px; color: var(--muted); min-height: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pt-out:empty { display: none; }
.pt-out.ok { color: var(--ok); }
.pt-out.bad { color: var(--bad); }
.pt-card.busy { opacity: .7; }
.pt-card.cooling .pt-chip-btn { opacity: .55; }

/* Phones: an action list. Big rows, one-tap actions inline. */
@media (max-width: 640px) {
  .pt-main { padding: 14px 12px calc(32px + env(safe-area-inset-bottom)); }
  .pt-board { grid-template-columns: 1fr; gap: 8px; }
  .pt-card { padding: 14px; gap: 12px; }
  .pt-tap { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .pt-tap .pt-head { flex: 1; min-width: 0; }
  .pt-tap .pt-run { width: auto; min-width: 84px; }
  .pt-tap .pt-out { flex-basis: 100%; }
  .pt-quick { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
  .pt-chip-btn { padding: 14px 6px; }
}

/* ---- preset library and snippets ---- */
.pr-list { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; max-height: 62vh; overflow-y: auto; }
.pr-list.compact { max-height: 320px; margin-top: 0; }
.pr-cat h3 { margin: 14px 0 6px; }
.pr-cat:first-child h3 { margin-top: 0; }
.pr-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.pr-row:hover { border-color: var(--line-strong); }
.pr-cmd { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); background: var(--surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pr-plus { width: 34px; height: 34px; padding: 0; flex: none; font-size: 20px; font-weight: 400; line-height: 1; color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.pr-plus:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.pr-plus.done { color: var(--ok); background: none; border-color: var(--line-strong); font-size: 15px; }
.pr-snippets { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; background: var(--surface-2); }
.pr-snippets summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 500; }

.field > span.hint { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); }

