/* Practice Studio: Material Design 3 theme.
   Layout: single centred column (max 1040px); session view is a full-height
   chat column with a docked composer; review view stacks score panel, tabs. */

:root {
  /* M3 colour scheme, seed teal #006A60 (light) */
  --md-sys-color-primary: #006a60;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #9ef2e4;
  --md-sys-color-on-primary-container: #00201c;
  --md-sys-color-secondary: #4a635f;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #cce8e2;
  --md-sys-color-on-secondary-container: #05201c;
  --md-sys-color-tertiary: #456179;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #cce5ff;
  --md-sys-color-on-tertiary-container: #001e31;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-background: #f4fbf8;
  --md-sys-color-on-background: #171d1b;
  --md-sys-color-surface: #f4fbf8;
  --md-sys-color-on-surface: #171d1b;
  --md-sys-color-surface-variant: #dae5e1;
  --md-sys-color-on-surface-variant: #3f4947;
  --md-sys-color-outline: #6f7977;
  --md-sys-color-outline-variant: #bec9c6;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #eff5f2;
  --md-sys-color-surface-container: #e9efec;
  --md-sys-color-surface-container-high: #e3eae7;
  --md-sys-color-surface-container-highest: #dde4e1;
  --md-sys-color-inverse-surface: #2b3230;
  --md-sys-color-inverse-on-surface: #ecf2ef;
  --md-sys-color-inverse-primary: #82d5c8;
  --md-sys-color-shadow: #000000;
  --md-sys-color-scrim: #000000;

  /* App semantic colours (response ratings) */
  --app-strong: #2e6c2f;
  --app-strong-container: #c8eec0;
  --app-on-strong-container: #002204;
  --app-caution: #7d5700;
  --app-caution-container: #ffdea6;
  --app-on-caution-container: #271900;
  --app-miss: var(--md-sys-color-error);
  --app-miss-container: var(--md-sys-color-error-container);
  --app-on-miss-container: var(--md-sys-color-on-error-container);

  /* Emotion families */
  --emo-low: #3f5f90;
  --emo-tense: #8a5a00;
  --emo-hot: #b3261e;
  --emo-shame: #7b4e8e;
  --emo-ease: #2e6c2f;

  /* Type */
  --md-ref-typeface-brand: 'Roboto Flex Variable', 'Roboto', system-ui, sans-serif;
  --md-ref-typeface-plain: 'Roboto Flex Variable', 'Roboto', system-ui, sans-serif;
  --app-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Shape and motion */
  --app-shape-s: 8px;
  --app-shape-m: 12px;
  --app-shape-l: 16px;
  --app-shape-xl: 28px;
  --app-ease: cubic-bezier(0.2, 0, 0, 1);

  color-scheme: light;
}

