/* Shared by every page: the palette, the site nav and the API-keys dialog
   (see site.js). Page layouts live with each page. */
/* NEAR brand, from defuse-near's theme: Figtree, neutral grays, and the
   #00EC97 green scale. Green carries meaning; everything else stays gray.
   Flow colors: request = neutral, peer shares = deep green, delivered
   signature = brand green. */
:root {
  color-scheme: dark;
  --ground: #171717;          /* gray-900 */
  --surface: #1f1f1f;         /* gray-850 */
  --surface-raised: #262626;  /* gray-800 */
  --line: rgba(255, 255, 255, 0.08);
  --ink: #ffffff;
  --ink-soft: #a3a3a3;        /* gray-400 */
  --ink-faint: #737373;       /* gray-500 */
  --accent: #00ec97;          /* green-500, the brand color */
  --accent-ink: #00ec97;      /* green text that passes contrast on this ground */
  --on-accent: #000000;
  --request: #d4d4d4;         /* gray-300 */
  --share: #009660;           /* green-700 */
  --response: #00ec97;        /* green-500 */
  --warning: #fac800;         /* yellow-400 */
  --danger: #ff6467;          /* red-400 */
  --map-ground: #0a0a0a;      /* gray-950 */
  --map-land: #262626;
  --map-border: #333333;
  --map-grid: #141414;
  --map-mesh: rgba(0, 236, 151, 0.06);

  --font-body: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: 0.75rem;
  --step-0: 0.8125rem;
  --step-1: 0.9375rem;
  --step-2: 1.25rem;
  --step-3: 1.6rem;
  --radius: 8px;
  --gutter: 16px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --ground: #f2f2f2;
    --surface: #ffffff;
    --surface-raised: #f5f5f5;  /* gray-100 */
    --line: #e5e5e5;            /* gray-200 */
    --ink: #171717;
    --ink-soft: #737373;
    --ink-faint: #a3a3a3;
    --accent: #00ec97;
    --accent-ink: #06754e;      /* green-800 */
    --on-accent: #000000;
    --request: #525252;         /* gray-600 */
    --share: #00c076;           /* green-600 */
    --response: #009660;        /* green-700 */
    --warning: #a65f00;         /* yellow-700 */
    --danger: #e7000b;          /* red-600 */
    --map-ground: #fafafa;
    --map-land: #e5e5e5;
    --map-border: #d4d4d4;
    --map-grid: #efefef;
    --map-mesh: rgba(0, 150, 96, 0.08);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f2f2f2;
  --surface: #ffffff;
  --surface-raised: #f5f5f5;
  --line: #e5e5e5;
  --ink: #171717;
  --ink-soft: #737373;
  --ink-faint: #a3a3a3;
  --accent: #00ec97;
  --accent-ink: #06754e;
  --on-accent: #000000;
  --request: #525252;
  --share: #00c076;
  --response: #009660;
  --warning: #a65f00;
  --danger: #e7000b;
  --map-ground: #fafafa;
  --map-land: #e5e5e5;
  --map-border: #d4d4d4;
  --map-grid: #efefef;
  --map-mesh: rgba(0, 150, 96, 0.08);
}

/* ── Site nav ────────────────────────────────────────────────────────── */

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font: 500 0.875rem/1.4 var(--font-body);
}
.site-nav > .button { margin-inline-start: auto; }
@media (max-width: 600px) {
  .site-nav ul { order: 1; flex-basis: 100%; margin-inline: -10px; }
}
.site-brand { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; text-decoration: none; }
.site-nav ul { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav ul a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
}
.site-nav ul a:hover { color: var(--ink); background: var(--surface-raised); }
.site-nav ul a[aria-current="page"] { color: var(--ink); background: var(--surface-raised); box-shadow: inset 0 -2px 0 var(--accent); }
.site-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 0 5px;
  border-radius: 3px;
}
.site-nav a:focus-visible, .button:focus-visible, .dialog input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button {
  font: 500 var(--step-0) var(--font-body);
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}
.button:hover { border-color: var(--ink-faint); }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ── API-keys dialog ─────────────────────────────────────────────────── */

.dialog {
  inline-size: min(440px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface-raised);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  font: 400 var(--step-0)/1.45 var(--font-body);
}
.dialog::backdrop { background: color-mix(in srgb, var(--ground) 70%, transparent); }
.dialog form { display: grid; gap: 8px; }
.dialog h2 { font-size: var(--step-2); margin: 0; }
.dialog p { margin: 0 0 6px; color: var(--ink-soft); }
.dialog label { font-weight: 600; margin-top: 6px; }
.dialog label span { font-weight: 400; color: var(--ink-faint); margin-inline-start: 6px; }
.dialog input {
  font: 400 var(--step-0) var(--font-data);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 9px;
}
.dialog .hint { font-size: var(--step--1); margin-top: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
