/* Shared brand tokens and explicit theme controls. Practice styles stay scoped. */
:root {
  --brand-accent: #94070a;
  --brand-accent-deep: #710508;
  --brand-rgb: 148, 7, 10;
  --brand-paper: #f5f1e8;
  --brand-ink: #262320;
  --brand-muted: #6b625b;
  --brand-soft: rgba(var(--brand-rgb), .08);
  --brand-tint: rgba(var(--brand-rgb), .14);
  --brand-border: rgba(var(--brand-rgb), .35);
}
:root[data-brand-theme="tsinghua"] {
  --brand-accent: #660874;
  --brand-accent-deep: #4d0658;
  --brand-rgb: 102, 8, 116;
}

.brand-theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.brand-theme-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--brand-muted);
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}
.brand-theme-choice:hover { background: var(--brand-soft); }
.brand-theme-choice[aria-pressed="true"] {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand-accent);
}
.brand-theme-choice:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; }
.brand-theme-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: #94070a; }
[data-brand-theme-choice="tsinghua"] .brand-theme-dot { background: #660874; }

body.practice-app {
  --paper: var(--brand-paper);
  --paper-deep: #eae3d7;
  --paper-soft: #fcfaf5;
  --ink: var(--brand-ink);
  --ink-2: var(--brand-muted);
  --ink-3: var(--brand-muted);
  --cinnabar: var(--brand-accent);
  --cinnabar-deep: var(--brand-accent-deep);
  --cinnabar-soft: var(--brand-soft);
  --line: rgba(38, 35, 32, .13);
  --line-strong: rgba(38, 35, 32, .26);
  background: var(--paper);
  color: var(--ink);
}
body.practice-app ::selection { background: rgba(var(--brand-rgb), .18); }
body.practice-app .header-inner { gap: 20px; }
body.practice-app .brand { flex: 0 1 309px; gap: 10px; }
body.practice-app .brand-symbol,
body.practice-app .brand-wordmark { display: block; min-width: 0; max-width: 100%; height: auto; object-fit: contain; }
body.practice-app .brand-symbol { flex: 0 1 74px; width: 74px; }
body.practice-app .brand-wordmark { flex: 0 1 225px; width: 225px; }
body.practice-app .site-nav { flex: none; white-space: nowrap; }
body.practice-app .header-stats { flex: none; gap: 14px; }
body.practice-app .header-stat + .header-stat { padding-left: 14px; }
body.practice-app .footer-note { opacity: 1; }
body.practice-app .footer-note a { color: var(--brand-accent); text-underline-offset: 3px; }

/* Replace decorative hard-coded cinnabar; correctness/error colors remain intact. */
body.practice-app .seg button[aria-pressed="true"] { background: var(--brand-accent); }
body.practice-app .chip[aria-pressed="true"],
body.practice-app .card-status.is-mastered { border-color: var(--brand-border); }
body.practice-app .anno-token { border-bottom-color: rgba(var(--brand-rgb), .45); }
body.practice-app .anno-token.is-active { border-bottom-color: var(--brand-accent); background: var(--brand-tint); }
body.practice-app .anno-item.is-active { background: rgba(var(--brand-rgb), .12); }
body.practice-app .cta-side { border-bottom-color: var(--brand-border); }
body.practice-app .cta-side:hover { border-bottom-color: var(--brand-accent); }

@media (max-width: 1000px) {
  body.practice-app .header-inner { gap: 16px; }
  body.practice-app .brand { flex-basis: 270px; }
  body.practice-app .brand-theme-label { display: none; }
}
@media (max-width: 880px) {
  body.practice-app .header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 16px; }
  body.practice-app .brand { grid-column: 1; grid-row: 1; }
  body.practice-app .brand-theme-switch { grid-column: 2; grid-row: 1; }
  body.practice-app .site-nav { grid-column: 1; grid-row: 2; }
  body.practice-app .header-stats {
    grid-column: 2;
    grid-row: 2;
    width: auto;
    padding-top: 0;
    border-top: 0;
    margin-left: 0;
    gap: 14px;
  }
  body.practice-app .header-stat { gap: 5px; }
  body.practice-app .header-stat + .header-stat { padding-left: 14px; }
}
@media (max-width: 600px) {
  body.practice-app .brand { max-width: 240px; gap: 7px; }
  body.practice-app .brand-symbol { flex-basis: 56px; width: 56px; }
  body.practice-app .brand-wordmark { flex-basis: 177px; width: 177px; }
  body.practice-app .header-inner { gap: 8px 10px; }
  body.practice-app .site-nav { grid-column: 1 / -1; }
  body.practice-app .header-stats {
    grid-column: 1 / -1;
    grid-row: 3;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  body.practice-app .header-stats:empty { display: none; }
  body.practice-app .header-stat { white-space: nowrap; }
  body.practice-app .footer-inner { overflow-wrap: anywhere; }
  body.practice-app .filter-row, body.practice-app .chips { min-width: 0; }
  body.practice-app .seg { max-width: 100%; }
  body.practice-app .seg button { padding-inline: 11px; }
}
