:root {
  color-scheme: dark;
  --bg: #111715;
  --panel: rgba(15, 22, 20, 0.92);
  --panel-border: rgba(159, 198, 178, 0.16);
  --text: #f3f4ef;
  --muted: #b5c2b7;
  --accent: #b7ef6d;
  --warn: #ff8a65;
  --offline: #c44536;
  --online: #4caf50;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

button,
input,
canvas,
.tool-row,
.action-button,
.overlay-button,
.graphs-launch,
.graph-close,
.graph-range,
.graph-toggle,
.mini-chip {
  -webkit-touch-callout: none;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  background:
    radial-gradient(circle at top, rgba(100, 160, 130, 0.28), transparent 35%),
    linear-gradient(180deg, #15211d 0%, #0d120f 100%);
  color: var(--text);
  padding:
    env(safe-area-inset-top, 0)
    env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left, 0);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(104, 174, 126, 0.18), transparent 32%),
    rgba(4, 8, 6, 0.84);
  backdrop-filter: blur(10px);
}

.start-screen.hidden {
  display: none !important;
}

.start-screen-panel {
  width: min(980px, calc(100vw - 28px));
  max-height: min(90vh, 900px);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid rgba(159, 198, 178, 0.18);
  border-radius: 24px;
  background: rgba(11, 17, 15, 0.95);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.34);
  overflow: auto;
}

.start-screen-copy h1,
.start-card-head h2 {
  margin: 0;
}

.start-screen-copy p,
.start-card-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.start-name-field {
  display: grid;
  gap: 8px;
  max-width: 320px;
}

.start-name-field span {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.start-name-field input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(9, 14, 12, 0.92);
  color: var(--text);
  font: inherit;
}

.start-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.start-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.start-save-slots {
  display: grid;
  gap: 10px;
}

.start-save-slot {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: rgba(8, 12, 10, 0.72);
}

.start-save-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.start-save-slot-head strong {
  font-size: 1rem;
}

.start-save-slot-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(183, 239, 109, 0.12);
  color: #dff4b9;
  font-size: 0.76rem;
  font-weight: 700;
}

.start-save-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.start-save-meta span,
.start-save-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.start-save-actions,
.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.start-primary-button,
.start-secondary-button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.start-primary-button {
  border: 0;
  background: var(--accent);
  color: #142112;
}

.start-secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.layout {
  display: block;
  padding: 0 !important;
  min-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  min-height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
  width: 100%;
}

.stage-shell {
  position: relative;
  min-height: 100%;
  height: 100%;
  max-height: 100%;
  width: 100%;
  min-width: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  display: block;
  overflow: hidden;
}

.top-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 10px);
  left: calc(env(safe-area-inset-left, 0) + 10px);
  right: calc(env(safe-area-inset-right, 0) + 10px);
  z-index: 8;
  display: grid;
  gap: 4px;
  pointer-events: none;
}

.top-controls {
  display: block;
}

.overlay-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: auto;
}

.top-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.top-stats-overlay {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  justify-content: center;
  pointer-events: none;
}

.top-stat {
  min-width: 100px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(9, 14, 12, 0.8);
  backdrop-filter: blur(6px);
}

.top-stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.top-stat-value {
  display: block;
  margin-top: 1px;
  font-weight: 700;
  font-size: 0.92rem;
}

.overlay-legend-inline {
  min-height: 0;
  font-size: 0.78rem;
  pointer-events: none;
}

.play-shell {
  position: absolute;
  inset: 0;
  min-height: 100%;
  height: 100%;
  display: grid;
  align-items: stretch;
  justify-items: stretch;
  overflow: hidden;
}

