/* Shared product design system, used by the app and domestic access screen. */
:root {
  color-scheme: light;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;
  --font-xs: 12px; --font-sm: 13px; --font-body: 14px; --font-md: 16px;
  --font-lg: 18px; --font-xl: 24px; --font-title: 30px;
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-pill: 999px;
  --control-sm: 32px; --control-md: 40px; --control-touch: 44px;
  --bg: #f4f6f8; --panel: #fff; --panel-2: #f7f9fa; --panel-3: #eaf0f3;
  --line: #dce3e8; --line-strong: #b8c7cf;
  --text: #22303a; --muted: #566571; --subtle: #657581;
  --accent: #356b7c; --accent-2: #2d5b69; --accent-soft: #eaf3f5;
  --good: #24754f; --good-soft: #edf7f0; --good-line: #81b397;
  --bad: #b64046; --bad-soft: #fcf0f0; --bad-line: #d89397;
  --blue: #32688e; --info-soft: #edf4fa;
  --paper: #faf9f5; --notation: #25282d;
  --disabled-bg: #edf1f3; --disabled-text: #73838d;
  --shadow: 0 8px 28px rgba(28,45,57,.12);
  --overlay: rgba(26,39,49,.32);
  --content-width: 1280px; --topbar-height: 64px;
  --page-gutter: clamp(20px,3vw,40px);
  --transition: 120ms ease;
  --border: var(--line); --brand: var(--accent); --soft: var(--accent-soft);
  --safe-top: env(safe-area-inset-top,0px); --safe-right: env(safe-area-inset-right,0px);
  --safe-bottom: env(safe-area-inset-bottom,0px); --safe-left: env(safe-area-inset-left,0px);
  --viewport-height: 100vh;
  --gutter-left: max(var(--page-gutter),var(--safe-left));
  --gutter-right: max(var(--page-gutter),var(--safe-right));
}