/* Theme: light by default; dark when chosen, or when "System" is chosen and the device is dark. */
:root[data-theme="dark"] {
    --md-sys-color-primary: #82d5c8;
    --md-sys-color-on-primary: #003731;
    --md-sys-color-primary-container: #005048;
    --md-sys-color-on-primary-container: #9ef2e4;
    --md-sys-color-secondary: #b1ccc6;
    --md-sys-color-on-secondary: #1c3531;
    --md-sys-color-secondary-container: #334b47;
    --md-sys-color-on-secondary-container: #cce8e2;
    --md-sys-color-tertiary: #adcae5;
    --md-sys-color-on-tertiary: #153349;
    --md-sys-color-tertiary-container: #2d4961;
    --md-sys-color-on-tertiary-container: #cce5ff;
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;
    --md-sys-color-background: #0e1513;
    --md-sys-color-on-background: #dde4e1;
    --md-sys-color-surface: #0e1513;
    --md-sys-color-on-surface: #dde4e1;
    --md-sys-color-surface-variant: #3f4947;
    --md-sys-color-on-surface-variant: #bec9c6;
    --md-sys-color-outline: #899390;
    --md-sys-color-outline-variant: #3f4947;
    --md-sys-color-surface-container-lowest: #090f0e;
    --md-sys-color-surface-container-low: #171d1b;
    --md-sys-color-surface-container: #1b2120;
    --md-sys-color-surface-container-high: #252b2a;
    --md-sys-color-surface-container-highest: #303635;
    --md-sys-color-inverse-surface: #dde4e1;
    --md-sys-color-inverse-on-surface: #2b3230;
    --md-sys-color-inverse-primary: #006a60;

    --app-strong: #9dd593;
    --app-strong-container: #155218;
    --app-on-strong-container: #c8eec0;
    --app-caution: #f7bd48;
    --app-caution-container: #5e4100;
    --app-on-caution-container: #ffdea6;

    --emo-low: #a9c7ff;
    --emo-tense: #f7bd48;
    --emo-hot: #ffb4ab;
    --emo-shame: #e3b5f5;
    --emo-ease: #9dd593;

    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --md-sys-color-primary: #82d5c8;
    --md-sys-color-on-primary: #003731;
    --md-sys-color-primary-container: #005048;
    --md-sys-color-on-primary-container: #9ef2e4;
    --md-sys-color-secondary: #b1ccc6;
    --md-sys-color-on-secondary: #1c3531;
    --md-sys-color-secondary-container: #334b47;
    --md-sys-color-on-secondary-container: #cce8e2;
    --md-sys-color-tertiary: #adcae5;
    --md-sys-color-on-tertiary: #153349;
    --md-sys-color-tertiary-container: #2d4961;
    --md-sys-color-on-tertiary-container: #cce5ff;
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;
    --md-sys-color-background: #0e1513;
    --md-sys-color-on-background: #dde4e1;
    --md-sys-color-surface: #0e1513;
    --md-sys-color-on-surface: #dde4e1;
    --md-sys-color-surface-variant: #3f4947;
    --md-sys-color-on-surface-variant: #bec9c6;
    --md-sys-color-outline: #899390;
    --md-sys-color-outline-variant: #3f4947;
    --md-sys-color-surface-container-lowest: #090f0e;
    --md-sys-color-surface-container-low: #171d1b;
    --md-sys-color-surface-container: #1b2120;
    --md-sys-color-surface-container-high: #252b2a;
    --md-sys-color-surface-container-highest: #303635;
    --md-sys-color-inverse-surface: #dde4e1;
    --md-sys-color-inverse-on-surface: #2b3230;
    --md-sys-color-inverse-primary: #006a60;

    --app-strong: #9dd593;
    --app-strong-container: #155218;
    --app-on-strong-container: #c8eec0;
    --app-caution: #f7bd48;
    --app-caution-container: #5e4100;
    --app-on-caution-container: #ffdea6;

    --emo-low: #a9c7ff;
    --emo-tense: #f7bd48;
    --emo-hot: #ffb4ab;
    --emo-shame: #e3b5f5;
    --emo-ease: #9dd593;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: var(--md-ref-typeface-plain);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--md-sys-color-primary); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
[hidden] { display: none !important; }

md-icon { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
md-icon.filled { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 2px; }

/* ---------- Top app bar ---------- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--app-shape-m);
  background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
}
.top-bar__spacer { flex: 1; }
.demo-badge {
  padding: 4px 12px;
  border-radius: 8px;
  background: var(--app-caution-container);
  color: var(--app-on-caution-container);
  font: 500 0.75rem/1.4 var(--md-ref-typeface-plain);
  letter-spacing: 0.04em;
}

/* ---------- Page ---------- */
.view {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}
.page-head { display: grid; gap: 8px; margin-block: 16px 32px; }
.page-head p { color: var(--md-sys-color-on-surface-variant); }
.section { display: grid; gap: 16px; margin-bottom: 40px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.muted { color: var(--md-sys-color-on-surface-variant); }
.eyebrow {
  font: 500 0.75rem/1.3 var(--md-ref-typeface-plain);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--md-sys-color-primary);
}
.loading { display: grid; place-items: center; gap: 16px; padding: 80px 0; color: var(--md-sys-color-on-surface-variant); }

/* ---------- Cards ---------- */
.card {
  position: relative;
  border-radius: var(--app-shape-l);
  background: var(--md-sys-color-surface-container-low);
  padding: 20px;
  --md-elevation-level: 1;
}
.card--outlined { background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); }
.card--filled { background: var(--md-sys-color-surface-container-highest); }

.scenario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.scenario-card {
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 12px;
  border-radius: var(--app-shape-l);
  background: var(--md-sys-color-surface-container-low);
  padding: 20px; position: relative; cursor: pointer;
  --md-elevation-level: 1;
  transition: --md-elevation-level 200ms var(--app-ease);
}
.scenario-card:hover { --md-elevation-level: 2; }
.scenario-card__icon {
  width: 48px; height: 48px; border-radius: var(--app-shape-m);
  display: grid; place-items: center;
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
}
.scenario-card p { color: var(--md-sys-color-on-surface-variant); }
.scenario-card__roles { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); align-items: center; }

