:root {
  --family-my: #4f8a3a;
  --family-your-sg: #3669c9;
  --family-his: #4c3a8e;
  --family-her: #8d3e64;
  --family-our: #2f3445;
  --family-your-pl: #bb7430;
  --family-their: #285f70;
}

.page-nav-link.nav-launcher {
  background: transparent;
  color: var(--accent, #bf5c39);
  font-weight: 600;
  border: 1px solid var(--accent, #bf5c39);
}

.page-nav-link.nav-launcher:hover {
  background: var(--accent, #bf5c39);
  color: #fff;
}

body.possessives-page {
  background:
    radial-gradient(circle at top left, rgba(79, 138, 58, 0.14), transparent 26%),
    radial-gradient(circle at top right, rgba(54, 105, 201, 0.12), transparent 30%),
    linear-gradient(180deg, #fbf8f1 0%, #efe7d8 100%);
}

.possessives-page .is-hidden {
  display: none !important;
}

.possessives-page .orb-a {
  background: rgba(79, 138, 58, 0.15);
}

.possessives-page .orb-b {
  background: rgba(54, 105, 201, 0.12);
}

/* ─── Step Navigator ───────────────────────────────────────── */

.step-nav {
  display: flex;
  gap: 6px;
  padding: 0 0 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.step-nav::-webkit-scrollbar {
  display: none;
}

.scope-strip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(79, 138, 58, 0.16);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(79, 138, 58, 0.12), rgba(255, 255, 255, 0.64)),
    rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.scope-strip strong {
  color: var(--ink);
  white-space: nowrap;
}

.step-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(49, 37, 28, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease,
    border-color 160ms ease;
  white-space: nowrap;
}

.step-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.8);
}

.step-btn:active {
  transform: translateY(1px) scale(0.98);
}

.step-btn.is-active {
  background: var(--ink);
  color: #fffaf4;
  border-color: var(--ink);
  box-shadow: 0 6px 16px rgba(31, 26, 23, 0.18);
}

.step-btn.is-recommended {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(26, 111, 105, 0.08);
}

.step-auto-btn {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 0.5rem 0.7rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(31, 26, 23, 0.08);
  font-size: 0.76rem;
  font-weight: 700;
  color: inherit;
}

.step-btn.is-active .step-num {
  background: rgba(255, 255, 255, 0.22);
}

.step-label {
  color: inherit;
}

/* ─── Metrics Sidebar ──────────────────────────────────────── */

.metrics-sidebar {
  display: grid;
  gap: 0.6rem;
}

.metrics-mini {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-mini-row {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.7rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(49, 37, 28, 0.08);
}

.metric-mini-row span {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.2;
}

.metric-mini-row strong {
  font-size: 0.98rem;
}

.reset-btn {
  font-size: 0.84rem;
  min-height: 38px;
  padding: 0.55rem 0.8rem;
}

/* ─── Practice Panel ───────────────────────────────────────── */

.possessives-page .practice-panel {
  padding: clamp(16px, 3vw, 28px);
}

.possessive-support {
  display: grid;
  gap: 0.85rem;
  padding: 18px;
}

.possessive-support .microcopy {
  max-width: 42ch;
}

.possessive-learn-grid .matrix-panel {
  grid-column: 1 / -1;
}

/* ─── Reference Matrix ─────────────────────────────────────── */

.reference-matrix {
  display: grid;
  grid-template-columns: minmax(82px, 0.8fr) repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 1.4rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.45rem;
}

.matrix-head,
.matrix-owner,
.matrix-cell {
  border-radius: var(--radius-md);
  border: 1px solid rgba(49, 37, 28, 0.08);
}

.matrix-head,
.matrix-owner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
  background: rgba(31, 26, 23, 0.04);
  text-align: center;
  font-weight: 700;
}

.matrix-head span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.matrix-owner {
  font-size: 1.15rem;
  color: var(--family-color, var(--ink));
}

.matrix-cell {
  appearance: none;
  font: inherit;
  text-align: left;
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0.4rem;
  align-content: space-between;
  min-height: 94px;
  padding: 0.9rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.52)),
    linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.matrix-cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(49, 37, 28, 0.1);
}

.matrix-cell:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--family-color) 70%, white);
  outline-offset: 3px;
}

.matrix-cell:active {
  transform: scale(0.97);
}

.matrix-cell::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: calc(var(--mastery, 0) * 100%);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), color-mix(in srgb, var(--family-color) 22%, white));
  opacity: 0.9;
}

.matrix-cell > * {
  position: relative;
  z-index: 1;
}

.matrix-word {
  font-family: "Literata", serif;
  font-size: 1.55rem;
  color: var(--family-color);
}

.matrix-percent {
  color: var(--muted);
  font-size: 0.78rem;
}

