/* Vibe Deus shell: tokens, layout and shared components.
   Source of truth: Figma file yX03P7XSWnvJl033zwG50p (Tokens + Components pages).
   Every tool page loads this file first, then adds its own page CSS. */

/* Fonts are bundled (static/fonts), so the desktop app renders the same offline. */
@import url('/static/fonts/fonts.css');

:root {
  /* Core colours */
  --bg: #050508;
  --surface-1: #0c0c14;
  --surface-2: #12121e;
  --border: #1a1a2e;
  --border-strong: #2a2a44;
  --text: #d0d0dc;
  --text-muted: #8a8aa0;
  --ok: #2ecc71;
  --warn: #f0a030;
  --err: #e5484d;
  --info: #5b8def;
  --off: #4a4a5e;

  /* Tool accents. A page sets its own with <body data-tool="..."> */
  --orpheus: #00cec9;    --orpheus-rgb: 0, 206, 201;
  --sirene: #7c6cf0;     --sirene-rgb: 124, 108, 240;
  --apollo: #c9a84c;     --apollo-rgb: 201, 168, 76;
  --atlas: #4a90e2;      --atlas-rgb: 74, 144, 226;
  --prometheus: #e67e22; --prometheus-rgb: 230, 126, 34;
  --accent: var(--apollo);
  --accent-rgb: var(--apollo-rgb);

  /* Spacing and radius */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px;
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-pill: 999px;

  /* Type */
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-display: 'Cinzel', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Legacy names used by older page CSS. Keep until every page is migrated. */
  --surface: var(--surface-1);
  --surface2: var(--surface-2);
  --border-hi: var(--border-strong);
  --text-dim: var(--text-muted);
  --gold: #c9a84c; --gold-dim: #8a7030; --gold-glow: #c9a84c20;
  --purple: #7c6cf0; --teal: #00cec9; --cyan: #00cec9;
  --red: #e5484d; --orange: #e67e22; --blue: #4a90e2; --green: #2ecc71; --pink: #e84393;
}

/* --accent-soft must be declared on body: a var() inside a custom property resolves
   where it is declared, so a :root declaration would always use the default accent. */
body { --accent-soft: rgba(var(--accent-rgb), 0.14); }
body[data-tool="orpheus"]    { --accent: var(--orpheus);    --accent-rgb: var(--orpheus-rgb); }
body[data-tool="sirene"]     { --accent: var(--sirene);     --accent-rgb: var(--sirene-rgb); }
body[data-tool="apollo"]     { --accent: var(--apollo);     --accent-rgb: var(--apollo-rgb); }
body[data-tool="atlas"]      { --accent: var(--atlas);      --accent-rgb: var(--atlas-rgb); }
body[data-tool="prometheus"] { --accent: var(--prometheus); --accent-rgb: var(--prometheus-rgb); }

/* ── Base ─────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body.ht {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

:where(body.ht) a { color: var(--accent); text-decoration: none; }
:where(body.ht) a:hover { text-decoration: underline; }
body.ht h1, body.ht h2, body.ht h3, body.ht p { margin: 0; }
:where(body.ht) button, :where(body.ht) input, :where(body.ht) select, :where(body.ht) textarea { font: inherit; color: inherit; }

/* ── Sidebar (desktop) ────────────────────────────────── */

.ht-sidebar {
  flex: 0 0 216px;
  width: 216px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 20px 12px 16px;
  background: var(--surface-1);
  border-right: 1px solid var(--border);
}

.ht-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 20px;
  font: 700 17px/28px var(--font-display);
  letter-spacing: 0.02em;
  color: var(--gold);
  white-space: nowrap;
}
.ht-brand:hover { text-decoration: none; color: var(--gold); }
.ht-brand-mark { width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex: none; background: #000; }
.ht-brand-mark img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.9); }

.ht-nav { display: flex; flex-direction: column; gap: var(--space-1); }

.ht-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font: 500 13px/16px var(--font-ui);
  color: var(--text-muted);
}
.ht-nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.ht-nav a.active { color: var(--text); background: var(--accent-soft); }

.ht-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--text-muted));
}
.ht-dot--orpheus { --dot: var(--orpheus); }
.ht-dot--sirene { --dot: var(--sirene); }
.ht-dot--apollo { --dot: var(--apollo); }
.ht-dot--atlas { --dot: var(--atlas); }
.ht-dot--prometheus { --dot: var(--prometheus); }
.ht-dot--ok { --dot: var(--ok); }
.ht-dot--off { --dot: var(--off); }
.ht-dot--warn { --dot: var(--warn); }
.ht-dot--err { --dot: var(--err); }

.ht-planned {
  padding: 22px 12px 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
}
.ht-planned .ht-overline { margin-bottom: 2px; }