/* Base and focus: the app intentionally stays light under a dark OS appearance. */
* { box-sizing: border-box; }
html,body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue",sans-serif; font-size: var(--font-body); line-height: 1.5; }
body { min-width: 0; overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
button,input,select { font: inherit; }
button { color: inherit; }
button,select,input { -webkit-tap-highlight-color: transparent; }
h1,h2,h3,p { margin-top: 0; }
h1 { font-size: var(--font-title); line-height: 1.3; font-weight: 700; letter-spacing: -.4px; }
h2 { font-size: var(--font-xl); line-height: 1.35; font-weight: 650; }
h3 { font-size: var(--font-md); line-height: 1.4; font-weight: 650; }
.hidden { display: none !important; }
:where(button,input,select,summary,[tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ui-icon { display: block; flex: 0 0 auto; width: 20px; height: 20px; }
.button-icon { display: inline-flex; align-items: center; }
.button-icon .ui-icon { width: 16px; height: 16px; }
.eyebrow { color: var(--muted); font-size: var(--font-xs); font-weight: 600; }

/* Button system: a small set of sizes and semantic variants, no movement. */
:where(.primary-button,.secondary-button,.control-button,.icon-button,.live-entry,.reference-song-button,.rhythm-audition-button,.mini-play,.text-button,.update-banner button) {
  min-width: 0; min-height: var(--control-md); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--panel); color: var(--text); font-size: var(--font-body); font-weight: 600; line-height: 1.25; white-space: nowrap;
  cursor: pointer; transition: background-color var(--transition),border-color var(--transition),color var(--transition);
}
:where(.secondary-button,.control-button,.icon-button,.live-entry,.mini-play):hover:not(:disabled) { background: var(--panel-3); border-color: var(--line-strong); }
:where(.secondary-button,.control-button,.icon-button,.live-entry,.mini-play):active:not(:disabled) { background: var(--panel-3); }
.primary-button:not(:disabled),.control-button.new-question:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary-button:hover:not(:disabled),.control-button.new-question:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.primary-button:active:not(:disabled),.control-button.new-question:active:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
:is(.primary-button,.secondary-button,.control-button,.icon-button,.live-entry,.reference-song-button,.rhythm-audition-button,.mini-play,.text-button,.update-banner button):disabled { background: var(--disabled-bg); border-color: var(--line); color: var(--disabled-text); cursor: not-allowed; }
.icon-button { width: var(--control-md); height: var(--control-md); flex: 0 0 auto; padding: 0; }
.text-button { min-height: var(--control-sm); padding: 0 var(--space-2); border-color: transparent; background: transparent; color: var(--accent-2); font-size: var(--font-sm); }
.text-button:hover:not(:disabled) { background: var(--accent-soft); }
.live-entry { min-height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--font-sm); color: var(--accent-2); }
.live-entry strong { font-size: inherit; font-weight: inherit; }
.live-entry[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--line-strong); }
/* Teaching toggles share one stable shape. A check complements the state color. */
.classroom-toggle { background: var(--panel-2); color: var(--muted); touch-action: manipulation; }
.classroom-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.classroom-toggle[aria-pressed="true"]:hover:not(:disabled),.classroom-toggle[aria-pressed="true"]:active:not(:disabled) { background: var(--panel-3); border-color: var(--accent); color: var(--accent-2); }
.classroom-toggle:disabled { background: var(--disabled-bg); border-color: var(--line); color: var(--disabled-text); }
.toggle-indicator { width: 14px; height: 14px; display: inline-grid; place-items: center; flex: 0 0 14px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--panel); }
.toggle-indicator::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--subtle); }
.classroom-toggle[aria-pressed="true"] .toggle-indicator { border-color: var(--accent); background: var(--accent); }
.classroom-toggle[aria-pressed="true"] .toggle-indicator::after { content: "✓"; width: auto; height: auto; border-radius: 0; background: transparent; color: #fff; font-size: 10px; line-height: 1; font-weight: 700; }
.classroom-toggle:disabled .toggle-indicator { border-color: var(--line); background: var(--disabled-bg); }
.classroom-toggle:disabled .toggle-indicator::after { color: var(--disabled-text); background: transparent; }
.classroom-toggle[aria-disabled="true"] { cursor: default; color: var(--subtle); }
.classroom-toggle[aria-disabled="true"]:hover,.classroom-toggle[aria-disabled="true"]:active { background: var(--panel-2); border-color: var(--line); color: var(--subtle); }
.reference-song-button,.rhythm-audition-button { min-height: var(--control-sm); min-width: 116px; padding: 0 var(--space-3); border-color: var(--line-strong); background: var(--accent-soft); color: var(--accent-2); font-size: var(--font-sm); }
.reference-song-button:hover:not(:disabled),.rhythm-audition-button:hover:not(:disabled) { background: var(--panel-3); border-color: var(--line-strong); transform: none; }
.is-playing { border-color: var(--accent); }
.is-loading { cursor: progress; }
.is-loading .button-icon,.control-button.is-loading > span:first-child { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: loading-spin .8s linear infinite; }
.is-loading .button-icon > *,.control-button.is-loading > span:first-child > * { visibility: hidden; }
@keyframes loading-spin { to { transform: rotate(360deg); } }

/* Input / form system. Switches mean enabled/disabled; checkboxes mean selection. */
:where(.field-input,.field input,.field select,.live-cycle-count input) { width: 100%; min-height: var(--control-md); padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); }
:where(.field-input,.field input,.field select,.live-cycle-count input):hover:not(:disabled) { border-color: var(--accent); }
:where(.field-input,.field input,.field select,.live-cycle-count input):disabled { background: var(--disabled-bg); color: var(--disabled-text); cursor: not-allowed; }
[aria-invalid="true"] { border-color: var(--bad) !important; outline-color: var(--bad); }
input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; margin: 0; accent-color: var(--accent); cursor: pointer; }
input[role="switch"] { appearance: none; -webkit-appearance: none; position: relative; width: 36px; height: 20px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--line-strong); transition: background-color var(--transition); }
input[role="switch"]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform var(--transition); }
input[role="switch"]:checked { background: var(--accent); border-color: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(16px); }
input[type="range"] { width: 100%; margin: 0; min-height: 24px; accent-color: var(--accent); }

@supports (height: 100dvh) { :root { --viewport-height: 100dvh; } }
/* Touch ergonomics belong to the shared controls, not individual pages. */
@media (any-pointer: coarse) {
  :root { --control-md: 44px; --control-sm: 44px; }
  :where(.field-input,.field input,.field select,.live-cycle-count input) { font-size: var(--font-md); }
  .control-button kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
