/* ==========================================================================
   Dikera Team — Engineering Console Design System
   "Mission Control for an AI Team": Calm, precise, trustworthy, dark theme only.
   WCAG AA compliant contrast across all surfaces and states.
   ========================================================================== */

:root {
  /* Dikera 2.0 (docs/CONSOLE_2_PLAN.md, docs/design/console-2.0): the assistant app's tones, the same status colours.
     Lagoon = the team is working; Thambili = waiting for Lahiru and primary actions; Lotus = planning and
     proposals; Laterite = failed and destructive. */

  /* Surfaces */
  --ground: #0b171a;
  --panel: #13262b;
  --raised: #203237;
  --hover: #24373c; /* muted and Lotus text keep AA (4.5:1) on it */
  --line: rgba(231, 237, 235, 0.12);
  --line-soft: rgba(231, 237, 235, 0.07);
  --glass: rgba(19, 38, 43, 0.82);

  /* Text */
  --text: #e7edeb;
  --soft: #c5cdcc;
  --muted: #9aa2a2;

  /* Lagoon: the team is working, running, passed, connected */
  --accent: #3fb8af;
  --accent-strong: #5dd6cc;
  --accent-ink: #051e1d;
  --accent-soft: rgba(63, 184, 175, 0.14);
  --accent-line: rgba(63, 184, 175, 0.35);
  --accent-glow: rgba(63, 184, 175, 0.22);

  /* Thambili: waiting for Lahiru, approvals (as text and tints) */
  --warn: #f09a3e;
  --warn-strong: #f6b56e;
  --warn-ink: #0b171a;
  --warn-soft: rgba(240, 154, 62, 0.14);
  --warn-line: rgba(240, 154, 62, 0.4);
  --warn-text: #f7ca9a;
  --warn-glow: rgba(240, 154, 62, 0.2);

  /* Primary actions: a Thambili fill with Monsoon deep text (8.2:1), in both themes */
  --primary-fill: #f09a3e;
  --primary-fill-strong: #f6b56e;
  --primary-ink: #0b171a;

  /* Lotus: planning, drafts, proposed lessons */
  --lotus: #c98bb9;
  --lotus-soft: rgba(201, 139, 185, 0.14);
  --lotus-line: rgba(201, 139, 185, 0.38);

  /* Laterite: failures, destructive actions, errors */
  --danger: #c4553a;
  --danger-strong: #e07d63;
  --danger-ink: #ffffff;
  --danger-soft: rgba(196, 85, 58, 0.14);
  --danger-line: rgba(224, 125, 99, 0.45);
  --danger-text: #f0a690;
  --danger-glow: rgba(196, 85, 58, 0.22);

  /* Radii & geometry (4px spacing scale, 16px cards, 10px controls) */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 9999px;
  --control-h: 40px;
  --control-h-touch: 44px;

  /* Depth comes from tone and hairlines; shadows only for things that float (menus, dialogs). */
  --shadow: none;
  --shadow-subtle: none;
  --shadow-hover: none;
  --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.45);

  /* Type: Apple's fonts first, as the Dikera apps; Inter and IBM Plex Mono where installed. Nothing loads from the
     network, so the console works offline on the Mac mini. */
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "IBM Plex Mono", SFMono-Regular, Menlo, Consolas, monospace;
  /* The agents' own words (answers, lessons, summaries), as Dikera's words in the apps. */
  --serif: ui-serif, "New York", Newsreader, Georgia, serif;

  /* Layout dimensions */
  --sidebar: 252px;

  color-scheme: dark;
}

