:root {
  --bg: #e8e2d6;
  --ink: #1c1915;
  --muted: #5f584e;
  --line: #d5ccbe;
  --card: #fbf8f3;
  --rail: #17241f;
  --rail-ink: #f3eee6;
  --accent: #0e5c48;
  --accent-ink: #f4efe6;
  --good: #0e5c48;
  --mid: #8a5a12;
  --bad: #8d1d1d;
  --shadow: 0 1px 0 rgba(28, 25, 21, 0.04);
  --sans: "Segoe UI", "PT Sans", "DejaVu Sans", sans-serif;
  --mono: "DejaVu Sans Mono", "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

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

.rail {
  background: var(--rail);
  color: var(--rail-ink);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #f4efe6;
  color: var(--rail);
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 8px;
}

.brand strong { display: block; font-size: 15px; }
.brand small { color: #c9c1b4; }

nav { display: flex; flex-direction: column; gap: 4px; }

nav a {
  color: #e7e1d6;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}

nav a:hover { background: rgba(255, 255, 255, 0.06); }

nav a[aria-current="page"] {
  background: #f4efe6;
  color: var(--rail);
  font-weight: 650;
}

.rail-note {
  margin-top: auto;
  color: #c9c1b4;
  font-size: 13px;
}

main { padding: 28px 32px 64px; max-width: 1080px; }

h1 { font-size: 32px; line-height: 1.15; margin: 0; font-weight: 680; }
h2 { font-size: 18px; margin: 0 0 12px; }

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lead { margin: 8px 0 0; max-width: 68ch; color: var(--muted); }
.muted { color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.live {
  min-height: 1.4em;
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--mid);
}

.btn {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn:disabled { opacity: 0.55; cursor: wait; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.stack { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card h2 { margin-top: 0; }

.status {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.pill {
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e7f3ee;
  color: var(--good);
}

.pill.wait { background: #f4ead8; color: var(--mid); }
.pill.bad { background: #f8e4e1; color: var(--bad); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; margin-bottom: 12px; }

textarea, input[type="number"] {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.task-head, .pair-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.task-head label { display: flex; gap: 8px; align-items: flex-start; font-weight: 650; }

details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); }

pre {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 13px;
  background: #f3eee6;
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0 0;
}

.metrics { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.metric {
  background: #f3eee6;
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 92px;
}

.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }

.result { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.result.good strong.score { color: var(--good); }
.result.mid strong.score { color: var(--mid); }
.result.bad strong.score { color: var(--bad); }

.track {
  position: relative;
  height: 10px;
  background: #efe8dc;
  border-radius: 999px;
  margin: 10px 0 4px;
}

.zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #cfe3da;
  border-radius: 999px;
}

.needle {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 16px;
  background: var(--ink);
  border-radius: 2px;
  transform: translateX(-2px);
}

.drop {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px dashed #b7ad9e;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 12px;
  text-align: center;
  padding: 12px;
  color: var(--muted);
}

.drop input { max-width: 100%; }

img { max-width: 100%; height: auto; border-radius: 8px; background: white; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { font-size: 12px; color: var(--muted); font-weight: 650; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.empty { color: var(--muted); padding: 12px 0; }

a.card-link { color: inherit; text-decoration: none; display: block; }
a.card-link:hover { border-color: var(--accent); }

.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 240px;
  max-height: 58vh;
  overflow: auto;
  margin-bottom: 12px;
}

.bubble {
  max-width: min(72ch, 100%);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: #e7f3ee;
}

.bubble .who {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.composer .field { margin: 0; }

.vision-chat { display: flex; flex-direction: column; }
.vision-chat .thread { flex: 1; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; z-index: 2; padding: 12px; gap: 10px; }
  .rail-note { display: none; }
  nav { flex-direction: row; overflow: auto; }
  main { padding: 18px 14px 48px; }
  .page-head, .split, .composer { display: block; }
  .composer .btn { margin-top: 8px; }
  h1 { font-size: 26px; }
}
