/* ==========================================================================
   components.css — the pieces: buttons, the brand mark, avatars and
   presence, role tags, staff lists, the face pile, the metric strip and its
   chart, dividers and system lines, messages, reactions, the crisis callout,
   briefing embeds, the typing line, the composer and its reply options, and
   the final report.
   Only consumes tokens from tokens.css; no literal colours here.
   ========================================================================== */

/* ---- Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: 0.005em;
  transition:
    transform var(--dur-press) var(--ease-out),
    background-color var(--dur-fast) ease;
}

.btn:active { transform: scale(0.97); }

.btn-accent {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-button);
}

.btn-lg {
  min-height: 50px;
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
}

.btn-block { width: 100%; }

.btn .i {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
  transition: transform var(--dur) var(--ease-out);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  transition:
    background-color var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
}

.icon-btn .i { width: 18px; height: 18px; }
.icon-btn:active { transform: scale(0.92); }

.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

@media (hover: hover) and (pointer: fine) {
  .btn-accent:hover { background: var(--accent-strong); }
  .btn-accent:hover .i-arrow { transform: translateX(3px); }
  .icon-btn:hover { background: var(--icon-hover, var(--surface-2)); }
}

/* ---- Brand mark: a wheat stalk on an amber tile ------------------------ */

.brand-mark {
  --size: 36px;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: calc(var(--size) * 0.3);
  background: linear-gradient(160deg, var(--brand-from), var(--brand-to));
  color: var(--brand-ink);
  box-shadow: var(--shadow-mark);
}

.brand-mark svg { width: 64%; height: 64%; fill: currentColor; }
.brand-mark-sm { --size: 28px; }
.brand-mark-lg { --size: 68px; }

/* ---- Avatars and presence ---------------------------------------------- */

[data-avatar="1"] { --avatar-color: var(--avatar-1); }
[data-avatar="2"] { --avatar-color: var(--avatar-2); }
[data-avatar="3"] { --avatar-color: var(--avatar-3); }
[data-avatar="4"] { --avatar-color: var(--avatar-4); }
[data-avatar="5"] { --avatar-color: var(--avatar-5); }
[data-avatar="me"] { --avatar-color: var(--accent); --on-avatar: var(--on-accent); }

.avatar {
  --size: 36px;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: var(--size);
  height: var(--size);
  border-radius: calc(var(--size) * 0.28);
  background-color: var(--avatar-color, var(--text-faint));
  background-image: var(--avatar-sheen);
  color: var(--on-avatar);
  font-size: calc(var(--size) * 0.36);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}

/* The ring colour is whatever the avatar sits on; set --ring on a parent. */
.presence {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--presence-online);
  box-shadow: 0 0 0 2.5px var(--ring, var(--surface));
}

/* Away reads as a crescent, the way chat apps draw "idle". */
[data-presence="away"] .presence {
  background:
    radial-gradient(circle at 26% 26%, var(--ring, var(--surface)) 0 3.4px, transparent 3.8px),
    var(--presence-away);
}

.role-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: color-mix(in oklab, var(--avatar-color) 76%, var(--text));
  background: color-mix(in oklab, var(--avatar-color) 14%, transparent);
}

/* ---- Staff list on the welcome card ------------------------------------ */

.staff { display: grid; gap: 2px; }

.staff-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  animation: arrive 420ms var(--ease-out) backwards;
}

.staff-card:nth-child(1) { animation-delay: 220ms; }
.staff-card:nth-child(2) { animation-delay: 260ms; }
.staff-card:nth-child(3) { animation-delay: 300ms; }
.staff-card:nth-child(4) { animation-delay: 340ms; }
.staff-card:nth-child(5) { animation-delay: 380ms; }

.staff-card .avatar { --size: 40px; }

.staff-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  min-height: 20px;
}

.staff-name { font-size: var(--text-md); font-weight: 800; }

.staff-bio {
  margin-top: 2px;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text-muted);
}

/* ---- Staff list on the rail -------------------------------------------- */

.members { display: grid; gap: 1px; }