/* ---------- Lists ---------- */
.history { border-radius: var(--app-shape-l); overflow: hidden; background: var(--md-sys-color-surface-container-low); --md-list-container-color: transparent; }
.score-badge {
  min-width: 48px; height: 32px; padding-inline: 10px; border-radius: 16px;
  display: inline-grid; place-items: center;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  font: 500 0.875rem/1 var(--md-ref-typeface-plain); font-variant-numeric: tabular-nums;
}
.score-badge--pending { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }
.empty { padding: 32px; text-align: center; color: var(--md-sys-color-on-surface-variant); display: grid; gap: 8px; justify-items: center; }

/* ---------- Dialog form ---------- */
.form { display: grid; gap: 20px; min-width: min(480px, 80vw); padding-top: 8px; }
.form md-outlined-select, .form md-outlined-text-field { width: 100%; }

/* ---------- Session (live) ---------- */
.session { display: grid; grid-template-rows: auto 1fr auto; height: calc(100dvh - 64px - 24px - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 420px; gap: 12px; }
.session-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-head__title { flex: 1; min-width: 0; }
.session-head__title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-family: var(--app-font-mono); font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface-variant); padding-inline: 8px; }

.chat {
  overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--app-shape-xl);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  scroll-behavior: smooth;
}
.opening { align-self: center; max-width: 52ch; text-align: center; color: var(--md-sys-color-on-surface-variant); display: grid; gap: 8px; justify-items: center; padding: 24px 8px; }
.opening md-icon { font-size: 40px; width: 40px; height: 40px; color: var(--md-sys-color-primary); }

.bubble { max-width: min(76ch, 90%); display: flex; align-items: flex-end; gap: 10px; animation: rise 240ms var(--app-ease); }
.bubble__body { display: grid; gap: 6px; min-width: 0; }
.bubble > .portrait { margin-bottom: 2px; }
.bubble__who { font: 500 0.75rem/1.3 var(--md-ref-typeface-plain); letter-spacing: 0.04em; color: var(--md-sys-color-on-surface-variant); display: flex; gap: 8px; align-items: center; }
.bubble__text { padding: 12px 16px 8px; border-radius: 20px; overflow-wrap: anywhere; display: grid; gap: 2px; }
.bubble__words { white-space: pre-wrap; }
.bubble--learner { align-self: flex-end; flex-direction: row-reverse; }
.bubble--learner .bubble__body { justify-items: end; }
.bubble--learner .bubble__text { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border-bottom-right-radius: 6px; }
.bubble--partner { align-self: flex-start; }
.bubble--partner .bubble__text { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); border-bottom-left-radius: 6px; }
.bubble--partial .bubble__text { background: transparent; border: 1px dashed var(--md-sys-color-outline); color: var(--md-sys-color-on-surface-variant); }
.typing { display: inline-flex; gap: 4px; padding: 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.4; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

.composer { display: grid; gap: 8px; }
.composer__status { min-height: 20px; font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.mic-meter { width: 72px; height: 8px; border-radius: 4px; background: var(--md-sys-color-surface-container-highest); overflow: hidden; flex: none; }
.mic-meter__bar { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--md-sys-color-primary); transform-origin: left; transform: scaleX(var(--level, 0)); transition: transform 80ms linear; }
.send-now { --md-text-button-container-height: 32px; }
.mic-help { --md-text-button-container-height: 32px; }
.demo-fab { margin-left: auto; }
.settings-heading { margin: 8px 0 -4px; color: var(--md-sys-color-primary); }
.mic-meter--wide { width: 100%; height: 12px; border-radius: 6px; display: block; }
.mic-check { max-width: 520px; }
.mic-check__level { padding: 4px 0; }
.mic-check__verdict { padding: 12px 16px; border-radius: 12px; background: var(--md-sys-color-surface-container-high); }
.mic-check__verdict.is-good, .is-good strong { color: var(--app-strong); }
.mic-check__verdict.is-bad, .is-bad strong { color: var(--app-miss); }
.mic-check__words { min-height: 1.5em; font-style: italic; margin: 0; }
.composer__row { display: flex; align-items: center; gap: 8px; }
.composer__row md-outlined-text-field { flex: 1; min-width: 0; --md-outlined-text-field-container-shape: 28px; }
.mic-fab.listening { animation: pulse 1.6s infinite; --md-fab-primary-container-color: var(--md-sys-color-error-container); --md-fab-primary-icon-color: var(--md-sys-color-on-error-container); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--md-sys-color-error) 40%, transparent); } 50% { box-shadow: 0 0 0 12px transparent; } }
@keyframes blink { 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Emotion chips ---------- */
.emo { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 8px; font: 500 0.75rem/1.5 var(--md-ref-typeface-plain); border: 1px solid currentColor; text-transform: capitalize; }
.emo::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.emo--low { color: var(--emo-low); }
.emo--tense { color: var(--emo-tense); }
.emo--hot { color: var(--emo-hot); }
.emo--shame { color: var(--emo-shame); }
.emo--ease { color: var(--emo-ease); }

/* ---------- Review ---------- */
.review-head { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-block: 8px 24px; }
.review-head__title { flex: 1; min-width: 220px; display: grid; gap: 4px; }
.review-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.score-panel { display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center; }
@media (max-width: 640px) { .score-panel { grid-template-columns: 1fr; justify-items: center; } .score-panel .criteria { width: 100%; } }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--md-sys-color-surface-container-highest); }
.ring__value { stroke: var(--md-sys-color-primary); stroke-linecap: round; transition: stroke-dashoffset 900ms var(--app-ease); }
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__num { font: 400 3rem/1 var(--md-ref-typeface-brand); font-variant-numeric: tabular-nums; }
.ring__max { color: var(--md-sys-color-on-surface-variant); font-size: 0.875rem; }

