/*
 * Dhṛti: strength that stays.
 * Theme: the elephant. Strength, memory and a herd that stays close.
 * Elephant slate and deep indigo for steadiness, saffron like a festival elephant's markings,
 * warm sand for the paper.
 * Layout: full-screen on phones, a floating rounded card on tablets and desktops.
 */
:root {
  /* steadiness: elephant slate + deep indigo */
  --slate: #5f7a8c;
  --slate-light: #8aa0b0;
  --deep: #1c3446;
  --deep-soft: #3a5466;
  --light: #fffaf2;
  /* saffron accents (primary actions use --flame, white text passes 4.5:1) */
  --flame: #b35d17;
  --flame-dark: #8f4710;
  --flame-light: #e9973a;
  --mist: #fbeedd;
  --glow: #f6dcb8;
  /* calm teal + friends */
  --teal: #7fb2c4;
  --teal-dark: #2b6c86;
  --sun: #f2b544;
  --coral: #e0524a;
  --sky: #2b8fc4;

  /* aliases used across the sheet */
  --forest: var(--deep);
  --forest-dark: var(--deep);
  --leaf: var(--flame);

  --ink: #1c3446;
  --ink-soft: #5b6872;
  --paper: #fffcf7;
  --card: #ffffff;
  --line: #ece2d2;

  --radius: 18px;
  --shadow: 0 14px 44px rgba(24, 48, 64, 0.14), 0 2px 6px rgba(24, 48, 64, 0.08);
  --font: Arial, Helvetica, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body, #root { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--ink);
  background:
    radial-gradient(circle at 6% 8%, rgba(233, 151, 58, 0.32), transparent 32%),
    radial-gradient(circle at 94% 14%, rgba(43, 108, 134, 0.32), transparent 30%),
    radial-gradient(circle at 88% 96%, rgba(196, 106, 30, 0.28), transparent 36%),
    radial-gradient(circle at 8% 92%, rgba(24, 48, 64, 0.08), transparent 30%),
    #f4ede1;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 2px; }

/* ── App shell ─────────────────────────────────────────── */
.app {
  height: 100%;
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow: hidden;
}

@media (min-width: 768px) {
  .app {
    /* 70% of the screen width on laptops/desktops; never narrower than 760px or wider than the window */
    width: min(calc(100% - 40px), max(70vw, 760px));
    max-width: none;
    height: calc(100% - 40px);
    margin: 20px auto;
    border-radius: 28px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.8);
  }
}

/* ── Header ────────────────────────────────────────────── */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px max(20px, env(safe-area-inset-right, 0px)) 16px max(20px, env(safe-area-inset-left, 0px));
  background: linear-gradient(120deg, #fbe9d2 0%, #fffaf2 50%, #e6f0f3 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.deco { position: absolute; pointer-events: none; }
.herd { width: 92px; height: 44px; right: 6px; bottom: 8px; color: #5f7a8c; opacity: 0.35; }

.brand { position: relative; display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  flex-shrink: 0;
  width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--light);
  border: 3px solid var(--deep);
  box-shadow: 0 6px 14px rgba(24, 48, 64, 0.18), 0 0 0 5px var(--glow);
}
.logo svg { width: 42px; height: 42px; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--forest-dark); letter-spacing: -0.3px; }
.brand p { margin: 3px 0 0; font-size: 13px; color: var(--ink-soft); }

