:root {
  color-scheme: dark;
  --ink-950: #071015;
  --ink-900: #0b171d;
  --ink-850: #102128;
  --ink-800: #142b32;
  --line: rgba(173, 220, 205, .16);
  --line-strong: rgba(173, 220, 205, .28);
  --text: #e7f1ed;
  --muted: #91aaa4;
  --faint: #5e7774;
  --mint: #9ce0c6;
  --mint-bright: #c9f3de;
  --amber: #f6bd72;
  --red: #f58b83;
  --blue: #99c7e5;
  --shadow: 0 24px 80px rgba(0, 0, 0, .28);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--ink-950); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(80, 147, 130, .14), transparent 32rem),
    radial-gradient(circle at 95% 15%, rgba(246, 189, 114, .08), transparent 28rem),
    var(--ink-950);
  letter-spacing: .01em;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.ambient { position: fixed; pointer-events: none; z-index: 0; width: 22rem; height: 22rem; border: 1px solid rgba(156, 224, 198, .05); border-radius: 50%; }
.ambient::after { content: ""; position: absolute; inset: 2rem; border: 1px solid rgba(156, 224, 198, .04); border-radius: 50%; }
.ambient-left { top: 16rem; left: -12rem; }
.ambient-right { right: -13rem; bottom: 2rem; }

.app-shell { position: relative; z-index: 1; width: min(1440px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 92px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 13px; color: var(--text); text-decoration: none; }
.brand-mark { display: flex; align-items: end; gap: 3px; width: 28px; height: 28px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(156, 224, 198, .06); }
.brand-mark span { display: block; width: 4px; border-radius: 3px 3px 1px 1px; background: var(--mint); }
.brand-mark span:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark span:nth-child(2) { height: 16px; opacity: .8; }
.brand-mark span:nth-child(3) { height: 21px; background: var(--amber); }
.brand-name { display: block; font-family: Georgia, serif; font-size: 1.06rem; font-weight: 500; letter-spacing: -.02em; }
.eyebrow { margin: 0 0 7px; color: var(--faint); font-family: "Bahnschrift", sans-serif; font-size: .66rem; font-weight: 700; letter-spacing: .16em; line-height: 1; text-transform: uppercase; }
.connection-cluster { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .78rem; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgba(94, 119, 116, .12); }
.connection-dot.is-online { background: var(--mint); box-shadow: 0 0 0 4px rgba(156, 224, 198, .1), 0 0 18px rgba(156, 224, 198, .7); }
.connection-dot.is-warning { background: var(--amber); box-shadow: 0 0 0 4px rgba(246, 189, 114, .1); }
.connection-dot.is-offline { background: var(--red); box-shadow: 0 0 0 4px rgba(245, 139, 131, .08); }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; margin-left: 9px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-size: 1.18rem; transition: border-color .2s, color .2s, transform .2s; }
.icon-button:hover { border-color: var(--mint); color: var(--mint-bright); transform: rotate(30deg); }
.global-search { display: flex; align-items: center; gap: 7px; margin-left: 16px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--faint); background: rgba(7, 16, 21, .42); }
.global-search input { width: 150px; padding: 8px 0; border: 0; outline: 0; background: transparent; font-size: .74rem; }
.global-search-submit { border: 0; padding: 0; color: var(--mint); background: transparent; font-size: .78rem; }
.global-search-submit:hover { color: var(--mint-bright); }

.main-content { padding: 70px 0 55px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(145deg, rgba(20, 43, 50, .84), rgba(11, 23, 29, .88)); box-shadow: var(--shadow); }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; letter-spacing: -.045em; }
input { border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); background: rgba(7, 16, 21, .66); }
input::placeholder { color: var(--faint); }
.dashboard-error { color: var(--red); }