/* Light (the sidebar's switch, or the system when nothing is chosen). Text colours are the deeper AA values. */
:root[data-theme="light"] {
  --ground: #e7edeb;
  --panel: #f3f6f5;
  --raised: #dfe7e4;
  --hover: #d4dedb;
  --line: rgba(11, 23, 26, 0.13);
  --line-soft: rgba(11, 23, 26, 0.07);
  --glass: rgba(216, 225, 222, 0.85);
  --text: #0b171a;
  --soft: #2c3a3d;
  --muted: #586263;
  --accent: #1a635e;
  --accent-strong: #134b47;
  --accent-ink: #ffffff;
  --accent-soft: rgba(26, 99, 94, 0.12);
  --accent-line: rgba(26, 99, 94, 0.35);
  --accent-glow: rgba(26, 99, 94, 0.15);
  --warn: #8a490d;
  --warn-strong: #6e3a0a;
  --warn-soft: rgba(240, 154, 62, 0.18);
  --warn-line: rgba(138, 73, 13, 0.4);
  --warn-text: #6e3a0a;
  --warn-glow: rgba(240, 154, 62, 0.18);
  --lotus: #814573;
  --lotus-soft: rgba(129, 69, 115, 0.12);
  --lotus-line: rgba(129, 69, 115, 0.35);
  --danger: #9b3b24;
  --danger-strong: #7e2f1c;
  --danger-soft: rgba(155, 59, 36, 0.1);
  --danger-line: rgba(155, 59, 36, 0.4);
  --danger-text: #9b3b24;
  --danger-glow: rgba(155, 59, 36, 0.15);
  --shadow-float: 0 16px 48px rgba(11, 23, 26, 0.18);
  color-scheme: light;
}

/* ---------------------------------------------------------------- Animations & Keyframes */

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseTeal {
  0% {
    box-shadow: 0 0 0 0 rgba(63, 184, 175, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(63, 184, 175, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(63, 184, 175, 0);
  }
}

@keyframes pulseAmber {
  0% {
    box-shadow: 0 0 0 0 rgba(242, 161, 74, 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(242, 161, 74, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(242, 161, 74, 0);
  }
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes backdropEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- Reset & Base */

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden; /* Page never scrolls as a whole */
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Headings: 28px / 18px / 15px */
h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--text);
  margin: 0;
  letter-spacing: -0.015em;
  font-weight: 600;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

p {
  margin: 0;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color 150ms ease;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

/* Monospace & Tabular Data */
code, kbd, samp, pre, .mono {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* Quiet, calm custom scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background-color 150ms ease;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--muted);
}

/* Accessibility: Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------- Controls & Buttons */

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  white-space: nowrap; /* Buttons keep one line */
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 100ms ease;
}

button:hover, a.button:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}

button:active, a.button:active {
  transform: scale(0.97) translateY(0);
}

/* Primary action: Thambili fill with Monsoon deep text (8.2:1), as the Dikera apps */
button.primary, a.button.primary {
  background: var(--primary-fill);
  border-color: var(--primary-fill);
  color: var(--primary-ink);
  font-weight: 600;
}

button.primary:hover, a.button.primary:hover {
  background: var(--primary-fill-strong);
  border-color: var(--primary-fill-strong);
  color: var(--primary-ink);
  box-shadow: none;
  transform: none;
}

button.primary:active, a.button.primary:active {
  transform: scale(0.98);
}

/* Destructive action: Laterite outline and text */
button.danger, a.button.danger {
  background: transparent;
  border-color: var(--danger-line);
  color: var(--danger-text);
  font-weight: 500;
}

button.danger:hover, a.button.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger-strong);
  box-shadow: 0 2px 10px var(--danger-glow);
  transform: translateY(-1px);
}

button.danger:active, a.button.danger:active {
  transform: scale(0.97) translateY(0);
}

/* Small button variant */
.small-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

/* Disabled state */
button:disabled, a.button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none !important;
}

/* Clear, distinct focus rings */
button:focus-visible,
a.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.day-bar:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- Form Fields & Inputs */

textarea, input, select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: 14px;
  padding: 9px 12px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
  outline: none;
}

input, select {
  min-height: var(--control-h);
}

textarea {
  resize: vertical;
  line-height: 1.5;
  font-family: var(--body);
}

textarea:hover, input:hover, select:hover {
  border-color: var(--accent-line);
}

textarea:focus, input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-soft);
  background: var(--ground);
}

::placeholder {
  color: var(--muted);
  opacity: 1;
}

.field {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 2px;
}