.member {
  --ring: var(--rail);
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background-color var(--dur) ease;
}

.member .avatar { --size: 30px; }
.member-text { min-width: 0; }

.member-name,
.member-status {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.member-name { font-size: var(--text-sm); font-weight: 700; color: var(--rail-text); }
.member-status { font-size: var(--text-xs); color: var(--rail-muted); }
.member.is-away .member-name { color: var(--rail-muted); }
.member.is-away .avatar { opacity: 0.7; }

.member.is-speaking {
  --ring: var(--rail-active-solid);
  background: var(--rail-active);
}

.member.is-speaking .member-status { color: var(--rail-live); font-weight: 600; }

/* ---- Face pile in the channel header ----------------------------------- */

.facepile {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.facepile .avatar {
  --size: 24px;
  transition:
    opacity var(--dur-slow) ease,
    filter var(--dur-slow) ease,
    box-shadow var(--dur-slow) ease;
}

.facepile .avatar.is-away { opacity: 0.45; filter: grayscale(0.6); }

/* Discord's "speaking" ring: whoever is talking to you right now. */
.facepile .avatar.is-speaking {
  z-index: 1;
  box-shadow: 0 0 0 2px var(--ring), 0 0 0 4px var(--presence-online);
}

/* ---- Stat level and trend -> colour (single source of truth) ---------- */

[data-level="critical"] { --level-color: var(--stat-critical); }
[data-level="danger"]   { --level-color: var(--stat-danger); }
[data-level="caution"]  { --level-color: var(--stat-caution); }
[data-level="good"]     { --level-color: var(--stat-good); }
[data-trend="up"]       { --trend-color: var(--trend-up); }
[data-trend="down"]     { --trend-color: var(--trend-down); }

/* ---- Metric strip ------------------------------------------------------ */

.strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

/* Each card is a button that opens its chart. On phones the eye sits at the
   end of the bar, where there's room; on wider screens it moves up beside
   the label. */
.metric {
  --metric-bg: var(--surface-2);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "top   top"
    "value value"
    "bar   eye";
  align-items: center;
  gap: 5px 6px;
  min-width: 0;
  padding: 8px 8px 9px;
  border-radius: var(--radius-md);
  background: var(--metric-bg);
  box-shadow: inset 0 0 0 1px var(--metric-line, transparent);
  transition:
    background-color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
}

.metric:active { transform: scale(0.97); }

.metric[data-level="danger"] {
  --metric-bg: color-mix(in oklab, var(--stat-danger) 8%, var(--surface));
  --metric-line: color-mix(in oklab, var(--stat-danger) 34%, transparent);
}

.metric[data-level="critical"] {
  --metric-bg: color-mix(in oklab, var(--stat-critical) 9%, var(--surface));
  --metric-line: color-mix(in oklab, var(--stat-critical) 42%, transparent);
}

.metric[data-level="good"] {
  --metric-bg: color-mix(in oklab, var(--stat-good) 9%, var(--surface));
  --metric-line: color-mix(in oklab, var(--stat-good) 36%, transparent);
}

.metric[aria-expanded="true"] {
  box-shadow:
    inset 0 0 0 2px color-mix(in oklab, var(--level-color) 60%, transparent),
    var(--shadow-sm);
}

/* A short ring pulse when the number moves, in the direction it moved. */
.metric.is-changed { animation: flash 900ms var(--ease-out); }
.metric.is-changed[data-trend="up"] { --flash: color-mix(in oklab, var(--trend-up) 45%, transparent); }
.metric.is-changed[data-trend="down"] { --flash: color-mix(in oklab, var(--trend-down) 45%, transparent); }

.metric-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.metric-emoji {
  display: none;
  font-size: 0.875rem;
  line-height: 1;
}

.metric-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.metric-value {
  grid-area: value;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.metric-number {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.metric[data-level="critical"] .metric-number { color: var(--stat-critical); }

.metric-delta {
  font-size: var(--text-2xs);
  font-weight: 800;
  color: var(--trend-color, var(--text-muted));
}

/* The track is tinted below the crisis line (30) and above the goal (95),
   so the bar shows how far each number is from both without a legend. */
.metric-bar {
  grid-area: bar;
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    var(--track-crisis) 0 30%,
    var(--stat-track) 30% 95%,
    var(--track-goal) 95%
  );
}

.metric-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--level-color);
  transform-origin: left center;
  transition:
    transform var(--dur-bar) var(--ease-out),
    background-color var(--dur-bar) ease;
}

@media (hover: hover) and (pointer: fine) {
  .metric:hover:not([aria-expanded="true"]) { background: color-mix(in oklab, var(--metric-bg) 100%, var(--text) 4%); }
}

/* The eye says "there's more here"; it closes when the chart is open. */
.metric-eye {
  grid-area: eye;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: color var(--dur-fast) ease;
}

.metric-eye .i { width: 13px; height: 13px; }
.metric-eye .i-eye-off { display: none; }
.metric[aria-expanded="true"] .metric-eye { color: var(--text); }
.metric[aria-expanded="true"] .metric-eye .i-eye { display: none; }
.metric[aria-expanded="true"] .metric-eye .i-eye-off { display: block; }

@media (hover: hover) and (pointer: fine) {
  .metric:hover .metric-eye { color: var(--text); }
}

/* ---- A metric's history, opened from the strip ------------------------- */

.strip-chart {
  --chart-dot-ring: var(--surface-2);
  margin-top: 8px;
  padding: 12px 12px 6px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  animation: arrive var(--dur) var(--ease-out);
}

.strip-chart-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.strip-chart-title { font-size: var(--text-sm); font-weight: 800; }
.strip-chart-desc { font-size: var(--text-xs); color: var(--text-muted); }

.strip-chart .icon-btn {
  width: 30px;
  height: 30px;
  margin: -6px -6px 0 auto;
  color: var(--text-muted);
  --icon-hover: var(--surface-3);
}

/* Charts are inline SVG drawn by js/chart.js. The line and area take
   currentColor, which follows the chart's own [data-level]. */
.chart {
  width: 100%;
  height: 128px;
  margin-top: 4px;
  overflow: visible;
  color: var(--level-color, var(--text-muted));
}

.chart-grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-limit { stroke-width: 1; stroke-dasharray: 3 4; }
.chart-limit-crisis { stroke: var(--stat-critical); stroke-opacity: 0.55; }
.chart-limit-goal { stroke: var(--stat-good); stroke-opacity: 0.6; }
.chart-area-stop { stop-color: currentColor; }

.chart-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-dot {
  fill: currentColor;
  stroke: var(--chart-dot-ring, var(--surface));
  stroke-width: 2;
}

.chart-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  fill: var(--chart-text);
}