.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.hero-row h1 { margin-bottom: 9px; font-size: clamp(2.5rem, 5vw, 4.6rem); line-height: .95; }
.muted { color: var(--muted); font-size: .82rem; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.metric { min-height: 122px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(20, 43, 50, .57); }
.metric-label { color: var(--faint); font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.metric-value { display: block; margin: 15px 0 6px; color: var(--mint-bright); font-family: Georgia, serif; font-size: 2.15rem; line-height: 1; }
.metric-caption { color: var(--muted); font-size: .76rem; }
.dashboard-error { margin-bottom: 14px; padding: 14px 17px; border: 1px solid rgba(245, 139, 131, .28); border-radius: var(--radius-sm); background: rgba(245, 139, 131, .08); font-size: .82rem; }
.workspace-grid { display: grid; grid-template-columns: minmax(270px, .84fr) minmax(0, 1.6fr); gap: 14px; }
.project-panel, .detail-panel { min-height: 520px; padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 14px; padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1.8rem; }
.search-field { display: flex; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--faint); }
.search-field input { width: 84px; padding: 7px 0; border: 0; background: transparent; outline: 0; font-size: .74rem; }
.project-list { display: grid; gap: 8px; padding-top: 14px; }
.project-item { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 12px; align-items: start; width: 100%; padding: 14px 12px; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text); background: transparent; text-align: left; transition: background .2s, border-color .2s; }
.project-item:hover, .project-item.is-selected { border-color: var(--line); background: rgba(156, 224, 198, .07); }
.project-item.is-selected { border-left-color: var(--mint); }
.project-status { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--faint); }
.project-status.is-healthy { background: var(--mint); box-shadow: 0 0 12px rgba(156, 224, 198, .65); }
.project-status.is-warning { background: var(--amber); }
.project-status.is-danger { background: var(--red); }
.project-title { display: block; overflow: hidden; font-size: .88rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.project-meta { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.project-count { color: var(--faint); font-size: .7rem; }
.empty-state, .detail-placeholder { display: grid; place-items: center; align-content: center; min-height: 360px; color: var(--muted); text-align: center; }
.empty-state { gap: 9px; padding: 20px; font-size: .78rem; }
.empty-state strong { color: var(--text); }
.empty-orbit, .detail-glyph { color: var(--amber); font-size: 2rem; }
.detail-placeholder { max-width: 350px; margin: auto; }
.detail-placeholder h2 { margin-bottom: 11px; font-size: 2.3rem; }
.detail-placeholder p:last-child { color: var(--muted); font-size: .84rem; line-height: 1.55; }
.detail-header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); line-height: .95; }
.detail-header .eyebrow { margin-bottom: 9px; }
.health-badge { align-self: start; border: 1px solid rgba(156, 224, 198, .26); border-radius: 999px; padding: 7px 10px; color: var(--mint); background: rgba(156, 224, 198, .06); font-size: .67rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.health-badge.is-warning { border-color: rgba(246, 189, 114, .3); color: var(--amber); background: rgba(246, 189, 114, .06); }
.health-badge.is-danger { border-color: rgba(245, 139, 131, .3); color: var(--red); background: rgba(245, 139, 131, .06); }
.detail-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 27px; }
.fact { padding: 13px; border-radius: var(--radius-sm); background: rgba(7, 16, 21, .36); }
.fact-label { display: block; margin-bottom: 7px; color: var(--faint); font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.fact-value { display: block; overflow: hidden; color: var(--text); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.change-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.change-heading h3 { margin: 0; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }
.change-heading span { color: var(--faint); font-size: .72rem; }
.change-list { display: grid; gap: 8px; }
.change-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(7, 16, 21, .24); }
.change-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.change-indicator.is-current { background: var(--amber); box-shadow: 0 0 11px rgba(246, 189, 114, .6); }
.change-name { overflow: hidden; font-size: .79rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.change-warning { display: block; margin-top: 4px; color: var(--amber); font-size: .68rem; }
.change-tasks { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.stale-note { margin-top: 16px; color: var(--amber); font-size: .73rem; }
.workspace-header { display: grid; grid-template-columns: minmax(130px, .45fr) minmax(0, 1.5fr) auto; align-items: end; gap: 24px; margin-bottom: 24px; }
.workspace-header h1 { margin: 0 0 8px; font-size: clamp(2.4rem, 5vw, 4.7rem); line-height: .9; }
.back-link { align-self: start; color: var(--muted); font-size: .76rem; text-decoration: none; }
.back-link:hover { color: var(--mint-bright); }
.sync-badge { align-self: start; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sync-badge.is-online { border-color: rgba(156, 224, 198, .3); color: var(--mint); background: rgba(156, 224, 198, .06); }
.sync-badge.is-warning { border-color: rgba(246, 189, 114, .3); color: var(--amber); background: rgba(246, 189, 114, .06); }
.workspace-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; }
.workspace-rail { align-self: start; padding: 15px; }
.workspace-nav { display: grid; gap: 4px; }
.workspace-nav a { padding: 11px 12px; border-left: 2px solid transparent; border-radius: 6px; color: var(--muted); font-size: .78rem; text-decoration: none; transition: background .2s, color .2s, border-color .2s; }
.workspace-nav a:hover, .workspace-nav a.is-active { border-left-color: var(--amber); color: var(--text); background: rgba(246, 189, 114, .08); }
.workspace-meta { display: grid; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.workspace-meta .fact { padding: 10px; }
.workspace-content { min-height: 560px; padding: 28px; }
.workspace-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.workspace-section-heading h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); line-height: .9; }
.workspace-intro { max-width: 650px; margin-top: 26px; color: var(--text); font-size: 1.1rem; line-height: 1.6; }
.workspace-intro .muted { margin-top: 22px; font-size: .76rem; }
.workspace-open { display: inline-flex; margin: 18px 0 24px; color: var(--mint); font-size: .76rem; text-decoration: none; }
.workspace-open:hover { color: var(--mint-bright); }
.memory-filter-strip, .category-strip { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.filter-chip, .category-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .65rem; }
.filter-chip.is-active, .category-chip { border-color: rgba(156, 224, 198, .24); color: var(--mint); background: rgba(156, 224, 198, .05); }
.memory-inline-search { display: block; margin: 18px 0; }
.memory-inline-search input { width: 100%; padding: 11px 13px; outline: 0; }
.memory-document-list { display: grid; gap: 8px; }
.memory-document-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); background: rgba(7, 16, 21, .28); text-decoration: none; transition: border-color .2s, background .2s, transform .2s; }
.memory-document-row:hover { border-color: var(--line-strong); background: rgba(156, 224, 198, .07); transform: translateX(2px); }
.memory-document-glyph { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(246, 189, 114, .26); border-radius: 7px; color: var(--amber); background: rgba(246, 189, 114, .07); font-size: .72rem; font-weight: 700; }
.memory-document-copy { min-width: 0; }
.memory-document-copy strong, .memory-document-meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-document-copy strong { font-size: .8rem; }
.memory-document-meta { margin-top: 4px; color: var(--muted); font-size: .67rem; }
.memory-document-size { color: var(--faint); font-size: .66rem; white-space: nowrap; }
.reader-heading { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.reader-heading h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); line-height: .92; }
.reader-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 15px 0; color: var(--muted); font-size: .68rem; }
.reader-meta span { padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; }
.reader-actions { display: flex; gap: 8px; margin-bottom: 19px; }
.reader-toggle, .reader-copy { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--muted); background: transparent; font-size: .7rem; }
.reader-toggle:hover, .reader-copy:hover { border-color: var(--mint); color: var(--mint-bright); }
.markdown-reader { max-width: 850px; color: #d6e4de; font-family: "Cascadia Code", "Consolas", monospace; font-size: .82rem; line-height: 1.7; }
.markdown-reader h2, .markdown-reader h3, .markdown-reader h4 { margin: 1.5em 0 .55em; color: var(--mint-bright); font-family: Georgia, serif; letter-spacing: -.03em; }
.markdown-reader h2 { font-size: 1.8rem; }
.markdown-reader h3 { font-size: 1.35rem; }
.markdown-reader h4 { font-size: 1.1rem; }
.markdown-reader p { margin: 0 0 .7em; white-space: pre-wrap; }
.markdown-reader li { margin-left: 1.2em; color: var(--mint); }
.markdown-reader pre { overflow: auto; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--mint-bright); background: rgba(7, 16, 21, .5); white-space: pre-wrap; }
.markdown-gap { height: .35em; }
.sync-callout, .workspace-error { margin-top: 24px; padding: 17px; border: 1px solid rgba(156, 224, 198, .2); border-radius: var(--radius-sm); color: var(--muted); background: rgba(156, 224, 198, .05); font-size: .8rem; line-height: 1.5; }
.workspace-error { border-color: rgba(245, 139, 131, .28); color: var(--red); background: rgba(245, 139, 131, .07); }
.usage-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; margin: 20px 0; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: rgba(7, 16, 21, .28); }
.usage-filter { display: grid; gap: 5px; min-width: 112px; color: var(--faint); font-size: .61rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.usage-filter input, .usage-filter select { min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: rgba(7, 16, 21, .65); font-size: .73rem; text-transform: none; }
.button-primary { padding: 9px 12px; border: 1px solid rgba(156, 224, 198, .3); border-radius: 7px; color: var(--ink-950); background: var(--mint); font-size: .7rem; font-weight: 700; }
.button-primary:hover { background: var(--mint-bright); }
.usage-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 14px; }
.usage-summary-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(20, 43, 50, .45); }
.usage-summary-value { display: block; overflow: hidden; margin: 10px 0 5px; color: var(--mint-bright); font-family: Georgia, serif; font-size: clamp(1.15rem, 2vw, 1.75rem); font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.usage-warning { margin-bottom: 12px; padding: 13px 15px; border: 1px solid rgba(246, 189, 114, .3); border-radius: var(--radius-sm); color: var(--amber); background: rgba(246, 189, 114, .07); font-size: .76rem; line-height: 1.45; }
.usage-panel { margin-top: 14px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(7, 16, 21, .25); }
.usage-panel h3 { margin: 0 0 13px; color: var(--mint-bright); font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; }
.usage-token-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.usage-token-grid .fact { min-width: 0; padding: 10px; }
.usage-trend { display: grid; gap: 6px; }
.usage-trend-row, .usage-model-row { display: grid; grid-template-columns: minmax(100px, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 11px; border-radius: 7px; color: var(--muted); background: rgba(20, 43, 50, .38); font-size: .72rem; }
.usage-trend-row strong, .usage-model-row strong { color: var(--mint); font-weight: 600; }
.usage-agent { border-top: 1px solid var(--line); }
.usage-agent:first-of-type { border-top: 0; }
.usage-agent summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 2px; cursor: pointer; color: var(--text); font-size: .78rem; }
.usage-agent-meta { color: var(--muted); font-size: .68rem; font-weight: 400; }
.usage-model-list { display: grid; gap: 6px; padding: 0 0 12px 17px; }
.usage-call { border-top: 1px solid var(--line); }
.usage-call:first-of-type { border-top: 0; }
.usage-call summary { display: flex; justify-content: space-between; gap: 12px; padding: 11px 2px; cursor: pointer; font-size: .76rem; }
.usage-call-copy { padding: 0 0 15px 17px; color: var(--muted); font-size: .72rem; }
.usage-call-copy h4 { margin: 13px 0 6px; color: var(--faint); font-size: .63rem; letter-spacing: .1em; text-transform: uppercase; }
.usage-call-copy pre, .usage-transcript { max-height: 260px; overflow: auto; margin: 6px 0; padding: 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--mint-bright); background: rgba(7, 16, 21, .62); font-family: "Cascadia Code", "Consolas", monospace; font-size: .7rem; line-height: 1.5; white-space: pre-wrap; }
.footer-note { display: flex; justify-content: center; gap: 8px; padding: 18px 0 28px; color: var(--faint); font-size: .7rem; }
.footer-separator { color: var(--line-strong); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 820px) {
  .app-shell { padding: 0 18px; }
  .main-content { padding-top: 45px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .project-panel, .detail-panel { min-height: auto; }
  .detail-panel { min-height: 420px; }
  .workspace-layout { grid-template-columns: 1fr; }
  .workspace-rail { order: 0; }
  .workspace-nav { grid-template-columns: repeat(6, 1fr); }
  .workspace-nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 9px 6px; text-align: center; }
  .workspace-nav a:hover, .workspace-nav a.is-active { border-bottom-color: var(--amber); border-left-color: transparent; }
  .workspace-meta { display: none; }
}

