:root {
  color-scheme: dark;
  --primary: #9be15d;
  --on-primary: #0c170d;
  --accent: #f4b860;
  --surface: #101612;
  --surface-subtle: #090d0b;
  --surface-raised: #171f1a;
  --surface-strong: #222d26;
  --on-surface: #f1f5f0;
  --muted: #98a49c;
  --faint: #667168;
  --border: #2b372f;
  --border-strong: #3a493f;
  --focus: #b6f27e;
  --success: #8ad653;
  --warning: #f4b860;
  --error: #f0776f;
  --info: #77b7d7;
  --disabled: #566159;
  --control-radius: 6px;
  --panel-radius: 7px;
  --dialog-radius: 12px;
  --rail-width: 228px;
  --font-ui: Inter, Pretendard, "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 120px; }
body { min-width: 320px; margin: 0; background: #080c0a; color: var(--on-surface); font-family: var(--font-ui); font-size: 15px; }
body.dialog-open { overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }
.visually-hidden-data, .chat-fab { display: none; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 200; padding: 10px 14px; border-radius: var(--control-radius); background: var(--primary); color: var(--on-primary); font-weight: 800; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
::selection { background: rgb(155 225 93 / 28%); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface-subtle); }
::-webkit-scrollbar-thumb { border: 3px solid var(--surface-subtle); border-radius: 999px; background: var(--border-strong); }

/* Login */
.login-view { position: relative; display: grid; min-height: 100dvh; overflow: hidden; place-items: center; padding: 24px; background: #080c09; }
.login-backdrop { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: rgb(155 225 93 / 2%); }
.login-backdrop span { display: none; }
.login-panel { position: relative; width: min(100%, 460px); padding: 36px; border: 1px solid var(--border); border-radius: var(--dialog-radius); background: rgb(16 22 18 / 97%); box-shadow: 0 30px 90px rgb(0 0 0 / 48%); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.brand-block { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border: 1px solid rgb(155 225 93 / 24%); border-radius: 10px; background: rgb(155 225 93 / 8%); }
.brand-block img { image-rendering: pixelated; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font: 800 13px var(--font-mono); letter-spacing: .12em; }
.login-brand small { margin-top: 4px; color: var(--muted); font: 600 10px var(--font-mono); }
.login-copy { padding: 32px 0 24px; }
.login-copy > span { color: var(--primary); font: 800 10px var(--font-mono); letter-spacing: .16em; }
.login-copy h1 { margin: 9px 0 12px; font-size: clamp(36px, 9vw, 50px); line-height: 1.02; letter-spacing: -.055em; }
.login-copy p { margin: 0; max-width: 34ch; color: var(--muted); line-height: 1.65; text-wrap: pretty; }
.login-fields { display: grid; gap: 8px; }
.login-fields label { margin-top: 8px; font-size: 12px; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--surface-subtle); color: var(--on-surface); transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease; }
input { height: 44px; padding: 0 13px; }
textarea { min-height: 74px; padding: 11px 13px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover { border-color: #4b5c51; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); background: #0e1510; box-shadow: 0 0 0 3px rgb(155 225 93 / 10%); }
.login-submit { display: flex; width: 100%; height: 48px; align-items: center; justify-content: space-between; margin-top: 22px; padding: 0 16px; border: 0; border-radius: var(--control-radius); background: var(--primary); color: var(--on-primary); font-weight: 850; cursor: pointer; transition: background 160ms ease, transform 160ms ease; }
.login-submit:hover { background: #b0ee78; transform: translateY(-1px); }
.login-submit:active { transform: translateY(0); }
.login-message { min-height: 20px; margin: 11px 0 0; color: var(--error); font-size: 12px; }
.login-security { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--faint); font-size: 11px; }
.login-security span { color: var(--success); font-size: 8px; }

/* Shell and rail */
.app-shell { min-height: 100dvh; }
.command-rail { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: var(--rail-width); flex-direction: column; border-right: 1px solid var(--border); background: #080d0a; }
.command-rail::after { display: none; }
.rail-brand { position: relative; z-index: 1; display: flex; min-height: 84px; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.rail-brand .brand-block { width: 38px; height: 38px; flex-basis: 38px; }
.rail-brand strong, .rail-brand small { display: block; }
.rail-brand strong { font: 850 12px var(--font-mono); letter-spacing: .08em; }
.rail-brand small { margin-top: 4px; color: var(--muted); font: 650 8px var(--font-mono); letter-spacing: .06em; }
.rail-servers { position: relative; z-index: 1; padding: 18px 12px; border-bottom: 1px solid var(--border); }
.rail-section-title { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 9px; }
.rail-section-title h2 { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.rail-section-title > span { color: var(--faint); font: 650 9px var(--font-mono); }
.server-list { display: grid; gap: 6px; }
.server-item { display: grid; width: 100%; min-height: 58px; grid-template-columns: 8px minmax(0, 1fr); align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--control-radius); background: transparent; color: var(--on-surface); text-align: left; cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.server-item:hover { background: var(--surface); }
.server-item.selected { border-color: rgb(155 225 93 / 28%); background: rgb(155 225 93 / 9%); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 4px rgb(138 214 83 / 9%); }
.status-dot.offline { background: var(--error); box-shadow: 0 0 0 4px rgb(240 119 111 / 9%); }
.server-item-body { min-width: 0; }
.server-item-body strong, .server-item-body small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-item-body strong { font-size: 12px; }
.server-item-body small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.rail-empty { padding: 12px 7px; color: var(--muted); font-size: 11px; }
.rail-nav { position: relative; z-index: 1; display: grid; gap: 4px; padding: 16px 12px; }
.rail-nav a { display: grid; min-height: 44px; grid-template-columns: 26px 1fr; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--control-radius); color: var(--muted); transition: color 160ms ease, background 160ms ease; }
.rail-nav a > span { font: 750 10px var(--font-mono); letter-spacing: .05em; }
.rail-nav a > strong { font-size: 13px; }
.rail-nav a:hover { color: var(--on-surface); background: var(--surface); }
.rail-nav a.active { border-color: var(--border); background: var(--surface-raised); color: var(--on-surface); }
.rail-nav a.active > span { color: var(--primary); }
.rail-bottom { position: relative; z-index: 1; display: grid; gap: 10px; margin-top: auto; padding: 12px; }
.rail-help { display: flex; min-height: 42px; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--control-radius); color: var(--muted); }
.rail-help span { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: rgb(155 225 93 / 9%); color: var(--primary); font-weight: 850; }
.rail-help strong { font-size: 10px; }
.rail-account { display: grid; grid-template-columns: 36px 1fr 32px; align-items: center; gap: 9px; min-width: 0; }
.rail-account img { border-radius: 8px; image-rendering: pixelated; }
.rail-account strong, .rail-account small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-account strong { font-size: 11px; }
.rail-account small { margin-top: 2px; color: var(--faint); font-size: 9px; }
.rail-account button { width: 32px; height: 32px; border: 0; border-radius: var(--control-radius); background: transparent; color: var(--muted); cursor: pointer; }
.rail-account button:hover { background: var(--surface-raised); color: var(--on-surface); }

/* Header */
.deck-shell { min-width: 0; margin-left: var(--rail-width); }
.deck-header { position: sticky; top: 0; z-index: 30; display: grid; min-height: 114px; grid-template-columns: minmax(320px, 1fr) auto auto auto; align-items: center; gap: 20px; padding: 15px clamp(20px, 2.2vw, 34px); border-bottom: 1px solid var(--border); background: rgb(8 12 10 / 96%); box-shadow: 0 10px 30px rgb(0 0 0 / 18%); backdrop-filter: blur(16px); }
.server-title-block { display: flex; min-width: 0; align-items: center; gap: 14px; }
.server-avatar { display: grid; width: 58px; height: 58px; flex: 0 0 58px; place-items: center; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.server-avatar img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; }
.server-title-block > div { min-width: 0; }
.title-meta { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 11px; }
.connection-state { display: inline-flex; min-height: 22px; align-items: center; padding: 0 8px; border: 1px solid rgb(138 214 83 / 25%); border-radius: 999px; color: var(--success); font-weight: 750; }
.connection-state.offline { border-color: rgb(240 119 111 / 28%); color: var(--error); }
.server-title-block h1 { margin: 6px 0 5px; overflow: hidden; font-size: clamp(26px, 2.7vw, 38px); line-height: 1; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.server-title-block p { display: flex; min-width: 0; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 11px; }
.server-title-block p > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-title-block code { color: var(--primary); font: 650 10px var(--font-mono); white-space: nowrap; }
.header-version { min-width: 0; overflow: hidden; color: var(--faint); font: 650 10px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.server-title-block p button { min-height: 26px; padding: 0 7px; border: 0; background: transparent; color: var(--muted); font-size: 9px; font-weight: 750; cursor: pointer; }
.server-state-block { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.state-symbol { width: 12px; height: 12px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 6px rgb(138 214 83 / 8%); }
.server-offline .state-symbol { background: var(--error); box-shadow: 0 0 0 6px rgb(240 119 111 / 8%); }
.server-state-block small, .server-state-block strong, .server-state-block div > span { display: block; }
.server-state-block small { color: var(--faint); font: 750 8px var(--font-mono); letter-spacing: .12em; }
.server-state-block strong { margin-top: 3px; font-size: 14px; }
.server-state-block div > span { max-width: 145px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.server-actions { display: grid; grid-template-columns: repeat(3, auto); gap: 7px; }
.server-actions button { min-width: 92px; height: 44px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--surface-raised); color: var(--on-surface); font-size: 11px; font-weight: 800; cursor: pointer; transition: transform 160ms ease, border-color 160ms ease, background 160ms ease; }
.server-actions button span { margin-right: 7px; font-size: 9px; }
.server-actions button:hover { border-color: #526257; background: var(--surface-strong); transform: translateY(-1px); }
.server-actions button:active { transform: translateY(0); }
.server-actions .primary { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.server-actions .primary:hover { background: #b0ee78; }
.server-actions button:nth-child(2) { border-color: rgb(244 184 96 / 40%); color: var(--warning); }
.server-actions .destructive { border-color: rgb(240 119 111 / 42%); background: rgb(240 119 111 / 8%); color: var(--error); }
.server-actions button:disabled { opacity: .45; cursor: wait; transform: none; }
.header-utilities { display: flex; align-items: center; gap: 7px; }
.header-utilities > span { color: var(--faint); font: 650 9px var(--font-mono); white-space: nowrap; }
.header-utilities button { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface); color: var(--muted); cursor: pointer; }
.header-utilities button:hover { border-color: var(--border-strong); color: var(--on-surface); }

/* Cockpit */
.deck-main { width: min(100%, 1800px); margin: 0 auto; padding: 14px clamp(14px, 1.6vw, 24px) 40px; }
.cockpit-grid { display: grid; min-height: calc(100dvh - 148px); grid-template-columns: 248px minmax(560px, 1fr) 310px; align-items: start; gap: 10px; }
.diagnostics-deck, .live-workspace, .people-deck { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--panel-radius); background: var(--surface); box-shadow: inset 0 1px rgb(255 255 255 / 2%); }
.diagnostics-deck, .people-deck { display: flex; flex-direction: column; }
.live-workspace, .people-deck { height: calc(100dvh - 174px); min-height: 680px; }
.deck-section-heading { position: relative; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.deck-section-heading > span { color: var(--primary); font: 750 10px var(--font-mono); letter-spacing: .09em; }
.deck-section-heading h2 { margin: 5px 0 0; font-size: 18px; letter-spacing: -.025em; }

/* Diagnostics */
.telemetry-stack { display: grid; grid-template-columns: 1fr; border-bottom: 1px solid var(--border); }
.telemetry-stack article { position: relative; min-width: 0; min-height: 82px; padding: 13px 14px; border-bottom: 1px solid var(--border); }
.telemetry-stack article:last-child { border-bottom: 0; }
.telemetry-stack article > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.telemetry-stack article span { color: var(--muted); font-size: 11px; font-weight: 700; }
.telemetry-stack article strong { overflow: hidden; font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.telemetry-stack article small { display: block; margin-top: 8px; overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.telemetry-stack b { position: absolute; right: 14px; bottom: 12px; left: 14px; height: 3px; overflow: hidden; border-radius: 99px; background: var(--surface-strong); }
.telemetry-stack b i { display: block; width: 0; height: 100%; background: var(--primary); transition: width 220ms ease; }
.world-facts { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.world-facts > div { min-width: 0; padding: 11px 14px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.world-facts > div:nth-child(2n) { border-right: 0; }
.world-facts > div:nth-child(n+5) { border-bottom: 0; }
.world-facts span, .world-facts strong { display: block; }
.world-facts > div > span { color: var(--faint); font-size: 10px; }
.world-facts strong { margin-top: 4px; overflow: hidden; font: 650 12px var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.world-facts strong span { display: inline; }
.readiness-drawer { min-height: 0; flex: 1; }
.readiness-drawer summary { display: flex; min-height: 56px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid transparent; list-style: none; cursor: pointer; }
.readiness-drawer[open] summary { border-bottom-color: var(--border); }
.readiness-drawer summary::-webkit-details-marker { display: none; }
.readiness-drawer summary small, .readiness-drawer summary strong { display: block; }
.readiness-drawer summary small { color: var(--accent); font: 750 8px var(--font-mono); letter-spacing: .1em; }
.readiness-drawer summary strong { margin-top: 3px; font-size: 12px; }
.readiness-drawer summary > span:last-child { color: var(--muted); transition: transform 180ms ease; }
.readiness-drawer[open] summary > span:last-child { transform: rotate(180deg); }
.readiness-drawer > div { max-height: 345px; overflow-y: auto; overscroll-behavior: contain; }
.readiness-drawer > div > p:first-child { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 10px; line-height: 1.45; }
.guide-checks { display: grid; }
.guide-check { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 9px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.check-mark { min-width: 34px; padding: 4px 5px; border: 1px solid var(--border-strong); border-radius: 5px; color: var(--muted); font: 750 7px var(--font-mono); text-align: center; }
.guide-check.ok .check-mark { border-color: rgb(138 214 83 / 32%); color: var(--success); }
.guide-check.warn .check-mark { border-color: rgb(244 184 96 / 34%); color: var(--warning); }
.guide-check strong, .guide-check small { display: block; }
.guide-check strong { font-size: 10px; }
.guide-check small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.next-step { margin: 0; padding: 10px 14px; background: rgb(244 184 96 / 6%); color: var(--warning); font-size: 9px; line-height: 1.45; }

/* Live workspace */
.live-workspace { display: flex; min-height: 680px; flex-direction: column; }
.workspace-header { display: flex; min-height: 76px; align-items: flex-end; justify-content: space-between; gap: 16px; padding-right: 12px; border-bottom: 1px solid var(--border); }
.workspace-header .deck-section-heading { border-bottom: 0; }
.workspace-tabs { display: flex; align-self: stretch; gap: 3px; }
.workspace-tabs button { position: relative; min-width: 78px; padding: 0 13px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; cursor: pointer; }
.workspace-tabs button::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 2px; background: transparent; }
.workspace-tabs button:hover { color: var(--on-surface); }
.workspace-tabs button[aria-selected="true"] { color: var(--on-surface); }
.workspace-tabs button[aria-selected="true"]::after { background: var(--primary); }
.workspace-panel { min-height: 0; flex: 1; }
.workspace-panel[hidden] { display: none !important; }
.workspace-panel.active { display: flex; min-height: 0; flex-direction: column; animation: panel-enter 200ms ease-out both; }
@keyframes panel-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.panel-toolbar { display: flex; min-height: 57px; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #0f1511; }
.panel-toolbar strong, .panel-toolbar div > span { display: block; }
.panel-toolbar strong { font-size: 13px; }
.panel-toolbar div > span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.panel-toolbar > button, .log-tools button { min-height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-raised); color: var(--muted); font-size: 9px; font-weight: 700; cursor: pointer; }
.panel-toolbar > button:hover, .log-tools button:hover { border-color: var(--border-strong); color: var(--on-surface); }
.security-label { padding: 5px 7px; border: 1px solid rgb(155 225 93 / 24%); border-radius: 5px; color: var(--primary); font: 750 8px var(--font-mono); letter-spacing: .08em; }
.chat-surface { display: flex; min-height: 0; flex: 1; flex-direction: column; }
.chat-messages { min-height: 360px; flex: 1; overflow-y: auto; padding: 10px 16px; overscroll-behavior: contain; }
.chat-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.chat-row:last-child { border-bottom: 0; }
.chat-meta strong, .chat-meta small { display: block; }
.chat-meta strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta small { margin-top: 4px; color: var(--faint); font: 8px var(--font-mono); }
.chat-row.mine .chat-meta strong { color: var(--primary); }
.chat-row.presence .chat-meta strong, .chat-row.advancement .chat-meta strong { color: var(--accent); }
.chat-text { color: #c5cec7; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.empty-state { display: grid; min-height: 180px; place-content: center; padding: 24px; color: var(--muted); text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--on-surface); font-size: 12px; }
.empty-state span { max-width: 34ch; margin-top: 5px; font-size: 10px; line-height: 1.5; }
.chat-composer { padding: 13px 14px 8px; border-top: 1px solid var(--border); background: #0f1511; }
.chat-composer > label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.chat-composer > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chat-composer button, .terminal-form button { min-width: 74px; border: 0; border-radius: var(--control-radius); background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 850; cursor: pointer; }
.quick-message-row { display: flex; align-items: center; gap: 6px; padding: 0 14px 8px; background: #0f1511; }
.quick-message-row > span { margin-right: 2px; color: var(--faint); font-size: 9px; }
.quick-message-row button, .preset-row button { min-height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.quick-message-row button:hover, .preset-row button:hover { border-color: var(--border-strong); color: var(--on-surface); }
.inline-result { min-height: 26px; margin: 0; padding: 0 14px 9px; background: #0f1511; color: var(--faint); font-size: 9px; }
.terminal-surface { display: flex; min-height: 0; flex: 1; flex-direction: column; background: #070c09; }
.terminal-surface pre { min-height: 390px; flex: 1; margin: 0; overflow: auto; padding: 20px; color: #c3d7be; font: 13px/1.72 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; overscroll-behavior: contain; }
.terminal-form { padding: 12px 14px 8px; border-top: 1px solid var(--border); background: #0f1511; }
.terminal-form > label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.terminal-form > div { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--surface-subtle); }
.terminal-form > div > span { color: var(--primary); font: 800 17px var(--font-mono); text-align: center; }
.terminal-form input { height: 42px; padding-left: 0; border: 0; border-radius: 0; box-shadow: none; font-family: var(--font-mono); }
.terminal-form button { align-self: stretch; margin: 5px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 9px; background: #0f1511; }
.logs-surface { min-height: 0; flex: 1; background: #070c09; }
.logs-surface pre { height: 100%; min-height: 420px; max-height: calc(100dvh - 440px); margin: 0; overflow: auto; padding: 20px; color: #c1d1bf; font: 12px/1.72 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; overscroll-behavior: contain; }
.log-tools { display: flex; align-items: center; gap: 6px; }
.log-tools label { color: var(--faint); font-size: 9px; }
.log-tools input { width: 180px; height: 34px; font-size: 10px; }
.console-command-dock { padding: 11px 14px 12px; border-top: 1px solid var(--border); background: #0f1511; }
.console-command-dock > label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.console-command-dock > div { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: #080d0a; }
.console-command-dock > div > span { color: var(--primary); font: 850 18px var(--font-mono); text-align: center; }
.console-command-dock input { height: 42px; padding-left: 0; border: 0; border-radius: 0; box-shadow: none; font-family: var(--font-mono); }
.console-command-dock button { min-width: 78px; align-self: stretch; margin: 5px; border: 0; border-radius: 5px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 850; cursor: pointer; }
.console-command-dock small { display: block; min-height: 14px; margin-top: 7px; color: var(--faint); font-size: 9px; }

/* People and operations */
.people-heading { padding-right: 54px; }
.people-heading > button { position: absolute; top: 17px; right: 14px; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-raised); color: var(--muted); cursor: pointer; }
.players-surface { display: flex; min-height: 0; flex: 1; flex-direction: column; border-bottom: 1px solid var(--border); }
.surface-title { display: flex; min-height: 49px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: #0f1511; }
.surface-title strong, .surface-title > span { display: block; }
.surface-title strong { font-size: 12px; }
.surface-title > span { color: var(--faint); font-size: 10px; }
.surface-title button { min-height: 32px; padding: 0 9px; border: 1px solid rgb(155 225 93 / 28%); border-radius: var(--control-radius); background: transparent; color: var(--primary); font-size: 9px; font-weight: 750; cursor: pointer; }
.player-list { min-height: 180px; max-height: 300px; flex: 1; overflow-y: auto; padding: 4px 13px; overscroll-behavior: contain; }
.player-row { display: grid; min-height: 52px; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); }
.player-avatar { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid rgb(155 225 93 / 18%); border-radius: 7px; background: rgb(155 225 93 / 8%); color: var(--primary); font: 750 9px var(--font-mono); text-transform: uppercase; }
.player-row strong, .player-row small { display: block; }
.player-row strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.player-row small { margin-top: 3px; color: var(--faint); font-size: 8px; }
.player-online { display: flex; align-items: center; gap: 5px; color: var(--success); font-size: 8px; font-weight: 750; }
.player-online::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.player-tools { padding: 11px 13px 13px; border-top: 1px solid var(--border); background: #0f1511; }
.player-tools > label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.player-tools input { height: 38px; font-size: 11px; }
.player-tools > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 7px; }
.player-tools button { min-height: 34px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-raised); font-size: 9px; font-weight: 750; cursor: pointer; }
.player-tools button:hover { border-color: var(--border-strong); background: var(--surface-strong); }
.player-tools .destructive { color: var(--error); }
.operations-surface { min-height: 240px; }
.backup-status { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.backup-status span { color: var(--faint); font-size: 9px; }
.backup-status strong { overflow: hidden; font: 600 9px var(--font-mono); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.backup-status small { grid-column: 1 / -1; color: var(--muted); font-size: 8px; text-align: right; }
.history-list { padding: 3px 13px 8px; }
.history-row { display: grid; min-height: 34px; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.history-row strong { font-size: 9px; }
.history-row small { overflow: hidden; color: var(--faint); font-size: 8px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.history-row.failed strong { color: var(--error); }
.history-empty { padding: 14px 0; color: var(--faint); font-size: 9px; }

/* Settings and footer */
.settings-deck { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--panel-radius); background: var(--surface); }
.settings-deck summary { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; list-style: none; cursor: pointer; }
.settings-deck summary::-webkit-details-marker { display: none; }
.settings-deck summary small, .settings-deck summary strong { display: block; }
.settings-deck summary small { color: var(--primary); font: 750 8px var(--font-mono); letter-spacing: .1em; }
.settings-deck summary strong { margin-top: 4px; font-size: 13px; }
.settings-deck summary > span:last-child { display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: 10px; }
.settings-deck summary i { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: var(--control-radius); font-style: normal; transition: transform 180ms ease; }
.settings-deck[open] summary i { transform: rotate(45deg); }
.settings-body { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 28px; padding: 20px 16px 22px; border-top: 1px solid var(--border); }
.settings-intro { display: flex; flex-direction: column; align-items: flex-start; }
.settings-intro p { margin: 0; line-height: 1.55; }
.settings-intro strong { margin-top: 15px; color: var(--primary); font-size: 10px; line-height: 1.5; }
.settings-intro span { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.settings-intro button { min-height: 36px; margin-top: 17px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-raised); color: var(--muted); font-size: 10px; cursor: pointer; }
.settings-intro button:disabled { opacity: .4; cursor: not-allowed; }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 13px; }
.settings-form label { color: var(--muted); font-size: 10px; font-weight: 700; }
.settings-form input, .settings-form textarea { margin-top: 6px; font-size: 11px; }
.settings-form .wide { grid-column: 1 / -1; }
.settings-save { min-height: 42px; border: 0; border-radius: var(--control-radius); background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 850; cursor: pointer; }
.settings-form :disabled { opacity: .42; cursor: not-allowed; }
.deck-footer { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 22px 2px 0; color: var(--faint); font: 8px var(--font-mono); letter-spacing: .05em; text-transform: uppercase; }
.deck-footer span:last-child { margin-left: auto; max-width: 45ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-nav { display: none; }

/* Dialog and toast */
.dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgb(4 8 5 / 76%); backdrop-filter: blur(10px); }
.dialog-card { display: grid; width: min(100%, 440px); grid-template-columns: 48px 1fr; gap: 16px; padding: 24px; border: 1px solid var(--border-strong); border-radius: var(--dialog-radius); background: var(--surface-raised); box-shadow: 0 28px 80px rgb(0 0 0 / 45%); }
.dialog-symbol { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid rgb(240 119 111 / 30%); border-radius: 50%; background: rgb(240 119 111 / 8%); color: var(--error); font-size: 18px; font-weight: 900; }
.dialog-card small { color: var(--error); font: 750 8px var(--font-mono); letter-spacing: .12em; }
.dialog-card h2 { margin: 5px 0 7px; font-size: 21px; }
.dialog-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.dialog-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 7px; }
.dialog-actions button { min-height: 40px; padding: 0 15px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--surface-strong); font-size: 11px; font-weight: 800; cursor: pointer; }
.dialog-actions .destructive { border-color: var(--error); background: var(--error); color: #250806; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 120; max-width: min(420px, calc(100vw - 36px)); padding: 13px 16px; border: 1px solid var(--border-strong); border-radius: var(--control-radius); background: var(--surface-raised); color: var(--on-surface); font-size: 11px; box-shadow: 0 18px 42px rgb(0 0 0 / 38%); }
.toast.success { border-color: rgb(138 214 83 / 38%); }
.toast.warn { border-color: rgb(240 119 111 / 40%); color: #ffc5c0; }

@media (max-width: 1380px) {
  .deck-header { grid-template-columns: minmax(280px, 1fr) auto auto; }
  .header-utilities > span { display: none; }
  .cockpit-grid { grid-template-columns: 232px minmax(450px, 1fr) 280px; }
}

@media (max-width: 1179px) {
  .deck-header { min-height: 104px; grid-template-columns: minmax(280px, 1fr) auto auto; }
  .server-state-block { display: none; }
  .cockpit-grid { min-height: auto; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr); }
  .diagnostics-deck { grid-column: 1 / -1; display: grid; grid-template-columns: 180px minmax(280px, 1fr) minmax(280px, 1fr); }
  .diagnostics-deck > .deck-section-heading { border-right: 1px solid var(--border); border-bottom: 0; }
  .telemetry-stack { grid-template-columns: 1fr 1fr; border-right: 1px solid var(--border); border-bottom: 0; }
  .telemetry-stack article { min-height: 106px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .telemetry-stack article:nth-child(2n) { border-right: 0; }
  .telemetry-stack article:nth-child(n+3) { border-bottom: 0; }
  .world-facts { border-bottom: 0; }
  .readiness-drawer { grid-column: 1 / -1; border-top: 1px solid var(--border); }
  .readiness-drawer > div { max-height: 280px; }
  .live-workspace { height: auto; min-height: 690px; }
  .people-deck { height: auto; min-height: 690px; }
}

@media (max-width: 859px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .command-rail { display: none; }
  .deck-shell { margin-left: 0; }
  .deck-header { position: relative; min-height: auto; grid-template-columns: 1fr auto; padding: 13px 14px 15px; }
  .server-title-block { grid-column: 1 / -1; }
  .server-avatar { width: 50px; height: 50px; flex-basis: 50px; }
  .server-avatar img { width: 42px; height: 42px; }
  .server-title-block h1 { font-size: 29px; white-space: normal; }
  .server-title-block p { flex-wrap: wrap; }
  .server-title-block p > span { flex-basis: 100%; }
  .server-actions { grid-column: 1; grid-template-columns: repeat(3, 1fr); }
  .server-actions button { min-width: 0; }
  .header-utilities { justify-self: end; }
  .deck-main { padding: 12px 12px 28px; }
  .cockpit-grid { display: flex; flex-direction: column; }
  .diagnostics-deck { display: grid; grid-template-columns: 1fr 1fr; order: 1; }
  .diagnostics-deck > .deck-section-heading { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--border); }
  .telemetry-stack { border-right: 1px solid var(--border); }
  .readiness-drawer { grid-column: 1 / -1; }
  .live-workspace { min-height: 700px; order: 2; }
  .people-deck { min-height: 650px; order: 3; }
  .settings-deck { order: 4; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 60; display: grid; height: calc(64px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: rgb(9 14 11 / 96%); box-shadow: 0 -10px 30px rgb(0 0 0 / 22%); backdrop-filter: blur(14px); }
  .mobile-nav a { display: flex; min-width: 0; align-items: center; justify-content: center; flex-direction: column; gap: 4px; color: var(--muted); font-size: 8px; font-weight: 700; }
  .mobile-nav a span { color: var(--primary); font: 750 9px var(--font-mono); }
  .mobile-nav a.active { color: var(--on-surface); background: rgb(155 225 93 / 7%); }
  .toast { right: 12px; bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}

@media (max-width: 639px) {
  html { scroll-padding-top: 12px; }
  .deck-header { gap: 13px 8px; }
  .title-meta { flex-wrap: wrap; }
  #lastSeen, #serverSummary, .header-version { display: none; }
  .server-title-block h1 { font-size: 27px; }
  .server-title-block code { max-width: 75%; overflow: hidden; text-overflow: ellipsis; }
  .server-actions { width: 100%; }
  .server-actions button { height: 44px; padding: 0 7px; }
  .server-actions button span { display: none; }
  .header-utilities button { width: 44px; height: 44px; }
  .diagnostics-deck { display: block; }
  .diagnostics-deck > .deck-section-heading { border-bottom: 1px solid var(--border); }
  .telemetry-stack { grid-template-columns: 1fr 1fr; border-right: 0; }
  .telemetry-stack article { min-height: 98px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .telemetry-stack article:nth-child(2n) { border-right: 0; }
  .telemetry-stack article:nth-child(n+3) { border-bottom: 0; }
  .telemetry-stack article strong { font-size: 15px; line-height: 1.2; white-space: normal; }
  .readiness-drawer { border-top: 0; }
  .workspace-header { min-height: 112px; align-items: stretch; flex-direction: column; gap: 0; padding: 0; }
  .workspace-header .deck-section-heading { padding-bottom: 9px; }
  .workspace-tabs { width: 100%; height: 46px; padding: 0 8px; }
  .workspace-tabs button { min-width: 0; flex: 1; }
  .panel-toolbar { align-items: flex-start; }
  .log-tools { width: 100%; flex-wrap: wrap; }
  .log-tools label { display: none; }
  .log-tools input { min-width: 0; flex: 1; }
  .chat-messages { min-height: 330px; padding-right: 13px; padding-left: 13px; }
  .chat-row { grid-template-columns: 82px minmax(0, 1fr); gap: 9px; }
  .chat-composer { padding-right: 12px; padding-left: 12px; }
  .quick-message-row { flex-wrap: wrap; padding-right: 12px; padding-left: 12px; }
  .quick-message-row > span { width: 100%; }
  .terminal-surface pre { min-height: 360px; font-size: 10px; }
  .logs-surface pre { min-height: 440px; font-size: 9px; }
  .console-command-dock { padding-right: 12px; padding-left: 12px; }
  .people-deck { min-height: auto; }
  .player-list { max-height: 330px; }
  .settings-deck summary > span:last-child { font-size: 0; }
  .settings-body { grid-template-columns: 1fr; padding: 18px 14px; }
  .settings-form { grid-template-columns: 1fr; }
  .settings-form .wide { grid-column: auto; }
  .deck-footer span:last-child { width: 100%; margin-left: 0; }
  .dialog-card { grid-template-columns: 1fr; padding: 20px; }
  .dialog-actions { grid-column: auto; }
}

@media (max-width: 380px) {
  .deck-main { padding-right: 8px; padding-left: 8px; }
  .server-avatar { display: none; }
  .server-title-block h1 { font-size: 25px; }
  .server-actions { gap: 5px; }
  .server-actions button { font-size: 10px; }
  .telemetry-stack article { min-height: 104px; padding: 12px; }
  .telemetry-stack article strong { font-size: 16px; }
  .workspace-tabs button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