.field-error {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--danger-text);
  font-weight: 500;
  line-height: 1.4;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  font-size: 14px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-subtle);
  transition: border-color 150ms ease, background-color 150ms ease, transform 100ms ease;
}

.check-row:hover {
  border-color: var(--line);
  background: var(--hover);
  transform: translateY(-1px);
}

.check-row input[type="checkbox"] {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------------------------------------------------------------- Layout Utilities */

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stack.tight {
  gap: 6px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row.end {
  justify-content: flex-end;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-between.wrap {
  flex-wrap: wrap;
}

.grow {
  flex-grow: 1;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.small-text {
  font-size: 13px;
}

.lead {
  margin: 6px 0 0;
  color: var(--soft);
  font-size: 14.5px;
  max-width: 72ch;
  line-height: 1.5;
}

.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;
}

/* Card container: 14px radius, 1px border, soft shadow, subtle top highlight */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
  transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.card p {
  color: var(--soft);
  max-width: 72ch;
}

.card p.small {
  color: var(--muted);
}

/* ---------------------------------------------------------------- Components */

/* Status Pills: Never wrap, distinct semantic tones */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap; /* Pills never wrap */
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
  transition: all 150ms ease;
}

.pill.tone-work {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}

.pill.tone-wait {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
  font-weight: 700;
}

.pill.tone-idle, .pill.tone-done {
  background: var(--raised);
  color: var(--soft);
  border-color: var(--line);
}

.pill.tone-plan {
  background: var(--lotus-soft);
  color: var(--lotus);
  border-color: var(--lotus-line);
}

.pill.tone-bad {
  background: var(--danger-soft);
  color: var(--danger-text);
  border-color: var(--danger-line);
}

.tone-wait {
  color: var(--warn-text);
}

/* Filter Chips */
.chip {
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--soft);
  background: var(--raised);
  border: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}

.chip:hover {
  background: var(--hover);
  color: var(--text);
}

.chip:active {
  transform: scale(0.96);
}

/* The chosen filter: raised, in the text colour (the Dikera apps' filters). */
.chip[aria-pressed="true"] {
  background: var(--hover);
  border-color: var(--line);
  color: var(--text);
  font-weight: 600;
}

/* Alert Notices */
.notice {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.45;
  border: 1px solid transparent;
}

.notice.warn {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn-text);
  box-shadow: 0 2px 12px var(--warn-soft);
}

.notice.error {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-text);
  box-shadow: 0 2px 12px var(--danger-soft);
}

/* Meters & Progress with Smooth Transitions */
.meter {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  position: relative;
}

.meter > div {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.meter.warn > div {
  background: var(--primary-fill);
}

/* Key-Value alignment rows */
.kv {
  display: grid;
  grid-template-columns: minmax(100px, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
}

.kv > :first-child {
  color: var(--muted);
  font-weight: 500;
}

.kv > :last-child {
  justify-self: end;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}

.kv > .pill:last-child {
  align-self: center;
}

/* ---------------------------------------------------------------- App Shell */

.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden; /* App-shell layout: page never scrolls as a whole */
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 12px 16px;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 10;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  user-select: none;
  cursor: pointer;
}

/* Dikera's Orb (the apps' brand mark): light centre, Thambili, an Ember edge, and a friendly face. */
.brand-mark {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 38% 32%, #ffe2b0 0%, #f09a3e 43%, #6e4a35 115%);
  box-shadow: 0 0 14px rgba(240, 154, 62, 0.3);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  top: 38%;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: #0b171a;
}

.brand-mark::before {
  left: 34%;
}

.brand-mark::after {
  right: 34%;
}

.brand-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}

/* Navigation */
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background-color 150ms ease, color 150ms ease;
}

.nav a:hover {
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
}

/* The chosen section: raised, with a Thambili bar on its leading edge (the Dikera apps' selection). */
.nav a[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
  box-shadow: inset 2px 0 0 var(--primary-fill);
}

.nav a[aria-current="page"] svg {
  color: var(--text);
}

.nav svg {
  flex-shrink: 0;
  color: var(--muted);
  transition: color 150ms ease;
}

