/* Shared shell for all three demos: tab bar, panels, toolbar, sheet, toast. */

:root {
  --panel: rgba(6, 18, 32, 0.6);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #e9f2f9;
  --muted: rgba(233, 242, 249, 0.68);
  --accent: #8fdcff;
  --accent-soft: rgba(143, 220, 255, 0.2);
  --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0b1a2a;
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

canvas.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.45;
}

/* ---- Tab bar ------------------------------------------------------------ */
.tabbar {
  top: calc(12px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  z-index: 40;
}
.tabbar a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tabbar a .n { font-family: var(--mono); font-size: 10.5px; opacity: 0.65; }
.tabbar a:hover { color: var(--text); }
.tabbar a.active { background: var(--accent-soft); color: var(--text); }

/* ---- Title (desktop only) ---------------------------------------------- */
.title { top: calc(16px + var(--safe-top)); left: calc(16px + var(--safe-left)); max-width: 340px; }
.title h1 { margin: 0 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.title p { margin: 0; color: var(--muted); }
.title a { color: var(--accent); text-decoration: none; }
.title a:hover { text-decoration: underline; }

/* ---- Buttons ------------------------------------------------------------ */
button {
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  touch-action: manipulation;
  min-height: 36px;
}
button:hover { background: rgba(255, 255, 255, 0.14); }
button:active { transform: translateY(1px); }
button.on { background: var(--accent-soft); border-color: rgba(143, 220, 255, 0.5); }
button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid rgba(143, 220, 255, 0.35);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
}

/* ---- Bottom toolbar ---------------------------------------------------- */
.toolbar {
  bottom: calc(14px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;              /* a fixed box at left:50% would otherwise shrink to half the viewport */
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  z-index: 30;
  max-width: calc(100vw - 24px);
}
.toolbar .sep { width: 1px; height: 24px; background: var(--panel-border); margin: 0 2px; }
.toolbar .slider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
}
.toolbar .slider svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
input[type="range"] { accent-color: var(--accent); width: 130px; margin: 0; touch-action: none; }

/* ---- Info sheet -------------------------------------------------------- */
.sheet {
  top: calc(16px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px - var(--safe-top));
  overflow: auto;
  z-index: 50;
}
.sheet h2 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.sheet h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 600; }
.sheet p, .sheet li { color: var(--muted); }
.sheet p { margin: 0 0 8px; }
.sheet ol, .sheet ul { margin: 0; padding-left: 20px; }
.sheet li { margin-bottom: 6px; }
.sheet li b { color: var(--text); font-weight: 600; }
.sheet code { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.sheet .close { padding: 2px 8px; min-height: 28px; }
.sheet .controls { list-style: none; padding: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.sheet .controls li { display: contents; }
.sheet .controls b { white-space: nowrap; }

/* ---- Toast ------------------------------------------------------------- */
.toast {
  position: fixed;
  top: calc(64px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 60;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; }

.error {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 460px;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(60, 12, 20, 0.85);
  z-index: 70;
}

[hidden] { display: none !important; }

/* ---- Small screens ----------------------------------------------------- */
@media (max-width: 720px) {
  .panel { padding: 10px 12px; font-size: 12px; }
  .title { display: none; }
  .tabbar a { padding: 7px 11px; font-size: 12px; }
  .tabbar a .n { display: none; }
  .toolbar { gap: 4px; padding: 5px; border-radius: 16px; }
  .toolbar button { min-width: 44px; min-height: 44px; padding: 0 10px; justify-content: center; }
  .toolbar button .label { display: none; }
  .toolbar .sep { display: none; }
  /* The slider gets its own full-width row under the buttons. */
  .toolbar .slider { flex: 1 1 100%; justify-content: center; order: 2; padding: 2px 8px 0; }
  input[type="range"] { width: min(220px, 55vw); }
  .sheet {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: calc(8px + var(--safe-bottom));
    width: auto;
    max-height: 70dvh;
    border-radius: 16px;
  }
}
