/* style.css */
:root {
  --bg: #0d1118;
  --bg2: #151c27;
  --panel: #1b2432;
  --ink: #e8eef6;
  --muted: #8b9bb0;
  --line: #2a3546;
  --accent: #3d9cf0;
  --gold: #e2b344;
  --good: #3ecf8e;
  --bad: #e85d5d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: Outfit, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #e7eef5;
    --bg2: #f6f8fb;
    --panel: #ffffff;
    --ink: #1c2430;
    --muted: #5b6b7e;
    --line: #d5deea;
    --shadow: 0 10px 24px rgba(30, 50, 80, 0.12);
  }
  .glyph { filter: none; }
}
html[data-theme="dark"] {
  --bg: #0d1118;
  --bg2: #151c27;
  --panel: #1b2432;
  --ink: #e8eef6;
  --muted: #8b9bb0;
  --line: #2a3546;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
html[data-theme="light"] {
  --bg: #e7eef5;
  --bg2: #f6f8fb;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #5b6b7e;
  --line: #d5deea;
  --shadow: 0 10px 24px rgba(30, 50, 80, 0.12);
}
html[data-theme="light"] .glyph { filter: none; }
html[data-theme="dark"] .glyph { filter: invert(1); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
}
#app {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  min-height: 100dvh;
  max-height: 100dvh;
}
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-brand strong { display: block; font-size: 0.95rem; letter-spacing: 0.02em; }
.hud-brand span { font-size: 0.72rem; color: var(--gold); font-family: var(--mono); }
.hud-stats {
  display: flex;
  gap: 14px;
  margin: 0;
  flex: 1;
  justify-content: center;
}
.hud-stats div { margin: 0; }
.hud-stats dt {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.hud-stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
}
.hud-tools { display: flex; gap: 6px; align-items: center; }
.glyph { width: 18px; height: 18px; display: block; filter: invert(1); }
.icon-btn, .text-btn, .round-btn, .ui-btn, .ghost-btn, .build-btn {
  min-height: 44px;
  min-width: 44px;
  border: 0;
  color: var(--ink);
  font-family: var(--font);
  cursor: pointer;
}
.icon-btn {
  display: grid;
  place-items: center;
  background: transparent;
  border-radius: 10px;
}
.icon-btn:hover, .text-btn:hover { background: rgba(127, 150, 180, 0.15); }
.icon-btn.off { opacity: 0.45; }
.text-btn {
  background: transparent;
  border-radius: 10px;
  padding: 0 12px;
  font-weight: 600;
}

.workspace {
  position: relative;
  min-height: 0;
  background: var(--bg2);
}
#view-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; }
#view { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
#hover-tip {
  position: absolute;
  pointer-events: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-family: var(--mono);
  box-shadow: var(--shadow);
}

.inspect {
  position: absolute;
  right: 8px;
  top: 8px;
  width: min(280px, calc(100% - 16px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.inspect header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.inspect h2 { margin: 0; font-size: 1rem; }
.inspect p { margin: 8px 0; color: var(--muted); font-size: 0.86rem; line-height: 1.4; }
.ins-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.ticker {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}

.dock {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.speed-cluster { display: flex; flex-direction: column; gap: 6px; }
.build-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.build-btn {
  flex: 0 0 auto;
  width: 76px;
  padding: 6px 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  color: #1a2430;
  font-weight: 700;
  background-color: transparent;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_rectangle_depth_border.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.build-btn.selected {
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
}
.build-btn.locked { filter: grayscale(0.7); opacity: 0.7; }
.build-btn .bn { font-size: 0.78rem; letter-spacing: 0.04em; }
.build-btn .bp { font-size: 0.62rem; font-family: var(--mono); font-weight: 500; }

.round-btn {
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-weight: 700;
  font-family: var(--mono);
  color: #1a2430;
  background-color: transparent;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_round_depth_border.png");
  background-size: 100% 100%;
}
.ui-btn {
  border-radius: 10px;
  padding: 0 14px;
  font-weight: 700;
  color: #1a2430;
  background-color: transparent;
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Blue/Default/button_rectangle_depth_border.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.ui-btn.green {
  background-image: url("https://assets.popchat.com/assets/kenney/ui-pack/PNG/Green/Default/button_rectangle_depth_gloss.png");
}
.ui-btn.danger { color: #5a1010; }
.ui-btn.play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  width: 100%;
}
.ui-btn.play img { width: 22px; height: 22px; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0 8px;
}
.ghost-btn .glyph { width: 16px; height: 16px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.62);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}
.overlay[hidden] { display: none !important; }
.boot-card {
  width: min(440px, 100%);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px 16px;
  box-shadow: var(--shadow);
}
.boot-card.slim { display: flex; flex-direction: column; gap: 8px; }
.boot-card h1, .boot-card h2 { margin: 0 0 8px; }
.boot-card p { margin: 0 0 10px; color: var(--muted); line-height: 1.45; }
.boot-tips { margin: 0 0 14px; padding-left: 18px; color: var(--ink); }
.boot-tips li { margin: 4px 0; }
.boot-actions { display: flex; flex-direction: column; gap: 8px; }
.boot-row { display: flex; justify-content: space-between; margin-top: 10px; }
.boot-tree {
  display: block;
  width: 120px;
  height: auto;
  margin: -8px auto 8px;
}

@media (max-width: 640px) {
  .hud-stats { justify-content: flex-start; overflow-x: auto; }
  .inspect { left: 8px; right: 8px; width: auto; }
  .speed-cluster { flex-direction: row; }
}
@media (min-width: 880px) {
  .dock { padding-left: 16px; padding-right: 16px; }
  .build-btn { width: 88px; }
}