.criteria { display: grid; gap: 14px; }
.criterion { display: grid; gap: 6px; }
.criterion__row { display: flex; justify-content: space-between; gap: 12px; }
.criterion__score { font-variant-numeric: tabular-nums; font-weight: 500; }
.criterion md-linear-progress { --md-linear-progress-track-height: 8px; --md-linear-progress-active-indicator-height: 8px; --md-linear-progress-track-shape: 4px; width: 100%; }

.summary-text { margin-top: 20px; }

md-tabs { margin-top: 24px; --md-primary-tab-container-color: transparent; background: var(--md-sys-color-surface); }
.tab-panel { padding-top: 24px; display: grid; gap: 24px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); }
.legend__item { display: inline-flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }
.swatch--learner { background: var(--md-sys-color-primary-container); border: 1px solid var(--md-sys-color-primary); }
.swatch--partner { background: var(--md-sys-color-tertiary-container); border: 1px solid var(--md-sys-color-tertiary); }
.swatch--strong { background: var(--app-strong); }
.swatch--caution { background: var(--app-caution); }
.swatch--miss { background: var(--app-miss); }

.playbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.turns { display: grid; gap: 8px; }
.turn {
  display: grid; grid-template-columns: 4px 1fr; gap: 0 14px;
  padding: 12px 16px 12px 12px; border-radius: var(--app-shape-m);
  background: var(--md-sys-color-surface-container-low);
  transition: background 200ms var(--app-ease), box-shadow 200ms var(--app-ease);
  scroll-margin-top: 140px;
}
.turn__stripe { grid-row: 1 / span 6; border-radius: 2px; background: var(--md-sys-color-outline-variant); }
.turn--learner { background: color-mix(in srgb, var(--md-sys-color-primary-container) 45%, var(--md-sys-color-surface)); }
.turn--partner { background: color-mix(in srgb, var(--md-sys-color-tertiary-container) 45%, var(--md-sys-color-surface)); }
.turn--partner .turn__stripe { background: var(--md-sys-color-tertiary); }
/* Laid out like the chat: the learner's turns sit to the right, the partner's to the left. */
.turns .turn--learner { margin-left: clamp(24px, 12%, 120px); }
.turns .turn--partner { margin-right: clamp(24px, 12%, 120px); }
.turn.rating-strong .turn__stripe { background: var(--app-strong); }
.turn.rating-okay .turn__stripe { background: var(--md-sys-color-primary); }
.turn.rating-caution .turn__stripe { background: var(--app-caution); }
.turn.rating-miss .turn__stripe { background: var(--app-miss); }
.turn.playing { box-shadow: 0 0 0 2px var(--md-sys-color-primary); }
.turn.flash { animation: flash 1.2s var(--app-ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--md-sys-color-primary); } 100% { box-shadow: 0 0 0 0 transparent; } }
.turn__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
.turn__who { font-weight: 500; }
.turn__id { font-family: var(--app-font-mono); font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.turn__text { overflow-wrap: anywhere; }
/* Local time each message was said, small in the bottom right corner */
.msg-time { justify-self: end; font-size: 0.6875rem; line-height: 1; letter-spacing: 0.02em; color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 85%, transparent); font-variant-numeric: tabular-nums; }
.turn .msg-time { grid-column: 2; margin-top: 6px; cursor: help; }
.bubble .msg-time { color: color-mix(in srgb, currentColor 65%, transparent); }
.turn__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.turn__detail { margin-top: 10px; display: grid; gap: 8px; font-size: 0.9375rem; }
.turn__toggle { justify-self: start; margin-top: 4px; }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 8px; font: 500 0.75rem/1.6 var(--md-ref-typeface-plain); }
.tag--strong { background: var(--app-strong-container); color: var(--app-on-strong-container); }
.tag--caution { background: var(--app-caution-container); color: var(--app-on-caution-container); }
.tag--miss { background: var(--app-miss-container); color: var(--app-on-miss-container); }
.tag--neutral { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }

