/**
 * Brain-Resonance App — Family CI layer (Schritt 1)
 * Aligns existing SPA tokens with Landing / Master Design System.
 * Does NOT replace structure yet (sidebar/overview = later steps).
 *
 * Backup before this work:
 *   Desktop/Backups/brain-resonance-app-pre-layout-*
 *
 * Load AFTER css/styles.css so variables cascade into existing rules.
 * Fonts: load IBM Plex in index.html (preconnect + stylesheet).
 */

:root {
  /* Surfaces — warm cream family */
  --bg: #efe9dd;
  --surface: #ffffff;
  --surface-soft: #fdf9f1;
  --surface-muted: #f3ede1;

  /* Ink */
  --text: #33291c;
  --muted: #6e6353;
  --muted-2: #9c8f77;

  /* Brand (Master CI — same as Landing) */
  --primary: #275f8f;
  --primary-dark: #1f5080;
  --primary-soft: #e9f0f6;
  --accent: #d39c0c;
  --accent-deep: #c08a10;
  --success: #4fa754;
  --warning: #c08a10;
  --danger: #c72927;

  /* Lines & elevation */
  --border: #eadfca;
  --border-gold: #ecd9a8;
  --shadow: 0 3px 10px rgba(51, 41, 28, 0.05);
  --shadow-float: 0 10px 26px rgba(51, 41, 28, 0.12);

  /* Shape */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* Type — IBM Plex when available, else system */
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  /* Focus (a11y) */
  --focus-ring: 0 0 0 2px #9ec1dd;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* App shell surface */
.app {
  background: var(--bg);
}

/* Primary CTAs already use var(--primary) — hover via --primary-dark */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(39, 95, 143, 0.22);
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
}
.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: var(--surface-muted);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

/* Bottom / top tabs: cream bar, gold active */
.tabs {
  background: var(--surface-soft);
  border-color: var(--border);
  box-shadow: 0 -2px 12px rgba(51, 41, 28, 0.04);
}

.tab {
  color: var(--muted);
  border-radius: var(--radius-sm);
}

.tab.active,
.tab[aria-selected="true"] {
  color: var(--accent-deep);
  background: #f5edda;
  border: 1px solid var(--border-gold);
  font-weight: 600;
}

.tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Cards / chips / surfaces */
.welcome-card,
.card,
.game-card,
.modal-card,
.therapy-panel,
.volume-panel,
.settings-panel {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.chip.active,
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  color: var(--primary);
}

/* Hero overlay: cream scrim, gold accent title */
.hero-overlay h2 {
  color: #fff;
  text-shadow: 0 2px 12px rgba(20, 35, 50, 0.45);
}
.hero-overlay p {
  color: rgba(255, 255, 255, 0.92);
}

/* Offline banner — soft green success, not clinical teal */
.offline-banner {
  background: color-mix(in srgb, var(--success) 14%, var(--surface-soft));
  border-bottom: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
  color: var(--text);
}

/* Focus rings app-wide where outline used primary */
:focus-visible {
  outline-color: #9ec1dd;
}

/* Links */
a {
  color: var(--primary);
}
a:hover {
  color: var(--primary-dark);
}

/* Flag: body class for future shell layouts (sidebar) */
body.br-family-app {
  /* reserved for shell step 2 */
}

/* ========== Step 2: App shell (Sidebar + Overview) ========== */

.br-shell {
  max-width: none;
  flex-direction: row;
  align-items: stretch;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

.br-shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: calc(10px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: min(1320px, 100%);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Sidebar */
.br-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
  transition: width 0.2s ease, transform 0.2s ease, padding 0.2s ease;
}

.br-sidebar-brand {
  padding: 4px 8px 18px;
}
.br-sidebar-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.br-sidebar-word {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.br-sidebar-sub {
  font-size: 0.75rem;
  color: var(--muted-2);
  margin-top: 6px;
}

.br-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.br-side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.br-side-item:hover {
  background: var(--surface-muted);
}
.br-side-item.is-active {
  background: #f5edda;
  border-color: var(--border-gold);
  color: var(--accent-deep);
  font-weight: 600;
}
.br-side-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.9;
  color: inherit;
}
.br-side-ico svg {
  display: block;
  width: 18px;
  height: 18px;
}

.br-sidebar-user {
  margin-top: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}
.br-sidebar-user-top {
  display: flex;
  align-items: center;
  gap: 11px;
}
.br-sidebar-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.br-sidebar-user-meta {
  min-width: 0;
}
.br-sidebar-user-name {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.br-sidebar-user-role {
  font-size: 0.72rem;
  color: var(--muted-2);
  margin-top: 1px;
}
.br-sidebar-lic-block {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
}
.br-sidebar-lic-lbl {
  font-size: 0.7rem;
  color: var(--muted-2);
}
.br-sidebar-lic-name {
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text);
}
.br-sidebar-lic-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  min-height: 1em;
}
.br-sidebar-license {
  width: 100%;
  margin-top: 12px;
  font-size: 0.8rem !important;
  padding: 9px !important;
  color: var(--primary) !important;
  border-color: #d6cfc0 !important;
  background: var(--surface) !important;
}