.matrix-cell.is-active {
  border-color: color-mix(in srgb, var(--family-color) 58%, black);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--family-color) 24%, white);
  transform: translateY(-1px);
}

/* ─── Family Colors ────────────────────────────────────────── */

.family-my {
  --family-color: var(--family-my);
}
.family-your-sg {
  --family-color: var(--family-your-sg);
}
.family-his {
  --family-color: var(--family-his);
}
.family-her {
  --family-color: var(--family-her);
}
.family-our {
  --family-color: var(--family-our);
}
.family-your-pl {
  --family-color: var(--family-your-pl);
}
.family-their {
  --family-color: var(--family-their);
}

/* ─── Prompt & Chips ───────────────────────────────────────── */

.translation-line {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.prompt-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 1rem;
}

.prompt-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.05);
  color: var(--muted);
  font-size: 0.88rem;
}

.prompt-chip strong {
  color: var(--ink);
  margin-right: 0.35rem;
}

.prompt-chip[class*="family-"] {
  background: color-mix(in srgb, var(--family-color) 14%, white);
  color: color-mix(in srgb, var(--family-color) 68%, black);
}

.prompt-chip[class*="family-"] strong {
  color: inherit;
}

/* ─── Typing Area ──────────────────────────────────────────── */

.typing-area {
  display: grid;
  gap: 0.55rem;
}

.typing-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.typing-input {
  flex: 1;
  min-height: 52px;
  padding: 0.75rem 1rem;
  border: 2px solid rgba(49, 37, 28, 0.14);
  border-radius: 16px;
  background: #fffaf2;
  color: var(--ink);
  font-family: "Literata", serif;
  font-size: 1.25rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.typing-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 111, 105, 0.12);
}

.typing-input::placeholder {
  color: rgba(93, 81, 73, 0.45);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
}

.typing-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing-submit-btn {
  flex: 0 0 auto;
  min-width: 80px;
  font-size: 0.92rem;
}

/* ─── Listening Controls ───────────────────────────────────── */

.listening-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  padding: 0.5rem 0;
}

.listen-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 54px;
  padding: 0.8rem 1.8rem;
  border: 2px solid rgba(26, 111, 105, 0.2);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(26, 111, 105, 0.08), rgba(26, 111, 105, 0.04));
  color: var(--teal);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.listen-play-btn:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(26, 111, 105, 0.14), rgba(26, 111, 105, 0.08));
  box-shadow: 0 8px 20px rgba(26, 111, 105, 0.15);
}

.listen-play-btn:active {
  transform: translateY(1px) scale(0.98);
}

.listen-clue-btn {
  min-height: 50px;
  padding-inline: 1rem;
}

.play-icon {
  font-size: 1.15rem;
}

.listen-placeholder {
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  font-style: italic;
}

.listen-fallback {
  font-family: "Literata", serif;
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
}

.listen-revealed {
  font-family: "Literata", serif;
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  color: var(--teal);
}

/* ─── Options Grid Override ────────────────────────────────── */

.possessives-page .practice-options-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ─── Speed Bands ──────────────────────────────────────────── */

.speed-band-list {
  display: grid;
  gap: 10px;
  margin-top: 1rem;
}

.speed-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(49, 37, 28, 0.08);
}

.speed-band strong {
  font-size: 0.96rem;
}

.speed-band span {
  color: var(--muted);
  text-align: right;
}

/* ─── Family Mastery ───────────────────────────────────────── */

.family-mastery-grid {
  display: grid;
  gap: 10px;
}

.family-card {
  display: grid;
  gap: 0.4rem;
  padding: 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(31, 26, 23, 0.04);
  border: 1px solid rgba(49, 37, 28, 0.08);
  color: var(--family-color, var(--ink));
}

.family-card strong {
  font-family: "Literata", serif;
  font-size: 1.2rem;
  color: var(--family-color);
}

.family-card small,
.family-card span {
  color: var(--muted);
}

.family-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.08);
  overflow: hidden;
}

.family-track-fill {
  display: block;
  height: 100%;
  width: calc(var(--mastery, 0) * 100%);
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--family-color) 84%, white), var(--family-color));
}

/* ─── Weak Spots ───────────────────────────────────────────── */

.weak-spot-item .weak-title {
  font-family: "Literata", serif;
  font-size: 1.1rem;
}

.weak-spot-item .weak-line {
  color: var(--muted);
  font-size: 0.92rem;
}

/* ─── Desktop (720px+) ─────────────────────────────────────── */

@media (min-width: 720px) {
  .step-nav {
    gap: 8px;
    padding-bottom: 12px;
  }

  .possessives-page .practice-grid {
    grid-template-columns: 1.35fr 0.85fr;
  }
}

/* ─── Medium screens ───────────────────────────────────────── */

@media (max-width: 900px) {
  .reference-matrix {
    grid-template-columns: minmax(70px, 0.9fr) repeat(4, minmax(92px, 1fr));
  }

  .matrix-word {
    font-size: 1.3rem;
  }
}

