/* Sophia design system — shared base.
   Theme tokens: :root is the LIGHT palette (default + the explicit-light theme). Dark applies
   when the OS prefers dark and the user has not forced light, or when data-theme="dark" is set.
   The toggle (theme.js) writes data-theme on <html> and persists it; a pre-paint <head> snippet
   restores it, so there is no flash. Structural CSS must only ever use var(--…), never a raw hex. */
:root {
  color-scheme: light dark;
  /* LIGHT */
  --bg: #f6f7fa; --surface: #ffffff; --card: #ffffff; --elevated: #eef1f6;
  --border: #e3e6ee; --border2: #d2d7e2;
  --text: #1b1e28; --muted: #5b6170; --faint: #9aa0b2;
  --accent: #4f6bff; --accent-dim: #c9d2f6; --error: #d64545; --good: #1f9d55; --warn: #b7791f;
  --graph-bg1: #eef1f7; --graph-bg2: #e5e9f2; --node-label: #3a3f4d;
  --node-domain: #7c5cf0; --node-subject: #4f6bff; --node-facet: #0d9488; --node-document: #64748b;
  --edge: #aab2c6; --edge-pole: #db2777; --edge-about: #0d9488;
  --stance-pos: #1f9d55; --stance-neg: #d64545; --stance-neu: #6b7280; --flag: #b7791f;
}
/* DARK — one definition applied both for the OS preference (unless the user forced light) and
   for the explicit data-theme="dark". Keep the two blocks in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117; --surface: #161923; --card: #1a1d27; --elevated: #212431;
    --border: #2a2d3a; --border2: #353a4d;
    --text: #e1e4ed; --muted: #8b8fa3; --faint: #5b6070;
    --accent: #6c8aff; --accent-dim: #3a4a80; --error: #ff6b6b; --good: #34d399; --warn: #fbbf24;
    --graph-bg1: #141826; --graph-bg2: #0e1017; --node-label: #c9cede;
    --node-domain: #a78bfa; --node-subject: #6c8aff; --node-facet: #4fd1c5; --node-document: #94a3b8;
    --edge: #7a839c; --edge-pole: #f472b6; --edge-about: #4fd1c5;
    --stance-pos: #34d399; --stance-neg: #f87171; --stance-neu: #94a3b8; --flag: #fbbf24;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117; --surface: #161923; --card: #1a1d27; --elevated: #212431;
  --border: #2a2d3a; --border2: #353a4d;
  --text: #e1e4ed; --muted: #8b8fa3; --faint: #5b6070;
  --accent: #6c8aff; --accent-dim: #3a4a80; --error: #ff6b6b; --good: #34d399; --warn: #fbbf24;
  --graph-bg1: #141826; --graph-bg2: #0e1017; --node-label: #c9cede;
  --node-domain: #a78bfa; --node-subject: #6c8aff; --node-facet: #4fd1c5; --node-document: #94a3b8;
  --edge: #7a839c; --edge-pole: #f472b6; --edge-about: #4fd1c5;
  --stance-pos: #34d399; --stance-neg: #f87171; --stance-neu: #94a3b8; --flag: #fbbf24;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding: 2rem; }
h1 { font-size: 1.6rem; font-weight: 600; margin-bottom: .4rem; }
.subtitle { color: var(--muted); font-size: .95rem; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; max-width: 1100px; }
.header-right { display: flex; align-items: center; gap: .8rem; }
/* Overall status indicator */
.overall-status { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex-shrink: 0; transition: background .3s; cursor: help; }
.overall-status.healthy { background: var(--good); }
.overall-status.degraded { background: var(--error); }
/* Burger menu */
.burger { background: none; border: 1px solid var(--border); border-radius: 6px; padding: .45rem .55rem; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.burger:hover { border-color: var(--accent); }
.burger span { display: block; width: 18px; height: 2px; background: var(--muted); border-radius: 1px; transition: background .15s; }
.burger:hover span { background: var(--text); }
.menu-overlay { display: none; position: fixed; inset: 0; z-index: 99; }
.menu-panel { position: fixed; top: 0; left: -280px; width: 260px; height: 100vh; background: var(--card); border-right: 1px solid var(--border); padding: 1.5rem; z-index: 100; transition: left .2s ease; display: flex; flex-direction: column; gap: .2rem; }
.menu-panel.open { left: 0; }
.menu-panel .close-btn { align-self: flex-start; background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; margin-bottom: .5rem; }
.menu-panel .close-btn:hover { color: var(--text); }
.menu-panel a, .menu-panel button { display: block; width: 100%; text-align: left; padding: .6rem .8rem; color: var(--text); text-decoration: none; font-size: .9rem; border: none; background: none; cursor: pointer; border-radius: 6px; font-family: inherit; }
.menu-panel a:hover, .menu-panel button:hover { background: rgba(108,138,255,.1); }
.menu-panel .sep { border-top: 1px solid var(--border); margin: .4rem 0; }
/* Grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; max-width: 1100px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.4rem; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; display: flex; gap: 1rem; align-items: flex-start; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card.no-link { cursor: default; }
.card.no-link:hover { transform: none; }
.icon { font-size: 1.8rem; flex-shrink: 0; width: 2.4rem; text-align: center; }
.card h2 { font-size: 1rem; font-weight: 600; margin-bottom: .3rem; display: flex; align-items: center; gap: .5rem; }
.card p { color: var(--muted); font-size: .85rem; line-height: 1.45; }
.card .url { color: var(--accent); font-size: .8rem; margin-top: .5rem; display: block; word-break: break-all; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.status-dot.online { background: var(--good); }
.status-dot.offline { background: var(--error); }
.section-label { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .6rem; }
/* Breadcrumb */
.breadcrumb { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: 1.5rem; max-width: 1100px; flex-wrap: wrap; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border); user-select: none; }
.breadcrumb .current { color: var(--text); }
/* Instance badge — Castor / Pollux */
.header-title { display: flex; align-items: center; gap: .7rem; }
.instance-badge { display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: .2rem .5rem; border-radius: 3px; background: rgba(108,138,255,.15); color: var(--accent); border: 1px solid rgba(108,138,255,.35); line-height: 1.4; }
/* Shared light/dark toggle button */
.theme-toggle { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* The language switcher (the i18n-switch partial of tools/pkg/i18n): the offered languages
   in a row, the current one marked. A page that places it somewhere special — the studio's
   drawer — narrows these rules with its own. */
.lang-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.lang-switch button { background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px 8px;
  color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.lang-switch button:hover { color: var(--text); border-color: var(--border); }
.lang-switch button[aria-current] { background: var(--accent); border-color: var(--accent); color: #fff; cursor: default; }