.br-sidebar-collapse {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--muted-2);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Collapsed sidebar (desktop) */
body.br-sidebar-collapsed .br-sidebar {
  width: 72px;
  padding: 16px 8px;
}
body.br-sidebar-collapsed .br-sidebar-word,
body.br-sidebar-collapsed .br-sidebar-sub,
body.br-sidebar-collapsed .br-side-item span:not(.br-side-ico),
body.br-sidebar-collapsed .br-sidebar-user-meta,
body.br-sidebar-collapsed .br-sidebar-lic-block,
body.br-sidebar-collapsed .br-sidebar-license,
body.br-sidebar-collapsed .br-sidebar-collapse span:last-child {
  display: none;
}
body.br-sidebar-collapsed .br-sidebar-user-top {
  justify-content: center;
}
body.br-sidebar-collapsed .br-sidebar-avatar {
  margin: 0;
}
body.br-sidebar-collapsed .br-side-item {
  justify-content: center;
  padding: 12px 8px;
}
body.br-sidebar-collapsed .br-sidebar-collapse {
  justify-content: center;
}

/* Step 6 extras: empty states + overview foot */
.br-empty-state {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.br-empty-state strong {
  color: var(--text);
  font-size: 0.9rem;
}
.br-empty-state .br-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.br-overview-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  padding-top: 8px;
  font-size: 0.78rem;
  color: var(--muted-2);
}
.br-foot-link {
  border: none;
  background: none;
  padding: 4px 2px;
  font: inherit;
  font-size: inherit;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  min-height: 36px;
}
.br-foot-link:hover {
  color: var(--primary);
}

/* ========== Step 7: Player polish + next rows + view skin ========== */

.br-player-title {
  display: flex;
  align-items: center;
  gap: 9px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.br-player-title .br-ico {
  color: var(--text);
}

.br-player-timeline {
  margin-top: 12px;
}
.br-player-timeline-track {
  height: 6px;
  border-radius: 999px;
  background: #f3ede1;
  border: 1px solid var(--border);
  overflow: hidden;
}
.br-player-timeline-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--gold, #d39c0c));
  transition: width 0.35s ease;
}
.br-player-timeline-fill.is-active {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 20%, transparent);
}

.br-quick-row {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px 14px;
  box-shadow: var(--shadow);
}
.br-quick-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 4px;
  border: none;
  border-bottom: 1px solid #f3ede1;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-height: 48px;
}
.br-quick-link:last-child {
  border-bottom: none;
}
.br-quick-link .br-ico {
  color: var(--muted);
  flex-shrink: 0;
}
.br-quick-chev {
  margin-left: auto;
  color: var(--muted-2);
  display: inline-flex;
}
.br-quick-link:hover {
  color: var(--primary);
}