.ht-sidebar-status {
  margin-top: auto;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ht-sidebar-status > .ht-status { margin: 0 12px; }
a.ht-status { color: var(--text-muted); }
a.ht-status:hover { color: var(--text); text-decoration: none; }
.ht-nav--settings { margin-top: 8px; }
.ht-gear { flex: 0 0 14px; }
.ht-bottombar-settings { flex: 0 0 auto; min-width: 72px; }

.ht-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Bottom bar (phone) ───────────────────────────────── */

.ht-bottombar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  z-index: 50;
}
.ht-bottombar a {
  display: flex;
  flex: 1 1 0;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 16px;
  color: var(--text-muted);
}
.ht-bottombar a.active { color: var(--text); }
.ht-bottombar a:hover { text-decoration: none; }

/* ── Main column ──────────────────────────────────────── */

.ht-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.ht-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 32px 16px;
}
.ht-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ht-tool {
  font: 700 22px/28px var(--font-display);
  letter-spacing: 0.02em;
  color: var(--accent);
  white-space: nowrap;
}
.ht-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); }

.ht-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.ht-tabs::-webkit-scrollbar { display: none; }

.ht-tab {
  flex: 0 0 auto;
  padding: 12px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: 500 13px/16px var(--font-ui);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.ht-tab:hover { color: var(--text); text-decoration: none; }
.ht-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.ht-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

.ht-content {
  flex: 1 1 auto;
  padding: 24px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ht-panel { display: none; }
.ht-panel.active { display: block; }

/* ── Type helpers ─────────────────────────────────────── */

.ht-overline {
  font: 500 11px/14px var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ht-h { font: 600 15px/20px var(--font-ui); color: var(--text); }
.ht-small { font-size: 12px; line-height: 16px; }
.ht-muted { color: var(--text-muted); }
.ht-mono { font: 400 13px/18px var(--font-mono); }
.ht-accent { color: var(--accent); }
.ht-warn-text { color: var(--warn); }
.ht-err-text { color: var(--err); }
.ht-ok-text { color: var(--ok); }

/* ── Buttons ──────────────────────────────────────────── */

.ht-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font: 500 13px/16px var(--font-ui);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ht-btn:hover { border-color: var(--accent); text-decoration: none; }
.ht-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* One focus ring for everything else that takes the keyboard. */
:where(body.ht) :is(a, input, select, textarea, [tabindex], .ht-chip, .ht-row, .ht-preset, .ht-check):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.ht-btn:disabled, .ht-btn[aria-disabled="true"] { opacity: 0.45; cursor: default; pointer-events: none; }

.ht-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.ht-btn--primary:hover { filter: brightness(1.1); }
.ht-btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.ht-btn--ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.ht-btn--sm { padding: 5px 10px; font-size: 12px; }

/* ── Cards and tiles ──────────────────────────────────── */

.ht-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.ht-card--tight { padding: 16px; gap: 10px; }
.ht-card > .ht-h { margin: 0; }

.ht-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}
.ht-stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ht-stat-value {
  font: 500 28px/32px var(--font-mono);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ht-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ht-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ht-split { display: flex; gap: 24px; align-items: flex-start; }
.ht-split > .ht-split-main { flex: 1 1 auto; min-width: 0; }
.ht-split > .ht-split-side { flex: 0 0 360px; width: 360px; display: flex; flex-direction: column; gap: 16px; }
.ht-stack { display: flex; flex-direction: column; gap: 16px; }
.ht-row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ht-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ht-toolbar .ht-spacer { flex: 1 1 auto; }

/* ── Badge, chip, status, banner ──────────────────────── */

.ht-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font: 400 13px/18px var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
}
.ht-badge--warn { background: rgba(240, 160, 48, 0.14); color: var(--warn); }
.ht-badge--err { background: rgba(229, 72, 77, 0.14); color: var(--err); }
.ht-badge--ok { background: rgba(46, 204, 113, 0.14); color: var(--ok); }
.ht-badge--muted { background: var(--surface-2); color: var(--text-muted); }

.ht-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  font: 500 13px/16px var(--font-ui);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.ht-chip:hover { color: var(--text); border-color: var(--border-strong); }
.ht-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.ht-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-left: 3px solid var(--info);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.ht-banner--warn { border-left-color: var(--warn); }
.ht-banner--err { border-left-color: var(--err); }
.ht-banner--ok { border-left-color: var(--ok); }
.ht-banner-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ht-banner-title { font: 600 15px/20px var(--font-ui); color: var(--text); }
.ht-banner-detail { font-size: 12px; line-height: 16px; color: var(--text-muted); }

/* ── Inputs ───────────────────────────────────────────── */

.ht-input, .ht-select, .ht-textarea {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font: 400 14px/20px var(--font-ui);
  color: var(--text);
  outline: none;
}
.ht-input::placeholder, .ht-textarea::placeholder { color: var(--text-muted); }
.ht-input:focus, .ht-select:focus, .ht-textarea:focus { border-color: var(--accent); }
.ht-select { appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a8aa0' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.ht-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ht-field > label { font: 500 11px/14px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.ht-input--sm, .ht-select--sm { padding: 5px 10px; font-size: 13px; line-height: 16px; }

.ht-check {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin: 0;
  flex: 0 0 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
}
.ht-check:checked { background: var(--accent); border-color: var(--accent); }
.ht-check:checked::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 2px solid var(--bg);
  border-bottom: 2px solid var(--bg);
  transform: translateY(-1px) rotate(-45deg);
}

/* ── Lists and rows ───────────────────────────────────── */

.ht-list {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ht-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.ht-row:last-child { border-bottom: 0; }
.ht-row.selected { background: var(--accent-soft); }
.ht-row:hover { background: var(--surface-2); }
.ht-row.selected:hover { background: var(--accent-soft); }
.ht-row-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ht-row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht-row-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ht-kv { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ht-kv .ht-mono { color: var(--text-muted); }

.ht-preset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.ht-preset:hover { border-color: var(--accent); background: var(--surface-2); }
.ht-preset:disabled { opacity: 0.45; cursor: default; }
.ht-preset-name { font: 600 15px/20px var(--font-ui); }
.ht-preset-desc { font-size: 12px; line-height: 16px; color: var(--text-muted); }
.ht-preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.ht-finding { display: flex; gap: 10px; align-items: flex-start; }
.ht-finding .ht-dot { margin-top: 6px; }
.ht-finding-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ht-finding-sub { font-size: 12px; line-height: 16px; color: var(--text-muted); }

.ht-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 64px 16px;
  text-align: center;
}
.ht-empty .ht-h { margin: 0; }
.ht-empty .ht-small { color: var(--text-muted); max-width: 520px; }

.ht-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ht-spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes ht-spin { to { transform: rotate(360deg); } }

/* ── Bars (simple charts) ─────────────────────────────── */

.ht-bars { display: flex; align-items: flex-end; gap: 4px; width: 100%; height: 172px; }
.ht-bar { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; cursor: default; }
.ht-bar i { display: block; width: 100%; min-height: 2px; border-radius: 2px; background: var(--accent); }
.ht-bar span { font-size: 10px; line-height: 16px; color: var(--text-muted); white-space: nowrap; }
.ht-bar.gap i { background: var(--border); height: 2px; }
.ht-bar.gap span { color: var(--warn); }
.ht-bar.clickable { cursor: pointer; }
.ht-bar.clickable:hover i { filter: brightness(1.2); }

/* ── Hub tool cards ───────────────────────────────────── */

.ht-tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text);
  transition: border-color 0.15s;
}
.ht-tool-card:hover { border-color: var(--tool, var(--border-strong)); text-decoration: none; }
.ht-tool-card-top { display: flex; align-items: center; gap: 10px; }
.ht-tool-mark {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(var(--tool-rgb), 0.14);
  display: grid; place-content: center;
}
.ht-tool-mark::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--tool); }
.ht-tool-name { font: 700 18px/28px var(--font-display); letter-spacing: 0.02em; }
.ht-tool-desc { color: var(--text-muted); }
.ht-tool-open { font: 500 13px/16px var(--font-ui); color: var(--tool); }

