:root {
  --bg: #0d0f10;
  --line: #2a3033;
  --text: #e8ecee;
  --muted: #7f8b91;
  --dim: #5a656a;
  --paper: #fbfbfa;
  --warn: #ff6b6b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

/* ---- canvas ---- */
#stage {
  position: absolute; inset: 0;
  touch-action: none;
}
#canvas {
  position: absolute; top: 0; left: 0;
  background: var(--paper);
  image-rendering: pixelated;
  cursor: crosshair;
}
#canvas.panning { cursor: grabbing; }

/* ---- left column: the pitch, then the log ---- */
#side {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 280px; padding: 22px 14px 84px 18px;
  display: flex; flex-direction: column;
  pointer-events: none;      /* clicks fall through to the canvas */
}

#about { flex: 0 0 auto; color: var(--dim); }
#about h1 {
  margin: 0 0 12px;
  font-size: 15px; letter-spacing: -.01em;
  color: var(--muted);
}
#about h1 span { color: var(--text); }
#about p { margin: 0 0 11px; font-size: 12px; line-height: 1.55; }
#about b { color: var(--muted); font-weight: 600; }

/* the log sits under the pitch and takes whatever height is left */
#logbox {
  flex: 1 1 auto;
  min-height: 90px;          /* never collapse to nothing on short windows */
  margin-top: 8px;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
  pointer-events: auto;      /* so it can be scrolled */
}
#logbox h2 {
  margin: 12px 0 8px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: #4a5458;
}
#log {
  flex: 1 1 auto;
  min-height: 0;             /* lets the flex child actually scroll */
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #333c40 transparent;
}
#log::-webkit-scrollbar { width: 8px; }
#log::-webkit-scrollbar-track { background: transparent; }
#log::-webkit-scrollbar-thumb {
  background: #333c40; border-radius: 4px;
  border: 2px solid transparent; background-clip: content-box;
}
#log:hover::-webkit-scrollbar-thumb { background-color: #465257; background-clip: content-box; }

.entry { font-size: 12px; }
.entry .line { color: var(--dim); }
.entry .who {
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.entry.fresh .who { color: var(--text); }
.entry .at { font-variant-numeric: tabular-nums; }
.entry.erased .at { text-decoration: line-through; }
.entry .when { color: #4a5458; margin-top: 1px; }

/* ---- the bar: one smooth pill, everything in a row ---- */
#bar {
  position: absolute; bottom: 46px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 5px;
  background: rgba(24, 28, 30, .88);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px rgba(0,0,0,.4);
  backdrop-filter: blur(14px);
  max-width: calc(100vw - 24px);
}

.tool, .aux {
  font: inherit; cursor: pointer;
  padding: 8px 17px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease;
}
.tool:hover, .aux:hover { color: var(--text); background: rgba(255,255,255,.06); }
.tool.sel, .tool.sel:hover { background: var(--text); color: #14181a; font-weight: 600; }

/* name and save are actions, not modes, so they read quieter */
.aux { color: var(--dim); }
#whoami { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

#cooldown {
  padding: 0 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 62px; text-align: center;
}
#cooldown.wait { color: var(--text); }

/* the warning sits just under the bar, small and red */
#status {
  position: absolute; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--warn);
  white-space: nowrap;
  pointer-events: none;
}
.hidden { display: none !important; }

/* ---- name gate ---- */
#gate {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13, 15, 16, .82);
  backdrop-filter: blur(3px);
}
#gateform {
  display: flex; flex-direction: column; gap: 10px;
  width: 240px;
}
#gateform label { color: var(--muted); }
#gateform input {
  font: inherit; padding: 9px 12px;
  background: #14181a; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  outline: none;
}
#gateform input:focus { border-color: var(--muted); }
#gateform button {
  font: inherit; cursor: pointer;
  padding: 9px 12px; border: 0; border-radius: 8px;
  background: var(--text); color: #14181a; font-weight: 600;
}

@media (max-width: 899px) {
  #side { display: none; }
  #bar { bottom: 38px; }
  .tool, .aux { padding: 8px 12px; }
  #cooldown { padding: 0 9px; min-width: 54px; }
  #whoami { max-width: 84px; }
  #status { bottom: 16px; }
}
