/* Control panel styles, shared by /panel/ and /panel/memory/. */
/* Phantazein design-system tokens (July 2026 · dark-only) + legacy aliases
   so the parchment-era class rules below resolve to the new palette. */
:root {
  color-scheme: dark;
  --bg: #000000; --bg-elev: #0a0a0a; --bg-card: #0e0e0e;
  --ink: #f4f2ee; --ink-soft: #a8a5a0; --ink-mute: #5e5c58;
  --rule: #1c1c1c; --rule-hi: #2a2a2a;
  --accent: #ff0018; --accent-dim: #b30011; --accent-hover: #d90014;
  --accent-glow: rgba(255, 0, 24, 0.18);
  --ok: #2f9e63; --ok-tint: rgba(47, 158, 99, 0.14);
  --display: "Archivo Black", "Archivo", ui-sans-serif, system-ui, sans-serif;
  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  /* legacy aliases */
  --scarlet: var(--accent); --scarlet-hover: var(--accent-hover); --scarlet-press: var(--accent-dim);
  --parchment: var(--bg); --parchment-deep: var(--bg-elev); --vellum: var(--bg-card); --sand: #161616;
  --ink-2: var(--ink-soft); --ink-3: var(--ink-mute); --ink-4: var(--ink-mute);
  --line: var(--rule); --line-strong: var(--rule-hi); --line-ink: var(--ink);
  --surface-sunken: var(--bg-elev);
  --text-body: var(--ink-soft); --text-muted: var(--ink-mute); --text-disabled: var(--ink-mute);
  --accent-press: var(--accent-dim);
  --border: var(--rule); --focus-ring: var(--accent);
  --font-serif: var(--display); --font-sans: var(--sans); --font-mono: var(--mono);
  --font-display: var(--display); --font-body: var(--sans);
  --text-2xs: 10px; --text-xs: 11.5px; --text-sm: 13.5px; --text-base: 15px; --text-md: 18px;
  --text-lg: 22px; --text-xl: 28px; --text-2xl: clamp(32px, 4.6vw, 44px); --text-3xl: 44px;
  --leading-normal: 1.55; --leading-relaxed: 1.7; --tracking-wider: 0.14em;
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.5rem;
  --space-6: 2rem; --space-7: 3rem; --space-8: 4rem; --space-9: 6rem; --space-10: 8rem;
  --radius-xs: 0; --radius-sm: 0; --radius-md: 0; --radius-lg: 0; --radius-pill: 0;
  --shadow-sm: none; --shadow-md: none; --shadow-lg: none;
  --ease-out: ease; --dur-fast: 200ms; --dur: 200ms;
  --container: 1280px; --container-narrow: 760px;
}

/* Light theme — inverts the ground, keeps the one red and the hard edges.
   These override only base tokens; the legacy aliases above cascade. */
:root[data-theme="light"] {
  --bg: #faf9f6; --bg-elev: #f2efe9; --bg-card: #ffffff; --sand: #ece8e0;
  --ink: #0d0b08; --ink-soft: #55524c; --ink-mute: #8f8b83;
  --rule: #e6e2d9; --rule-hi: #d4cfc4;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #faf9f6; --bg-elev: #f2efe9; --bg-card: #ffffff; --sand: #ece8e0;
    --ink: #0d0b08; --ink-soft: #55524c; --ink-mute: #8f8b83;
    --rule: #e6e2d9; --rule-hi: #d4cfc4;
  }
}
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="system"] { color-scheme: light dark; }

/* Display headings: Archivo Black, uppercase (site signature) */
h1, h2 { text-transform: uppercase; letter-spacing: -0.01em; }


*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--parchment); color: var(--ink);
  font-family: var(--font-body); font-size: var(--text-base); line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