.ht-planned-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}
.ht-planned-card b { font-weight: 500; font-size: 13px; color: var(--text); }

/* ── Docs prose ───────────────────────────────────────── */

.ht-prose { max-width: 720px; display: flex; flex-direction: column; gap: 12px; color: var(--text-muted); }
.ht-prose h2 { font: 600 15px/20px var(--font-ui); color: var(--text); margin-top: 12px; }
.ht-prose h3 { font: 500 13px/16px var(--font-ui); color: var(--text); margin-top: 4px; }
.ht-prose code, .ht-prose pre { font: 400 12px/18px var(--font-mono); background: var(--surface-2); border-radius: 4px; }
.ht-prose code { padding: 1px 5px; }
.ht-prose pre { padding: 12px; overflow-x: auto; margin: 0; color: var(--text); }
.ht-prose table { border-collapse: collapse; width: 100%; font-size: 13px; }
.ht-prose th, .ht-prose td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.ht-prose th { font-weight: 500; color: var(--text); }
.ht-prose ul, .ht-prose ol { margin: 0; padding-left: 20px; }
.ht-prose strong { color: var(--text); font-weight: 500; }

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 900px) {
  .ht-sidebar { display: none; }
  .ht-bottombar { display: flex; }
  .ht-main { padding-bottom: 64px; }
  .ht-header { padding: 16px 16px 8px; }
  .ht-tabs { padding: 0 4px; gap: 4px; }
  .ht-content { padding: 16px 16px 32px; gap: 12px; }
  .ht-grid-2, .ht-grid-3 { grid-template-columns: 1fr; }
  .ht-split { flex-direction: column; align-items: stretch; }
  .ht-split > .ht-split-side { flex: 1 1 auto; width: 100%; }
  .ht-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .ht-sub { display: none; }
}

/* Public server (HERMES_PUBLIC=1): no Settings page, no local connections, no setup card. */
body[data-public] .ht-status,
body[data-public] .ht-sidebar-status,
body[data-public] .ht-nav--settings,
body[data-public] .ht-bottombar-settings,
body[data-public] #setup,
body[data-public] #reload-btn { display: none !important; }