.floating-panel {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(159, 198, 178, 0.18);
  border-radius: 16px;
  background: rgba(11, 17, 15, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
  padding: 12px;
  pointer-events: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.inspect-panel {
  top: 14px;
  right: 14px;
  width: min(300px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow-y: auto;
}

.bot-popup {
  top: 14px;
  right: 14px;
  width: min(380px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow-y: auto;
}

.chat-overlay {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  display: grid;
  gap: 10px;
  justify-items: start;
  pointer-events: none;
}

.chat-overlay .chat-log {
  max-width: min(520px, 100%);
  width: min(520px, 100%);
  max-height: 190px;
  padding: 8px;
  border: 1px solid rgba(159, 198, 178, 0.16);
  border-radius: 16px;
  background: rgba(9, 14, 12, 0.86);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

canvas {
  display: block;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100%;
  aspect-ratio: auto;
  margin-inline: 0;
  justify-self: stretch;
  margin-top: 0;
  margin-bottom: 0;
  border-radius: 0;
  background: #1a1f1c;
  touch-action: none;
  cursor: crosshair;
}

canvas.panning {
  cursor: grabbing;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.chat-form-overlay {
  width: min(520px, 100%);
  padding: 10px;
  border: 1px solid rgba(159, 198, 178, 0.16);
  border-radius: 16px;
  background: rgba(9, 14, 12, 0.9);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.chat-form input,
.chat-form button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(9, 14, 12, 0.92);
  color: var(--text);
  font: inherit;
  min-height: 38px;
}

.chat-form input {
  padding: 12px 14px;
}

.chat-form button {
  padding: 12px 16px;
  cursor: pointer;
}

.chat-log {
  display: grid;
  gap: 8px;
  max-height: 108px;
  overflow: auto;
}

.chat-line {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.chat-name {
  display: block;
  margin-bottom: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tagline {
  margin-top: 4px;
  color: var(--muted);
}

.graphs-launch,
.overlay-button {
  flex: 0 0 100px;
  width: 100px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.graphs-launch {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.dev-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dev-action-status {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(183, 239, 109, 0.28);
  border-radius: 12px;
  background: rgba(183, 239, 109, 0.08);
  color: #dff4b9;
  font-weight: 700;
}

.stats,
.tool-list,
.feed,
.action-list {
  display: grid;
  gap: 0;
}

.tool-list,
.action-list {
  display: flex;
  flex-wrap: wrap;
}

.mini-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.mini-chip-grid-secondary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-chip {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mini-chip.active {
  border-color: rgba(183, 239, 109, 0.45);
  background: rgba(183, 239, 109, 0.1);
}

.mini-chip.danger {
  border-color: rgba(255, 116, 116, 0.28);
  color: #ffd7d7;
}

.bot-roster {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.bot-picker {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(12, 18, 16, 0.96);
  color: #f3f4ef;
  font: inherit;
  color-scheme: dark;
}

.bot-picker option {
  background: #101714;
  color: #f3f4ef;
}

.bot-close {
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.bot-roster-item {
  display: grid;
  gap: 8px;
}

.bot-roster-item.active .bot-roster-row {
  border-color: rgba(183, 239, 109, 0.3);
  background: rgba(183, 239, 109, 0.08);
}

.bot-roster-title {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bot-roster-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bot-roster-row strong {
  color: var(--muted);
}

.bot-roster-empty {
  margin-top: 10px;
  color: var(--muted);
}

.bot-editor {
  display: grid;
  gap: 8px;
  padding: 10px 12px 2px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.bot-editor-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.icon-chip .control-icon {
  width: 20px;
  height: 20px;
}

.icon-chip span {
  white-space: nowrap;
}

.incident-feed {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  display: grid;
  gap: 8px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(240px, 42vh);
  padding: 10px;
  border: 1px solid rgba(255, 120, 120, 0.22);
  border-radius: 16px;
  background: rgba(10, 14, 12, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.28);
  overflow: auto;
  pointer-events: none;
}

.stat-row,
.tool-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.sell-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
}

.sell-copy {
  display: grid;
  gap: 2px;
}

.sell-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

.sell-price {
  text-align: right;
}

.sell-button {
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: #b7ef6d;
  color: #142112;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sell-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.tool-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex: 0 0 100px;
  width: 100px;
  min-height: 36px;
  padding: 2px 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.icon-button {
  position: relative;
}

.control-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
}

.control-icon svg {
  width: 100%;
  height: 100%;
}

.tool-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.tool-cost {
  display: none;
}

.tool-row.active {
  border-color: rgba(183, 239, 109, 0.45);
  background: rgba(183, 239, 109, 0.1);
}

.tool-row,
.action-button,
.overlay-button,
.sell-button,
.graphs-launch,
.graph-close,
.graph-range,
.graph-toggle,
.chat-form button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tool-dock {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0) + 10px);
  right: calc(env(safe-area-inset-right, 0) + 10px);
  bottom: calc(env(safe-area-inset-bottom, 0) + 8px);
  z-index: 8;
  margin-top: 0;
  min-height: 0;
  pointer-events: none;
}

.tool-dock-inner {
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(15, 22, 20, 0.94);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.tool-dock-title {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.action-list {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.action-list-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auto-launch-button {
  display: none;
}

.auto-panel-shell {
  display: none;
  gap: 6px;
}

.auto-panel-shell.open {
  position: fixed;
  left: 10px;
  bottom: calc(env(safe-area-inset-bottom, 0) + 84px);
  z-index: 12;
  display: grid;
  gap: 6px;
  width: min(360px, calc(100vw - 20px));
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: rgba(15, 22, 20, 0.97);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.auto-panel-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
}

.auto-panel-shell .action-list,
.auto-panel-shell .action-list-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 100px;
  width: 100px;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.action-button-menu {
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  gap: 8px;
  padding: 6px 8px;
  text-align: left;
}

.action-button-label {
  font-weight: 700;
  font-size: 0.88rem;
}

.action-button.active {
  border-color: rgba(183, 239, 109, 0.45);
  background: rgba(183, 239, 109, 0.1);
}

.auto-area-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 0.78rem;
}

.overlay-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.overlay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.overlay-button.active {
  border-color: rgba(102, 215, 170, 0.5);
  background: rgba(102, 215, 170, 0.12);
  color: #e8fff5;
}

.overlay-legend {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.graph-page {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 9, 8, 0.72);
  backdrop-filter: blur(12px);
}

.graph-page.hidden {
  display: none;
}

.graph-page-inner {
  width: min(1200px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  display: grid;
  gap: 18px;
  padding: 22px;
  border: 1px solid rgba(179, 223, 197, 0.18);
  border-radius: 22px;
  background: rgba(11, 18, 16, 0.94);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
}

.graph-page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.dev-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.graph-page-copy {
  color: var(--muted);
}

.graph-close {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: #b7ef6d;
  color: #142112;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.dev-page-inner {
  width: min(980px, 100%);
  background: rgba(11, 18, 16, 0.72);
  backdrop-filter: blur(8px);
}

.dev-controls {
  display: grid;
  gap: 18px;
}

.dev-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}

.dev-group h3 {
  margin: 0;
}

.dev-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dev-control {
  display: grid;
  gap: 8px;
}

.dev-control-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.dev-control-top span {
  color: var(--muted);
  font-size: 0.88rem;
}

.dev-control input[type="range"] {
  width: 100%;
}

.graph-toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.graph-range-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.graph-range {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.graph-range.active {
  border-color: rgba(102, 215, 170, 0.5);
  background: rgba(102, 215, 170, 0.12);
  color: #e8fff5;
}

.graph-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.graph-toggle.active {
  border-color: color-mix(in srgb, var(--graph-color) 55%, transparent);
  background: color-mix(in srgb, var(--graph-color) 16%, rgba(255, 255, 255, 0.03));
}

.graph-toggle-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--graph-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--graph-color) 18%, transparent);
}

.graph-grid {
  display: block;
}

.graph-combo-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.graph-combo-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.graph-combo-top strong,
.graph-combo-top span {
  display: block;
}

.graph-combo-top span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.graph-legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.graph-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--graph-color);
}

.graph-legend-label {
  color: var(--muted);
}

.graph-legend-item strong {
  margin-left: auto;
}

.graph-svg {
  width: 100%;
  height: 120px;
}

.graph-svg-large {
  height: 360px;
}

.graph-empty {
  padding: 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.info-title {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #d9ff92;
  letter-spacing: 0.01em;
}

.feed {
  max-height: 240px;
  overflow: auto;
}

.feed-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 110, 110, 0.08);
  border: 1px solid rgba(255, 132, 132, 0.12);
  color: #ffe1e1;
}

.feed-item::before {
  content: "SECURITY";
  display: block;
  margin-bottom: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffb2b2;
}

@media (max-width: 1180px) {
  .overlay-strip {
    justify-content: flex-start;
  }
}

@media (min-width: 900px) {
  .tool-list {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .layout {
    gap: 14px;
    padding: 14px;
  }

  .stage-shell {
    padding: 12px;
    border-radius: 16px;
  }

  .tool-dock-inner {
    padding: 10px;
  }

  .top-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tool-list,
  .action-list {
    justify-content: flex-start;
  }

  .graph-page {
    padding: 12px;
  }

  .graph-page-inner {
    padding: 16px;
    border-radius: 18px;
  }

  .graph-toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .graph-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .graph-svg-large {
    height: 280px;
  }
}

@media (max-width: 680px) {
  .layout {
    padding: 4px;
  }

  .stage-shell {
    padding: 6px;
    gap: 4px;
    border-radius: 12px;
  }

  .top-hud {
    gap: 2px;
  }

  .overlay-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .overlay-strip::-webkit-scrollbar {
    display: none;
  }

  canvas {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    margin-top: 0;
    margin-bottom: 0;
  }

  h1 {
    font-size: 1.7rem;
  }

  .layout {
    gap: 12px;
    padding: 10px;
  }

  .stage-shell {
    padding: 12px;
    border-radius: 14px;
  }

  .chat-log {
    max-height: 92px;
  }

  .chat-form {
    display: none;
  }

  .top-stats-overlay {
    display: none;
  }

  .tool-list,
  .action-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .tool-list::-webkit-scrollbar,
  .action-list::-webkit-scrollbar {
    display: none;
  }

  .graph-range-grid,
  .graph-toggle-grid,
  .dev-group-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dev-header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .sell-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sell-price {
    text-align: left;
  }

  .graph-page-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .graph-legend {
    grid-template-columns: 1fr;
  }

  .auto-area-status {
    display: none;
  }

  .tool-dock-inner {
    gap: 4px;
    padding: 6px;
  }

  .tool-dock {
    display: block;
    min-height: 36px;
  }

  .tool-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    min-height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .auto-panel-shell.open {
    bottom: calc(env(safe-area-inset-bottom, 0) + 64px);
    gap: 6px;
    padding: 8px;
    width: min(320px, calc(100vw - 16px));
    left: 8px;
  }

  .tool-row,
  .action-button,
  .overlay-button,
  .graphs-launch {
    min-height: 42px;
    padding: 6px 8px;
    border-radius: 10px;
  }

  .top-stat {
    min-width: 90px;
    padding: 5px 8px;
  }

  .top-stat-label {
    font-size: 0.62rem;
  }

  .top-stat-value {
    font-size: 0.88rem;
  }
}

@media (pointer: coarse) {
  body {
    font-size: 16px;
  }

  .layout {
    padding: 8px;
  }

  .stage-shell {
    padding: 10px;
    gap: 6px;
  }

  .overlay-button,
  .graphs-launch,
  .tool-row,
  .action-button,
  .chat-form input,
  .chat-form button,
  .mini-chip,
  .bot-picker {
    min-height: 44px;
    font-size: 0.95rem;
  }

  .overlay-button,
  .graphs-launch {
    width: 88px;
    flex: 0 0 88px;
  }

  .tool-row,
  .action-button {
    width: 88px;
    flex: 0 0 88px;
  }

  .top-stat {
    min-width: 112px;
    padding: 8px 12px;
  }

  .top-stat-label {
    font-size: 0.74rem;
  }

  .top-stat-value {
    font-size: 1rem;
  }

  .tool-cost {
    font-size: 0.9rem;
  }

  .incident-feed {
    width: min(280px, calc(100vw - 12px));
    max-height: 160px;
    right: 6px;
    bottom: 6px;
    padding: 8px;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .tool-dock {
    bottom: max(calc(env(safe-area-inset-bottom, 0) + 6px), 46px);
  }
}

@media (max-width: 420px), (max-height: 500px) and (pointer: coarse) {
  .tool-dock-inner {
    gap: 3px;
    padding: 4px 6px;
  }

  .control-icon {
    width: 26px;
    height: 26px;
  }

  .tool-row,
  .action-button,
  .overlay-button,
  .graphs-launch {
    min-height: 28px;
    padding: 2px 4px;
    border-radius: 8px;
  }

  .overlay-button,
  .graphs-launch,
  .tool-row,
  .action-button {
    width: 56px;
    flex: 0 0 56px;
  }

  .action-button-menu {
    min-height: 30px;
    padding: 4px 6px;
    gap: 6px;
  }

  .action-button-label {
    font-size: 0.74rem;
  }

  .auto-panel-shell.open {
    width: min(260px, calc(100vw - 12px));
    padding: 6px;
    gap: 4px;
  }

  .auto-panel-shell .action-list,
  .auto-panel-shell .action-list-compact {
    gap: 4px;
  }

  .auto-panel-title {
    font-size: 0.64rem;
  }

  .incident-feed {
    width: min(220px, calc(100vw - 10px));
    max-height: 110px;
    right: 4px;
    bottom: 4px;
    padding: 6px;
  }

  .tool-list,
  .action-list,
  .overlay-strip,
  .graph-range-grid,
  .graph-toggle-grid,
  .dev-group-grid,
  .dev-header-actions {
    grid-template-columns: 1fr;
  }
}

@media ((max-width: 420px) and (pointer: coarse)), ((max-height: 500px) and (pointer: coarse)) {
  .overlay-button,
  .graphs-launch,
  .tool-row,
  .action-button,
  .chat-form input,
  .chat-form button,
  .mini-chip,
  .bot-picker {
    min-height: 28px;
    font-size: 0.72rem;
  }

  .overlay-button,
  .graphs-launch,
  .tool-row,
  .action-button {
    width: 56px;
    flex: 0 0 56px;
    padding: 2px 4px;
    border-radius: 8px;
  }

  .control-icon {
    width: 26px;
    height: 26px;
  }

  .tool-dock {
    display: block;
    min-height: 32px;
    margin-top: 2px;
  }

  .tool-dock-inner {
    display: grid;
    gap: 1px;
    padding: 2px 4px;
  }

  .tool-list {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    min-height: 28px;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .tool-row {
    width: 50px;
    flex: 0 0 50px;
    padding: 1px 0;
  }

  .action-button-menu {
    min-height: 30px;
    padding: 4px 6px;
    gap: 6px;
  }

  .action-button-label {
    font-size: 0.74rem;
  }

  .auto-panel-shell.open {
    width: min(260px, calc(100vw - 12px));
    padding: 6px;
    gap: 4px;
  }

  .auto-panel-shell .action-list,
  .auto-panel-shell .action-list-compact {
    gap: 4px;
  }

  .auto-panel-title {
    font-size: 0.64rem;
  }

  .incident-feed {
    width: min(220px, calc(100vw - 10px));
    max-height: 110px;
    right: 4px;
    bottom: 4px;
    padding: 6px;
  }
}

@media (pointer: coarse) and (orientation: portrait) and (max-width: 680px) {
  .tool-dock {
    min-height: 40px;
  }

  .tool-list {
    min-height: 34px;
  }
}