::selection { background: var(--scarlet); color: #fff; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.container { max-width: var(--container); margin: 0 auto; padding-left: var(--space-6); padding-right: var(--space-6); width: 100%; }
.eyebrow {
  font-family: var(--font-body); text-transform: uppercase; letter-spacing: var(--tracking-wider);
  font-weight: 600; font-size: var(--text-xs); color: var(--accent); margin: 0;
}
.hidden { display: none !important; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--parchment) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .bar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand .wordmark { font-weight: 800; letter-spacing: 0.14em; color: var(--ink); font-size: var(--text-sm); }
.brand .sub { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); border-left: 1px solid var(--line); padding-left: 0.6rem; }
.header-right { display: flex; align-items: center; gap: var(--space-4); }
.whoami { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
@media (max-width: 720px) { .whoami { display: none; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  font-family: var(--font-body); font-weight: 600; line-height: 1; letter-spacing: 0.005em;
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: wait; }
.btn--sm { font-size: var(--text-sm); padding: 0.5rem 0.85rem; height: 34px; }
.btn--md { font-size: var(--text-base); padding: 0.65rem 1.15rem; height: 42px; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-press); }
.btn--secondary { background: transparent; color: var(--ink); border-color: var(--line-ink); }
.btn--secondary:hover { background: var(--ink); color: var(--parchment); }
.btn--ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn--ghost:hover { background: var(--surface-sunken); }

/* Forms */
label { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--ink); margin: 0 0 var(--space-1); }
.field { margin-bottom: var(--space-4); }
input[type="text"], input[type="email"], select, textarea {
  width: 100%; font-family: var(--font-body); font-size: var(--text-base); color: var(--ink);
  background: var(--parchment); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
}
textarea { min-height: 96px; resize: vertical; line-height: var(--leading-normal); }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--accent); }
.hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* Layout */
main { flex: 1; }
.section { border-top: 3px solid var(--ink); padding-top: var(--space-4); margin-top: var(--space-8); }
.section:first-child { margin-top: var(--space-7); }
.section-head-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.section h2 { margin: var(--space-2) 0 0; font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); letter-spacing: -0.015em; color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 var(--space-6); }
.card {
  background: var(--vellum); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-5);
}
.mono { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

/* Login card */
.login-panel { max-width: 520px; margin: var(--space-9) auto var(--space-8); padding: 0 var(--space-6); }
.login-card {
  background: var(--vellum); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: var(--space-7) var(--space-6);
}
.login-card h1 { margin: var(--space-2) 0 var(--space-3); font-family: var(--font-display); font-weight: 600; font-size: var(--text-2xl); letter-spacing: -0.015em; line-height: 1.1; }
.login-card .lede { margin: 0 0 var(--space-5); color: var(--text-body); max-width: 44ch; }

/* Messages */
.msg {
  margin: 0 0 var(--space-4); font-size: var(--text-sm); border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4); display: none; border: 1px solid var(--accent); color: var(--accent);
}
.msg.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-tint); }
.msg ul { margin: var(--space-1) 0 0; padding-left: 1.2em; }

/* ── Connectors grid (redesign) ── */
.cx-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: var(--space-2) 0 var(--space-5); }
.cx-search { flex: 1 1 260px; min-width: 200px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--rule-hi); background: var(--bg-elev); padding: 0 14px; height: 44px; transition: border-color .2s ease; color: var(--ink-mute); }
.cx-search:focus-within { border-color: var(--ink-mute); }
.cx-search input { flex: 1; background: transparent; border: none; outline: none; color: var(--ink); font-family: var(--mono); font-size: 12.5px; letter-spacing: .04em; height: 100%; padding: 0; }
.cx-toolbar-note { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-mute); }

.cx-grid { border: 1px solid var(--rule); background: var(--rule); display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; }
.cx-card { background: var(--bg); padding: 26px 24px; min-height: 296px; display: flex; flex-direction: column; position: relative; min-width: 0; transition: background .3s ease; }
.cx-card:hover { background: var(--bg-card); }
.cx-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cx-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--rule-hi); color: var(--ink); flex: none; }
.cx-live { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--ink); }
.cx-live.paused { color: var(--ink-mute); }
.cx-dot { width: 7px; height: 7px; display: inline-block; background: var(--accent); animation: cx-pulse 2s ease-out infinite; }
.cx-live.paused .cx-dot { background: var(--ink-mute); animation: none; }
.cx-name { font-family: var(--display); font-weight: 900; font-size: 26px; line-height: 1; letter-spacing: -.015em; text-transform: uppercase; margin: 22px 0 0; color: var(--ink); }
.cx-desc { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin: 12px 0 0; max-width: 38ch; }
.cx-ns { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--ink-mute); margin: 16px 0 0; word-break: break-word; }
.cx-scopes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.cx-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; color: var(--ink-soft); border: 1px solid var(--rule-hi); padding: 4px 8px; }
.cx-used { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); margin-top: 14px; }
.cx-foot { border-top: 1px solid var(--rule); margin-top: 24px; padding-top: 20px; }
.cx-connect { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #fff; background: var(--accent); border: 1px solid var(--accent); padding: 12px 16px; cursor: pointer; transition: background .18s ease; }
.cx-connect:hover { background: var(--accent-dim); }
.cx-connecting { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 11px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); border: 1px solid var(--rule-hi); padding: 12px 16px; }
.cx-spin { width: 12px; height: 12px; border: 2px solid var(--ink-mute); border-top-color: var(--accent); display: inline-block; animation: cx-spin .7s linear infinite; }
.cx-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.cx-toggle { display: inline-flex; align-items: center; gap: 10px; background: transparent; border: none; padding: 0; cursor: pointer; }
.cx-track { width: 40px; height: 20px; border: 1px solid var(--rule-hi); display: inline-flex; align-items: center; padding: 2px; transition: background .18s ease, border-color .18s ease; }
.cx-toggle.on .cx-track { border-color: var(--accent); background: var(--accent); }
.cx-knob { width: 14px; height: 14px; background: var(--ink-mute); display: block; transition: transform .18s ease, background .18s ease; }
.cx-toggle.on .cx-knob { background: #fff; transform: translateX(20px); }
.cx-tlabel { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); }
.cx-toggle.on .cx-tlabel { color: var(--ink); }
.cx-disconnect { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); background: transparent; border: 1px solid var(--rule-hi); padding: 8px 12px; cursor: pointer; transition: background .18s, color .18s, border-color .18s; }
.cx-disconnect:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.cx-add { background: var(--bg); padding: 26px 24px; min-height: 296px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; transition: background .3s ease; }
.cx-add:hover { background: var(--bg-card); }
.cx-add h3 { font-family: var(--display); font-weight: 900; font-size: 23px; line-height: 1.02; letter-spacing: -.015em; text-transform: uppercase; margin: 22px 0 0; color: var(--ink); }
.cx-add p { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin: 12px 0 0; max-width: 34ch; }
.cx-add-foot { border-top: 1px solid var(--rule); margin-top: 24px; padding-top: 20px; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.cx-add-btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); background: transparent; border: 1px solid var(--rule-hi); padding: 12px 16px; cursor: pointer; transition: background .18s, color .18s, border-color .18s; }
.cx-add-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.cx-add-req { width: 100%; text-align: center; font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mute); background: transparent; border: none; cursor: pointer; transition: color .18s ease; }
.cx-add-req:hover { color: var(--ink); }
.cx-note { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; color: var(--ink-mute); margin: 26px 0 0; line-height: 1.7; max-width: 90ch; }
.cx-note b { color: var(--ink); font-weight: 600; }
.cx-noresults { grid-column: 1 / -1; background: var(--bg); padding: var(--space-6); font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--ink-mute); text-align: center; }