/* ---- The exchange: dividers, system lines, messages -------------------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 16px 8px;
  animation: arrive var(--dur) var(--ease-out);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* "Dev is in the field." Discord's join/leave line. */
.system {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
  padding: 4px 16px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  animation: arrive var(--dur) var(--ease-out);
}

.system .i {
  justify-self: center;
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
  color: var(--presence-away);
}

.system.is-back .i { color: var(--presence-online); }
.system b { font-weight: 700; color: var(--text); }

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 12px;
  padding: 8px 16px;
  animation: arrive var(--dur) var(--ease-out);
}

.msg > .avatar { margin-top: 2px; }
.msg-body { min-width: 0; }

.who {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
  margin-bottom: 2px;
  line-height: 1.35;
}

.who-name { font-size: var(--text-md); font-weight: 800; color: var(--text); }

.lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: var(--measure);
}

/* Lines arrive one at a time; the first comes in with its message row. */
.lines > * { animation: arrive var(--dur) var(--ease-out); }
.lines > :first-child { animation: none; }

.line {
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--text);
  overflow-wrap: break-word;
}

/* The question: marked with the Director's amber, since it's theirs to answer. */
.line-question {
  padding-left: 12px;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* The Director's own message: the mention highlight. */
.msg-me {
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .msg:hover { background: color-mix(in oklab, var(--surface-2) 75%, transparent); }
  .msg-me:hover { background: color-mix(in oklab, var(--accent) 19%, transparent); }
}

/* ---- Reactions: the numbers that moved --------------------------------- */

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  animation: pop-in 300ms var(--ease-out) backwards;
}

