/* The console. No framework, no build step, and both themes (SPEC 13).
   Colours come from a small token set so light and dark are one definition. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1b1b19;
  --ink-soft: #5b5b55;
  --line: #dcdcd6;
  --accent: #2c5d63;
  --held: #8a5a00;
  --bad: #9b2226;
  --good: #2d6a4f;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --panel: #1f2124;
    --ink: #e8e8e4;
    --ink-soft: #a3a39c;
    --line: #34363a;
    --accent: #7fb4bb;
    --held: #e0a34a;
    --bad: #e88b8e;
    --good: #7ec8a4;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu,
        "Helvetica Neue", sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: baseline;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header h1 { font-size: 1.1rem; margin: 0; letter-spacing: 0.02em; }

nav { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; }

nav a {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
}
nav a:hover { background: var(--bg); color: var(--ink); }
nav a[aria-current="page"] { background: var(--accent); color: var(--panel); }

#identity { display: flex; gap: 0.5rem; align-items: baseline; color: var(--ink-soft); }

main { padding: 1.25rem; max-width: 72rem; }

#screen-header { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
#screen-header h2 { margin: 0 0 0.75rem; font-size: 1.3rem; }
#screen-actions { display: flex; gap: 0.5rem; margin-left: auto; }

button {
  font: inherit;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

input {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  min-width: 18rem;
}

textarea {
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  width: 100%;
  min-height: 12rem;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}

form { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
label { display: block; color: var(--ink-soft); font-size: 0.85rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.card h3 { margin: 0 0 0.4rem; font-size: 1rem; }

/* Ages before counts: the age is the headline, the count is the aside. */
.age { font-size: 1.15rem; font-weight: 600; }
.count { color: var(--ink-soft); font-size: 0.9rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; }

table { border-collapse: collapse; width: 100%; margin-top: 0.5rem; }
th, td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--ink-soft); font-weight: 600; font-size: 0.85rem; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}
pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
  overflow-x: auto;
}

.tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.tag.held, .tag.drifted, .tag.anchor_lost { color: var(--held); border-color: var(--held); }
.tag.failed, .tag.high { color: var(--bad); border-color: var(--bad); }
.tag.in_sync, .tag.done, .tag.live { color: var(--good); border-color: var(--good); }

.error { color: var(--bad); }
.note { color: var(--ink-soft); }

/* Empty states are designed, not blank (SPEC 13). */
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--ink-soft);
  background: var(--panel);
}
.empty strong { color: var(--ink); display: block; margin-bottom: 0.25rem; }

footer {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.blast {
  border-left: 3px solid var(--bad);
  padding-left: 0.75rem;
  margin: 0.5rem 0;
}

/* ── Chat (SPEC 19) ─────────────────────────────────────────────────────── */
.tab-group {
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 0.35rem 0 0.75rem;
  align-self: center;
}

.chat {
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 52rem) {
  .chat { grid-template-columns: 1fr; }
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-entry {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.chat-entry:hover { border-color: var(--accent); }
.chat-entry.current { border-color: var(--accent); background: var(--bg); }

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-message {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  background: var(--panel);
  overflow-x: auto;
}

.chat-message.user {
  border-color: var(--accent);
  background: var(--bg);
}

.chat-message.user p { margin: 0; }
.chat-body h4 { margin: 0.75rem 0 0.25rem; font-size: 0.95rem; }
.chat-body p { margin: 0.35rem 0; }

.verified {
  color: var(--good);
  font-size: 0.8rem;
  margin: 0.5rem 0 0;
}

.chat-message details { margin-top: 0.5rem; }
.chat-message summary { cursor: pointer; color: var(--ink-soft); font-size: 0.85rem; }
.sources { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.sources li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem; }

.chat-examples { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--ink-soft); }
.chat-examples li { margin: 0.15rem 0; }

.chat-composer { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-composer textarea { flex: 1; min-width: 0; }

.progress {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--line), var(--accent), var(--line));
  background-size: 200% 100%;
  animation: chat-progress 1.4s linear infinite;
}

@keyframes chat-progress {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .progress { animation: none; background: var(--accent); }
}

/* Settings. One card per credential; the field never shows a stored secret, so
   the row has to say where the value came from in words. */
.setting-state { font-weight: 600; color: var(--ink); }
.setting-state.environment, .setting-state.unset { font-weight: 400;
  color: var(--ink-soft); }
.setting-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
  margin-top: 0.5rem; }
.setting-row input { flex: 1; min-width: 14rem; }
