:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #20262f;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #e59b18;
  --accent-2: #f0ad35;
  --ok: #4cd28b;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.app-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; height: 100vh; border-right: 1px solid var(--border); background: #0b0f14; padding: 22px 16px 18px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid var(--border); }
.sidebar-brand > div, .sidebar-brand strong, .sidebar-brand small { display: block; min-width: 0; }
.sidebar-brand strong { font-size: 1rem; }
.sidebar-brand small { color: var(--muted); font-size: .72rem; margin-top: 3px; }
.brand-mark { display: block; flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid #3b4655; border-radius: 4px; object-fit: cover; }
.sidebar-nav { display: grid; gap: 3px; margin-top: 18px; }
.sidebar-nav a { display: flex; align-items: center; min-height: 40px; border-left: 3px solid transparent; border-radius: 4px; color: var(--muted); font-size: .88rem; font-weight: 650; padding: 9px 12px; text-decoration: none; transition: background .12s ease, color .12s ease; }
.sidebar-nav a:hover { background: var(--surface); color: var(--text); }
.sidebar-nav a.active { border-left-color: var(--accent); background: var(--surface); color: var(--text); }
.sidebar-foot { display: flex; align-items: center; gap: 9px; color: #67778a; font-size: .72rem; margin-top: auto; padding: 12px 9px 2px; }
.sidebar-foot > span { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px rgba(76, 210, 139, .1); }
.dashboard-content { width: 100%; min-width: 0; margin: 0; padding: 32px clamp(18px, 2.5vw, 40px) 64px; }
.dashboard-content > section { margin-top: 38px; }
.dashboard-content > .overview-section { margin-top: 0; }
.scroll-target { scroll-margin-top: 22px; }
header, .section-title { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
header { align-items: center; margin-bottom: 24px; }
.header-actions { display: flex; gap: 9px; }
h1 { margin: 3px 0 7px; font-size: clamp(1.9rem, 3vw, 2.7rem); letter-spacing: -.025em; line-height: 1.1; }
h2 { margin: 2px 0 0; font-size: 1.35rem; }
.dashboard-content > section > .section-title > h2 { color: var(--accent); }
p { margin: 0; }
.subtitle { color: var(--muted); }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 750; letter-spacing: .08em; }
h3 { margin: 0; }

.status-grid { display: grid; grid-template-columns: minmax(150px, 180px) minmax(260px, 440px) minmax(190px, 230px); gap: 12px; width: fit-content; max-width: 100%; margin-top: 0; }
.status-grid article, .preset, .map-button, .output-section, .command-form, .inline-form, .player-action-form, .library-grid article {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: none;
}
.status-grid article { min-width: 0; border-radius: 7px; padding: 16px; }
.status-grid span { display: block; color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.status-grid strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online { color: var(--ok); }
.offline { color: var(--bad); }

button, input { font: inherit; }
button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #17120a;
  cursor: pointer;
  font-weight: 800;
  padding: 12px 17px;
  transition: background .12s ease, opacity .12s ease;
}
button:hover:not(:disabled) { background: var(--accent-2); }
button:disabled { cursor: wait; opacity: .5; }
button.secondary { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
button.small { padding: 8px 12px; font-size: .85rem; }

.map-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; margin-top: 15px; }
.map-panel { min-width: 0; border: 0; border-radius: 0; background: transparent; padding: 0; }
.map-panel-title { padding: 0 0 11px; }
.map-panel-title h3 { margin: 0; font-size: 1.08rem; }
.map-panel .stock-map-grid, .map-panel .library-grid { margin-top: 0; }
.map-panel .stock-map-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.map-panel .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.map-panel .inline-form { margin: 0 0 12px; }
.workshop-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .5fr) auto; }
.workshop-form button { width: auto; }
.stock-map-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 15px; }
.stock-map-card { display: grid; grid-template-columns: minmax(125px, .9fr) minmax(120px, 1.1fr); min-width: 0; min-height: 170px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.stock-map-preview { display: grid; min-width: 0; place-items: center; border-right: 1px solid var(--border); background: #0f141b; padding: 14px; }
.stock-map-preview img { width: min(100%, 165px); max-height: 165px; object-fit: contain; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .3)); }
.stock-map-details { display: flex; flex-direction: column; min-width: 0; padding: 16px; }
.stock-map-details h3 { overflow: hidden; margin: 0; font-size: clamp(1rem, 1.15vw, 1.25rem); letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.stock-map-load { width: 100%; margin-top: auto; padding: 13px 16px; }
.map-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.map-type-card { --map-type-color: #6f7c8a; display: flex; flex-direction: column; min-width: 0; min-height: 180px; border: 1px solid var(--border); border-top: 3px solid var(--map-type-color); border-radius: 7px; background: var(--surface); padding: 16px; }
.map-type-card-header, .map-type-identity, .map-type-card-actions { display: flex; align-items: center; }
.map-type-card-header { justify-content: space-between; gap: 12px; }
.map-type-identity { min-width: 0; gap: 9px; }
.map-type-identity h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-type-swatch { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 3px; background: var(--map-type-color); }
.map-type-kind { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.map-type-card > p { min-height: 2.8em; color: var(--muted); font-size: .82rem; line-height: 1.4; margin-top: 12px; }
.map-type-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.map-type-facts span { border: 1px solid var(--border); border-radius: 5px; background: #0c1118; color: #bac6d2; font-size: .7rem; padding: 5px 7px; }
.map-type-card-actions { gap: 8px; margin-top: auto; padding-top: 16px; }
.map-type-builder { display: grid; gap: 13px; margin-top: 18px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); padding: 16px; }
.map-type-builder > label, .map-type-builder-row label, .map-type-command-grid label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.map-type-builder input:not([type="checkbox"]):not([type="color"]), .map-type-builder textarea { display: block; width: 100%; margin-top: 6px; }
.map-type-builder-row { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 12px; }
.map-type-color-label input { display: block; width: 100%; height: 43px; margin-top: 6px; border: 1px solid var(--border); border-radius: 7px; background: #0c1118; padding: 4px; }
.map-type-builder fieldset { margin: 0; border: 1px solid var(--border); border-radius: 7px; padding: 11px 13px; }
.map-type-builder legend { color: var(--muted); font-size: .74rem; font-weight: 700; padding: 0 5px; }
.module-option { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .84rem; }
.module-option input { width: 17px; height: 17px; accent-color: var(--accent); }
.map-type-command-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.map-type-command-grid textarea { min-height: 140px; }
.map-type-builder-actions { display: flex; justify-content: flex-end; gap: 9px; }
.toggle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 15px; }
.toggle-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 62px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; padding: 10px 13px; }
.toggle-card > span:first-child, .toggle-card strong, .toggle-card small { display: block; }
.toggle-card small { color: var(--muted); font-size: .76rem; line-height: 1.25; margin-top: 3px; }
.toggle-card input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.toggle-control { position: relative; flex: 0 0 52px; width: 52px; height: 29px; border: 1px solid #d74747; border-radius: 999px; background: #b72f38; box-shadow: 0 0 0 3px rgba(183, 47, 56, .12); transition: .16s ease; }
.toggle-control::after { content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px rgba(0, 0, 0, .3); transition: .16s ease; }
.toggle-card input:checked + .toggle-control { border-color: #35c978; background: #1fa866; box-shadow: 0 0 0 3px rgba(31, 168, 102, .14); }
.toggle-card input:checked + .toggle-control::after { background: #fff; transform: translateX(23px); }
.toggle-card input:focus-visible + .toggle-control { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.toggle-card input:disabled + .toggle-control { cursor: wait; opacity: .55; }
.toggle-card.unknown .toggle-control { border-color: #647488; border-style: dashed; background: #303b49; box-shadow: none; }
.rule-block { margin-top: 18px; }
.rule-block + .rule-block { margin-top: 30px; }
.rule-block > h3 { color: var(--muted); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.setting-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; min-height: 58px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); padding: 8px 12px; }
.setting-copy { display: block; min-width: 0; }
.setting-copy strong, .setting-copy small { display: block; }
.setting-copy strong { font-size: 1rem; }
.setting-copy small { color: var(--muted); font-size: .76rem; line-height: 1.25; margin-top: 3px; }
.setting-select { flex: 0 0 min(190px, 42%); min-width: 150px; border-radius: 8px; font-weight: 750; }
.value-stepper { display: grid; grid-template-columns: 42px minmax(82px, 112px) 42px; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #0c1118; }
.value-stepper button { border-radius: 0; background: var(--surface-2); color: var(--text); font-size: 1.2rem; line-height: 1; padding: 8px 6px; }
.value-stepper button:first-child { border-right: 1px solid var(--border); }
.value-stepper button:last-child { border-left: 1px solid var(--border); }
.value-stepper input { width: 100%; border: 0; border-radius: 0; background: transparent; font-size: 1.05rem; font-weight: 800; text-align: center; }
.value-stepper input::-webkit-inner-spin-button, .value-stepper input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.value-stepper input[type="number"] { appearance: textfield; }
.setting-card.saving .value-stepper { border-color: #526171; }
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 15px; }
.bot-action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 15px; }
.bot-action-grid .preset-card { height: 100%; }
.bot-action-grid .preset { height: 100%; }
.preset-card { display: flex; flex-direction: column; gap: 7px; }
.preset { color: var(--text); text-align: left; padding: 18px; }
.preset strong, .preset span { display: block; }
.preset span { color: var(--muted); font-size: .85rem; font-weight: 500; line-height: 1.45; margin-top: 7px; }

.command-form, .inline-form { display: flex; gap: 10px; border-radius: 7px; margin-top: 15px; padding: 10px; }
.command-form input, .inline-form input { flex: 1; min-width: 0; }
input, select { border: 1px solid var(--border); border-radius: 9px; outline: 0; background: #0c1118; color: var(--text); padding: 11px 12px; }
textarea { border: 1px solid var(--border); border-radius: 12px; outline: 0; background: #0c1118; color: var(--text); font: 500 .92rem/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; padding: 16px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #617083; }
.compact { margin-top: 12px; }
.preset-builder { display: grid; gap: 10px; margin-top: 24px; }
.preset-builder > label { font-size: 1.05rem; font-weight: 800; }
.preset-builder textarea { width: 100%; min-height: 260px; }
.preset-builder-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 18px; }
.preset-builder-footer input { width: min(520px, 65%); }
.preset-builder-footer button { min-width: 150px; }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 15px; }
.library-grid article { border-radius: 8px; padding: 0; }
.workshop-card { --map-type-color: #6f7c8a; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.workshop-preview { position: relative; display: grid; aspect-ratio: 16 / 9; min-height: 0; place-items: center; overflow: hidden; background: #0f141b; }
.workshop-preview::after { content: ''; position: absolute; inset: 0; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, .18)); pointer-events: none; }
.workshop-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.workshop-preview > span { z-index: 1; max-width: 80%; color: #dce5ed; font-size: clamp(1.45rem, 3vw, 2.5rem); font-weight: 800; letter-spacing: -.035em; text-align: center; }
.workshop-preview.has-image > span { display: none; }
.workshop-details { display: flex; flex: 1; flex-direction: column; min-width: 0; padding: 16px; }
.workshop-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.workshop-details h3 { overflow: hidden; margin: 2px 0 0; font-size: 1.05rem; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.workshop-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.workshop-meta > span { min-width: 0; border: 1px solid var(--border); border-radius: 5px; background: #0e141c; color: #aeb9c5; font-size: .71rem; line-height: 1; padding: 6px 8px; }
.workshop-type-badge { border-color: transparent !important; background: color-mix(in srgb, var(--map-type-color) 72%, #111820) !important; color: #fff !important; font-weight: 750; }
.workshop-map-id { overflow: hidden; max-width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; text-overflow: ellipsis; white-space: nowrap; }
.map-settings-button { flex: 0 0 34px; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); font-size: 1rem; line-height: 1; padding: 0; }
.map-settings-button[aria-expanded="true"] { border-color: #8c651f; background: #3b2c12; color: #ffc860; }
.map-type-editor { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px 10px; margin-top: 14px; border: 1px solid var(--border); border-radius: 7px; background: #0c1118; padding: 10px; }
.map-type-editor[hidden] { display: none; }
.map-type-editor label { color: var(--muted); font-size: .74rem; font-weight: 700; }
.map-type-editor select { display: block; width: 100%; margin-top: 5px; padding: 8px 9px; }
.map-type-editor small { grid-column: 1 / -1; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.map-type-editor button { padding: 9px 11px; }
.workshop-links { display: flex; align-items: center; gap: 9px; margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.workshop-links a { color: var(--muted); font-size: .78rem; font-weight: 700; text-decoration: none; }
.workshop-links a:hover { text-decoration: underline; }
.workshop-load { width: auto; min-width: 112px; margin-left: auto; padding: 10px 17px; font-size: .88rem; }
.remove-button { background: transparent; border: 1px solid #5f3333; color: #ffb0b0; font-size: .8rem; padding: 8px 11px; }
.remove-button:hover:not(:disabled) { background: #351b1b; }
.workshop-links .remove-button { border: 0; padding: 8px 5px; }
.workshop-links .remove-button:hover:not(:disabled) { background: transparent; color: #ffd0d0; text-decoration: underline; }
.empty-state { display: block; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); padding: 20px; }
.player-table-wrap { overflow-x: auto; margin-top: 15px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.player-table { width: 100%; min-width: 900px; border-collapse: collapse; }
.player-table th, .player-table td { padding: 13px 14px; text-align: left; vertical-align: middle; }
.player-table th { border-bottom: 1px solid var(--border); background: rgba(24, 34, 48, .76); color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.player-table td { border-bottom: 1px solid rgba(38, 52, 70, .72); font-size: .88rem; }
.player-table tbody tr:last-child td { border-bottom: 0; }
.player-table tbody tr:hover:not(.player-empty) { background: rgba(255, 255, 255, .025); }
.player-table tbody tr.selected { background: rgba(229, 155, 24, .09); }
.player-table tbody tr.selected:hover { background: rgba(229, 155, 24, .12); }
.player-identity strong, .player-identity small { display: block; }
.player-identity strong { color: var(--text); }
.player-identity small { color: var(--muted); margin-top: 3px; }
.team-badge { display: inline; font-size: .8rem; font-weight: 900; }
.team-badge.ct { color: #9fd2ff; }
.team-badge.t { color: #ffe09b; }
.life-stats { display: flex; align-items: center; gap: 7px; min-height: 24px; white-space: nowrap; }
.life-value { color: var(--text); font-weight: 800; }
.life-value.alive { color: var(--text); }
.life-value.dead { color: var(--bad); font-weight: 800; }
.player-status-icon { display: inline-flex; position: relative; flex: 0 0 auto; align-items: center; justify-content: center; color: #c8d3de; }
.health-icon { width: 19px; height: 19px; border: 1px solid #718196; border-radius: 50%; font-size: 1rem; font-weight: 900; line-height: 1; }
.armor-group { display: inline-flex; align-items: center; gap: 5px; margin-left: 5px; }
.armor-icon { gap: 2px; min-width: 17px; height: 19px; }
.kevlar-shape { width: 13px; height: 16px; background: #91a3b7; clip-path: polygon(50% 0, 100% 20%, 86% 78%, 50% 100%, 14% 78%, 0 20%); }
.helmet-shape { width: 12px; height: 9px; border: 2px solid #91a3b7; border-bottom-width: 3px; border-radius: 9px 9px 2px 2px; }
.armor-value { color: #b8c6d5; font-weight: 800; }
.equipment-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 440px; }
.equipment-item { border: 1px solid var(--border); border-radius: 7px; background: #0c1118; color: #c9d4de; padding: 4px 7px; font-size: .72rem; white-space: nowrap; }
.player-select-cell { width: 120px; text-align: right !important; }
.player-select-button { min-width: 92px; }
.player-select-button.selected { border-color: #8c651f; background: #3b2c12; color: #ffc860; }
.player-empty td { color: var(--muted); padding: 20px; text-align: center; }
.player-action-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; border-radius: 14px; margin-top: 12px; padding: 14px; }
.player-action-form label, .selected-player-display { color: var(--muted); font-size: .78rem; }
.player-action-form select, .player-action-form input { display: block; width: 100%; margin-top: 6px; }
.player-action-form button { align-self: end; }
.selected-player-display { display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.selected-player-display strong { overflow: hidden; min-height: 43px; margin-top: 6px; border: 1px solid var(--border); border-radius: 9px; background: #0c1118; color: var(--text); padding: 11px 12px; text-overflow: ellipsis; white-space: nowrap; }
code { color: var(--accent-2); }

.output-section { border-radius: 7px; padding: 20px; }
.output-section .section-title { align-items: center; }
pre { min-height: 130px; max-height: 420px; overflow: auto; margin: 18px 0 0; border-radius: 11px; background: #080b0f; color: #cad5df; padding: 18px; white-space: pre-wrap; word-break: break-word; }

#toast { display: none !important; }

.login-page { display: grid; place-items: center; padding: 22px; }
.login-shell { width: min(460px, 100%); margin: 0; padding: 0; }
.login-card { margin: 0; border: 1px solid var(--border); border-radius: 22px; background: rgba(18, 25, 35, .92); box-shadow: 0 28px 90px rgba(0, 0, 0, .38); padding: clamp(26px, 7vw, 46px); }
.login-card h1 { margin-top: 12px; font-size: clamp(2.2rem, 10vw, 3.4rem); }
.login-copy { color: var(--muted); line-height: 1.55; margin-top: 14px; }
.login-form { display: grid; gap: 16px; margin-top: 30px; }
.login-form label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.login-form input { display: block; width: 100%; margin-top: 7px; }
.login-form button { margin-top: 4px; padding: 14px 18px; }
.login-error { min-height: 1.3em; color: #ff9d9d; font-size: .86rem; margin-top: 15px; }
.login-note { color: #647488; font-size: .78rem; margin-top: 18px; text-align: center; }

.confirm-dialog { width: min(440px, calc(100% - 28px)); border: 1px solid #3a4654; border-radius: 10px; outline: 0; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, .6); padding: 0; }
.confirm-dialog::backdrop { background: rgba(4, 7, 11, .76); backdrop-filter: blur(2px); }
.confirm-dialog-card { padding: 22px; }
.confirm-dialog h2 { margin: 7px 0 0; font-size: 1.25rem; }
.confirm-dialog #confirm-message { color: var(--muted); line-height: 1.5; margin-top: 12px; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.confirm-dialog .confirm-danger { background: #bd3d45; color: #fff; }
.confirm-dialog .confirm-danger:hover:not(:disabled) { background: #d64b54; }

@media (max-width: 1350px) {
  .map-panel .stock-map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .map-panel .stock-map-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-panel .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 9px 12px; }
  .sidebar-brand { flex: 0 0 auto; border-right: 1px solid var(--border); border-bottom: 0; padding: 0 13px 0 0; }
  .sidebar-brand > div, .sidebar-foot { display: none; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; border-radius: 4px; }
  .sidebar-nav { display: flex; gap: 5px; min-width: 0; overflow-x: auto; margin: 0 0 0 10px; scrollbar-width: none; }
  .sidebar-nav::-webkit-scrollbar { display: none; }
  .sidebar-nav a { flex: 0 0 auto; gap: 0; padding: 10px 11px; white-space: nowrap; }
  .sidebar-nav a > span { display: none; }
  .dashboard-content { padding-top: 25px; }
  .scroll-target { scroll-margin-top: 76px; }
}

@media (max-width: 820px) {
  .status-grid { grid-template-columns: minmax(130px, .7fr) minmax(220px, 1.5fr) minmax(170px, 1fr); width: 100%; }
  .map-panel .stock-map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-panel .library-grid { grid-template-columns: 1fr; }
  .workshop-form { grid-template-columns: 1fr; }
  .workshop-form button { width: 100%; }
  .toggle-grid { grid-template-columns: repeat(2, 1fr); }
  .setting-grid { grid-template-columns: 1fr; }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }
  .bot-action-grid { grid-template-columns: repeat(2, 1fr); }
  .player-action-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-type-command-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .dashboard-content { width: 100%; padding: 24px 11px 60px; }
  header, .section-title { align-items: flex-start; flex-direction: column; gap: 13px; }
  header button { width: 100%; }
  .header-actions { width: 100%; }
  .status-grid, .preset-grid, .bot-action-grid { grid-template-columns: 1fr; }
  .map-type-grid, .map-type-builder-row { grid-template-columns: 1fr; }
  .map-panel { padding: 0; }
  .map-panel .stock-map-grid { grid-template-columns: 1fr; }
  .toggle-grid { grid-template-columns: 1fr; }
  .setting-card { align-items: stretch; flex-direction: column; }
  .setting-select { flex-basis: auto; width: 100%; }
  .value-stepper { grid-template-columns: 48px minmax(0, 1fr) 48px; width: 100%; }
  .player-action-form { grid-template-columns: 1fr; }
  .library-grid { grid-template-columns: 1fr; }
  .command-form, .inline-form { flex-direction: column; }
  .preset-builder-footer { align-items: stretch; flex-direction: column; padding: 0; }
  .preset-builder-footer input, .preset-builder-footer button { width: 100%; }
  .workshop-details { padding: 16px; }
  .workshop-links { flex-wrap: wrap; }
  .workshop-load { flex: 1 0 100%; width: 100%; margin-left: 0; }
}
