/* ============================================================
   Minecraft Web Manager — theme tokens
   Light is the default (:root); dark is applied via
   :root[data-theme="dark"]. theme.js resolves "system".
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #eef2f0;
  --surface: #ffffff;
  --surface-2: #f5f8f6;
  --surface-3: #eef2f0;
  --border: #e2e8e5;
  --border-strong: #d2dbd7;
  --text: #16211d;
  --text-muted: #59695f;
  --text-faint: #869a90;
  --accent: #159a5b;
  --accent-hover: #0f8850;
  --accent-soft: #e3f4eb;
  --on-accent: #ffffff;
  --danger: #d64545;
  --danger-hover: #c23a3a;
  --danger-soft: #fbe9e9;
  --warn: #c9821c;
  --warn-soft: #f8efdb;
  --glow: rgba(21, 154, 91, .07);
  --term-bg: #0b100e;
  --term-text: #cad7d0;
  --term-border: #1e2c27;
  --shadow-sm: 0 1px 2px rgba(16, 32, 26, .06), 0 1px 3px rgba(16, 32, 26, .04);
  --shadow-md: 0 6px 16px -6px rgba(16, 32, 26, .14), 0 2px 6px -2px rgba(16, 32, 26, .08);
  --shadow-lg: 0 24px 50px -18px rgba(16, 32, 26, .30);
  --chart-1: #159a5b;
  --chart-2: #2f6fed;
  --chart-3: #8b5cf6;
  --chart-4: #e0821a;
  --chart-grid: #e6ecea;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b110f;
  --surface: #131c19;
  --surface-2: #172220;
  --surface-3: #1c2926;
  --border: #253430;
  --border-strong: #33473f;
  --text: #e7efeb;
  --text-muted: #93a59d;
  --text-faint: #6b7d76;
  --accent: #3ad685;
  --accent-hover: #55e097;
  --accent-soft: #123329;
  --on-accent: #05231a;
  --danger: #f2807d;
  --danger-hover: #f6928f;
  --danger-soft: #37201f;
  --warn: #e6b24d;
  --warn-soft: #352b18;
  --glow: rgba(58, 214, 133, .07);
  --term-bg: #080c0a;
  --term-text: #cad7d0;
  --term-border: #1c2a25;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 22px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 28px 60px -18px rgba(0, 0, 0, .72);
  --chart-1: #3ad685;
  --chart-2: #5aa2ff;
  --chart-3: #a78bfa;
  --chart-4: #f0b45a;
  --chart-grid: #21302c;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  color: var(--text);
  background: radial-gradient(circle at 12% -8%, var(--glow), transparent 42%), var(--bg);
  background-attachment: fixed;
  font: 15px/1.5 "Inter", ui-sans-serif, system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ---------- form controls ---------- */
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem .95rem; border: 1px solid transparent; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-weight: 650;
  transition: filter .15s, background .15s, border-color .15s, transform .08s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); }