.reaction:nth-child(2) { animation-delay: 50ms; }
.reaction:nth-child(3) { animation-delay: 100ms; }
.reaction:nth-child(4) { animation-delay: 150ms; }
.reaction:nth-child(5) { animation-delay: 200ms; }

.reaction-emoji { font-size: 0.875rem; line-height: 1; }
.reaction-delta { font-weight: 800; color: var(--trend-color); }

.reaction[data-trend="up"] {
  background: color-mix(in oklab, var(--trend-up) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--trend-up) 30%, transparent);
}

.reaction[data-trend="down"] {
  background: color-mix(in oklab, var(--trend-down) 8%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--trend-down) 30%, transparent);
}

/* ---- Crisis callout ---------------------------------------------------- */

.callout {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--stat-critical) 8%, var(--surface));
  box-shadow: inset 3px 0 0 var(--stat-critical);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.callout .i {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--stat-critical);
}

.callout-title {
  display: block;
  font-weight: 800;
  color: color-mix(in oklab, var(--stat-critical) 82%, var(--text));
}

/* ---- Briefing embed: the editorial heart ------------------------------- */

.embed {
  max-width: 34rem;
  padding: 12px 16px 12px 14px;
  border-left: 4px solid var(--embed-rule, var(--avatar-color, var(--border-strong)));
  border-radius: var(--radius-xs) var(--radius-md) var(--radius-md) var(--radius-xs);
  background: var(--embed-bg);
}

.embed-source {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.embed-source .i { width: 14px; height: 14px; }

.embed-title {
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}

.embed-desc {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-2);
}

.embed-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  margin-top: 4px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--link);
  text-decoration: none;
}

.embed-link .i { width: 14px; height: 14px; stroke-width: 2.4; }

@media (hover: hover) and (pointer: fine) {
  .embed-link:hover { text-decoration: underline; }
}

/* ---- Typing indicator -------------------------------------------------- */

.typing {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--dur) ease;
}

.typing.is-on { opacity: 1; }
.typing b { font-weight: 700; color: var(--text-2); }

.typing-dots { display: inline-flex; gap: 3px; }

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: typing-dot 1.2s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 150ms; }
.typing-dots i:nth-child(3) { animation-delay: 300ms; }

/* ---- Composer: the reply picker ---------------------------------------- */

.composer-box {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm);
  transition: box-shadow var(--dur) ease;
}

/* Your turn: the box takes the amber focus ring. */
.composer[data-state="choosing"] .composer-box {
  box-shadow:
    inset 0 0 0 1px color-mix(in oklab, var(--accent) 60%, var(--border-strong)),
    0 0 0 3px var(--accent-soft),
    var(--shadow-md);
}

.composer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.composer-reply {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.composer-reply .i { width: 14px; height: 14px; }
.composer-reply b { font-weight: 700; color: var(--text); }

.composer-hint {
  display: none;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 var(--border-strong);
  font: 700 var(--text-2xs) / 1 var(--font-ui);
  color: var(--text-muted);
}

.chip-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}

.chip {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 10px 10px 8px;
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  line-height: 1.4;
  color: var(--text);
  transition:
    background-color var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
  animation: arrive var(--dur) var(--ease-out) backwards;
}

.chip:nth-child(2) { animation-delay: 45ms; }
.chip:nth-child(3) { animation-delay: 90ms; }

.chip-key {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 var(--border-strong);
  font-size: var(--text-xs);
  font-weight: 800;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease;
}

.chip-send {
  display: none;
  width: 18px;
  height: 18px;
  color: var(--accent-ink);
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity var(--dur-fast) ease,
    transform var(--dur) var(--ease-out);
}

.chip:active { transform: scale(0.985); background: var(--surface-3); }