.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  min-width: 21px;
  padding: 4px 7px;
  text-align: center;
  background: var(--primary-fill);
  color: var(--primary-ink);
  line-height: 1;
}

/* Team memory's badge counts proposals: Lotus, as everything still to be decided by Lahiru that the team drafted. */
#badge-memory {
  background: var(--lotus-soft);
  color: var(--lotus);
}

/* Status Card on Sidebar */
.status-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-row.small {
  margin-bottom: 6px;
}

.status-row .right {
  margin-left: auto;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.status-card #spend-label {
  color: var(--text);
}

.status-card #worker-detail {
  overflow-wrap: anywhere;
  color: var(--muted);
  line-height: 1.4;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.dot.on {
  background: var(--accent);
  animation: pulseTeal 2.4s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.dot.off {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}

/* Signed in indicator */
.me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 6px 0 8px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
}

.me strong {
  color: var(--text);
  font-weight: 600;
}

/* Light / Dark, at the bottom of the sidebar */
.theme-toggle {
  justify-content: flex-start;
  gap: 11px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.theme-toggle:hover {
  background: var(--raised);
  color: var(--text);
}

.me button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* Main Viewport Container */
main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

main > * {
  flex-shrink: 0;
  animation: viewFadeIn 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

main > header:not(.row-between) {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

main > header.row-between {
  align-items: flex-end;
}

/* Signed-out / Login Centered View */
.centered {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--ground);
}

.centered .card {
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalEnter 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.signin-mark {
  width: 56px;
  height: 56px;
}

.signin-mark::before,
.signin-mark::after {
  width: 5px;
  height: 10px;
}

.command {
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
}

.command code {
  color: var(--accent);
  font-size: 13px;
}

/* ---------------------------------------------------------------- Overview Screen */

.count {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  background: var(--raised);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

.count.wait, .waiting .count {
  background: var(--primary-fill);
  color: var(--primary-ink);
  font-weight: 700;
}

/* Waiting for you (Console 2.0 Overview): an eyebrow, then the approval cards two to a row, each outlined in
   Thambili. */
.waiting {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.waiting h2 {
  color: var(--warn);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.waiting .row {
  align-items: center;
}

.waiting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.waiting-item {
  background: var(--panel);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.waiting-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.waiting-title:hover {
  color: var(--text);
}

.waiting-item .approval-card {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

/* The approval's summary is the team's words: serif, as Dikera's in the apps. */
.waiting-item .approval-card strong {
  color: var(--soft);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 400;
  font-style: italic;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

/* Stat Tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tile-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tile-value {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.tile-value.tone-wait {
  color: var(--warn);
}

.tile-value.tone-work {
  color: var(--accent);
}

/* Pipeline: one column per workflow step; each task card has a dot in its column's status colour. */
.pipeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.column {
  --tone: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.column-wait { --tone: var(--warn); }
.column-plan { --tone: var(--lotus); }
.column-work { --tone: var(--accent); }

.column-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--tone);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.column-idle .column-name {
  color: var(--soft);
}

.column-task {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.column-wait .column-task {
  border-color: var(--warn-line);
}

.column-task:hover {
  color: var(--text);
  background: var(--raised);
  text-decoration: none;
}

.column-task-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.column-task-title .status-dot {
  order: 2;
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--tone);
}

.column-task-meta {
  font-size: 11.5px;
}

.column-task .team-tag {
  align-self: flex-start;
}

/* Latest activity: who (an initial on a tinted circle), the task, the time, then their words in serif. */
.activity {
  display: flex;
  flex-direction: column;
}

.feed-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 6px;
  border-top: 1px solid var(--line-soft);
  align-items: start;
}

.feed-row:first-child {
  border-top: 0;
}

.feed-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.feed-avatar.sender-human {
  background: var(--lotus-soft);
  color: var(--lotus);
}

.feed-avatar.sender-system {
  background: var(--raised);
  color: var(--muted);
}

.feed-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.feed-who {
  font-weight: 600;
  color: var(--text);
}

.feed-task {
  font-size: 12px;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.feed-task:hover {
  color: var(--text);
}

.feed-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.feed-text {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--soft);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.5;
}

/* ---------------------------------------------------------------- Tasks & Chat Screen (Three Panes) */

/* The screen fills the window; list, thread, and details each scroll independently */
main[data-screen="tasks"] {
  overflow: hidden;
  height: 100%;
  padding: 20px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

main[data-screen="tasks"] > .tasks-layout {
  flex: 1 1 100%;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.tasks-layout {
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Pane 1: Tasks List */
.task-column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.h-tasks {
  font-size: 24px;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.task-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 6px;
}

.task-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: background-color 150ms ease;
  position: relative;
}

.task-item:hover {
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
}

/* The open task: raised, with a Thambili bar, as the sidebar's chosen section. */
.task-item[aria-current="true"] {
  background: var(--raised);
  box-shadow: inset 2px 0 0 var(--primary-fill);
}

.task-item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.task-item-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  color: var(--text);
}

.task-item .pill {
  align-self: flex-start;
  font-size: 11px;
}

/* Pane 2: Thread & Live Messages */
.thread {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
}

.thread > h2 {
  padding: 22px 22px 0;
}

.thread > p {
  padding: 6px 22px 22px;
}

.thread-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background: var(--panel);
}

.thread-header .row-between {
  align-items: flex-start;
}

.thread-header > p.small {
  overflow-wrap: anywhere;
  max-width: none;
  color: var(--soft);
}

.thread-title {
  font-size: 20px;
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.3;
  flex: 1 1 260px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.thread-title .mono {
  font-size: 13px;
  font-weight: 500;
  margin-right: 6px;
}

/* Workflow steps (Console 2.0): a row of steps; done ones in Lagoon with a tick, the current one filled in
   Thambili, a gate ahead outlined in Thambili, a failed one in Laterite. */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
}

.step {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  padding: 3px 0;
  color: var(--muted);
}

.step.done {
  color: var(--accent);
}

.step.now {
  padding: 3px 10px;
  background: var(--primary-fill);
  color: var(--primary-ink);
  font-weight: 600;
}

.step.gate {
  padding: 2px 9px;
  border: 1px solid var(--warn-line);
  color: var(--warn);
}

.step.failed {
  padding: 3px 10px;
  background: var(--danger-soft);
  color: var(--danger-text);
  font-weight: 600;
}

/* Message Stream */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 20px 16px;
  display: flex;
  flex-direction: column;
}

.message {
  display: flex;
  gap: 12px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line-soft);
}

.message:last-child {
  border-bottom: 0;
}

/* Avatars: an initial on a tinted circle, Lagoon for agents and Lotus for people (as the Overview's feed). */
.avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  user-select: none;
}

.avatar.from-human {
  background: var(--lotus-soft);
  color: var(--lotus);
}

.avatar.from-system {
  background: var(--raised);
  color: var(--muted);
}

.message-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.message-who {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.message-meta .mono {
  font-size: 11.5px;
  color: var(--muted);
}

.message-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--soft);
  max-width: 78ch; /* a readable line length on wide screens */
  overflow-wrap: anywhere;
}

/* What an agent says is in serif, as Dikera's words in the apps; code, tables and lists keep their own fonts. */
.message.from-agent .message-text {
  font-family: var(--serif);
  font-size: 15.5px;
  color: var(--text);
}

.message.from-agent .message-text :is(code, pre, table) {
  font-family: var(--mono);
}

/* Agent messages rendered from Markdown (markdown.js) */
.md > * + * {
  margin-top: 10px;
}
.md p {
  margin: 0;
}
.md .md-heading {
  color: var(--text);
  font-weight: 650;
  margin-top: 14px;
}
.md strong {
  color: var(--text);
  font-weight: 650;
}
.md ul,
.md ol {
  margin: 0;
  padding-left: 22px;
}
.md li + li {
  margin-top: 6px;
}
.md li > ul,
.md li > ol {
  margin-top: 6px;
}
.md li::marker {
  color: var(--muted);
}
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  color: var(--soft);
}
.md pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ground);
  border: 1px solid var(--line-soft);
  overflow-x: auto;
}
.md pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 12.5px;
  white-space: pre;
}
.md-table {
  overflow-x: auto; /* a wide table scrolls inside the message, never the page */
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  line-height: 1.5;
}
.md th,
.md td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--line-soft);
  overflow-wrap: normal;
  min-width: 80px;
}
.md thead th {
  border-top: 0;
  background: var(--raised);
  color: var(--text);
  font-weight: 650;
}
.md th.md-right,
.md td.md-right {
  text-align: right;
}
.md th.md-center,
.md td.md-center {
  text-align: center;
}
.md a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tool-line {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--soft);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tool-line::before {
  content: "› ";
  color: var(--accent);
}