.better { border-left: 3px solid var(--app-strong); padding: 6px 12px; background: var(--md-sys-color-surface-container-lowest); border-radius: 0 8px 8px 0; }
.better strong { color: var(--app-strong); font-weight: 500; }

.arc { width: 100%; height: auto; display: block; }
.arc { max-height: 260px; }
.arc text { fill: var(--md-sys-color-on-surface-variant); font: 12px var(--md-ref-typeface-plain); }
.arc .grid { stroke: var(--md-sys-color-outline-variant); stroke-dasharray: 2 4; }
.arc .line { fill: none; stroke: var(--md-sys-color-tertiary); stroke-width: 2.5; stroke-linejoin: round; }
.arc .area { fill: color-mix(in srgb, var(--md-sys-color-tertiary) 14%, transparent); }
.arc circle { stroke: var(--md-sys-color-surface); stroke-width: 2; cursor: pointer; }

.feedback-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.feedback-grid > *, .card, .improvement { min-width: 0; }
/* Cards with long evidence quotes stay within the screen; the quotes are shortened with an ellipsis. */
.criteria-cards { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.criteria-cards > .card { grid-template-columns: minmax(0, 1fr); }
.evidence { min-width: 0; }
.label-short { display: none; }
.plain-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
/* What went well: ticks instead of bullets */
.tick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tick-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.tick-list md-icon { --md-icon-size: 22px; color: var(--app-strong); margin-top: 1px; }
.improvement { display: grid; gap: 8px; padding: 16px; border-radius: var(--app-shape-m); background: var(--md-sys-color-surface-container); }
.quote { font-style: italic; color: var(--md-sys-color-on-surface-variant); }
.evidence { display: flex; flex-wrap: wrap; gap: 6px; }
.evidence button {
  all: unset; cursor: pointer; padding: 4px 10px; border-radius: 8px;
  background: var(--md-sys-color-surface-container-highest); font-size: 0.8125rem; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.evidence button:hover { background: var(--md-sys-color-secondary-container); }
.evidence button:focus-visible { outline: 2px solid var(--md-sys-color-primary); }

.objective { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; padding: 16px; border-radius: var(--app-shape-m); background: var(--md-sys-color-surface-container-low); }
.objective md-icon { grid-row: span 2; }
.objective--met md-icon { color: var(--app-strong); }
.objective--partial md-icon { color: var(--app-caution); }
.objective--not-met md-icon { color: var(--md-sys-color-outline); }

.persona { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 12px 24px; }
@media (max-width: 560px) { .persona { grid-template-columns: 1fr; gap: 4px; } .persona dd { margin-bottom: 12px; } }
.persona dt { color: var(--md-sys-color-on-surface-variant); font-size: 0.875rem; }
.persona dd { margin: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.kv dt { color: var(--md-sys-color-on-surface-variant); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--app-shape-m); background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.notice--error { background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container); }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: min(560px, calc(100vw - 32px));
  padding: 14px 20px; border-radius: 4px;
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.25);
  animation: rise 200ms var(--app-ease);
}

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

