:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #17202b;
  --muted: #647181;
  --line: #d4dbe4;
  --green: #23845d;
  --teal: #087b83;
  --amber: #9f6400;
  --blue: #2c64c7;
  --shadow: 0 8px 22px rgba(23, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Arial Nova", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #aeb8c5;
}

.primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
  font-weight: 700;
}

.app {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
}

.rail {
  background: #121923;
  color: white;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.24));
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.status-stack small {
  color: #aeb8c5;
  font-size: 0.82rem;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  width: 100%;
  background: transparent;
  color: #dbe2eb;
  border-color: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.24);
}

.status-stack {
  margin-top: auto;
  display: grid;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  margin-right: 8px;
}

.dot.ready {
  background: var(--green);
}

main {
  padding: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.topbar h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.42rem;
  line-height: 1.05;
  max-width: 520px;
}

.subhead {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 1.1rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metric {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric strong {
  color: var(--ink);
}

.has-tip {
  position: relative;
}

.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: 240px;
  transform: translateX(-50%) translateY(4px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: #0f1720;
  color: #f4f8fb;
  padding: 7px 9px;
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  box-shadow: 0 10px 24px rgba(15, 23, 32, 0.22);
}

.has-tip::before {
  content: "";
  position: absolute;
  z-index: 31;
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #0f1720;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.has-tip:hover::after,
.has-tip:focus-visible::after,
.has-tip:hover::before,
.has-tip:focus-visible::before {
  opacity: 1;
}

.has-tip:hover::after,
.has-tip:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.landing {
  min-height: 440px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.85fr);
  gap: 12px;
}

.landing-copy,
.audience-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.landing-copy {
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.landing-logo {
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  filter: drop-shadow(0 14px 22px rgba(23, 32, 43, 0.18));
}

.landing-copy h2 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(1.9rem, 3.2vw, 3.1rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.landing-copy p:not(.eyebrow) {
  max-width: 610px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.landing-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.audience-grid {
  padding: 14px;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.audience-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  background: #fbfcfe;
  display: grid;
  align-content: center;
  gap: 6px;
}

.audience-grid strong,
.audience-grid span {
  display: block;
}

.audience-grid span {
  color: var(--muted);
  line-height: 1.35;
}

.agent-grid,
.memory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.75fr);
  gap: 12px;
}

.workspace,
.signals,
.memory-form,
.ledger {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  color: var(--ink);
  padding: 9px 10px;
}

.query-grid,
.memory-form label {
  display: grid;
  gap: 6px;
}

.query-grid {
  gap: 10px;
}

.query-grid label,
.memory-form label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

#questionInput {
  min-height: 112px;
}

.actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.response-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.response-head small {
  color: var(--teal);
  font-size: 0.76rem;
}

.answer {
  margin: 0;
  min-height: 180px;
  white-space: pre-wrap;
  overflow: auto;
  background: #0f1720;
  color: #e8eef6;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.42;
  font-size: 0.9rem;
}

.retrieved,
.memory-list,
.action-list,
.lock-list,
.proof-list,
.timeline-list {
  display: grid;
  gap: 8px;
}

.memory-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfe;
}

.action-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 11px;
  background: #fbfcfe;
}

.action-card.status-approved {
  border-left-color: var(--green);
  background: #f4fbf7;
}

.action-card h3 {
  margin: 0 0 6px;
  font-size: 0.94rem;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.36;
  font-size: 0.9rem;
}

.action-card button {
  min-height: 32px;
  white-space: nowrap;
}

.action-card button:disabled {
  color: var(--green);
  background: #e7f5ed;
  border-color: #bde3ce;
  cursor: default;
}

.lock-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  padding: 11px;
  background: #fff9ed;
}

.lock-card.lock-winner {
  border-left-color: var(--green);
  background: #f4fbf7;
}

.lock-card h3 {
  margin: 0 0 5px;
  font-size: 0.94rem;
}

.lock-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.36;
  font-size: 0.9rem;
}

.lock-card code {
  background: #eef2f5;
  border-radius: 4px;
  padding: 1px 4px;
  color: var(--ink);
  font-size: 0.82rem;
}

.proof-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 11px;
  background: #f3fbfa;
}

.proof-card p {
  margin: 9px 0;
  color: var(--muted);
  line-height: 1.36;
  font-size: 0.9rem;
}

.proof-card strong {
  color: var(--ink);
}

.proof-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.proof-card small {
  color: var(--teal);
  font-weight: 700;
}

.proof-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-ok {
  background: #e7f5ed;
  color: #176c43;
}

.pill-warn {
  background: #fff3d6;
  color: #8a5a00;
}

.type-incident {
  border-left-color: var(--amber);
}

.type-runbook {
  border-left-color: var(--blue);
}

.type-decision {
  border-left-color: var(--green);
}

.type-postmortem {
  border-left-color: var(--teal);
}

.type-agent_event {
  border-left-color: #818b99;
}

.type-external {
  border-left-color: #8b5cf6;
}

.memory-card h3 {
  margin: 0 0 6px;
  font-size: 0.94rem;
}

.memory-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.36;
  font-size: 0.9rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: #edf2f7;
  color: #344257;
  font-size: 0.72rem;
  font-weight: 700;
}

.source-link {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  background: #efeafe;
  color: #53389e;
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #fbfcfe;
}

.timeline-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.timeline-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf2f7;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.timeline-item strong {
  display: block;
  font-size: 0.88rem;
}

.timeline-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.32;
}

.memory-form {
  display: grid;
  gap: 10px;
  align-content: start;
}


.app-footer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

@media (max-width: 920px) {
  .app,
  .landing,
  .agent-grid,
  .memory-layout {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    padding: 16px;
    gap: 16px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  main {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 1.45rem;
  }

  .section-head,
  .actions {
    flex-direction: column;
  }

  .actions button,
  .landing-actions,
  .landing-actions button,
  .top-actions,
  .metric {
    width: 100%;
  }

  .landing {
    min-height: auto;
  }

  .landing-copy {
    padding: 18px;
  }

  .landing-copy h2 {
    font-size: 1.75rem;
  }

  .landing-copy p:not(.eyebrow) {
    font-size: 0.98rem;
  }

  .landing-actions {
    flex-direction: column;
  }

  .audience-grid {
    grid-template-rows: none;
  }

  .metric {
    justify-content: space-between;
  }

  .nav-item {
    gap: 6px;
    padding: 0 8px;
    font-size: 0.92rem;
  }

  main {
    padding: 12px;
  }

  .rail {
    padding: 14px 12px;
  }

  .workspace,
  .signals,
  .memory-form,
  .ledger,
  .topbar {
    padding: 12px;
  }

  .answer {
    min-height: 180px;
  }

  .action-card {
    grid-template-columns: 1fr;
  }

  .action-card button {
    width: 100%;
  }

  .app-footer {
    text-align: left;
    line-height: 1.35;
  }
}

@media (hover: none) {
  .has-tip::before,
  .has-tip::after {
    display: none;
  }
}