.chip:active .chip-key,
.chip:focus-visible .chip-key {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: inset 0 0 0 1px var(--accent-strong), 0 1px 0 var(--accent-strong);
}

.chip:focus-visible { outline-offset: -2px; }
.chip:disabled { opacity: 0.5; }

@media (hover: hover) and (pointer: fine) {
  .chip { grid-template-columns: 24px minmax(0, 1fr) 18px; }
  .chip-send { display: block; }
  .chip:hover { background: var(--surface-2); }
  .chip:hover .chip-key {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: inset 0 0 0 1px var(--accent-strong), 0 1px 0 var(--accent-strong);
  }
  .chip:hover .chip-send { opacity: 1; transform: none; }
}

.composer-idle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  font-size: var(--text-md);
  color: var(--text-faint);
}

.composer-idle > .i { width: 16px; height: 16px; flex: none; }

.composer-idle-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Skip ahead: brings the next line in now. */
.composer-skip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  height: 32px;
  margin-right: -6px;
  padding: 0 12px 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  transition:
    background-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-press) var(--ease-out);
}

.composer-skip .i { width: 13px; height: 13px; stroke-width: 2.4; }
.composer-skip:active { transform: scale(0.96); background: var(--surface-3); }
.composer-skip-key { display: none; margin-left: 2px; }

@media (hover: hover) and (pointer: fine) {
  .composer-skip:hover { background: var(--surface-3); color: var(--text); }
  .composer-skip-key { display: inline-grid; }
}

.composer:not([data-state="choosing"]) .composer-head,
.composer:not([data-state="choosing"]) .chip-list,
.composer[data-state="choosing"] .composer-idle { display: none; }

/* ---- Final report ------------------------------------------------------ */

[data-tier="solved"]   { --tier-color: var(--tier-solved); }
[data-tier="progress"] { --tier-color: var(--tier-progress); }
[data-tier="stalled"]  { --tier-color: var(--tier-stalled); }
[data-tier="crisis"]   { --tier-color: var(--tier-crisis); }

.report {
  --embed-rule: var(--tier-color);
  max-width: 38rem;
  padding: 14px 16px 16px 14px;
}

.report-tier {
  margin: 2px 0 8px;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: color-mix(in oklab, var(--tier-color) 82%, var(--text));
}

.report-text { font-size: var(--text-md); line-height: 1.55; color: var(--text-2); }

.report-shortfall {
  margin-top: 10px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.75rem, 1fr));
  gap: 6px;
  margin: 16px 0 6px;
}

.field {
  --metric-bg: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 10px 11px;
  border-radius: var(--radius-md);
  background: var(--metric-bg);
  box-shadow: inset 0 0 0 1px var(--border);
}

.field-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--text-muted);
}

.field-value {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.field-value .i { width: 16px; height: 16px; stroke-width: 3; color: var(--stat-good); }
.field[data-level="critical"] .field-value { color: var(--stat-critical); }

.summary { margin-top: 10px; border-top: 1px solid var(--border); }

.summary-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.summary-toggle .i {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease-out);
}

.summary-toggle[aria-expanded="true"] .i { transform: rotate(180deg); }

/* 0fr -> 1fr animates open without guessing a height. */
.summary-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-slow) var(--ease-out);
}

.summary-content.is-open { grid-template-rows: 1fr; }
.summary-panel { min-height: 0; overflow: hidden; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 6px;
  padding-bottom: 10px;
}

.chart-card {
  --chart-dot-ring: var(--surface);
  padding: 10px 12px 4px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}

.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.chart-card-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.chart-card .chart { height: 104px; }

.log { padding-bottom: 8px; }

.log-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

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

.log-num {
  padding-top: 1px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.log-headline { font-weight: 700; line-height: 1.4; }

.log-reply {
  margin-top: 4px;
  padding-left: 10px;
  line-height: 1.45;
  color: var(--text-muted);
  box-shadow: inset 2px 0 0 var(--accent);
}

.report-again { margin-top: 14px; }