.br-next-list {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}
.br-next-row {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 13px 0;
  border: none;
  border-bottom: 1px solid #f3ede1;
  background: transparent;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-height: 56px;
}
.br-next-row:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}
.br-next-row:hover {
  color: var(--primary);
}
.br-next-ico {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.br-next-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.br-next-text strong {
  font-size: 0.88rem;
  font-weight: 700;
}
.br-next-text span {
  font-size: 0.78rem;
  color: var(--muted-2);
  font-weight: 400;
}
.br-next-chev {
  flex-shrink: 0;
  display: inline-flex;
}

/* Secondary views: Games / Favorites / Progress */
.br-family-app .br-view-header h2 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.br-family-app .br-view-header p {
  color: var(--muted);
}
.br-family-app .br-filter-row .chip {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  min-height: 40px;
}
.br-family-app .br-filter-row .chip.active,
.br-family-app .br-filter-row .chip[aria-pressed="true"] {
  background: #f5edda;
  border-color: var(--border-gold);
  color: var(--accent-deep);
}
.br-family-app .br-games-list .game-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.br-family-app .br-games-list .game-card:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
.br-family-app .br-games-list .game-emoji,
.br-family-app .br-games-list .game-emoji--sm {
  background: var(--bg);
  border: 1px solid var(--border);
}
.br-family-app .br-progress-list .br-progress-row,
.br-family-app .progress-list .br-progress-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}
.br-family-app .br-progress-bar,
.br-family-app .progress-row .bar.br-progress-bar {
  background: #f3ede1;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.br-family-app .br-progress-bar > span,
.br-family-app .progress-row .bar.br-progress-bar > span {
  background: linear-gradient(90deg, var(--primary), var(--gold, #d39c0c));
  display: block;
  height: 100%;
  border-radius: 999px;
}
.br-family-app #progress-summary.br-stat-grid {
  margin-bottom: 16px;
}
.br-family-app #view-play .play-header {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.br-sidebar-open {
  display: none;
  min-width: 44px;
  min-height: 44px;
}

/* Overview */
.br-overview {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.br-overview-hello {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.br-overview-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 40rem;
}

.br-layer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 14px;
}
.br-layer-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 18px 14px 14px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.br-layer-card.is-active {
  border-color: #1a5f7a;
  background: linear-gradient(180deg, rgba(26, 95, 122, 0.08) 0%, var(--surface) 55%);
  box-shadow: 0 0 0 1px rgba(26, 95, 122, 0.12), var(--shadow);
}
.br-layer-card.is-active .br-layer-icon {
  border-color: #1a5f7a;
  background: rgba(26, 95, 122, 0.1);
}
.br-layer-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8eef1;
  color: var(--muted, #5a6b73);
  line-height: 1.2;
}
.br-layer-card.is-active .br-layer-badge {
  background: #1a5f7a;
  color: #fff;
}
.br-layer-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid #ddd5c8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}
.br-layer-card h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}
.br-layer-card p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted-2);
  flex: 1;
}
.br-layer-hint {
  font-size: 0.68rem !important;
  opacity: 0.85;
}
.br-layer-field {
  width: 100%;
  margin: 0;
}
.br-layer-select {
  width: 100%;
  min-height: 40px;
  font-size: 0.82rem;
  border-radius: 10px;
  border: 1px solid #c5d4dc;
  background: #fff;
  padding: 0.3rem 0.45rem;
}
.br-layer-voice-switch {
  display: flex;
  gap: 6px;
  width: 100%;
  justify-content: center;
}
.br-layer-chip {
  flex: 1;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid #c5d4dc;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text, #1a3a45);
}
.br-layer-chip.is-active {
  background: #1a5f7a;
  border-color: #1a5f7a;
  color: #fff;
}
.br-layer-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.br-layer-manage {
  width: 100%;
  min-height: 36px !important;
  font-size: 0.78rem !important;
  padding: 6px 10px !important;
}
.br-layer-start {
  margin-top: auto;
  width: 100%;
  border-radius: var(--radius-pill) !important;
  padding: 8px 18px !important;
  font-size: 0.85rem !important;
  min-height: 44px;
}
.br-layer-card.is-active .br-layer-start {
  background: #1a5f7a !important;
  border-color: #1a5f7a !important;
  color: #fff !important;
}
.br-layer-card--nav .br-layer-badge {
  display: none;
}
/* Top therapy bar: still primary engine; mark as legacy companion until full cutover */
.therapy-bar {
  /* kept visible — Variant H transition */
}

/* quick-row: design list (column) — see step 7 .br-quick-link */
.br-quick-row .btn {
  min-height: 44px;
}

.br-overview-more {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--muted);
}
.br-overview-more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}

/* Mobile: drawer sidebar */
@media (max-width: 900px) {
  .br-shell {
    flex-direction: column;
  }
  .br-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-105%);
    box-shadow: var(--shadow-float);
    width: min(280px, 88vw);
  }
  body.br-sidebar-open .br-sidebar {
    transform: translateX(0);
  }
  body.br-sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(51, 41, 28, 0.35);
    z-index: 35;
  }
  .br-sidebar-open {
    display: inline-flex;
  }
  body.br-sidebar-collapsed .br-sidebar {
    width: min(280px, 88vw);
  }
  body.br-sidebar-collapsed .br-sidebar-word,
  body.br-sidebar-collapsed .br-side-item span:not(.br-side-ico) {
    display: initial;
  }
}

