/* TUHI CONSOLE — screen styles on top of BrainTrust's verbatim tuhi.css + tuhi-shell.css (tokens, shell, db-* components) and the
   shared kg-view.css. Only tokens from tuhi-shell.css are used, so light and dark follow html.tuhi / html.tuhi.light. Every class is
   tc-*. No inline style anywhere in the console (the CSP forbids it); widths that depend on data are set through the CSSOM. */

html.tuhi body{ min-height:100vh; }
.tc-i{ display:inline-flex; align-items:center; justify-content:center; flex:none; line-height:0; }
.tc-i svg{ display:block; }
.tc-mark{ width:30px; height:30px; border-radius:8px; background:var(--acc); color:var(--on-acc); display:inline-flex; align-items:center; justify-content:center;
  font-weight:800; font-size:15px; letter-spacing:-.02em; flex:none; }

/* ── boot + sign-in ── */
.tc-boot{ position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:var(--bg); }
.tc-boot-mark{ width:44px; height:44px; border-radius:12px; background:var(--acc); animation:tcpulse 1.1s ease-in-out infinite; }
@keyframes tcpulse{ 0%,100%{ opacity:.45; transform:scale(.94); } 50%{ opacity:1; transform:scale(1); } }
.tc-signin{ min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:24px 16px; gap:18px; background:var(--bg); }
.tc-signin-card{ width:min(440px,100%); background:var(--surface); border:1px solid var(--bd); border-radius:14px; box-shadow:var(--shadow-md); padding:28px; }
.tc-signin-brand{ display:flex; align-items:center; gap:14px; margin-bottom:14px; }
.tc-signin-brand .tc-mark{ width:44px; height:44px; font-size:21px; border-radius:12px; }
.tc-signin-brand h1{ margin:0; font-size:22px; color:var(--fg); }
.tc-signin-brand p{ margin:2px 0 0; color:var(--mut); font-size:13px; }
.tc-signin-lead{ color:var(--fg-2); line-height:1.55; font-size:13.5px; }
.tc-signin-form{ display:flex; flex-direction:column; gap:8px; }
.tc-signin-form label{ font-size:12px; font-weight:600; color:var(--mut); }
.tc-signin-form input{ height:40px; padding:0 12px; font-size:14px; border-radius:10px; }
.tc-signin-form button{ height:40px; border-radius:10px; font-size:14px; margin-top:6px; }
.tc-signin-msg{ min-height:20px; color:var(--fg-2); font-size:13px; line-height:1.5; margin:12px 0 0; }
.tc-signin-foot{ display:flex; gap:8px; color:var(--mut); font-size:12px; }

/* ── header: the scope switch ── */
.tc-scope{ display:inline-flex; align-items:center; gap:8px; }
.tc-scope-l{ font-size:11.5px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--mut); }
html.tuhi .tc-scope select{ height:34px; padding:0 10px; font-size:12.5px; font-weight:650; border-radius:8px; max-width:280px; }
@media (max-width:767px){ .tc-scope-l{ display:none; } html.tuhi .tc-scope select{ max-width:130px; } }
.tc-navbadge{ margin-left:auto; min-width:18px; height:18px; padding:0 6px; border-radius:99px; background:var(--warn-bg); color:var(--warn-fg); border:1px solid var(--warn-bd);
  font-size:11px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; }
#app.rail .tc-navbadge{ display:none; }
#app.rail .bt-side:hover .tc-navbadge{ display:inline-flex; }
html.tuhi #refreshBtn .tc-i{ margin-right:2px; }