.btn.warn { background: var(--warn); color: #241503; }
.btn.warn:hover:not(:disabled) { background: var(--warn); filter: brightness(1.06); }
.btn[hidden] { display: none !important; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn.sm { padding: .4rem .7rem; font-size: .85rem; }

input.field, select.field {
  width: 100%; padding: .62rem .7rem; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input.field:focus, select.field:focus {
  outline: 0; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---------- theme toggle ---------- */
.theme-toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-toggle button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.theme-toggle svg { width: 16px; height: 16px; }
.lang-toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.lang-toggle button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 28px; padding: 0 .5rem; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-muted); font-size: .78rem; font-weight: 650;
  transition: background .15s, color .15s;
}
.lang-toggle button:hover { color: var(--text); }
.lang-toggle button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ============================================================
   App shell (console page)
   ============================================================ */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; gap: 1.2rem; padding: 1.2rem 1rem;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: .35rem .45rem; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.brand .mark svg { width: 20px; height: 20px; }
.brand .title { font-weight: 750; font-size: .98rem; letter-spacing: -.01em; }
.brand .subtitle { font-size: .68rem; letter-spacing: .14em; color: var(--text-faint); font-weight: 700; text-transform: uppercase; }

.nav { display: grid; gap: .25rem; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; width: 100%; padding: .6rem .75rem;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: .9rem; text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }

.sidebar-footer { margin-top: auto; display: grid; gap: .8rem; }
.sidebar-footer .row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sidebar-footer .self-update { width: 100%; }

/* ---------- main column ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.15rem; letter-spacing: -.01em; }
.topbar .crumb { font-size: .74rem; color: var(--text-faint); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: .7rem; }

.badge {
  display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .7rem;
  border-radius: 999px; font-size: .78rem; font-weight: 600;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
}
.badge .dot { width: .5em; height: .5em; border-radius: 50%; background: var(--text-faint); }
.badge.live .dot { background: var(--accent); box-shadow: 0 0 .5em color-mix(in srgb, var(--accent) 75%, transparent); }
.badge.down .dot { background: var(--danger); }

.content { padding: 1.4rem 1.6rem 2.4rem; display: grid; gap: 1.4rem; }

/* ---------- status pill / dot ---------- */
.status-dot { display: inline-block; width: .58em; height: .58em; border-radius: 50%; margin-right: .5em; background: var(--text-faint); vertical-align: baseline; }
.status-dot.running { background: var(--accent); box-shadow: 0 0 .5em color-mix(in srgb, var(--accent) 70%, transparent); }
.status-dot.starting { background: var(--warn); box-shadow: 0 0 .5em color-mix(in srgb, var(--warn) 70%, transparent); }
.status-dot.stopped { background: var(--danger); }

/* ---------- metric cards ---------- */
.metrics { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem; box-shadow: var(--shadow-sm); min-width: 0; }
.metric .label { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.metric .value { font-size: 1.5rem; font-weight: 750; margin-top: .4rem; line-height: 1.18; overflow-wrap: anywhere; }
.metric .value.md { font-size: 1.18rem; }
.metric .value.sm { font-size: .95rem; }
.metric .sub { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem; box-shadow: var(--shadow-sm); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel-head h2 { font-size: 1rem; font-weight: 700; }
.panel-head .hint { font-size: .8rem; color: var(--text-muted); }

.view { display: none; gap: 1.4rem; }
.view.active { display: grid; }

/* console view is a two-column layout */
.console-grid { grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); align-items: start; }
.side-stack { display: grid; gap: 1.4rem; align-content: start; }

/* ---------- terminal ---------- */
.term-toolbar { display: flex; align-items: center; gap: .6rem; }
.term-toolbar .spacer { flex: 1; }
.term-toolbar label { font-size: .8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: .35rem; }
.term-toolbar select { padding: .35rem .5rem; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); }
.terminal {
  height: 460px; overflow: auto; margin-top: 1rem; padding: .85rem 1rem;
  background: var(--term-bg); color: var(--term-text); border: 1px solid var(--term-border); border-radius: 12px;
  white-space: pre-wrap; word-break: break-word;
  font: 13px/1.55 ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
}

.command-bar { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; padding: .5rem .5rem .5rem .85rem; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.command-bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.command-bar .prompt { color: var(--accent); font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
.command-input-wrap { position: relative; flex: 1; min-width: 0; }
.command-input-wrap input { width: 100%; background: transparent; border: 0; outline: 0; color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.command-result { font-size: .82rem; color: var(--text-muted); margin-top: .7rem; white-space: pre-wrap; word-break: break-word; }

.suggestions {
  position: absolute; left: 0; right: 0; bottom: calc(100% + .5rem); margin: 0; padding: .3rem; list-style: none;
  max-height: 260px; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 30;
}
.suggestions[hidden] { display: none; }
.suggestions li { padding: .45rem .6rem; border-radius: 7px; cursor: pointer; font: 13px ui-monospace, Consolas, monospace; color: var(--text); }
.suggestions li.active, .suggestions li:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- plugins list ---------- */
.plugins { list-style: none; padding: 0; margin: 0; max-height: 340px; overflow: auto; display: grid; gap: .1rem; }
.plugins li { padding: .6rem .2rem; border-bottom: 1px solid var(--border); }
.plugins li:last-child { border-bottom: 0; }
.plugins .p-name { font-size: .92rem; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plugins .p-meta { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- server actions ---------- */
.action-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }

/* ---------- data table ---------- */
.table-scroll { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.data-table thead th { background: var(--surface-2); color: var(--text-faint); font-weight: 700; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; position: sticky; top: 0; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.data-table .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; }

/* Plugin / mod management tables: fixed column layout so long names, ids and
   descriptions are truncated with an ellipsis instead of widening the table
   (keeps the whole table visible on small laptop screens). */
.manage-table { table-layout: fixed; }
.manage-table th, .manage-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-table .p-name, .manage-table .p-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-table .p-name { font-size: .92rem; font-weight: 700; color: var(--text); }
.manage-table .p-meta { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }
.manage-plugins th:nth-child(1) { width: 34%; }
.manage-plugins th:nth-child(2) { width: 24%; }
.manage-plugins th:nth-child(3) { width: 12%; }
.manage-plugins th:nth-child(4) { width: 30%; }
.manage-mods th:nth-child(1) { width: 30%; }
.manage-mods th:nth-child(2) { width: 22%; }
.manage-mods th:nth-child(3) { width: 11%; }
.manage-mods th:nth-child(4) { width: 9%; }
.manage-mods th:nth-child(5) { width: 28%; }
.tag { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.tag.muted { background: var(--surface-3); color: var(--text-muted); }

.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.na { color: var(--text-faint); }

/* ---------- charts ---------- */
.range-picker { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.range-picker button {
  border: 0; border-radius: 7px; background: transparent; color: var(--text-muted);
  padding: .3rem .6rem; font-size: .8rem; font-weight: 650; transition: background .15s, color .15s;
}
.range-picker button:hover { color: var(--text); }
.range-picker button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.chart-block { padding-top: .9rem; border-top: 1px solid var(--border); margin-top: .9rem; }
.chart-block:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }
.chart-title { font-size: .85rem; font-weight: 650; color: var(--text); }
.chart-legend { display: inline-flex; gap: .9rem; flex-wrap: wrap; font-size: .78rem; color: var(--text-muted); }
.chart-legend .key { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend .swatch { width: .6rem; height: .6rem; border-radius: 2px; display: inline-block; }
.chart-legend .now { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.chart { display: block; width: 100%; overflow: visible; }
.chart-line { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { stroke: none; opacity: .13; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { fill: var(--text-faint); font-size: 10px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.chart-empty { fill: var(--text-faint); font-size: 12px; }
.chart-note { font-size: .78rem; color: var(--text-faint); margin-top: .9rem; }
.chart-crosshair { stroke: var(--text-faint); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-dot { stroke: var(--surface); stroke-width: 1.5; }
.chart-block { position: relative; }
.chart-tooltip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; z-index: 15;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: .5rem .65rem; box-shadow: var(--shadow-lg); font-size: .78rem; white-space: nowrap;
  display: grid; gap: .2rem;
}
.chart-tooltip[hidden] { display: none; }
.chart-tooltip-time { color: var(--text-faint); font-family: ui-monospace, Consolas, monospace; margin-bottom: .1rem; }
.chart-tooltip .key { display: flex; align-items: center; gap: .4rem; color: var(--text-muted); }
.chart-tooltip .key b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tooltip .swatch { width: .6rem; height: .6rem; border-radius: 2px; display: inline-block; }

/* ---------- roster + access control ---------- */
.tag.op { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.bot { background: var(--surface-3); color: var(--text-muted); border: 1px dashed var(--border-strong); }
.bot-section { margin-top: 1.1rem; }
.player-name { font-weight: 650; }
.player-copy-uuid { padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.player-copy-uuid:hover { color: var(--accent); text-decoration: underline; }
.player-copy-uuid:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font-size: .8rem; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn:disabled { opacity: .45; pointer-events: none; }

/* row "⋯" menu (low-frequency / destructive plugin actions) */
.row-menu-wrap { position: relative; display: inline-block; }
.row-menu-toggle { letter-spacing: 1px; padding: 0 .1rem; }
.row-menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
  display: flex; flex-direction: column; gap: .15rem; align-items: stretch;
  min-width: 7rem; padding: .3rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-md);
  white-space: nowrap;
}
.row-menu .link-btn { text-align: left; padding: .3rem .5rem; border-radius: 6px; }
.row-menu .link-btn:hover { background: var(--surface-2); text-decoration: none; }
.row-menu[hidden] { display: none; }

/* whitelist master switch */
.toggle-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .85rem 1rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.toggle-info { display: flex; align-items: center; gap: .85rem; }
.toggle-title { font-weight: 650; font-size: .92rem; }
.toggle-hint { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.toggle { position: relative; display: inline-flex; flex: none; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track { width: 44px; height: 25px; border-radius: 999px; background: var(--border-strong); transition: background .18s; display: block; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s; }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track .knob { transform: translateX(19px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.subtabs { display: inline-flex; flex-wrap: wrap; max-width: 100%; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.subtabs button { border: 0; border-radius: 7px; background: transparent; color: var(--text-muted); padding: .35rem .75rem; font-size: .84rem; font-weight: 650; transition: background .15s, color .15s; }
.subtabs button:hover { color: var(--text); }
.subtabs button.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.subtabs button .tab-count { margin-left: .3rem; padding: .05rem .4rem; border-radius: 999px; background: var(--surface-3); color: var(--text-muted); font-size: .72rem; font-weight: 650; line-height: 1.3; }
.subview { display: none; }
.subview.active { display: block; }
.subview-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: .8rem; }
.subview-head[hidden] { display: none !important; }
.manage-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.manage-toolbar .subtabs { flex: 0 0 auto; }
.manage-toolbar .subview-head { flex: 1 1 0; min-width: 0; margin-bottom: 0; margin-left: auto; }
.manage-toolbar .subview-head > .inline-actions { width: 100%; min-width: 0; justify-content: flex-end; }
.world-manage-toolbar .subview-head { min-width: 0; }
.world-manage-toolbar .inline-actions { flex-wrap: nowrap; }
.world-manage-toolbar .inline-actions > .hint { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.world-manage-toolbar .sm-field { flex: 1 1 12rem; width: auto; min-width: 0; max-width: 260px; height: 34px; box-sizing: border-box; }
.world-manage-toolbar .btn.sm { flex-shrink: 0; white-space: nowrap; height: 34px; box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.world-manage-toolbar .hint { line-height: 34px; white-space: nowrap; }
.section-title { font-size: .85rem; font-weight: 700; color: var(--text-muted); margin: 1.2rem 0 .6rem; }
.subview .section-title:first-child { margin-top: 0; }

.scroll-area { max-height: 360px; overflow: auto; }
.entry-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row-hover-action { opacity: 0; transition: opacity .12s; white-space: nowrap; }
.entry-row:hover .row-hover-action, .row-hover-action:focus-visible { opacity: 1; }

/* ---------- mod management ---------- */
.mod-config-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 1.2rem; align-items: start; margin-top: .9rem; }
.mod-config-list .panel-head { margin-bottom: .6rem; }
.mod-config-list .panel-head h3 { font-size: .95rem; font-weight: 700; }
.mod-config-list .sm-field { width: 100%; }
.config-file-list { list-style: none; margin: .8rem 0 0; padding: 0; max-height: calc(100vh - 340px); min-height: 120px; overflow: auto; overscroll-behavior: contain; }
.config-file-list li { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .55rem; border-radius: 9px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: .84rem; min-width: 0; }
.config-file-list li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.config-file-list li:hover { background: var(--surface-2); }
.config-file-list li.active { background: var(--accent-soft); color: var(--accent); }
.config-file-list li.empty { color: var(--text-faint); justify-content: flex-start; cursor: default; }
.config-file-list .file-size { color: var(--text-faint); font-size: .74rem; white-space: nowrap; }
.mod-config-heading { min-width: 0; }
.mod-config-heading h3 { font-size: .95rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mod-config-heading .hint { margin-top: .2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-editor {
  width: 100%; min-height: 480px; resize: vertical; padding: .8rem; margin-top: .4rem;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.config-editor:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.config-editor:disabled { opacity: .6; }
.mod-config-editor-pane .hint { margin-top: .6rem; }

/* server.properties editor */
.sm-field { width: auto; min-width: 160px; padding: .35rem .55rem; }
.properties-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .7rem;
  max-height: calc(100vh - 280px); min-height: 120px; overflow: auto; overscroll-behavior: contain;
  padding: .15rem .25rem .3rem; margin-top: .8rem;
}
.mcdr-config-list {
  max-height: calc(100vh - 320px); min-height: 120px; overflow: auto; overscroll-behavior: contain;
  padding: .15rem .25rem .3rem; margin-top: .8rem;
}
.mcdr-config-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .7rem;
}
.property-card {
  display: flex; flex-direction: column; gap: .45rem; padding: .7rem .8rem; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
}
.property-card.dirty { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.property-card.dirty .property-name { color: var(--accent); }
.property-card.pending { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 6%, transparent); }
.property-card.pending .property-name { color: var(--warn); }
.property-name .tag { margin-left: .4rem; }
.tag.pending { background: var(--warn-soft); color: var(--warn); }
.plugin-update { color: var(--warn); font-weight: 650; }
.plugin-up-to-date { color: var(--text-faint); }
.property-pending { font-size: .75rem; color: var(--warn); overflow-wrap: anywhere; }
.property-label { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.property-name { font-weight: 600; font-size: .88rem; }
.property-key { font-size: .74rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }
.property-control .field, .property-control select { width: 100%; padding: .4rem .55rem; }
.switch { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); cursor: pointer; }
.switch input { width: 1rem; height: 1rem; accent-color: var(--accent); }

@media (max-width: 960px) {
  .mod-config-layout { grid-template-columns: 1fr; }
  .config-editor { min-height: 360px; }
  .properties-grid { max-height: 60vh; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .mcdr-config-list { max-height: 60vh; }
  .mcdr-config-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 760px) {
  .manage-toolbar .subview-head { flex-basis: 100%; }
  .world-manage-toolbar .inline-actions { flex-wrap: wrap; }
  .world-manage-toolbar .sm-field { flex: 1 1 180px; }
}

.inline-actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; }
.inline-form .field { flex: 1; min-width: 140px; }
.access-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; max-height: 320px; overflow: auto; }
.access-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem .2rem; border-bottom: 1px solid var(--border); }
.access-list li:last-child { border-bottom: 0; }
.access-list li.empty { color: var(--text-faint); font-size: .85rem; justify-content: flex-start; }
.access-entry { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.access-meta { font-size: .76rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; }

.raw-output {
  max-height: 240px; overflow: auto; margin: 0; padding: .8rem; border-radius: 10px;
  background: var(--term-bg); color: var(--term-text); border: 1px solid var(--term-border);
  white-space: pre-wrap; word-break: break-word;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* ============================================================
   Modal + toast
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; background: color-mix(in srgb, #05100b 62%, transparent); backdrop-filter: blur(3px); }
.modal-overlay[hidden] { display: none; }
#confirm-modal { z-index: 150; }
#config-modal { z-index: 100; }
.modal-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow-lg); }
.modal-card h3 { font-size: 1.1rem; margin-bottom: .6rem; }
.modal-card p { color: var(--text-muted); font-size: .9rem; line-height: 1.55; margin-bottom: 1.5rem; white-space: pre-wrap; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* config editor modal (Bootstrap-like open animation) */
.config-modal .modal-card {
  width: min(1000px, 96vw);
  height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
  padding: 1.1rem;
  animation: config-modal-in .18s ease-out;
}
@keyframes config-modal-in {
  from { opacity: 0; transform: translateY(-14px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.config-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.config-modal-heading { min-width: 0; }
.config-modal-heading h3 { font-size: 1rem; margin-bottom: .15rem; }
.config-modal-heading .hint { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-modal-layout { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); gap: 1rem; min-height: 0; flex: 1; }
.config-modal-list { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: .6rem; }
.config-modal-list-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.config-modal-list-head .sm-field { flex: 1; min-width: 0; }
.config-modal-list .config-file-list { margin: 0; max-height: none; flex: 1; min-height: 160px; }
.config-modal-editor-pane { display: flex; flex-direction: column; min-height: 0; }
.config-modal-editor-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .5rem; }
.config-modal-editor-name { font-weight: 650; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-modal .config-editor { flex: 1; min-height: 0; height: 100%; margin-top: 0; }
.config-modal-editor-pane .hint { margin-top: .5rem; }

.toast-stack { position: fixed; top: 1.1rem; right: 1.1rem; z-index: 200; display: grid; gap: .5rem; max-width: min(360px, 92vw); }
.toast { display: flex; gap: .55rem; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 11px; padding: .75rem .9rem; font-size: .85rem; box-shadow: var(--shadow-lg); animation: toast-in .16s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Login page
   ============================================================ */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; position: relative; }
.login-topright { position: absolute; top: 1.2rem; right: 1.2rem; display: flex; align-items: center; gap: .5rem; }
.login-card { width: min(410px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2.2rem; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; margin-bottom: 1.4rem; padding: 0; }
.login-card h1 { font-size: 1.45rem; text-align: center; letter-spacing: -.01em; }
.login-card .lead { text-align: center; color: var(--text-muted); font-size: .88rem; margin-top: .5rem; }
.login-form { display: grid; gap: .3rem; margin-top: 1.6rem; }
.login-form label { font-size: .8rem; color: var(--text-muted); font-weight: 600; margin-top: .8rem; }
.login-form .btn { margin-top: 1.4rem; width: 100%; padding: .7rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: .8rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 940px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: .6rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { flex: 1; }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; gap: .25rem; }
  .nav-item { white-space: nowrap; }
  .sidebar-footer { margin: 0; }
  .sidebar-footer .row { gap: .5rem; }
  .console-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
  .terminal { height: 340px; }
  .nav-item span { display: none; }
  .nav-item { padding: .55rem .65rem; }
  .config-modal-layout { grid-template-columns: 1fr; overflow: auto; }
  .config-modal-list { max-height: 220px; }
  .config-modal .config-editor { min-height: 320px; height: auto; }
}