/* ---------- Activity loader (long waits) ---------- */
.activity { display: grid; justify-items: center; gap: 16px; padding: 56px 16px 32px; text-align: center; color: var(--md-sys-color-on-surface); }
.activity__orb { position: relative; width: 168px; height: 168px; display: grid; place-items: center; margin-bottom: 8px; }
.activity__ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--md-sys-color-primary); opacity: 0; animation: activity-ring 2.7s cubic-bezier(.2, .6, .3, 1) infinite; }
.activity__ring:nth-child(2) { animation-delay: .9s; }
.activity__ring:nth-child(3) { animation-delay: 1.8s; }
.activity__arc { position: absolute; inset: 26px; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 62%, var(--md-sys-color-tertiary) 100%); -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); animation: activity-spin 1.4s linear infinite; }
.activity__core { position: relative; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--md-sys-color-primary) 55%, white), var(--md-sys-color-primary) 70%); box-shadow: 0 10px 30px color-mix(in srgb, var(--md-sys-color-primary) 35%, transparent); animation: activity-breathe 2.7s ease-in-out infinite; }
.activity__core md-icon { color: var(--md-sys-color-on-primary); --md-icon-size: 44px; }
.activity__title { margin: 0; }
.activity__line { margin: 0; min-height: 1.5em; color: var(--md-sys-color-on-surface-variant); transition: opacity .25s, transform .25s; }
.activity__line.is-changing { opacity: 0; transform: translateY(4px); }
.activity__bar { width: min(340px, 80vw); --md-linear-progress-track-shape: 4px; }
.activity__done { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; min-height: 84px; color: var(--md-sys-color-on-surface-variant); font-size: .875rem; }
.activity__done li { display: flex; align-items: center; justify-content: center; gap: 6px; opacity: .8; animation: rise .35s ease-out; }
.activity__done md-icon { --md-icon-size: 18px; color: var(--app-strong); }
@keyframes activity-ring { 0% { transform: scale(.5); opacity: .75; } 100% { transform: scale(1.2); opacity: 0; } }
@keyframes activity-spin { to { transform: rotate(1turn); } }
@keyframes activity-breathe { 0%, 100% { transform: scale(.96); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .activity__ring, .activity__arc, .activity__core { animation: none; }
  .activity__ring { opacity: .25; }
}

/* ---------- Portraits ---------- */
.portrait { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--md-sys-color-surface), 0 1px 3px rgba(0, 0, 0, .12); }
.portrait svg { width: 100%; height: 100%; display: block; }
.portrait--you { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.portrait--you md-icon { --md-icon-size: 1em; }
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.profile-head h3 { margin: 0 0 4px; }
.profile-head p { margin: 0; max-width: 60ch; }
.turn__meta .portrait { box-shadow: none; }

/* Quick tooltips: appear after 0.45 s (about half the browser's own delay) */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none;
  font: 400 0.75rem/1.3 var(--md-ref-typeface-plain, inherit); letter-spacing: normal; font-weight: 400;
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease; transition-delay: 0s;
}
[data-tip]:hover::after { opacity: 1; transform: none; transition-delay: .45s; }