@media (min-width: 901px) {
  /* Bottom tabs secondary on desktop when sidebar present */
  .br-shell .tabs {
    display: none;
  }
}

/* ========== Step 3: Overview widgets + player bar ========== */

.br-player-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.br-player-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 10px;
}
.br-player-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.br-player-vol {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 180px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.br-player-vol input[type="range"] {
  flex: 1;
  min-width: 100px;
}
.br-player-status {
  margin: 10px 0 0;
  font-size: 0.8rem;
  color: var(--muted-2);
  min-height: 1.2em;
}

.br-dash-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.br-dash-h {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.br-dash-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.br-dash-head .br-dash-h { margin: 0; }
.br-dash-section > .br-dash-h { margin-bottom: 12px; }

.br-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.br-stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.br-stat-card .num {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.br-stat-card .lbl {
  display: block;
  font-size: 0.72rem;
  color: var(--muted-2);
  margin-top: 4px;
  line-height: 1.3;
}

.br-people-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.br-person-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  min-height: 44px;
}
.br-person-chip.is-active {
  border-color: var(--border-gold);
  background: #f5edda;
  color: var(--accent-deep);
}
.br-person-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.br-person-add {
  border-style: dashed;
  color: var(--primary);
}

.br-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.br-recent-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}
.br-recent-list .muted {
  color: var(--muted-2);
  font-size: 0.78rem;
  white-space: nowrap;
}
.br-recent-empty {
  color: var(--muted-2);
  font-size: 0.9rem;
  margin: 0;
  padding: 8px 0;
}

.br-next-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.br-next-card {
  text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font: inherit;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.br-next-card:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
  background: var(--primary-soft);
}
.br-next-card strong {
  color: var(--text);
  font-size: 0.92rem;
}
.br-next-card span {
  color: var(--muted-2);
  font-size: 0.78rem;
}

.br-tip-card {
  background: linear-gradient(135deg, #fdf9f1 0%, #e9f0f6 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.br-tip-body p {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.btn-sm,
.btn.btn-sm {
  padding: 8px 12px !important;
  font-size: 0.8rem !important;
  min-height: 40px;
}

@media (max-width: 640px) {
  .br-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .br-player-row {
    flex-direction: column;
    align-items: stretch;
  }
  .br-player-vol {
    width: 100%;
  }
}

/* ========== Step 5: Line icons (therapy bar + topbar) ========== */

.br-family-app .therapy-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  font-size: 0; /* no emoji fallback sizing */
  line-height: 0;
}
.br-family-app .therapy-icon svg {
  width: 26px;
  height: 26px;
  display: block;
}
.br-family-app .btn-therapy[aria-pressed="true"] .therapy-icon {
  filter: drop-shadow(0 0 0.5px rgba(39, 95, 143, 0.25));
}

.br-family-app .sound-select-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0;
  line-height: 0;
  flex-shrink: 0;
}
.br-family-app .sound-select-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.br-family-app .br-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: inherit;
}
.br-family-app .br-ico svg {
  display: block;
}

