:root { color-scheme: dark; --bg:#0b0d10; --fg:#e8eaed; --muted:#8b919a; --line:#2a3038; --accent:#fc0400; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, sans-serif; }
.viewer { display: flex; flex-direction: column; min-height: 100%; }
.viewer-bar { display: flex; gap: 0.75rem; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.viewer-bar h1 { font-size: 1rem; margin: 0; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.btn { background: #1a1f26; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.node-list { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 1rem; }
.node-card { border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; min-width: 14rem; }
.stage { flex: 1; display: flex; align-items: center; justify-content: center; background: #050607; position: relative; min-height: 60vh; }
.stage canvas { display: block; max-width: 100%; max-height: 100%; }

.pause-dialog { background: #1a1f26; border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; max-width: 22rem; }
.btn.sm { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 0.85rem; }
.screen-tile { appearance: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: #0a0f16; overflow: hidden; cursor: pointer; text-align: left; color: inherit; display: grid; grid-template-rows: 1fr auto; }
.screen-tile:hover { border-color: #5b9fd4; }
.screen-tile img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; }
.screen-tile-ph { display: grid; place-items: center; aspect-ratio: 16 / 9; background: #000; color: var(--muted); font-size: 0.85rem; }
.screen-tile-cap { padding: 0.45rem 0.65rem 0.2rem; font-size: 0.8rem; color: var(--muted); }
.screen-tile-actions { display: flex; gap: 0.35rem; padding: 0 0.45rem 0.45rem; }
.screen-tile.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.app-grid { margin-top: 1.1rem; }
.app-grid-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.5rem; }
.app-dock-tab {
  position: fixed;
  left: 50%;
  bottom: 0.7rem;
  z-index: 120;
  transform: translateX(-50%);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
.screen-fs:has(.app-dock.open) .app-dock-tab { bottom: 7.6rem; }
.app-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 119;
  width: 100%;
  height: auto;
  background: rgba(10, 15, 22, 0.94);
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.65rem 0.55rem;
  backdrop-filter: blur(8px);
  transform: translateY(100%);
  transition: transform 0.2s ease;
  pointer-events: none;
}
.app-dock.open {
  transform: translateY(0);
  pointer-events: none;
}
.app-dock.open .app-dock-strip { pointer-events: auto; }
.app-dock-strip { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.2rem; }
.app-dock-tile { flex: 0 0 9.5rem; border: 1px solid var(--line); border-radius: 6px; background: #05080c; cursor: pointer; overflow: hidden; padding: 0; text-align: left; color: inherit; }
.app-dock-tile.sel { border-color: var(--accent); }
.app-dock-tile img { display: block; width: 100%; height: 4.6rem; object-fit: cover; background: #000; }
.app-dock-tile span { display: block; padding: 0.25rem 0.4rem; font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-fs { position: fixed; inset: 0; z-index: 80; background: #000; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr) 0; grid-auto-rows: 0; }
.screen-fs.debug-open { grid-template-columns: minmax(0, 1fr) 20rem; }
.screen-fs.chrome-off { grid-template-rows: 1fr; }
.screen-fs.chrome-off .screen-fs-bar { display: none; }
.screen-fs-bar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.55rem 0.85rem; background: #0a0f16; border-bottom: 1px solid var(--line); z-index: 95; }
.screen-fs-switch { display: flex; align-items: center; gap: 0.35rem; }
.screen-fs-stage { position: relative; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; grid-row: 2; grid-column: 1; }
.screen-fs.chrome-off .screen-fs-stage { grid-row: 1; }
.screen-fs-edge { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 10px; height: 28%; min-height: 3.5rem; margin: 0; padding: 0; border: 0; border-radius: 0; background: rgba(10, 15, 22, 0.45); color: inherit; font-size: 0.7rem; line-height: 1; cursor: pointer; }
.screen-fs-edge.left { left: 0; }
.screen-fs-edge.right { right: 0; }
.screen-fs-edge:hover { background: rgba(10, 15, 22, 0.8); }
.screen-fs-canvas { display: block; flex: 0 0 auto; image-rendering: auto; touch-action: none; }
.spike-track {
  position: absolute;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #7ec8ff;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 0 0 1px #041018;
}
.spike-track::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: #7ec8ff;
}
.fs-exit {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 130;
  grid-row: 2;
  grid-column: 1;
  justify-self: end;
  align-self: start;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  line-height: 1;
  font-size: 0.95rem;
  border-radius: 6px;
  background: rgba(10, 15, 22, 0.72);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}
.screen-fs.chrome-off .fs-exit { grid-row: 1; }
.kb-fab {
  position: absolute;
  right: 0.55rem;
  left: auto;
  bottom: 0.55rem;
  z-index: 97;
}
.osk {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  z-index: 140;
  padding: 0 0.35rem 0.45rem;
  background: rgba(10, 15, 22, 0.96);
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  user-select: none;
  touch-action: none;
}
.osk-handle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.85rem;
  padding: 0.15rem 0.1rem 0.1rem 0.15rem;
  touch-action: none;
}
.osk-grip {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 0.45rem 0 0.2rem;
  cursor: grab;
  touch-action: none;
}
.osk-grip::before {
  content: "";
  display: block;
  width: 2.4rem;
  height: 0.28rem;
  margin: 0 auto 0.15rem;
  border-radius: 99px;
  background: #5a6573;
}
.osk-close {
  flex: 0 0 1.7rem;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1a1f26;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}
.osk[hidden] { display: none !important; }
.osk-row { display: flex; gap: 0.28rem; justify-content: center; }
.osk-key {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.15rem;
  padding: 0.2rem 0.15rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1a1f26;
  color: var(--fg);
  font-size: 0.78rem;
  line-height: 1;
}
.osk-key.fn { flex: 0.85 1 0; font-size: 0.7rem; color: var(--muted); }
.osk-key.wide { flex: 1.4 1 0; }
.osk-key.space { flex: 3.2 1 0; }
.osk-key.latch.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.osk-key.hit {
  background: #3a4554;
  border-color: #8aa0b8;
  color: #fff;
  transform: scale(0.96);
}
.osk-key.latch.on.hit { background: #ff3b30; filter: brightness(1.15); }
.osk-key { transition: background 0.08s ease, border-color 0.08s ease, transform 0.08s ease; }
.screen-fs.app-view .screen-fs-stage { align-items: stretch; justify-content: stretch; }
.screen-fs.app-view .screen-fs-canvas { width: 100%; height: 100%; flex: 1 1 auto; }
.spike-debug-tab {
  display: none;
  position: absolute;
  right: 0;
  top: calc(50% + 100px);
  z-index: 7;
  transform: translateY(-50%);
  border-radius: 6px 0 0 6px;
  writing-mode: vertical-rl;
}
.spike-debug-tab.vis { display: block; }
.spike-debug-btns { display: flex; gap: 0.35rem; flex-shrink: 0; }
.spike-debug {
  grid-row: 2;
  grid-column: 2;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 20rem;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  padding: 0.65rem 0.75rem;
  background: #0a0f16;
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.18s ease;
}
.screen-fs.debug-open .spike-debug { transform: none; }
.spike-debug pre {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  color: #d7e3f0;
  font: 11px/1.4 ui-monospace, Consolas, monospace;
  white-space: pre;
}
.spike-click-mark {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #ff3b30;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}