/* ── screen building blocks ── */
.tc-root{ display:flex; flex-direction:column; gap:14px; min-width:0; }
.tc-root > .db-head{ margin-bottom:4px; }
.tc-tabs{ display:flex; gap:6px; flex-wrap:wrap; }
html.tuhi:not(.tc-narrow) #app:not(.rail) .tc-tabs{ display:none; }  /* the sidebar shows the sub-items; the tabs are for rail/drawer */
@media (max-width:767px){ html.tuhi #app .tc-tabs{ display:flex; } }
.tc-note{ color:var(--mut); font-size:12.5px; line-height:1.55; margin:0; }
.tc-ok-text{ color:var(--ok-fg); font-weight:600; font-size:13px; }
.tc-h4{ margin:18px 0 8px; font-size:11.5px; font-weight:800; letter-spacing:.07em; text-transform:uppercase; color:var(--fg-2); }
.tc-form{ display:flex; flex-direction:column; gap:10px; }
.tc-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.tc-grow{ flex:1 1 220px; min-width:0; }
.tc-grow .tc-field{ width:100%; }
.tc-field{ display:flex; flex-direction:column; gap:5px; min-width:0; }
.tc-field > label{ font-size:11.5px; font-weight:600; color:var(--mut); letter-spacing:.02em; }
.tc-field input:not([type=checkbox]):not([type=file]), .tc-field select{ height:34px; border-radius:8px; padding:0 10px; font:inherit; font-size:13px; max-width:100%; }
.tc-field textarea{ border-radius:8px; padding:9px 10px; font:inherit; font-size:13px; width:100%; resize:vertical; }
.tc-hint{ color:var(--mut); font-size:11.5px; }
.tc-acts{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:4px; }
.tc-acts button, .tc-fbtns button{ height:34px; display:inline-flex; align-items:center; gap:6px; padding:0 14px; border-radius:8px; }
html.tuhi button.ghost{ border:1px solid var(--bd-strong); border-radius:8px; padding:6px 12px; cursor:pointer; font-size:13px; }
html.tuhi button.tc-danger{ background:var(--err); color:#fff; }
html.tuhi button.tc-danger-ghost{ color:var(--err-fg); border-color:var(--err-bd); }
html.tuhi button.tc-danger-ghost:hover{ background:var(--err-bg); }
.tc-filters{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; background:var(--surface); border:1px solid var(--bd); border-radius:12px; padding:12px 14px; box-shadow:var(--shadow-sm); }
.tc-fbtns{ display:flex; gap:8px; }
.tc-add > summary{ cursor:pointer; font-weight:650; color:var(--fg); display:flex; align-items:center; gap:8px; list-style:none; }
.tc-add > summary::-webkit-details-marker{ display:none; }
.tc-add[open] > summary{ margin-bottom:12px; }
.tc-check{ display:inline-flex; align-items:center; gap:8px; font-size:13px; color:var(--fg-2); cursor:pointer; }
.tc-check.tc-big{ font-size:14px; color:var(--fg); font-weight:600; margin-bottom:8px; }
.tc-checks{ display:flex; flex-wrap:wrap; gap:8px 18px; }
.tc-wrap{ white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; display:inline-block; max-width:100%; }
.tc-click{ cursor:pointer; }
.tc-click:hover td, .db-row.tc-click:hover{ background:var(--surface-2); }
.tc-click:focus-visible{ outline:2px solid var(--acc); outline-offset:-2px; }
.tc-text{ min-width:220px; color:var(--fg); line-height:1.5; overflow-wrap:anywhere; }
.tc-sub{ margin-top:4px; }
.tc-mem td{ vertical-align:top; }
.tc-conf{ display:flex; align-items:center; gap:8px; min-width:110px; }
.tc-conf .db-bar{ flex:1; margin:0; }
.tc-conf span{ font-size:12px; color:var(--fg-2); font-variant-numeric:tabular-nums; }
.tc-log{ background:var(--inset); border:1px solid var(--bd); border-radius:10px; padding:12px; min-height:60px; max-height:360px; overflow:auto; font-size:12px; color:var(--fg-2); white-space:pre-wrap; margin:12px 0 0; }
.tc-searchopts{ display:flex; flex-direction:column; gap:4px; margin-top:6px; }
.tc-searchopts select{ height:30px; border-radius:8px; padding:0 8px; font-size:12.5px; }
.tc-usage-h{ padding:10px 0 2px; font-size:13px; }
.tc-key{ font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:13px; height:38px; padding:0 10px; border-radius:8px; flex:1 1 auto; min-width:0; }
.tc-keyrow{ display:flex; gap:8px; align-items:center; }
.tc-keyrow button{ height:38px; display:inline-flex; align-items:center; gap:6px; padding:0 14px; border-radius:8px; }
.tc-sharelist{ margin:0 0 10px; padding-left:18px; color:var(--fg); line-height:1.6; }
.tc-sharelist li{ margin:4px 0; overflow-wrap:anywhere; }
.tc-audit .tc-detail{ min-width:200px; max-width:420px; font-size:12px; }
.tc-audit code{ font-size:11.5px; }

/* ── the memory model's tags ── */
.db-tag.tc-type{ background:var(--surface-3); color:var(--fg-2); border-color:var(--bd); text-transform:lowercase; }
.db-tag.tc-type-working{ background:var(--warn-bg); color:var(--warn-fg); border-color:var(--warn-bd); }
.db-tag.tc-type-episodic{ background:var(--vio-bg); color:var(--vio); border-color:var(--bd-strong); }
.db-tag.tc-type-semantic{ background:var(--acc-soft); color:var(--acc-fg); border-color:var(--acc-ring); }
.db-tag.tc-type-procedural{ background:var(--ok-bg); color:var(--ok-fg); border-color:var(--ok-bd); }
.db-tag.tc-type-preference{ background:var(--err-bg); color:var(--err-fg); border-color:var(--err-bd); }
.db-tag.tc-type-profile{ background:var(--surface-3); color:var(--info); border-color:var(--bd-strong); }
.db-tag.tc-type-reflective{ background:var(--vio-bg); color:var(--fg); border-color:var(--vio); }
.db-tag.tc-type-resource{ background:var(--inset); color:var(--fg-2); border-color:var(--bd-strong); border-style:dashed; }
.db-tag.tc-type-entity{ background:var(--surface); color:var(--fg-2); border-color:var(--bd-strong); }
.db-tag.tc-tier{ background:transparent; color:var(--fg-2); border-color:var(--bd-strong); }
.db-tag.tc-tier-working{ color:var(--warn-fg); border-color:var(--warn-bd); }
.db-tag.tc-tier-short{ color:var(--acc-fg); border-color:var(--acc-ring); }
.db-tag.tc-tier-long{ color:var(--ok-fg); border-color:var(--ok-bd); }
.db-tag.tc-sens{ background:var(--surface-2); color:var(--mut); border-color:var(--bd); font-weight:600; }
.db-tag.tc-sens-restricted{ color:var(--warn-fg); border-color:var(--warn-bd); background:var(--warn-bg); }
.db-tag.tc-sens-sensitive{ color:var(--err-fg); border-color:var(--err-bd); background:var(--err-bg); }
.db-tag.tc-sens-public{ color:var(--ok-fg); border-color:var(--ok-bd); }

/* ── Memory Hub board: 8 types × 3 tiers ── */
.tc-board{ display:grid; grid-template-columns:minmax(200px,1.6fr) repeat(4,minmax(80px,1fr)); gap:6px; overflow-x:auto; }
.tc-bh{ font-size:11.5px; font-weight:700; color:var(--mut); letter-spacing:.04em; text-transform:uppercase; padding:4px 6px; display:flex; flex-direction:column; gap:4px; align-items:flex-start; }
.tc-bh small{ text-transform:none; letter-spacing:0; font-weight:500; }
.tc-bt{ display:flex; flex-direction:column; gap:4px; padding:8px 6px; align-items:flex-start; border-top:1px solid var(--bd-soft); }
.tc-bt small{ color:var(--mut); font-size:11.5px; line-height:1.4; }
.tc-bc{ border:1px solid var(--bd); border-radius:10px; background:var(--surface-2); color:var(--mut); font-size:18px; font-weight:700; font-variant-numeric:tabular-nums;
  display:flex; align-items:center; justify-content:center; min-height:52px; cursor:pointer; font-family:inherit; }
.tc-bc.has{ background:var(--acc-soft); color:var(--acc-fg); border-color:var(--acc-ring); }
.tc-bc:hover{ border-color:var(--acc); }
.tc-bc.tot{ background:var(--surface); color:var(--fg); }
.tc-bc.na{ cursor:default; border-style:dashed; font-size:13px; }
.tc-bc.na:hover{ border-color:var(--bd); }

/* ── episodic timeline ── */
.tc-timeline{ list-style:none; margin:0; padding:0 0 0 18px; border-left:2px solid var(--bd-strong); display:flex; flex-direction:column; gap:8px; }
.tc-tl-day{ position:relative; margin:10px 0 2px; font-size:12px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; color:var(--fg-2); }
.tc-tl-day::before{ content:""; position:absolute; left:-25px; top:3px; width:10px; height:10px; border-radius:99px; background:var(--acc); box-shadow:0 0 0 3px var(--acc-soft); }
.tc-tl-card{ width:100%; text-align:left; background:var(--surface-2); border:1px solid var(--bd); border-radius:10px; padding:10px 12px; cursor:pointer; font:inherit; color:var(--fg); }
.tc-tl-card:hover{ border-color:var(--acc); }
.tc-tl-meta{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-bottom:5px; }
.tc-tl-time{ font-size:12px; font-weight:700; color:var(--fg-2); font-variant-numeric:tabular-nums; }
.tc-tl-text{ font-size:13px; line-height:1.5; overflow-wrap:anywhere; white-space:pre-wrap; }

/* ── knowledge graph host ── */
.tc-kg .kgw{ --kgw-height:min(70vh,700px); }
.tc-kgd .tc-acts{ margin-top:14px; }
.tc-kgd .tc-acts button{ height:30px; padding:0 10px; font-size:12px; }
.tc-prov{ margin-top:12px; font-size:12px; color:var(--mut); }

/* ── drawer + modal + toast ── */
.tc-drawer-ov{ position:fixed; inset:0; z-index:120; background:rgba(10,14,24,.42); display:flex; justify-content:flex-end; }
.tc-drawer{ width:min(560px,100vw); height:100%; background:var(--surface); border-left:1px solid var(--bd); box-shadow:var(--shadow-md); display:flex; flex-direction:column; }
.tc-drawer-h{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; padding:16px 18px; border-bottom:1px solid var(--bd); }
.tc-drawer-h h2{ margin:0; font-size:16px; color:var(--fg); }
.tc-drawer-h .db-sub{ font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:11.5px; }
html.tuhi button.tc-x{ padding:6px; line-height:0; }
.tc-drawer-body{ padding:16px 18px 28px; overflow-y:auto; flex:1 1 auto; display:flex; flex-direction:column; gap:10px; }
.tc-memtext{ white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; line-height:1.6; color:var(--fg); background:var(--inset); border:1px solid var(--bd); border-radius:10px; padding:12px 14px; }
.tc-share{ border-top:1px solid var(--bd); margin-top:10px; }
.tc-share-out{ margin-top:8px; display:flex; flex-direction:column; gap:8px; }
.tc-doc-title{ margin:0; font-size:16px; color:var(--fg); overflow-wrap:anywhere; }
.tc-chunk{ border:1px solid var(--bd); border-radius:10px; background:var(--surface-2); }
.tc-chunk-h{ font-size:11px; font-weight:700; color:var(--mut); padding:6px 10px; border-bottom:1px solid var(--bd-soft); }
.tc-chunk-t{ margin:0; padding:10px; white-space:pre-wrap; overflow-wrap:anywhere; font:inherit; font-size:12.5px; line-height:1.55; color:var(--fg-2); max-height:300px; overflow:auto; }
.tc-modal-ov{ position:fixed; inset:0; z-index:130; background:rgba(10,14,24,.5); display:flex; align-items:center; justify-content:center; padding:16px; }
.tc-modal{ width:min(440px,100%); background:var(--surface); border:1px solid var(--bd); border-radius:14px; box-shadow:var(--shadow-md); padding:20px; }
.tc-modal h3{ margin:0 0 8px; font-size:16px; color:var(--fg); }
.tc-modal p{ margin:0 0 16px; color:var(--fg-2); font-size:13px; line-height:1.55; }
.tc-modal-acts{ display:flex; justify-content:flex-end; gap:8px; }
.tc-modal-acts button{ height:34px; padding:0 14px; border-radius:8px; }
.tc-toast{ position:fixed; right:18px; bottom:18px; z-index:140; max-width:min(440px,calc(100vw - 36px)); padding:11px 14px; border-radius:10px; font-size:13px; font-weight:600;
  box-shadow:var(--shadow-md); line-height:1.45; overflow-wrap:anywhere; }
.tc-toast.t-ok{ background:var(--ok-bg); color:var(--ok-fg); border:1px solid var(--ok-bd); }
.tc-toast.t-err{ background:var(--err-bg); color:var(--err-fg); border:1px solid var(--err-bd); }
html.tuhi.light .tc-toast.t-ok, html.tuhi.light .tc-toast.t-err{ background:var(--surface); }
@media (max-width:767px){ .tc-board{ grid-template-columns:minmax(150px,1.4fr) repeat(4,minmax(56px,1fr)); } .tc-bc{ font-size:15px; min-height:44px; } .tc-text{ min-width:160px; } }

img.tc-mark{ background:none; object-fit:cover; display:inline-block; }
.tc-signin-logo{ display:block; margin:0 auto 14px; width:180px; height:auto; border-radius:16px; }