/* consent modal */
.cx-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.cx-overlay[hidden] { display: none; }
.cx-modal { width: 100%; max-width: 480px; background: var(--bg-elev); border: 1px solid var(--rule-hi); max-height: 90vh; overflow: auto; }
.cx-modal-head { padding: 26px 28px 22px; border-bottom: 1px solid var(--rule); }
.cx-meyebrow { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .24em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 16px; }
.cx-mtitle { display: flex; align-items: center; gap: 14px; }
.cx-mtitle h3 { font-family: var(--display); font-weight: 900; font-size: 22px; line-height: 1.05; letter-spacing: -.01em; text-transform: uppercase; margin: 0; color: var(--ink); }
.cx-mlede { font-size: 14px; color: var(--ink-soft); line-height: 1.55; margin: 16px 0 0; }
.cx-mlede strong { color: var(--ink); font-weight: 600; }
.cx-mscopes { padding: 8px 28px 6px; }
.cx-srow { display: flex; align-items: flex-start; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.cx-srow svg { flex: none; margin-top: 2px; }
.cx-slabel { font-size: 14.5px; color: var(--ink); line-height: 1.4; }
.cx-sns { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--ink-mute); margin-top: 4px; }
.cx-mfoot { padding: 20px 28px 26px; }
.cx-mnote { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 20px; }
.cx-mactions { display: flex; gap: 12px; }
.cx-btn-ghost { flex: 1; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); background: transparent; border: 1px solid var(--rule-hi); padding: 13px 16px; cursor: pointer; transition: border-color .18s, color .18s; }
.cx-btn-ghost:hover { border-color: var(--ink-mute); }
.cx-btn-primary { flex: 1.4; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: #fff; background: var(--accent); border: 1px solid var(--accent); padding: 13px 16px; cursor: pointer; transition: background .18s ease; }
.cx-btn-primary:hover { background: var(--accent-dim); }
@keyframes cx-pulse { 0%{box-shadow:0 0 0 0 rgba(255,0,24,.55);} 70%{box-shadow:0 0 0 6px rgba(255,0,24,0);} 100%{box-shadow:0 0 0 0 rgba(255,0,24,0);} }
@keyframes cx-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cx-dot, .cx-spin { animation: none !important; } }
.empty { color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-4) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

/* Activity */
.audit-list { display: flex; flex-direction: column; font-family: var(--font-mono); font-size: var(--text-xs); }
.audit-row { display: flex; gap: var(--space-4); padding: var(--space-2) 0; border-top: 1px solid var(--line); color: var(--text-body); flex-wrap: wrap; }
.audit-row .at { color: var(--text-muted); flex: none; }
.audit-row .action { color: var(--ink); font-weight: 600; }

.footer-bar {
  margin-top: var(--space-9); border-top: 1px solid var(--line); padding: var(--space-4) var(--space-6);
  display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted);
}
.footer-bar a { color: var(--ink-soft); text-decoration: none; transition: color .2s ease; }
.footer-bar a:hover { color: var(--accent); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--text-body);
  cursor: pointer; transition: color .2s ease, border-color .2s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .theme-toggle .icon-sun { display: block; }
  :root[data-theme="system"] .theme-toggle .icon-moon { display: none; }
}

/* Beta footer on panel pages and the privacy notice. */
.beta-foot {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5);
  margin-top: var(--space-8); padding-top: var(--space-4); padding-bottom: var(--space-6);
  border-top: 1px solid var(--rule); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted);
}
.beta-foot a { color: var(--ink-soft); }
.beta-foot a:hover { color: var(--ink); }