/* ─── Mobile (< 720px) ────────────────────────────────────── */

@media (max-width: 719px) {
  .possessives-page .page-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 8px 10px;
    gap: 8px;
    scroll-padding-inline: 10px;
  }

  .possessives-page .page-nav::-webkit-scrollbar {
    display: block;
    height: 4px;
  }

  .possessives-page .page-nav-link {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0.52rem 0.76rem;
    font-size: 0.8rem;
  }

  .possessives-page .app-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .practice-panel {
    order: 1;
  }

  .possessive-support {
    order: 2;
  }

  .possessive-learn-grid {
    order: 3;
    min-width: 0;
    overflow-x: clip;
  }

  .anchor-panel {
    order: 4;
  }

  /* Step nav mobile */
  .step-nav {
    gap: 5px;
    padding-bottom: 8px;
    scrollbar-width: thin;
  }

  .step-nav::-webkit-scrollbar {
    display: block;
    height: 4px;
  }

  .step-btn {
    min-height: 36px;
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .step-num {
    width: 19px;
    height: 19px;
    font-size: 0.7rem;
  }

  .step-auto-btn {
    font-size: 0.68rem;
    padding: 0.4rem 0.55rem;
  }

  .scope-strip {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.84rem;
  }

  .scope-strip strong {
    white-space: normal;
  }

  /* Metrics */
  .metrics-mini {
    gap: 6px;
  }

  .metric-mini-row {
    padding: 0.5rem 0.55rem;
  }

  /* Practice */
  .possessives-page .practice-panel {
    padding: 12px;
  }

  .prompt-card {
    gap: 0.65rem;
    padding: 12px;
  }

  .prompt-toolbar {
    min-height: 42px;
  }

  .translation-line {
    margin-top: 0.45rem;
  }

  .prompt-chip-row {
    gap: 6px;
    margin-top: 0.65rem;
  }

  .prompt-chip {
    min-height: 30px;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }

  .prompt-label,
  .sidebar-kicker {
    margin-bottom: 0.35rem;
  }

  .possessives-page .prompt-text {
    font-size: clamp(1.45rem, 8vw, 1.95rem);
  }

  .possessives-page .option-button {
    min-height: 44px;
    padding: 0.62rem 0.7rem;
    border-radius: 14px;
    font-size: 1.05rem;
  }

  .practice-options {
    gap: 0.4rem;
  }

  .practice-options,
  .typing-area {
    order: 4;
  }

  .hint-row {
    order: 5;
  }

  .feedback-card {
    order: 6;
  }

  .action-row {
    order: 7;
  }

  .possessives-page .practice-options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Typing */
  .typing-input-row {
    flex-direction: column;
    gap: 8px;
  }

  .typing-input {
    min-height: 48px;
    font-size: 1.15rem;
  }

  .typing-submit-btn {
    min-height: 48px;
  }

  /* Listening */
  .listen-play-btn {
    min-height: 50px;
    padding: 0.7rem 1.4rem;
    font-size: 0.92rem;
  }

  /* Reference matrix */
  .reference-matrix {
    grid-template-columns: 66px repeat(4, 88px);
    gap: 6px;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .matrix-head,
  .matrix-owner,
  .matrix-cell {
    min-width: 0;
  }

  .matrix-cell {
    min-height: 72px;
    padding: 0.6rem;
  }

  .matrix-panel {
    overflow-x: hidden;
  }

  .matrix-word {
    font-size: 1.18rem;
  }

  /* Speed bands */
  .speed-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .possessive-support {
    padding: 14px 16px;
  }
}


/* ─── Phase transition banner ────────────────────────────── */

.phase-banner {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 28px;
  border-radius: 16px;
  background: rgba(31, 26, 23, 0.92);
  color: #fffaf4;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
  pointer-events: none;
  text-align: center;
}

.phase-banner.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.phase-banner strong {
  font-size: 1.05rem;
}

.phase-banner span {
  font-size: 0.88rem;
  opacity: 0.78;
}


/* ─── Session summary overlay ────────────────────────────── */

.session-summary-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 26, 23, 0.45);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.session-summary-overlay.is-visible {
  opacity: 1;
}

.session-summary-card {
  background: var(--panel-strong, rgba(255, 251, 244, 0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 32px;
  max-width: 380px;
  width: calc(100% - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.session-summary-card h3 {
  margin: 0 0 16px;
  font-size: 1.3rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.summary-stat strong {
  font-size: 1.4rem;
}

.summary-stat span {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted, #5d5048);
}

.summary-note {
  margin: 0 0 16px;
  font-size: 0.92rem;
  color: var(--muted, #5d5048);
  line-height: 1.45;
}

.summary-dismiss {
  min-width: 140px;
}
