/* pyrokinesis — dashboard theme. Dark, with a fire-gradient accent. */
:root {
  --bg:        #0c0c0f;
  --bg-soft:   #121217;
  --surface:   #17171d;
  --surface-2: #1d1d26;
  --border:    #2a2a34;
  --border-2:  #383844;
  --text:      #e7e7ec;
  --muted:     #8b8b97;
  --faint:     #5c5c67;

  --accent:    #ff7a18;
  --accent-2:  #ff3326;
  --fire: linear-gradient(135deg, #ffb020 0%, #ff7a18 45%, #ff3326 100%);

  --c-tags:     #ff9d3d;  /* explicit  */
  --c-detected: #7a8290;  /* implicit  */
  --c-env:      #43d17f;  /* env       */
  --c-ai:       #b794f6;  /* llm       */
  --c-meta:     #5aa9ff;  /* author/ingest */
  --c-act:      #f6d743;  /* act: session events (commands, edits) */

  --radius: 12px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
body {
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 80% -10%, #1a1208 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, .mono { font-family: var(--mono); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  border-right: 1px solid var(--border);
  padding: 1.1rem .9rem;
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: .35rem;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem;
  letter-spacing: -.02em; padding: .2rem .4rem 1rem; }
.brand .flame { font-size: 1.3rem; filter: drop-shadow(0 0 6px rgba(255,122,24,.6)); }
.brand .word {
  background: var(--fire); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.navlink {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500;
}
.navlink:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.navlink.active { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.navlink .ico { width: 1.1rem; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.sidebar form { margin: 0; }
.sidebar .build { color: var(--faint); font-size: .72rem; padding: .4rem; }

.main { padding: 1.6rem 2rem 4rem; max-width: 1180px; }

.page-head { display: flex; align-items: baseline; gap: .75rem; margin: 0 0 1.4rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: .9rem; }

/* ---------- buttons / inputs ---------- */
button, .btn {
  background: var(--fire); color: #1a0a02; border: 0; border-radius: var(--radius-sm);
  padding: .5rem .9rem; cursor: pointer; font-family: inherit; font-weight: 650; font-size: .85rem;
  transition: filter .15s, transform .05s;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active { transform: translateY(1px); }
button.ghost, .btn.ghost {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
}
button.danger { background: #3a1414; color: #ff8d8d; border: 1px solid #5c2020; }
button.danger:hover { background: #4a1818; }

input[type=text], input[type=password], textarea, select {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .55rem .65rem; width: 100%;
  font-family: inherit; font-size: .88rem;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,24,.12);
}
textarea { font-family: var(--mono); resize: vertical; }
form.inline { display: inline; margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad { padding: 1.1rem 1.2rem; }

.grid { display: grid; gap: 1rem; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1.3rem; }

.stat { position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; margin-top: .15rem; line-height: 1; }
.stat .value.mono { font-family: var(--mono); }
.stat .foot { color: var(--faint); font-size: .76rem; margin-top: .35rem; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  background: var(--fire); opacity: .08; border-radius: 50%; }

.cols-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .cols-2 { grid-template-columns: 1fr; } }

h2.section { font-size: .82rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 .85rem; font-weight: 650; }

/* ---------- bars ---------- */
.bars { display: flex; flex-direction: column; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 8.5rem 1fr 2.4rem; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-row .blabel { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: .8rem; }
.bar-row .btrack { background: var(--bg-soft); border-radius: 5px; height: 9px; overflow: hidden; }
.bar-row .bfill { height: 100%; border-radius: 5px; background: var(--fire); }
.bar-row .bcount { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row.env  .bfill { background: var(--c-env); }
.bar-row.ai   .bfill { background: var(--c-ai); }
.bar-row.meta .bfill { background: var(--c-meta); }
.bar-row.detected .bfill { background: var(--c-detected); }
.bar-row.act  .bfill { background: var(--c-act); }

/* ---------- sparkline ---------- */
.spark { width: 100%; height: 64px; display: block; }
.spark path.area { fill: url(#fireFill); opacity: .25; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.spark .pt circle { fill: var(--accent); opacity: 0; transition: opacity .1s; }
.spark .pt:hover circle { opacity: 1; }

/* ---------- inline tabs (content view, sparkline period) ---------- */
.content-tabs { display: flex; align-items: center; gap: .35rem; margin-bottom: .8rem; }
.content-tabs .spacer { flex: 1; }
.tab {
  background: transparent; border: 1px solid var(--border-2); color: var(--muted);
  border-radius: 999px; padding: .15rem .7rem; font-size: .76rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.tab:hover { color: var(--text); text-decoration: none; filter: none; }
.tab.active { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }

/* ---------- breadcrumb chips, grouped ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; }
.crumb {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--mono); font-size: .76rem; line-height: 1.4;
  padding: .12rem .45rem; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
}
.crumb .k { color: var(--muted); }
.crumb .v { font-weight: 600; }
.crumb.tags     { border-color: rgba(255,157,61,.4);  color: var(--c-tags); }
.crumb.detected { border-color: var(--border-2); color: var(--c-detected); }
.crumb.env      { border-color: rgba(67,209,127,.4);  color: var(--c-env); }
.crumb.ai       { border-color: rgba(183,148,246,.4); color: var(--c-ai); }
.crumb.meta     { border-color: rgba(90,169,255,.4);  color: var(--c-meta); }
.crumb.act      { border-color: rgba(246,215,67,.4);  color: var(--c-act); }
a.crumb:hover { text-decoration: none; filter: brightness(1.2); border-style: solid; }

.crumb-group { margin-bottom: .7rem; }
.crumb-group .gh { display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.gh .dot { width: .55rem; height: .55rem; border-radius: 50%; }
.dot.tags { background: var(--c-tags); } .dot.detected { background: var(--c-detected); }
.dot.env { background: var(--c-env); } .dot.ai { background: var(--c-ai); } .dot.meta { background: var(--c-meta); }
.dot.act { background: var(--c-act); }

/* ---------- record list ---------- */
.rec-list { display: flex; flex-direction: column; gap: .7rem; }
.rec {
  display: block; padding: .9rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color .15s, transform .05s;
}
.rec:hover { border-color: var(--border-2); text-decoration: none; transform: translateY(-1px); }
.rec .rlink { display: block; color: var(--text); }
.rec .rlink:hover { text-decoration: none; }
.rec .rlink:hover .rtext { color: #fff; }
.rec .rtext { color: var(--text); margin-bottom: .55rem; }
.rec .rtext em { color: var(--faint); }
.rec .rmeta { display: flex; gap: .6rem; align-items: center; color: var(--faint); font-size: .75rem; margin-top: .55rem; flex-wrap: wrap; }
.rec .rmeta .author { color: var(--c-meta); }
.rec .rmeta .sess { color: var(--accent); font-family: var(--mono); font-size: .75rem; }
.dot-sep::before { content: "·"; margin: 0 .15rem; color: var(--border-2); }
mark { background: rgba(255,176,32,.3); color: #ffd28d; border-radius: 3px; padding: 0 .1em; }

/* bulk selection (records page) */
.rec.sel { display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: start; }
.rec.sel .selbox { padding-top: .15rem; }
.rec.sel .selbox input { accent-color: var(--accent); }
.bulkbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  margin-bottom: .7rem; padding: .35rem .5rem; }
.bulkbar label { font-size: .8rem; cursor: pointer; }
.bulkbar input { accent-color: var(--accent); }

/* pager */
.pager { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: 1rem; }

/* ---------- search bar ---------- */
.searchbar { display: grid; grid-template-columns: 1.3fr 1fr auto auto auto; gap: .5rem; margin-bottom: 1.1rem; }
@media (max-width: 720px) { .searchbar { grid-template-columns: 1fr; } }

.with-aside { display: grid; grid-template-columns: 1fr 260px; gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .with-aside { grid-template-columns: 1fr; } }
.aside .facet { margin-bottom: 1.15rem; }
.aside .facet h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .5rem; }
.facet-list { display: flex; flex-direction: column; gap: .15rem; }
.facet-item { display: flex; justify-content: space-between; gap: .5rem; align-items: center;
  padding: .25rem .45rem; border-radius: 6px; font-size: .8rem; color: var(--text); }
.facet-item:hover { background: var(--surface-2); text-decoration: none; }
.facet-item .fv { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facet-item .fn { color: var(--faint); font-variant-numeric: tabular-nums; }
.facet-item.env .fv { color: var(--c-env); } .facet-item.tags .fv { color: var(--c-tags); }
.facet-item.meta .fv { color: var(--c-meta); } .facet-item.ai .fv { color: var(--c-ai); }
.facet-item.detected .fv { color: var(--c-detected); }
.facet-item.act .fv { color: var(--c-act); }

.active-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; align-items: center; }
.active-filters .lbl { color: var(--muted); font-size: .78rem; }
.chip-x { background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 999px; padding: .15rem .6rem; font-size: .76rem; font-family: var(--mono); }
.chip-x:hover { border-color: var(--accent-2); color: #ff9d8d; text-decoration: none; }
.chip-x .x { color: var(--faint); margin-left: .3rem; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: 5px; top: .3rem; bottom: .3rem; width: 2px;
  background: linear-gradient(var(--accent), transparent); opacity: .35; }
.tl-day { margin-bottom: 1.6rem; }
.tl-date { position: relative; font-weight: 650; margin: 0 0 .8rem -1.4rem; padding-left: 1.4rem; }
.tl-date::before { content: ""; position: absolute; left: 0; top: .35rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--fire); box-shadow: 0 0 0 3px var(--bg); }
.tl-date .cnt { color: var(--muted); font-weight: 400; font-size: .82rem; margin-left: .4rem; }
.tl-more summary { cursor: pointer; color: var(--accent); font-size: .85rem; padding: .3rem 0;
  list-style-position: inside; }
.tl-more summary:hover { text-decoration: underline; }
.tl-more[open] summary { color: var(--muted); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.error { color: #ff7a7a; background: rgba(255,60,40,.08); border: 1px solid rgba(255,60,40,.3);
  padding: .6rem .8rem; border-radius: var(--radius-sm); }
.ok { color: #7fe0a0; }
.badge { font-size: .75rem; color: #9fe6b6; background: #0e1a10; border: 1px solid #2a6;
  padding: .1rem .45rem; border-radius: var(--radius-sm); }
/* recall-event badges: shown = candidate (cool/neutral), injected = confirmed
   in context (green), pulled = full read (warm) */
.evt { font-size: .75rem; padding: .1rem .45rem; border-radius: var(--radius-sm); border: 1px solid; }
.evt-shown { color: #9ec3e6; background: #0d141a; border-color: #2a4a6b; }
.evt-injected { color: #9fe6b6; background: #0e1a10; border-color: #2a6; }
.evt-pulled { color: #ffd28d; background: #1a130a; border-color: #6b4a1a; }
.ph-chip { font-family: var(--mono); font-size: .85rem; color: #ffd28d; background: #1a130a;
  border: 1px solid #6b4a1a; padding: .15rem .5rem; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; }
.ph-chip:hover { background: #241a0d; border-color: #9a6c26; }
.ph-chip.copied { color: #9fe6b6; border-color: #2a6; background: #0e1a10; }
.token { font-family: var(--mono); background: #0e1a10; border: 1px solid #2a6; color: #9fe6b6;
  padding: .7rem .8rem; border-radius: var(--radius-sm); word-break: break-all; }
pre.content { font-family: var(--mono); white-space: pre-wrap; word-break: break-word;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; font-size: .82rem; line-height: 1.55; }

/* rendered-markdown record content */
.md-content { font-size: .9rem; line-height: 1.6; overflow-wrap: break-word; }
.md-content > :first-child { margin-top: 0; }
.md-content > :last-child { margin-bottom: 0; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 {
  letter-spacing: -.01em; margin: 1.1em 0 .45em; line-height: 1.25; }
.md-content h1 { font-size: 1.25rem; } .md-content h2 { font-size: 1.1rem; }
.md-content h3 { font-size: .95rem; } .md-content h4 { font-size: .88rem; color: var(--muted); }
.md-content code { font-family: var(--mono); font-size: .85em; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 4px; padding: .08em .35em; color: #ffd28d; }
.md-content pre { background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .8rem .9rem; overflow-x: auto; }
.md-content pre code { background: none; border: 0; padding: 0; color: var(--text); font-size: .8rem; }
.md-content ul, .md-content ol { padding-left: 1.4rem; }
.md-content li { margin: .15rem 0; }
.md-content blockquote { margin: .8rem 0; padding: .1rem .9rem; border-left: 3px solid var(--accent);
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--muted); }
.md-content table { border-collapse: collapse; margin: .8rem 0; font-size: .85rem; }
.md-content th, .md-content td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; }
.md-content th { background: var(--surface-2); color: var(--muted); }
.md-content hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.md-content img { max-width: 100%; }
.kv { color: var(--muted); font-size: .82rem; }
.kv b { color: var(--text); font-weight: 600; }
table.keys { border-collapse: collapse; width: 100%; }
table.keys td, table.keys th { border-bottom: 1px solid var(--border); padding: .6rem .5rem; text-align: left; }
table.keys th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty .big { font-size: 2rem; opacity: .5; }

/* htmx in-flight indicator: dim the working pane */
body.loading .main { opacity: .55; transition: opacity .15s; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: .15rem; padding: .6rem .7rem;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: .2rem .5rem; font-size: 1rem; }
  .sidebar .navlink { padding: .35rem .5rem; font-size: .85rem; }
  .sidebar .spacer { display: none; }
  .sidebar form { margin-left: auto; }
  .sidebar form button { width: auto !important; padding: .3rem .6rem; }
  .sidebar .build { display: none; }
  .main { padding: 1rem 1rem 3rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* secrets */
.secret-ref { font-family: var(--mono); font-size: .85em; background: rgba(255,170,40,.1);
  border: 1px solid rgba(255,170,40,.35); color: #ffc46b; border-radius: 4px;
  padding: .05rem .35rem; text-decoration: none; white-space: nowrap; }
.secret-ref:hover { background: rgba(255,170,40,.2); }
pre.secret-value { background: #0e1a10; border: 1px solid #2a6; color: #9fe6b6; margin-top: .8rem; }

/* quarantined records (ROADMAP п.34) */
.qbadge { font-size: .75rem; color: #ffb86b; background: #1a130a; border: 1px solid #6b4a1a;
  padding: .1rem .45rem; border-radius: var(--radius-sm); }
