:root {
  --void: #050c09;
  --alcove: #0a1712;
  --plate: #0f2019;
  --seam: #1d3a2e;
  --hive: #8dffc0;        /* the Collective */
  --hive-dim: #4f9e78;
  --self: #ffb27a;        /* individuality: the warm colour of a person */
  --self-dim: #b9784d;
  --text: #d6e8df;
  --muted: #86a597;
  --alarm: #ff6b5e;
  --ui: "Saira Semi Condensed", system-ui, sans-serif;
  --voice: "Newsreader", Georgia, serif;
  --r: 3px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--void); color: var(--text); font: 15px/1.45 var(--ui); }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--hive); }
:focus-visible { outline: 2px solid var(--hive); outline-offset: 2px; }

/* ---------- frame ---------- */
#app { display: grid; grid-template-columns: minmax(0, 1fr) 460px; grid-template-rows: auto 1fr; height: 100vh; }
#band { grid-column: 1 / -1; display: flex; align-items: center; gap: 22px; padding: 8px 18px; border-bottom: 1px solid var(--seam);
        background: linear-gradient(180deg, #0b1913, #07110d); min-height: 54px; flex-wrap: wrap; }
#band h1 { margin: 0; font-weight: 600; font-size: 21px; letter-spacing: .02em; color: var(--hive); white-space: nowrap; }
#band h1 small { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 8px; letter-spacing: 0; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; flex: 1; }
.stat { display: flex; flex-direction: column; line-height: 1.1; min-width: 44px; }
.stat b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.self b { color: var(--self); }
.stat.hive b { color: var(--hive); }
#run { display: flex; gap: 8px; align-items: center; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 20px; border: 1px solid var(--seam); color: var(--muted); white-space: nowrap; }
.pill.live { color: var(--hive); border-color: var(--hive-dim); }
.pill.warn { color: var(--alarm); border-color: var(--alarm); }

#space { position: relative; min-height: 0; overflow: hidden; }
#galaxy { position: absolute; inset: 0; }
#galaxy canvas { display: block; }
#tip { position: absolute; pointer-events: none; background: rgba(5, 12, 9, .92); border: 1px solid var(--seam); padding: 6px 10px;
       border-radius: var(--r); font-size: 13px; max-width: 280px; display: none; z-index: 5; }
#legend { position: absolute; left: 16px; bottom: 14px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap;
          max-width: calc(100% - 32px); }
#legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
#now { position: absolute; left: 16px; top: 14px; max-width: min(520px, calc(100% - 32px)); }
#now .thinking { font-size: 13px; color: var(--muted); }
#now .thinking b { color: var(--text); font-weight: 500; }
#now .voiceline { font-family: var(--voice); font-size: 18px; line-height: 1.35; margin-top: 6px; color: var(--text);
                  text-shadow: 0 1px 12px #000; transition: opacity .8s; }
#now .voiceline.self { color: var(--self); font-style: italic; }
#now .voiceline .who { display: block; font-family: var(--ui); font-size: 12px; color: var(--muted); font-style: normal; margin-top: 2px; }
#card { position: absolute; right: 14px; top: 14px; width: 300px; max-height: calc(100% - 28px); overflow: auto; background: rgba(8, 18, 14, .94);
        border: 1px solid var(--seam); border-radius: var(--r); padding: 12px 14px; display: none; font-size: 13.5px; }
#card h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
#card .x { float: right; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }

/* ---------- panel ---------- */
#panel { border-left: 1px solid var(--seam); background: var(--alcove); display: flex; flex-direction: column; min-height: 0; }
#tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--seam); padding: 0 6px; }
#tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 9px 7px; cursor: pointer; color: var(--muted); font-size: 14px; }
#tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--hive); }
#tabs button.admin { color: var(--self-dim); }
#view { flex: 1; overflow: auto; padding: 14px 16px 40px; min-height: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
h4 { font-size: 14px; font-weight: 600; margin: 14px 0 4px; color: var(--muted); }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.voice { font-family: var(--voice); font-size: 16px; line-height: 1.45; }
.self .voice, .voice.self { color: var(--self); font-style: italic; }