/* ---------- Admin ---------- */
.admin-head { display: flex; gap: 8px; align-items: flex-start; }
.admin-toolbar { margin: 0 0 20px; }
.admin-picker { min-width: min(360px, 100%); }
.admin-area { display: grid; gap: 16px; }
.admin-tabs { margin: 0; background: transparent; --md-primary-tab-container-color: transparent; }
.admin-card { display: grid; gap: 16px; padding: 24px; }
.admin-card > h2 { margin: 0; }
.admin-intro { margin: -8px 0 0; }
.admin-field { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--md-sys-color-outline-variant); }
.admin-field__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-field__head h3 { margin: 0; }
.admin-help { margin: -4px 0 0; font-size: .875rem; }
.admin-field__body md-outlined-text-field, .admin-field__body md-outlined-select { width: 100%; }
.admin-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-error { color: var(--md-sys-color-error); margin: 0; }
.admin-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.admin-fixed { padding: 12px 16px; border-radius: 12px; background: var(--md-sys-color-surface-container-high); }
.admin-fixed__label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin-bottom: 4px; }
.admin-fixed__label md-icon { --md-icon-size: 18px; }
.admin-fixed p { margin: 0; font-size: .875rem; color: var(--md-sys-color-on-surface-variant); }
.admin-choices { display: grid; gap: 16px; }
.admin-choice-group { display: grid; gap: 10px; }
.admin-choice-group h4 { margin: 4px 0 0; color: var(--md-sys-color-primary); }
.admin-list { display: grid; gap: 10px; }
.admin-list__rows { display: grid; gap: 10px; }
.admin-list__row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; padding: 12px; border-radius: 12px; background: var(--md-sys-color-surface-container); }
.admin-list__fields { display: flex; flex-wrap: wrap; gap: 10px; }
.admin-list__fields > * { flex: 1 1 100%; min-width: 0; }
.admin-list__fields > .admin-list__half { flex: 1 1 calc(50% - 10px); }
.admin-list__fields > .admin-list__narrow { flex: 0 1 140px; }
.admin-list > md-text-button { justify-self: start; }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  /* Session header: title on the first row, the clock and buttons on the second */
  .session-head { gap: 4px 8px; }
  .session-head__title { flex: 1 1 calc(100% - 120px); }
  .session-head .eyebrow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .session-head__title h1 { font-size: 1.125rem; line-height: 1.4; }
  .session-head .timer { margin-left: auto; }
  .session-head .portrait { width: 36px !important; height: 36px !important; }
  /* Tabs share the width instead of scrolling off the edge */
  md-tabs md-primary-tab { flex: 1 1 0; min-width: 0; }
  .label-long { display: none; }
  .label-short { display: inline; }
  .view { padding-top: 16px; }
  .admin-card { padding: 16px; }
  .turns .turn--learner { margin-left: 16px; }
  .turns .turn--partner { margin-right: 16px; }
  .profile-head { gap: 14px; }
}
/* Very narrow: the header keeps the logo and buttons; the app name would wrap. */
@media (max-width: 420px) {
  .brand__name { display: none; }
}

/* ---------- Sign in ---------- */
body.signed-out .top-bar { display: none; }
.signin-wrap { display: grid; place-items: center; min-height: calc(100dvh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.signin { width: min(400px, 100%); display: grid; gap: 14px; padding: 28px; text-align: center; }
.signin h1 { margin: 4px 0 0; }
.signin p { margin: 0; }
.signin md-outlined-text-field, .signin md-filled-button { width: 100%; }
.signin__mark { justify-self: center; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.signin__error { color: var(--md-sys-color-error); text-align: left; }
.account p { margin: 0 0 8px; }

/* ---------- Users ---------- */
.users-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.users-wrap { overflow-x: auto; }
.users { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.users th { text-align: left; font: 500 .75rem/1.3 var(--md-ref-typeface-plain, inherit); letter-spacing: .04em; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); padding: 8px 10px; border-bottom: 1px solid var(--md-sys-color-outline-variant); white-space: nowrap; }
.users td { padding: 10px; border-bottom: 1px solid var(--md-sys-color-outline-variant); vertical-align: middle; }
.users code { font-family: var(--app-font-mono); font-size: .875rem; }
.users__name { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.users__initial { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); font-size: .8125rem; font-weight: 600; flex: none; }
.users__actions { white-space: nowrap; text-align: right; }
md-filled-button.danger { --md-filled-button-container-color: var(--md-sys-color-error); --md-filled-button-label-text-color: var(--md-sys-color-on-error); }
/* On phones each user becomes a card */
@media (max-width: 760px) {
  .users thead { display: none; }
  .users, .users tbody, .users tr, .users td { display: block; width: 100%; }
  .users tr { margin-bottom: 12px; padding: 12px 14px; border-radius: 16px; background: var(--md-sys-color-surface-container-low); }
  .users td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .users td::before { content: attr(data-label); color: var(--md-sys-color-on-surface-variant); text-align: left; font-size: .8125rem; }
  .users td:first-child { justify-content: flex-start; text-align: left; padding-bottom: 10px; }
  .users td:first-child::before { content: none; }
  .users__actions { justify-content: flex-end !important; padding-top: 4px !important; }
  .users__actions::before { content: none !important; }
}