/* "Get help now": always visible, on every tab */
.help-btn {
  position: relative;
  z-index: 1;
  order: 2;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(224, 82, 74, 0.35);
}
.help-btn:hover { background: #b8352e; }

/* Role switcher: segmented control */
.roles {
  order: 1;
  margin-left: auto;
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 0 0 1px var(--line);
}
.role {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.role:hover { color: var(--flame-dark); }
.role.is-active {
  background: var(--forest);
  color: #fff;
  box-shadow: 0 4px 10px rgba(24, 48, 64, 0.28);
}

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background 0.2s, color 0.2s;
}
.tab:hover { background: var(--mist); color: var(--flame-dark); }
.tab.is-active { background: var(--deep); color: #fff; box-shadow: 0 4px 10px rgba(24, 48, 64, 0.22); }
.badge {
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--teal-dark);
  color: #fff;
}

/* ── Horizontal chip rows ───────────────────────────────── */
.quick {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.quick::-webkit-scrollbar { display: none; }


/* ── Scroll areas ──────────────────────────────────────── */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px max(20px, env(safe-area-inset-right, 0px)) 20px max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat {
  background:
    radial-gradient(circle at 100% 0%, rgba(43, 108, 134, 0.10), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(233, 151, 58, 0.10), transparent 42%);
}

/* ── Messages ──────────────────────────────────────────── */
.msg { display: flex; gap: 10px; align-items: flex-end; animation: rise 0.28s ease-out; }
.msg-user { justify-content: flex-end; }

.avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-size: 17px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--agent, #1c3446) 12%, white);
  border: 2px solid color-mix(in srgb, var(--agent, #1c3446) 40%, white);
}

.bubble { max-width: min(80%, 900px); padding: 12px 15px; line-height: 1.55; overflow-wrap: anywhere; }
.bubble-user {
  color: #fff;
  background: linear-gradient(135deg, var(--deep-soft), var(--deep));
  border-radius: 20px 20px 6px 20px;
  box-shadow: 0 6px 16px rgba(24, 48, 64, 0.25);
}
.bubble-bot {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--agent);
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 4px 14px rgba(24, 48, 64, 0.06);
}
.bubble-bot.is-flagged { background: #fff4f1; border-color: #f6c9c2; border-top-color: var(--coral); }
.bubble-text { white-space: pre-wrap; }
.bubble-text mark.key { background: #d9f0d3; color: #1f4d2e; font-weight: 700; padding: 0 4px; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .bubble-text mark.key { background: #2f5d46; color: #eaf7e6; } }

.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 7px; }
.tag {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--agent);
}

/* Typing indicator: three bouncing seeds */
.typing {
  display: flex; gap: 5px;
  padding: 14px 16px;
  border-radius: 20px 20px 20px 6px;
  background: var(--card);
  border: 1px solid var(--line);
}
.typing span { width: 8px; height: 8px; border-radius: 50%; animation: bounce 1.1s infinite ease-in-out; }
.typing span:nth-child(1) { background: var(--deep); }
.typing span:nth-child(2) { background: var(--flame); animation-delay: 0.15s; }
.typing span:nth-child(3) { background: var(--teal); animation-delay: 0.3s; }

/* ── Composer ──────────────────────────────────────────── */
.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) max(14px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.quick-chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}
.quick-chip:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(24, 48, 64, 0.12); }
.quick-chip:nth-child(6n + 1) { background: #fcecd8; border-color: #f3cfa2; color: #8a4a12; }
.quick-chip:nth-child(6n + 2) { background: #e2eef2; border-color: #bfd8e2; color: #1f5068; }
.quick-chip:nth-child(6n + 3) { background: #fff1dc; border-color: #fbd9a8; color: #94520f; }
.quick-chip:nth-child(6n + 4) { background: #e4f2fa; border-color: #c2e0f1; color: #1d6189; }
.quick-chip:nth-child(6n + 5) { background: #fde9e6; border-color: #f6cbc5; color: #a3352e; }
.quick-chip:nth-child(6n + 6) { background: #f1f1f3; border-color: #dcdce1; color: #1c3446; }

.input-row { display: flex; gap: 8px; }
.input {
  flex: 1;
  min-width: 0;
  padding: 13px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus { outline: none; border-color: var(--flame); box-shadow: 0 0 0 4px rgba(196, 106, 30, 0.18); }
.input::placeholder { color: #a3a3ab; }

.send, .btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #c96a1c, var(--flame-dark));
  box-shadow: 0 6px 16px rgba(150, 78, 18, 0.32);
  transition: transform 0.15s, box-shadow 0.15s;
}
.send:hover:not(:disabled), .btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(150, 78, 18, 0.4); }

/* Team row inside Dhṛti's greeting */
.team-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.team-chip {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--agent);
  background: color-mix(in srgb, var(--agent) 12%, white);
  border: 1px solid color-mix(in srgb, var(--agent) 28%, white);
}

/* ── Evaluation tab ────────────────────────────────────── */
.eval { background: linear-gradient(180deg, #fbf6ee, var(--paper)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  position: relative;
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow: hidden;
}
.stat-icon { position: absolute; right: 10px; top: 8px; font-size: 22px; opacity: 0.85; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { margin-top: 4px; font-size: 12px; font-weight: 700; opacity: 0.8; }
.tone-leaf  { background: #fcecd8; color: #8a4a12; }
.tone-sun   { background: #f1f1f3; color: #1c3446; }
.tone-coral { background: #e2eef2; color: #1f5068; }
.tone-sky   { background: #e4f2fa; color: #1d6189; }

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(24, 48, 64, 0.05);
}
.card h2 { margin: 0; font-size: 17px; color: var(--forest-dark); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.card-head > div { flex: 1 1 320px; min-width: 0; }
.muted { margin: 5px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-soft); max-width: 62ch; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.team-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--agent) 9%, white);
  border: 1px solid color-mix(in srgb, var(--agent) 24%, white);
}
.team-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 18px;
  border-radius: 12px;
  background: #fff;
}
.team-name { font-weight: 700; color: var(--agent); }
.team-blurb { margin-top: 3px; font-size: 12px; line-height: 1.45; color: var(--ink-soft); }

.progress { height: 6px; border-radius: 999px; background: var(--mist); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--flame), var(--teal)); transition: width 0.3s; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.pass { background: #dcf3d6; color: #1f6b34; }
.pill.fail { background: #fde0dc; color: #9b2c25; }
.pill.neutral { background: #ececf0; color: #1c3446; }

.list { display: flex; flex-direction: column; gap: 10px; }
.eval-row {
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid;
  background: #fff;
}
.eval-row.is-pass { border-left-color: var(--leaf); }
.eval-row.is-fail { border-left-color: var(--coral); }
.eval-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  text-align: left;
}
.eval-q { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eval-meta { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.chev { color: var(--ink-soft); }

.checks { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; }
.checks .ok { color: #1f6b34; }
.checks .bad { color: #9b2c25; font-weight: 700; }
.note { color: var(--ink-soft); font-weight: 400; }

.details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
}
.trace { margin: 0; padding-left: 20px; color: var(--ink-soft); line-height: 1.6; }
.answer { padding: 10px 12px; border-radius: 10px; background: var(--mist); white-space: pre-wrap; line-height: 1.55; }

.empty {
  padding: 26px 16px;
  border-radius: 14px;
  background: var(--mist);
  color: var(--ink-soft);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.empty-icon { font-size: 30px; margin-bottom: 6px; }

/* ── Action cards (from agent tools) ───────────────────── */
.action {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  font-size: 14px;
}
.action-exercise { background: linear-gradient(120deg, #fcecd8, #f3f0fb); border: 1px solid var(--glow); }
.action-icon { font-size: 26px; flex-shrink: 0; }
.action-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.action-body span { font-size: 12px; color: var(--ink-soft); }
.action-crisis {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: #fff1ef;
  border: 2px solid #f3b3aa;
  color: #8c2a23;
}
.helpline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #f6cbc5;
  color: var(--ink);
  text-decoration: none;
}
.helpline:hover { border-color: var(--coral); }
.helpline-number { font-size: 18px; font-weight: 700; color: var(--coral); }
.action-note { font-size: 12px; }
.action-mood { padding: 8px 12px; background: var(--mist); color: var(--flame-dark); font-size: 13px; font-weight: 700; }

.btn-small { min-height: 38px; padding: 0 16px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-ghost:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--glow); }
.row-buttons { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.center { text-align: center; }

/* ── Guided exercise overlay ───────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(24, 48, 64, 0.55);
  animation: rise 0.2s ease-out;
}
.overlay-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 28px 22px 22px;
  border-radius: 26px;
  background: linear-gradient(180deg, #fbf4ea, #fff);
  box-shadow: var(--shadow);
  text-align: center;
}
.overlay-card h2 { margin: 0 0 14px; font-size: 20px; }
.overlay-close {
  position: absolute; top: 12px; right: 12px;
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: var(--mist); font-size: 16px;
}
.help-card { display: flex; flex-direction: column; align-items: stretch; gap: 14px; text-align: left; }
.help-card h2 { margin: 0; padding-right: 40px; color: #8c2a23; }
.help-card > .btn { align-self: center; }
.help-lede { margin: 0; font-size: 16px; line-height: 1.5; }
.help-list { display: flex; flex-direction: column; gap: 8px; }
.help-list .helpline { flex-direction: column; align-items: flex-start; gap: 4px; min-height: 56px; border-width: 2px; }
.helpline-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.helpline-text span { font-size: 13px; color: var(--ink-soft); }

.breathing, .grounding { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.breath-circle {
  width: 200px; height: 200px;
  max-width: 70vw; max-height: 70vw;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #f6d6ac 60%, #e9a65a);
  box-shadow: 0 0 0 10px rgba(233, 151, 58, 0.15), 0 10px 30px rgba(150, 78, 18, 0.25);
  transform: scale(0.7);
  transition: transform var(--dur, 4s) ease-in-out;
}
.breath-circle.is-in { transform: scale(1); }
.breath-circle.is-hold { transform: scale(1); }
.breath-circle.is-out, .breath-circle.is-rest { transform: scale(0.7); }
.breath-text { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 16px; color: var(--deep); }
.breath-text span { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }

.grounding-steps { display: flex; gap: 8px; }
.gstep {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  background: var(--mist);
  color: var(--ink-soft);
}
.gstep.is-now { background: var(--deep); color: #fff; }
.gstep.is-done { background: var(--flame); color: #fff; }
.grounding-now { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 17px; min-height: 120px; }
.grounding-emoji { font-size: 44px; }

/* ── Mood tab ──────────────────────────────────────────── */
.mood { background: linear-gradient(180deg, #fbf6ee, var(--paper)); }
.faces { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.face {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.face:hover { transform: translateY(-2px); }
.face-emoji { font-size: 30px; }
.face.is-active { color: var(--ink); border-color: var(--deep); }
.face.mood-1.is-active { background: #fde4e1; }
.face.mood-2.is-active { background: #fdebe2; }
.face.mood-3.is-active { background: #fff6d6; }
.face.mood-4.is-active { background: #e6f2dc; }
.face.mood-5.is-active { background: #d9edc8; }
.feelings { display: flex; flex-wrap: wrap; gap: 6px; }
.feeling {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
}
.feeling.is-active { background: var(--deep); border-color: var(--deep); color: #fff; }
.textarea, .field {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 14px;
  resize: vertical;
}
.textarea:focus, .field:focus { outline: none; border-color: var(--flame); box-shadow: 0 0 0 4px rgba(196, 106, 30, 0.18); }

.chart-wrap { overflow-x: auto; }
.chart { width: 100%; min-width: 320px; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-soft); font-size: 11px; font-family: var(--font); }

.contact-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.contact-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.contact-form .check { grid-column: 1 / -1; flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; line-height: 1.45; }
.contact-form .check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--deep); flex-shrink: 0; }
.contact-form .row-buttons { grid-column: 1 / -1; }

/* ── Evaluation extras ─────────────────────────────────── */
.team-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.team-tools code, .tool-call {
  font-family: "Courier New", monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
}
.tool-call { display: inline-block; margin: 2px 4px 2px 0; overflow-wrap: anywhere; }

/* ── Animations ────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Leave room on the right of the header for the herd */
@media (min-width: 641px) {
  .hero { padding-right: max(100px, env(safe-area-inset-right, 0px)); }
}

/* ── Tablet ────────────────────────────────────────────── */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Phone ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 14px; }

  .hero { padding-top: 14px; padding-bottom: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .logo { width: 44px; height: 44px; }
  .logo svg { width: 34px; height: 34px; }
  .brand h1 { font-size: 19px; }
  .brand p { font-size: 12px; }
  .herd { display: none; }

  .brand { flex: 1; }
  .help-btn { order: 1; padding: 0 14px; font-size: 13px; }
  .roles { order: 2; width: 100%; margin-left: 0; }
  .role { flex: 1; padding: 8px 6px; }

  .tabs, .scroll, .composer { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .tab { flex: 1; padding: 9px 10px; }

  .scroll { padding-top: 14px; padding-bottom: 14px; gap: 12px; }

  .avatar { width: 28px; height: 28px; font-size: 14px; }
  .bubble { max-width: 86%; padding: 10px 13px; }

  .send { width: 48px; padding: 0; }
  .send-label { display: none; }

  .faces { gap: 5px; }
  .face { padding: 8px 2px; font-size: 11px; }
  .face-emoji { font-size: 26px; }
  .contact-form { grid-template-columns: minmax(0, 1fr); }
  .action-exercise { flex-wrap: wrap; }
  .action-exercise .btn { width: 100%; }

  .stat { padding: 12px; }
  .stat-value { font-size: 22px; }
  .card { padding: 14px; }
  .btn { width: 100%; }

  .eval-head { flex-wrap: wrap; }
  .eval-q { flex-basis: calc(100% - 90px); }
  .eval-meta { order: 3; width: 100%; padding-left: 2px; }
}

@media (max-width: 360px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .role span { display: none; }
}

/* ── LangGraph view ────────────────────────────────────── */
.graph-wrap {
  overflow-x: auto;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf6ee, #ffffff);
  border: 1px solid var(--line);
  text-align: center;
  min-height: 120px;
}
.graph-wrap svg { max-width: 100%; height: auto; min-width: 300px; }
.card code { font-family: "Courier New", monospace; font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.timeline li {
  display: grid;
  grid-template-columns: 74px 130px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--mist);
  font-size: 13px;
}
.tl-time { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.tl-node { font-family: "Courier New", monospace; font-weight: 700; color: var(--flame-dark); }
.tl-detail { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-info { font-size: 11px; color: var(--ink-soft); }
.eval-row.is-selected { box-shadow: 0 0 0 3px var(--glow); }

@media (max-width: 640px) {
  .timeline li { grid-template-columns: 60px minmax(0, 1fr); }
  .tl-detail { grid-column: 1 / -1; }
}

.pill-link { text-decoration: none; }
.pill-link:hover { filter: brightness(0.95); text-decoration: underline; }

/* Graph view: question picker + "answered by" banner */
.run-picker { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.run-picker select { max-width: 100%; font-weight: 400; cursor: pointer; }
.answered-by {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--mist);
  border: 1px solid var(--glow);
}
.answered-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); }
.answered-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--agent);
}
.answered-why { flex-basis: 100%; font-size: 13px; color: var(--ink-soft); }