@media (max-width: 560px) {
  .topbar { min-height: 76px; }
  .connection-cluster > #connection-label { display: none; }
  .global-search { margin-left: 5px; }
  .global-search input { width: 92px; }
  .hero-row { align-items: start; flex-direction: column; }
  .hero-row h1 { font-size: 2.8rem; }
  .panel-heading { flex-direction: column; }
  .search-field, .search-field input { width: 100%; }
  .detail-facts { grid-template-columns: 1fr; }
  .usage-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .usage-token-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-header { flex-direction: column; }
  .workspace-header { grid-template-columns: 1fr auto; align-items: start; gap: 13px; }
  .workspace-header .back-link { grid-column: 1 / -1; }
  .workspace-header h1 { font-size: 2.8rem; }
  .workspace-content { padding: 20px 15px; }
  .workspace-nav { grid-template-columns: repeat(3, 1fr); }
  .usage-filters { align-items: stretch; flex-direction: column; }
  .usage-filter, .usage-filter input, .usage-filter select, .button-primary { width: 100%; }
  .usage-summary-grid { grid-template-columns: 1fr; }
  .usage-token-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-document-row { grid-template-columns: 28px minmax(0, 1fr); }
  .memory-document-size { display: none; }
  .footer-note { flex-direction: column; align-items: center; gap: 4px; }
  .footer-separator { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