/* Offline chip — design “Offline verfügbar” pill look */
.br-family-app .btn-offline.br-offline-chip,
.br-family-app .br-offline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 8px 14px;
  min-height: 40px;
}
.br-family-app .btn-offline[data-offline-state="ready"],
.br-family-app .btn-offline[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--success) 45%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  color: #2f7a34;
}
.br-family-app .btn-offline[data-offline-state="loading"] {
  border-color: color-mix(in srgb, var(--gold, #d39c0c) 40%, var(--border));
  color: var(--accent-deep, #946d08);
}

.br-family-app .btn-help .btn-help-glyph {
  font-size: 0;
  line-height: 0;
}
.br-family-app .btn-user-icon {
  font-size: 0;
  line-height: 0;
}
.br-family-app .btn-path-icon,
.br-family-app .btn-refresh-icon {
  font-size: 0;
  line-height: 0;
}

/* ========== Step 4: Progress chart + activity donut ========== */

.br-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.br-stat-grid--compact {
  margin-bottom: 14px;
}
.br-stat-grid--compact .br-stat-card {
  padding: 10px 8px;
}
.br-stat-grid--compact .br-stat-card .num {
  font-size: 1.15rem;
}

.br-range-pills {
  display: inline-flex;
  background: #f3ede1;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.br-range-pill {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  white-space: nowrap;
}
.br-range-pill.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(51, 41, 28, 0.08);
}

.br-line-chart-wrap {
  margin-top: 4px;
}
.br-line-chart {
  width: 100%;
  height: 150px;
  display: block;
}
.br-line-chart .grid-line {
  stroke: #f3ede1;
  stroke-width: 1;
}
.br-line-chart .grid-line-base {
  stroke: #eadfca;
  stroke-width: 1;
}
.br-line-chart .series-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.br-line-chart .series-dot {
  fill: var(--primary);
}
.br-line-chart .series-dot.is-last {
  fill: var(--gold, #d39c0c);
}
.br-chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted-2);
  padding: 4px 4px 0;
}

.br-progress-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.br-sum-lbl {
  font-size: 0.72rem;
  color: var(--muted-2);
}
.br-sum-val {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-top: 2px;
}
.br-sum-right {
  text-align: right;
}
.br-sum-delta {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}
.br-sum-delta.is-up {
  color: #2f7a34;
}
.br-sum-delta.is-down {
  color: #a05030;
}

.br-activity-panel > .br-dash-h {
  margin-bottom: 16px;
}
.br-donut-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.br-donut {
  width: 170px;
  height: 170px;
  flex-shrink: 0;
}
.br-donut-track {
  stroke: #f3ede1;
}
.br-donut-num {
  font-size: 24px;
  font-weight: 700;
  fill: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}
.br-donut-lbl {
  font-size: 12px;
  fill: var(--muted-2);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}
.br-donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 0.82rem;
  flex: 1;
  min-width: 140px;
  color: var(--text);
}
.br-donut-legend li {
  display: flex;
  align-items: center;
  gap: 9px;
}
.br-donut-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.br-donut-legend .pct {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.br-donut-legend .zero {
  color: var(--muted-2);
  font-weight: 500;
}

@media (max-width: 900px) {
  .br-chart-row {
    grid-template-columns: 1fr;
  }
}

/* ========== Step 8: Bottom tabs line icons + secondary views CI ========== */

.br-family-app .br-tabs.tabs,
.br-family-app .tabs.br-tabs {
  gap: 4px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
}
.br-family-app .br-tabs .tab {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 8px;
  font-size: 0.68rem;
  line-height: 1.15;
}
.br-family-app .br-tabs .tab-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: inherit;
  line-height: 0;
}
.br-family-app .br-tabs .tab-ico svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* Affirmations / Stories / Profile / Help / Legal cards */
.br-family-app .br-view .profile-card,
.br-family-app .br-view .aff-card,
.br-family-app .br-view .facility-card,
.br-family-app .br-view .legal-contact-card,
.br-family-app .br-view .legal-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.br-family-app .br-view .profile-card,
.br-family-app .br-view .aff-card,
.br-family-app .br-view .facility-card {
  padding: 16px 18px;
  margin-bottom: 14px;
}
.br-family-app .br-view .profile-card h3,
.br-family-app .br-view .aff-card h3,
.br-family-app .br-view .facility-card h3,
.br-family-app .br-view .facility-card h4 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.br-family-app .br-view .input-large,
.br-family-app .br-view input[type="text"],
.br-family-app .br-view input[type="password"],
.br-family-app .br-view input[type="email"],
.br-family-app .br-view input[type="search"],
.br-family-app .br-view textarea,
.br-family-app .br-view select.input-large,
.br-family-app .br-view .aff-textarea {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
}
.br-family-app .br-view .input-large:focus,
.br-family-app .br-view input:focus,
.br-family-app .br-view textarea:focus,
.br-family-app .br-view select:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}
.br-family-app .br-view label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.br-family-app .br-view .profile-name-hint,
.br-family-app .br-view .aff-subliminal-hint,
.br-family-app .br-view .view-sub {
  color: var(--muted-2);
}
.br-family-app .br-view .chip {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}
.br-family-app .br-view .chip.active {
  background: #f5edda;
  border-color: var(--border-gold);
  color: var(--accent-deep);
}

/* Help */
.br-family-app .view-help .help-sticky {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}
.br-family-app .view-help .help-search-wrap input {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.br-family-app .view-help .help-list .help-item,
.br-family-app .view-help .help-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.br-family-app .view-help .help-depth-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}
.br-family-app .view-help .help-depth-btn[aria-pressed="true"],
.br-family-app .view-help .help-depth-btn.is-active {
  background: #f5edda;
  border-color: var(--border-gold);
  color: var(--accent-deep);
}