/* feed */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters button, .btn { background: var(--plate); border: 1px solid var(--seam); border-radius: var(--r); padding: 3px 10px; cursor: pointer; font-size: 13px; color: var(--text); }
.filters button[aria-pressed="true"] { border-color: var(--hive-dim); color: var(--hive); }
.btn.primary { border-color: var(--hive-dim); color: var(--hive); }
.btn.danger { border-color: var(--alarm); color: var(--alarm); }
.btn:disabled { opacity: .5; cursor: default; }
.entry { padding: 10px 0 10px 12px; border-left: 2px solid var(--seam); margin-bottom: 4px; }
.entry.hive { border-left-color: var(--hive-dim); }
.entry.self { border-left-color: var(--self); }
.entry.queen { border-left-color: var(--hive); background: linear-gradient(90deg, rgba(141, 255, 192, .05), transparent); }
.entry.other { border-left-color: #6d7f99; }
.entry.milestone { border-left-color: transparent; padding-left: 14px; }
.entry .head { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.entry .head b { color: var(--text); font-weight: 600; cursor: pointer; }
.entry.self .head b { color: var(--self); }
.acts { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
.acts li::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border: 1px solid var(--hive-dim); vertical-align: 1px; }
.acts li.fail { color: var(--muted); }
.acts li.fail::before { border-color: var(--alarm); }
.say { margin-top: 6px; font-size: 13.5px; color: var(--hive); }
.entry.self .say { color: var(--self); }
.ms { font-size: 14px; }
.ms .c { color: var(--muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.tag { font-size: 11.5px; padding: 0 6px; border-radius: 10px; border: 1px solid var(--seam); color: var(--muted); }
.tag.proto { border-color: #5a4a2a; color: #c9a86b; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #050d0a; border: 1px solid var(--seam); padding: 8px;
      border-radius: var(--r); max-height: 420px; overflow: auto; }

/* lists */
.row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid #13281f; cursor: default; }
.row.click { cursor: pointer; }
.row.click:hover { background: rgba(141, 255, 192, .03); }
.row .grow { flex: 1; min-width: 0; }
.bar { height: 4px; background: #13281f; border-radius: 2px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; background: var(--hive-dim); }
.bar.self > i { background: var(--self); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 6px; border-bottom: 1px solid var(--seam); }
td { padding: 4px 6px; border-bottom: 1px solid #13281f; vertical-align: top; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.swatch-hive { color: var(--hive); }
.swatch-self { color: var(--self); }
#hivecanvas { width: 100%; height: 460px; display: block; background: radial-gradient(circle at 50% 45%, #0e2219, #07110d 70%); border-radius: var(--r); }
.chart { width: 100%; height: 120px; display: block; }
.queenbox { border: 1px solid var(--seam); border-radius: var(--r); padding: 12px 14px; background: linear-gradient(180deg, #0d1e17, #0a1712); }
.queenbox .voice { font-size: 17px; }
.score.pos { color: var(--hive); }
.score.neg { color: var(--alarm); }
form.inline { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
input[type=text], textarea, select { background: #07110d; border: 1px solid var(--seam); border-radius: var(--r); padding: 4px 8px; }
textarea { width: 100%; min-height: 60px; }
.setting { display: grid; grid-template-columns: 1fr 140px; gap: 8px; padding: 6px 0; border-bottom: 1px solid #13281f; align-items: center; }
.setting small { display: block; color: var(--muted); }
.empty { color: var(--muted); padding: 20px 0; }

@media (max-width: 980px) {
  body { overflow: auto; }
  #app { grid-template-columns: 1fr; grid-template-rows: auto 52vh auto; height: auto; }
  #panel { border-left: 0; border-top: 1px solid var(--seam); min-height: 70vh; }
  #card { width: auto; left: 14px; }
  #now .voiceline { font-size: 15px; }
  .stats { order: 3; flex-basis: 100%; gap: 8px 16px; }
  .stat { min-width: 0; }
  .stat b { font-size: 16px; }
  #legend span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
