/* Base UI for vibeware's live apps (brainstorming, teamgames): tokens, buttons,
   fields, dialogs, toasts. Each app adds its own stylesheet on top. */
:root {
  --bg: #e9ecf1; --surface: #ffffff; --sunk: #f2f4f7; --ink: #1e2433; --muted: #566074; --line: #d2d8e2;
  --focus: #1e2433; --accent: #1e2433; --on-accent: #ffffff;
  --ok: #0f7a4f; --warn: #9a5b00; --danger: #b42318;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161f; --surface: #1a2030; --sunk: #151a26; --ink: #e8ebf2; --muted: #9ca5b8; --line: #2b3345;
    --focus: #e8ebf2; --accent: #e8ebf2; --on-accent: #12161f; --ok: #5fd39b; --warn: #f0b75a; --danger: #ff8a7a; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.45 "Archivo", system-ui, sans-serif; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
h1, h2, h3 { line-height: 1.15; }
.display { font-family: "Archivo Black", "Archivo", system-ui, sans-serif; font-weight: 400; letter-spacing: -0.02em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  font: 700 0.9375rem/1.1 "Archivo", system-ui, sans-serif; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { border-color: var(--line); }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: 0.875rem; border-radius: 8px; }
.btn.big { min-height: 52px; padding: 12px 24px; font-size: 1.0625rem; border-radius: 12px; }
.btn.danger { color: var(--danger); }
.btn svg { width: 18px; height: 18px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-weight: 700; font-size: 0.875rem; }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px;
}
.field textarea, textarea.input { resize: vertical; }
.hint { color: var(--muted); font-size: 0.8125rem; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check b { display: block; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }

dialog.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
}
dialog.dialog::backdrop { background: rgb(10 14 22 / 0.5); }
.dialog-in { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.2rem; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 0.9375rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
}
.toast.error { background: var(--danger); color: #fff; }

.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn[data-s="live"]::before { background: var(--ok); }
.conn[data-s="closed"]::before { background: var(--danger); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; padding: 6px;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
}
.menu-pop button, .menu-pop a {
  text-align: left; padding: 9px 10px; border-radius: 8px; font: inherit; color: var(--ink); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--sunk); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.code { font: 400 1em/1 "Archivo Black", "Archivo", system-ui, sans-serif; letter-spacing: 0.08em; }
