/* cogx — unified dark dashboard theme.
   Source lives in the Cog vault at scripts/c0g_static/c0g.css and is
   deployed to ~/c0g/static/c0g.css on cogx. The design deliberately mirrors
   reports/cog-custom-skills-reference.html: dark gradient, slate cards,
   cyan links, and one shared sticky navigation bar. */

:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-2: #111827;
  --bg-3: #020617;
  --card: rgba(17, 24, 39, 0.88);
  --card-solid: #111827;
  --card-hover: rgba(30, 41, 59, 0.82);
  --muted: #94a3b8;
  --muted-2: #64748b;
  --text: #e5e7eb;
  --ink: #f8fafc;
  --accent: #38bdf8;
  --accent-2: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --line: #334155;
  --line-2: #1e293b;
  --good: #86efac;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #93c5fd;
  --shadow: 0 20px 55px rgba(2, 6, 23, 0.38);
  --shadow-soft: 0 10px 32px rgba(2, 6, 23, 0.24);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --tap: 44px;
  --gutter: clamp(16px, 4vw, 32px);
  --content-width: 1100px;
  --chat-width: 980px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* legacy aliases used by older generated reports */
  --surface: var(--bg);
  --surface-2: var(--bg-3);
  --paper: var(--bg);
  --paper-2: var(--bg-2);
  --panel: var(--card-solid);
  --panel-2: var(--card);
  --panel-3: var(--bg-3);
  --border: var(--line);
  --border-2: var(--line-2);
  --button: var(--accent);
  --focus: var(--accent);
  --focus-ring: rgba(56, 189, 248, 0.30);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.14), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(129, 140, 248, 0.10), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  font: 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

::selection { background: rgba(56, 189, 248, 0.25); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

h1, h2, h3, h4 { color: var(--ink); line-height: 1.16; letter-spacing: -0.02em; margin: 0 0 .65rem; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.8rem); margin-top: 2rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.1rem; margin-top: 1.25rem; }
p { margin: 0 0 1rem; max-width: 76ch; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
strong, b { color: var(--ink); }
small, .muted, .meta, .hint { color: var(--muted); }
code, pre { font-family: var(--font-mono); }
code { background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 6px; padding: .1rem .32rem; color: var(--text); }
pre { background: rgba(2, 6, 23, .78); border: 1px solid var(--line-2); border-radius: 12px; color: var(--text); padding: 14px; overflow: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* Shared navigation ---------------------------------------------------- */
.c0g-nav,
.chat-page header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .7rem 1rem;
  min-height: 58px;
  padding: .65rem var(--gutter);
  background: rgba(2, 6, 23, .90);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
          backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(2, 6, 23, .20);
}
.c0g-brand, .brand {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: .04em;
  text-decoration: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 32px;
}
.c0g-brand::before, .brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(56, 189, 248, .12), 0 0 24px rgba(56, 189, 248, .60);
}
.c0g-links,
.chat-page header .status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem .8rem;
  color: var(--muted-2);
  font-size: .94rem;
}
.c0g-links a,
.chat-page header .status a {
  color: var(--muted);
  text-decoration: none;
  border: 0;
  padding: .2rem .05rem;
}
.c0g-links a:hover,
.c0g-links a.active,
.chat-page header .status a:hover,
.chat-page header .status a.active { color: var(--accent); }
.sep { color: var(--line); }

main,
.app {
  width: min(var(--content-width), calc(100% - 2 * var(--gutter)));
  margin: 0 auto;
  padding: 32px 0 64px;
}
.chat-page .app { width: min(var(--chat-width), calc(100% - 2 * var(--gutter))); padding-bottom: 180px; }

/* Cards, grids, lists -------------------------------------------------- */
.card, .talk-card, .alert-card, .auth-card,
.map-section, .detail-card, .item,
.report-list-item, .stat, .kv,
.dashboard-panel, .dashboard-head,
.markdown-report {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card, .talk-card, .alert-card, .auth-card, .map-section, .detail-card, .item, .stat, .kv { padding: 16px; }
.cards, .grid, .map-grid, .kv-grid, .stat-rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
ul { padding-left: 1.3rem; }
li { margin: .28rem 0; }
.report-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .75rem; }
.report-list-item { padding: .9rem 1rem; }
.report-list-item a { font-weight: 700; }
.pills, .neighbors { display: flex; flex-wrap: wrap; gap: .45rem; }
.pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  background: rgba(15, 23, 42, .70);
  padding: .18rem .55rem;
  font-size: .86rem;
}
.badge.ok { border-color: rgba(134, 239, 172, .45); color: var(--good); }
.badge.warn { border-color: rgba(251, 191, 36, .45); color: var(--warn); }
.badge.danger { border-color: rgba(248, 113, 113, .45); color: var(--danger); }
.badge.info { border-color: rgba(147, 197, 253, .45); color: var(--info); }