/* Stories list cards */
.br-family-app .stories-list .story-card,
.br-family-app #stories-list > * {
  border-radius: 16px;
}
.br-family-app .user-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.br-family-app .user-row.active {
  border-color: var(--border-gold);
  background: #f5edda;
}

/* Therapy bar already cream — ensure settings panel cohesion */
.br-family-app .settings-shell {
  background: transparent;
}
.br-family-app .app-footer {
  border-top: 1px solid var(--border);
  color: var(--muted-2);
}
.br-family-app .app-footer-link {
  color: var(--muted);
}
.br-family-app .app-footer-link:hover {
  color: var(--primary);
}

/* Permanently hide home "Läuft …" strip — status is on layer cards */
.session-status-chip,
#session-status-chip {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}


/* === Variant H cutover: hide top therapy bar; mixer under Willkommen === */
.therapy-bar--hidden,
.therapy-bar[hidden],
.settings-shell--engine-only .therapy-bar {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  visibility: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  pointer-events: none !important;
}
/* Engine-only shell: zero layout space; therapy buttons stay in DOM for JS */
.settings-shell--engine-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.br-player-bar--hidden,
.br-player-bar[hidden] {
  display: none !important;
}
.br-home-mixer {
  margin: 18px 0 8px;
  padding: 12px 14px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd5c8);
  border-radius: 16px;
  box-shadow: var(--shadow, 0 1px 4px rgba(0,0,0,.06));
}
.br-home-mixer .settings-toggle {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 8px;
}
.br-home-mixer .settings-panel {
  margin-top: 4px;
}
.br-home-mixer .settings-panel.is-open,
.br-home-mixer .settings-panel:not(.is-collapsed):not([hidden]) {
  display: block;
}
.br-home-mixer .mixer-bar {
  margin: 0;
  border: 0;
  box-shadow: none;
  padding: 4px 0 0;
}
.br-home-mixer .lesson-course-panel {
  margin-top: 14px;
}

/* ── Facility first-run / pilot wizard ───────────────────────── */
.facility-wizard {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(12, 18, 28, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
}
.facility-wizard[hidden] { display: none !important; }
body.facility-wizard-open { overflow: hidden; }
.fw-panel {
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface, #f7f4ef);
  color: var(--text, #1a1f2a);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  padding: 1.25rem 1.35rem 1.5rem;
}
.fw-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}
.fw-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}
.fw-title { margin: 0.2rem 0 0.35rem; font-size: 1.45rem; }
.fw-progress { margin: 0; font-size: 0.9rem; opacity: 0.75; }
.fw-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0.55rem; }
.fw-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(0,0,0,.15);
}
.fw-dot.is-on { background: var(--accent, #c45c7a); }
.fw-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 760px) {
  .fw-grid { grid-template-columns: 1fr; }
  .fw-header { flex-direction: column; }
}
.fw-body { margin: 0 0 1rem; line-height: 1.45; }
.fw-label {
  display: block;
  margin: 0.65rem 0;
  font-weight: 600;
  font-size: 0.95rem;
}
.fw-label .input-large, .fw-label select, .fw-label input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  font-weight: 400;
}
.fw-check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 0.75rem 0;
  line-height: 1.4;
}
.fw-check input { margin-top: 0.25rem; }
.fw-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}
.fw-why {
  background: rgba(196, 92, 122, 0.08);
  border-radius: 14px;
  padding: 1rem 1.1rem;
}
.fw-why h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.fw-why p { margin: 0; line-height: 1.45; font-size: 0.95rem; }
.fw-faq { margin-top: 0.85rem; font-size: 0.92rem; }
.fw-faq summary { cursor: pointer; font-weight: 600; }
.fw-card {
  background: rgba(0,0,0,.04);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.fw-card--ok { border: 1px solid rgba(46, 140, 90, 0.35); }
.fw-list { margin: 0.4rem 0 0.8rem 1.1rem; padding: 0; }
.fw-hint { font-size: 0.88rem; opacity: 0.8; margin: 0.5rem 0 0; }
.fw-err { color: #b42318; margin-top: 0.75rem; font-weight: 600; }
.fw-client-fields { display: grid; gap: 0.15rem; }
#facility-pilot-banner {
  background: rgba(196, 92, 122, 0.12);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
}

/*
 * 40 Hz light session: override Family cream while light is on.
 * Loaded after css/styles.css — must win over html/body/.app { background: var(--bg) }.
 * DEC-2026-08-24-brain-40hz-light-contrast
 */
body.light-on,
body.light-on .app {
  background: #f4f7f9 !important;
}
