:root {
  color-scheme: dark;
  --ink: #ede9df;
  --muted: #938f87;
  --ground: #10110f;
  --surface: #171814;
  --line: #35372f;
  --acid: #d4ff55;
  --ember: #ff7455;
  --blue: #89b4ff;
  font-family: "DejaVu Sans Mono", "Liberation Mono", monospace;
  background: var(--ground);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 72% 8%, #29301c 0, transparent 28rem),
    linear-gradient(135deg, #10110f 0%, #141510 48%, #0c0d0c 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .45; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image:
    repeating-linear-gradient(17deg, transparent 0 3px, #ffffff08 3px 4px),
    repeating-linear-gradient(103deg, transparent 0 7px, #00000020 7px 8px);
}

.masthead, footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem clamp(1.25rem, 4vw, 4rem);
  border-bottom: 1px solid var(--line);
  font-size: .72rem;
  letter-spacing: .12em;
}

.wordmark { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .75rem; }
.mark { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--ground); background: var(--acid); font-weight: 900; font-size: 1.15rem; }
.session-bar { display: flex; align-items: center; gap: .8rem; }
.signal { width: .55rem; height: .55rem; border-radius: 50%; background: var(--acid); box-shadow: 0 0 1rem var(--acid); }

main { position: relative; z-index: 1; width: min(1440px, 100%); margin: 0 auto; padding: clamp(2rem, 5vw, 5rem) clamp(1.25rem, 4vw, 4rem); }
.entry { max-width: 950px; padding: 7vh 0 12vh; }
.eyebrow, .index { color: var(--acid); text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; }
h1 { margin: .5rem 0 1.75rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.2rem, 9vw, 8rem); font-weight: 400; line-height: .87; letter-spacing: -.055em; }
h1 em { color: var(--acid); font-weight: 400; }
.lede { max-width: 660px; color: #b8b4aa; font-family: system-ui, sans-serif; font-size: clamp(1rem, 2vw, 1.3rem); line-height: 1.7; }
.entry .primary-button { margin-top: 2rem; }
.entry-note, .panel-note { color: var(--muted); font-size: .72rem; line-height: 1.5; }
.entry-note { margin-top: 1rem; text-transform: uppercase; letter-spacing: .08em; }

.primary-button, .secondary-button {
  border: 1px solid var(--acid);
  padding: .95rem 1.2rem;
  background: var(--acid);
  color: var(--ground);
  font-weight: 800;
}
.primary-button:hover { background: transparent; color: var(--acid); }
.secondary-button { background: transparent; color: var(--acid); }
.secondary-button:hover { background: var(--acid); color: var(--ground); }
.compact { padding: .65rem .85rem; font-size: .78rem; }
.text-button { border: 0; padding: .35rem; background: transparent; color: var(--blue); text-decoration: underline; text-underline-offset: .25rem; }
.text-button.danger { color: var(--ember); }

.callback { min-height: 60vh; display: grid; place-items: center; align-content: center; gap: 1.5rem; color: var(--muted); }
.loader { width: 3rem; height: 3rem; border: 2px solid var(--line); border-top-color: var(--acid); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.workspace-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 3rem; }
.workspace-heading h1 { font-size: clamp(3rem, 7vw, 6.5rem); margin-bottom: 0; }
.notice { padding: 1rem; margin-bottom: 1.25rem; border: 1px solid var(--line); background: #1c2017; }
.notice[data-tone="error"] { border-color: var(--ember); color: #ffb09d; }
.notice[data-tone="success"] { border-color: var(--acid); }

.panel { border-top: 1px solid var(--line); padding: 1.5rem 0 3.5rem; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.panel h2 { margin: .1rem 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.7rem, 3vw, 2.5rem); font-weight: 400; }
.index { margin: 0; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: end; }
input { min-width: min(22rem, 70vw); border: 1px solid var(--line); border-radius: 0; padding: .65rem .8rem; background: #0c0d0b; color: var(--ink); }
input:focus { outline: 2px solid var(--acid); outline-offset: 1px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.agent-card { min-height: 15rem; padding: 1.25rem; background: var(--surface); }
.agent-card.archived { opacity: .62; }
.agent-top, .card-actions, .event-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.agent-card h3 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 1rem; }
.badge { display: inline-block; border: 1px solid var(--line); padding: .25rem .45rem; color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .07em; }
.badge[data-configured="true"], .decision-approved { border-color: var(--acid); color: var(--acid); }
.decision-rejected { border-color: var(--ember); color: var(--ember); }
.mono { color: var(--muted); font-size: .74rem; }
.policy { margin: 1.5rem 0; font-size: .75rem; }
.policy summary { color: var(--blue); cursor: pointer; }
.policy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem 1rem; margin-top: 1rem; }
.policy-grid dt { color: var(--muted); }
.policy-grid dd { margin: 0; text-align: right; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { color: var(--muted); font-weight: 400; text-align: left; }
th, td { padding: .85rem .65rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.state { color: var(--blue); }
.state-finished { color: var(--muted); }
.state-running { color: var(--acid); }

.split-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; }
.event-list { list-style: none; padding: 0; margin: 0; }
.event { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); font-size: .75rem; }
.event-heading { grid-column: 1 / -1; }
.event p, .event time { margin: 0; color: var(--muted); }
.empty { color: var(--muted); font-style: italic; }
.credential-panel { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.credential-actions { display: flex; align-items: center; justify-content: end; gap: .7rem; flex-wrap: wrap; }

footer { border-top: 1px solid var(--line); border-bottom: 0; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .masthead { align-items: flex-start; }
  .wordmark span:last-child { display: none; }
  .workspace-heading, .panel-heading, .credential-panel { align-items: stretch; flex-direction: column; }
  .inline-form, .credential-actions { justify-content: stretch; }
  input { min-width: 0; width: 100%; }
  .inline-form .primary-button { flex: 1; }
  .split-panels { grid-template-columns: 1fr; gap: 0; }
  footer { align-items: flex-start; gap: 1rem; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .loader { animation: none; }
}