/* Forms and buttons ---------------------------------------------------- */
button, .button-link, .btn, input, textarea, select { font: inherit; }
button, .button-link, .btn {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent);
  color: #062033;
  font-weight: 750;
  padding: .6rem .9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
}
button:hover, .button-link:hover, .btn:hover { filter: brightness(1.08); color: #031522; }
button:disabled { cursor: not-allowed; opacity: .55; filter: grayscale(.2); }
.btn.secondary, .btn.ghost, .small-controls button, .alert-actions button, .button-link {
  background: rgba(15, 23, 42, .86);
  color: var(--text);
}
.btn.danger, button.danger { background: var(--danger); color: #280304; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 6, 23, .62);
  color: var(--text);
  padding: .75rem .85rem;
}
textarea { min-height: 116px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
form { margin: 0; }
.auth-card { width: min(420px, 100%); display: grid; gap: .8rem; }
.auth-card h1 { text-align: center; }
.err, .error-note { color: #fecaca; background: rgba(127, 29, 29, .52); border: 1px solid rgba(248, 113, 113, .45); border-radius: 12px; padding: .75rem; }

/* Chat page ------------------------------------------------------------ */
.home-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}
.home-action {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  color: var(--text);
}
.home-action:hover { background: var(--card-hover); color: var(--text); }
.home-action.primary { border-color: rgba(56, 189, 248, .55); }
.home-action b { display: block; font-size: 1.03rem; }
.home-action span { display: block; color: var(--muted); font-size: .9rem; margin-top: .16rem; }
#messages { display: grid; gap: 12px; }
.msg {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  box-shadow: var(--shadow-soft);
}
.msg.user { border-color: rgba(56, 189, 248, .45); }
.msg.assistant { border-color: rgba(134, 239, 172, .28); }
.msg .meta { margin-bottom: .35rem; font-size: .82rem; }
.composer {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  padding: .9rem var(--gutter) max(.9rem, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(2, 6, 23, .96) 22%);
}
.composer-inner {
  width: min(var(--chat-width), 100%);
  margin: 0 auto;
  background: rgba(17, 24, 39, .95);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.composer .row { display: flex; justify-content: flex-end; margin-top: .55rem; }
.composer .hint { margin-top: .5rem; font-size: .84rem; }
.dot { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; background: var(--danger); box-shadow: 0 0 0 4px rgba(248,113,113,.12); }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px rgba(134,239,172,.12); }

/* Alerts / status / call ---------------------------------------------- */
.mode { font-size: 1.15rem; font-weight: 800; color: var(--accent); }
table { width: 100%; border-collapse: collapse; background: rgba(17,24,39,.72); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 1rem 0; }
th, td { text-align: left; vertical-align: top; padding: 10px; border-bottom: 1px solid var(--line); }
th { color: var(--accent); font-weight: 700; }
.alert-card { margin: 1rem 0; }
.alert-meta { color: var(--muted); font-size: .88rem; margin-bottom: .35rem; }
.alert-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; }
.sev-p0 { border-color: rgba(248, 113, 113, .75); }
.sev-p1 { border-color: rgba(251, 191, 36, .65); }
.sev-p2 { border-color: rgba(56, 189, 248, .55); }
.hero { text-align: center; }
.call-button {
  width: min(88vw, 24rem) !important;
  min-height: 7.5rem !important;
  border-radius: 28px !important;
  font-size: clamp(1.7rem, 8vw, 2.2rem) !important;
  box-shadow: 0 18px 44px rgba(56, 189, 248, .20) !important;
}
.call-button.running { background: var(--danger) !important; color: #fff !important; }
.log { white-space: pre-wrap; max-height: 18rem; overflow: auto; background: rgba(2,6,23,.72); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; }
.composer-row { display: flex; gap: .5rem; }
.composer-row input { flex: 1; }

/* Dashboard/report wrappers ------------------------------------------ */
.dashboard-head { padding: 1rem; margin: 0; border-radius: 0; box-shadow: none; }
.dashboard-panel { padding: .7rem 1rem; border-radius: 0; box-shadow: none; position: sticky; top: 58px; z-index: 5; }
.dashboard-archive { display: inline-flex; flex-wrap: nowrap; gap: .55rem; list-style: none; padding: 0; margin: 0; max-width: calc(100vw - 9rem); overflow-x: auto; vertical-align: middle; }
.dashboard-archive li { white-space: nowrap; }
.dashboard-archive a { display: inline-block; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: .18rem .55rem; background: rgba(2,6,23,.62); }
.dashboard-archive a.active, .dashboard-archive a:hover { color: var(--accent); }
.dashboard-frame { display: block; width: 100%; height: calc(100vh - 150px); min-height: 760px; border: 0; background: #fff; }
.markdown-report { white-space: pre-wrap; line-height: 1.45; }
body.report-html-page > main, body.markdown-report-page > main { max-width: min(1100px, calc(100% - 2 * var(--gutter))); }

/* Capabilities graph/report compatibility ----------------------------- */
.graph-shell { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 14px; min-height: calc(100vh - 100px); }
.graph-side, .graph-main { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow: auto; }
.graph-main svg, svg#graph { background: rgba(2,6,23,.40); border-radius: 12px; }

@media (max-width: 820px) {
  body { font-size: 15.5px; }
  .c0g-nav, .chat-page header { align-items: flex-start; }
  .c0g-links, .chat-page header .status { justify-content: flex-start; width: 100%; font-size: .9rem; }
  main, .app, .chat-page .app { width: min(100% - 28px, var(--content-width)); padding-top: 24px; }
  .composer-row { flex-direction: column; }
  .dashboard-panel { position: static; }
  .dashboard-frame { height: calc(100vh - 175px); min-height: 620px; }
  .graph-shell { grid-template-columns: 1fr; }
}