.status-line {
  display: grid;
  /* Wide enough for an older message's "Oct 15, 10:17 PM", so every row lines up the same. */
  grid-template-columns: 9.6em minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  overflow-wrap: anywhere;
}

.status-line > .mono {
  white-space: nowrap;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Amber Approval Cards */
.approval-card {
  background: var(--panel);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.approval-card strong {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.4;
}

.approval-slot > p.small {
  margin-top: 4px;
  font-style: italic;
}

/* Thread Composer: Pinned to bottom of thread */
.composer {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 5;
}

.composer textarea {
  min-height: 64px;
  max-height: 160px;
}

/* Pane 3: Task Details */
.details {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.details .card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.details .card > h3 {
  margin-bottom: 2px;
}

.details .card p {
  max-width: none;
}

.details .card > button {
  align-self: stretch;
  margin-top: 4px;
}

.path {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
  background: var(--ground);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.hands-on-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hands-on-actions > * {
  width: 100%;
}

.read-lesson {
  overflow-wrap: anywhere;
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
}

/* Modal Dialog for New Task */
dialog.card {
  width: min(560px, calc(100vw - 32px));
  color: var(--text);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-float);
  overscroll-behavior: contain;
  animation: modalEnter 220ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

dialog::backdrop {
  background: rgba(3, 8, 9, 0.75);
  backdrop-filter: blur(8px);
  overflow: hidden;
  overscroll-behavior: contain;
  animation: backdropEnter 220ms ease forwards;
}

/* ---------------------------------------------------------------- Spend & Budget Screen */

.month-picker {
  align-items: center;
}

.month-name {
  min-width: 160px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
}

.spend-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  align-items: start;
}

.spend-body {
  min-width: 0;
  gap: 20px;
}

.spend-side {
  min-width: 0;
  gap: 16px;
}

.spend-side .stopped {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  box-shadow: 0 4px 20px rgba(242, 161, 74, 0.12);
}

.two-up {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* Per-day Spend Bar Chart */
.day-chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-top: 20px;
}

.day-bar {
  flex: 1 1 0;
  min-width: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  cursor: default;
  transition: background 150ms ease, box-shadow 150ms ease, transform 150ms cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  transform-origin: bottom;
}

.day-bar.today {
  background: var(--primary-fill);
}

.day-bar.empty {
  background: var(--line-soft);
}

.day-bar:hover, .day-bar:focus-visible {
  background: var(--accent-strong);
  transform: scaleY(1.04) translateY(-2px);
}

/* A keyboard user sees which day they're on, not only a change of colour. */
.day-bar:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.pace-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--muted);
  pointer-events: none;
  z-index: 1;
  opacity: 0.75;
}

.chart-tip {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: var(--text);
  backdrop-filter: blur(8px);
}

.axis {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

details summary {
  cursor: pointer;
  color: var(--soft);
  font-size: 13px;
  user-select: none;
  transition: color 150ms ease;
}

details summary:hover {
  color: var(--text);
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-top: 8px;
  text-align: left;
}

.data-table th {
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  transition: background-color 150ms ease;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.data-table .meter {
  margin-top: 4px;
  max-width: 160px;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Category Share Bars */
.share {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--raised);
  overflow: hidden;
}

.share-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.spend-body .tiles {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

/* ---------------------------------------------------------------- Agents & Models Screen */

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.ladder {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ladder li {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.rung-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.rung-grid .wide {
  grid-column: span 2;
}

/* Host Job Panel */
.job-panel {
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.job-headline {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.job-headline.ok {
  color: var(--accent);
}

.job-headline.error {
  color: var(--danger-text);
}

.checks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.checks li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.check-mark {
  flex: 0 0 16px;
  font-weight: 700;
}

.checks .ok .check-mark {
  color: var(--accent);
}

.checks .bad .check-mark {
  color: var(--danger-text);
}

/* Version History Rows */
.version-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
}

.version-note {
  flex: 1 1 240px;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- Providers & Keys Screen */

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.provider-grid > .card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.provider-grid > .card > .row-between {
  align-items: flex-start;
}

.provider-grid > .card > .row-between h2 {
  overflow-wrap: anywhere;
}

.provider-grid > .card > :last-child {
  margin-top: auto;
}

.provider-grid .row > button {
  flex: 1 1 auto;
}

.facts {
  margin: 0;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px 14px;
  font-size: 13px;
  align-items: baseline;
}

.facts dt {
  color: var(--muted);
  font-weight: 500;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* ---------------------------------------------------------------- Team Memory Screen */

.search-box {
  min-width: 260px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.lesson-grid > .lesson-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.lesson-grid > .lesson-card > .row.end {
  margin-top: auto;
}

/* A lesson is the team's own words: serif, as Dikera's words in the apps. */
.lesson-card .lesson-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* Proposed by the team, still to be approved: a Lotus outline. */
.lesson-card.lesson-proposed {
  border-color: var(--lotus-line);
}

.lesson-card .row.small {
  align-items: center;
  color: var(--muted);
}

/* ---------------------------------------------------------------- Model Trial Screen */

.trial-table th[scope="row"] {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.trial-table td {
  overflow-wrap: anywhere;
  max-width: 360px;
}

/* ---------------------------------------------------------------- Responsive Layouts */

/* Medium Windows: 861px - 1240px: Two panes (details sit under the thread) */
@media (max-width: 1240px) {
  main[data-screen="tasks"] {
    overflow-y: auto;
    height: 100%;
  }

  .tasks-layout {
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    height: auto;
    min-height: 100%;
  }

  .tasks-layout > .details {
    grid-column: 2;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    align-items: start;
    margin: 0;
    padding: 0;
  }

  .thread {
    height: calc(100dvh - 120px);
    min-height: 540px;
  }

  .task-column {
    max-height: calc(100dvh - 48px);
    position: sticky;
    top: 0;
  }

  .spend-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Narrow & Mobile Screens: Below 860px (One column with sticky top navigation) */
@media (max-width: 860px) {
  :root {
    --control-h: var(--control-h-touch);
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    height: auto;
    max-height: none;
    background: var(--panel);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    gap: 4px;
  }

  .nav a {
    min-height: var(--control-h-touch);
    padding: 8px 12px;
  }

  .sidebar .grow,
  .status-card {
    display: none;
  }

  .me {
    margin-left: auto;
    border-top: 0;
    padding-top: 0;
  }

  main {
    padding: 18px 16px 36px;
  }

  main[data-screen="tasks"] {
    overflow-y: auto;
    height: auto;
  }

  .tasks-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .tasks-layout > .details {
    grid-column: auto;
    display: flex;
    flex-direction: column;
  }

  .task-column {
    position: static;
    max-height: 380px;
  }

  .thread {
    height: auto;
    min-height: 0;
  }

  .messages {
    max-height: 65vh;
  }

  .rung-grid .wide {
    grid-column: auto;
  }

  .feed-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .feed-text {
    grid-column: 1 / -1;
  }

  button, a.button, input, select {
    min-height: var(--control-h-touch);
  }
}

/* ---------------------------------------------------------------- projects */

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: stretch; }
.project-card { display: flex; flex-direction: column; }
.project-card h2 { font-size: 17px; }
.project-card > .row.end { margin-top: auto; }
.check-line { display: grid; grid-template-columns: minmax(70px, auto) minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 13px; }
.check-line .check-name { font-weight: 600; }
.check-line code { color: var(--soft); overflow-wrap: anywhere; }
.folder-where { padding: 8px 12px; background: var(--ground); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.folder-list { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
.folder-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-top: 1px solid var(--line-soft); }
.folder-row:first-child { border-top: 0; }
.folder-open { flex: 1 1 auto; justify-content: flex-start; min-width: 0; border: 0; background: transparent; padding: 0 8px; }
.folder-open:hover { background: var(--raised); }
.folder-icon { color: var(--accent); width: 14px; }
.folder-name { overflow: hidden; text-overflow: ellipsis; }
.check-edit { border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-grid .wide { grid-column: 1 / -1; }
.check-grid input { font-family: var(--mono); font-size: 13px; }
.notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.project-filter { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.kind-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--ground); }
.kind-choice:has(input:checked) { border-color: var(--warn-line); background: var(--raised); box-shadow: inset 2px 0 0 var(--primary-fill); }
.kind-choice input { width: 16px; height: 16px; min-height: 0; margin: 3px 0 0; accent-color: var(--primary-fill); flex: 0 0 16px; }
@media (max-width: 560px) { .kind-choices { grid-template-columns: 1fr; } }
.source-choice { flex-direction: column; align-items: flex-start; gap: 4px; height: auto; min-height: 72px; padding: 12px 14px; white-space: normal; text-align: left; }
.repo-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; }

/* Long status notes and status lines: first lines only until "Show all". */
.foldable { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.folded { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--fold-lines, 3); line-clamp: var(--fold-lines, 3); overflow: hidden; white-space: pre-line; }
.foldable > :first-child:not(.folded) { white-space: pre-line; }
.fold-toggle { min-height: 0; padding: 2px 8px; border: 0; background: transparent; color: var(--accent); font-size: 12px; }
.fold-toggle:hover { background: var(--accent-soft); color: var(--accent-strong); }
.thread-header .foldable { max-width: 100%; }

/* ---------------------------------------------------------------- Skills Screen */

dialog.card.skill-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.skill-dialog textarea.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
}
.skill-preview {
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--ground);
  max-height: 360px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--soft);
}
.skill-description {
  margin: 0;
  color: var(--soft);
}

/* Tokens: the live counter on a task */
.live-dot {
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-dot::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  vertical-align: 1px;
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  50% { opacity: 0.3; }
}
.token-total strong {
  font-size: 1.5rem;
}
.token-total.grew strong {
  animation: token-grew 1.2s ease-out;
}
@keyframes token-grew {
  from { color: var(--accent-strong); text-shadow: 0 0 12px var(--accent-soft); }
}
.token-role {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
}
@media (prefers-reduced-motion: reduce) {
  .live-dot::before,
  .token-total.grew strong {
    animation: none;
  }
}

/* Screenshots in the thread */
.shot {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  max-width: min(260px, 100%);
  text-decoration: none;
}
.shot img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.shot:hover img,
.shot:focus-visible img {
  border-color: var(--accent);
}

/* Team switcher (sidebar) and team tags on rows that mix every team's work */
.team-switch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 2px;
}
.team-switch select {
  min-height: var(--control-h);
  width: 100%;
}
.team-tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  color: var(--soft);
  background: var(--raised);
  white-space: nowrap;
}
.team-tag.team-backend { border-color: var(--warn-line); color: var(--warn-text); }
.team-tag.team-web { border-color: var(--accent-line); color: var(--accent-strong); }
.team-tag.team-mobile { border-style: dashed; border-color: var(--soft); color: var(--text); }
.team-note { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- Chat (P1): the agents by name */

.agent-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.person {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}

/* How the agent describes their job, in serif: their own words. */
.person p {
  flex: 1;
  margin: 0;
  color: var(--soft);
  font-family: var(--serif);
  font-size: 15px;
}

.avatar.big {
  flex-basis: 40px;
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.chat-row:hover,
.chat-row:focus-visible {
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
}

.thinking:empty {
  display: none;
}

.thinking {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--accent);
}
