/* Shared design tokens + chrome (topbar, buttons, links, tables, forms).
 * Mobile-first: defaults target small screens; one @media tweak widens
 * paddings + uncloaks topbar items at 640px and up.
 * Mirrored from shared/ui.py BASE_CSS — coordinator's /tos page still
 * inlines the Python copy. If you change one, sync the other (or
 * collapse them in a follow-up that moves /tos onto static assets too).
 */
:root {
  --brand: #2d6cdf;
  --brand-hover: #1f55b8;
  --text: #1a1a1a;
  --muted: #666;
  --surface: #ffffff;
  --bg: #f7f7f8;
  --border: #e5e5e5;
  --border-soft: #f0f0f0;
  --radius: 6px;
  --err-bg: #fde0e0;
  --err-border: #f5b0b0;
  --err-text: #900;
  --code-bg: #f3f3f3;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
code {
  background: var(--code-bg); padding: .05rem .3rem; border-radius: 3px;
  font-size: .9em; font-family: var(--mono);
}
.muted { color: var(--muted); font-size: .9rem; }
.page { max-width: 720px; margin: 1.5rem auto; padding: 0 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.alert-err {
  background: var(--err-bg); border: 1px solid var(--err-border);
  color: var(--err-text); padding: .6rem .9rem;
  border-radius: var(--radius); margin-bottom: 1rem;
}
table {
  width: 100%; border-collapse: collapse; font-size: .9rem;
  /* tables get a horizontal scroll on phones so a wide admin grid
     doesn't blow out the layout */
  display: block; overflow-x: auto;
}
th, td {
  padding: .5rem .55rem; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top; white-space: nowrap;
}
th { background: #f5f5f5; font-weight: 600; }
/* Buttons and form controls scale to full width by default — looks
   right on a phone, gets capped on desktop via the breakpoint below. */
button, .btn {
  display: inline-block; padding: .6rem 1rem; font-size: 1rem;
  background: var(--brand); color: #fff; border: 0;
  border-radius: var(--radius); cursor: pointer;
  font-family: inherit; line-height: 1.3;
}
.btn { text-decoration: none; }
.btn:hover, button:hover { background: var(--brand-hover); }
button:disabled, .btn[disabled] {
  background: #aaa; cursor: not-allowed;
}
.btn-quiet {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-quiet:hover { background: #f5f5f5; }
input[type=text], input[type=email], input[type=password], textarea {
  width: 100%; padding: .6rem; font-size: 1rem;
  font-family: inherit; line-height: 1.4;
  border: 1px solid #ccc; border-radius: var(--radius);
}
input:focus, textarea:focus { outline: 0; border-color: var(--brand); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .9rem; background: var(--surface);
  border-bottom: 1px solid var(--border); font-size: .9rem;
  gap: .5rem;
}
.topbar .brand { font-weight: 600; color: var(--text); }
/* Version chip: small transparent text tucked under the GamerAI title,
   right-aligned against it. Tracks shared.config.CLIENT_CACHE_VERSION
   so a deploy is visually verifiable from any tab without opening
   devtools. The display intentionally crowds the title (line-height: 1,
   negative margin-top) so the chip reads as a subtitle, not as its
   own row taking up vertical space. */
.topbar .brand-stack {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1;
}
.topbar .brand-version {
  font-size: .5rem; color: var(--text); opacity: .35;
  margin: 0; padding: 0; font-variant-numeric: tabular-nums;
  user-select: none;
}
.topbar .topbar-actions { display: flex; gap: .9rem; align-items: center; }
.topbar a { color: var(--brand); }
/* On phones, hide non-essential topbar items; admin/terms/logout still
   reachable from the dashboard. Override per page if needed. */
.topbar .hide-mobile { display: none; }
.topbar .hide-desktop { display: inline; }

/* Topbar "Contribute and invite friends" CTA — chip-style so it
   reads as a call-to-action rather than another nav link. Sits next
   to the brand on the left edge. */
.topbar .contribute-cta {
  background: var(--brand);
  color: #fff;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
}
.topbar .contribute-cta:hover { background: var(--brand-hover); }

@media (min-width: 640px) {
  .page { max-width: 760px; margin: 2.5rem auto; padding: 0 1.5rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.25rem; }
  table { display: table; overflow: visible; }
  .topbar { padding: .55rem 1.25rem; }
  .topbar .hide-mobile { display: inline; }
  .topbar .hide-desktop { display: none; }
  /* Buttons inside .topbar / forms stop trying to be full-width once
     we have horizontal room. */
  button.full, .btn.full { width: auto; }
}

/* PWA opt-in banners (Phase 6). Two flavors — push opt-in (default
   styling) and install prompt (.install modifier). Both float at the
   bottom of the viewport so they don't shove chat content around when
   they appear mid-session. Respects safe-area-inset for notched
   phones. */
.pwa-banner {
  position: fixed;
  left: 50%;
  bottom: calc(.75rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: .5rem;
  align-items: center;
  max-width: min(38rem, calc(100% - 1rem));
  padding: .55rem .75rem;
  background: #1d4ed8;
  color: #fff;
  border-radius: .5rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  font-size: .9rem;
  z-index: 1000;
}
.pwa-banner-text { flex: 1 1 auto; min-width: 0; }
.pwa-banner-action,
.pwa-banner-dismiss {
  flex: 0 0 auto;
  padding: .35rem .65rem;
  border: 0;
  border-radius: .35rem;
  font-size: .85rem;
  cursor: pointer;
}
.pwa-banner-action {
  background: #ffffff;
  color: #1d4ed8;
  font-weight: 600;
}
.pwa-banner-action:hover { background: #f3f4f6; }
.pwa-banner-action:disabled { opacity: .6; cursor: progress; }
.pwa-banner-dismiss {
  background: transparent;
  color: #ffffff;
  opacity: .8;
}
.pwa-banner-dismiss:hover { opacity: 1; }
