:root {
  color-scheme: light;
  --ink: #2d211a;
  --muted: #715b4c;
  --paper: #f7f0e5;
  --paper-deep: #eadbc6;
  --wood: #68452f;
  --wood-dark: #3f2a21;
  --brass: #b57a37;
  --brass-light: #e6bf77;
  --line: rgba(74, 45, 28, 0.18);
  --danger: #963f35;
  --shadow: 0 20px 50px rgba(57, 34, 22, 0.12);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html { min-width: 0; background: var(--paper); }

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.78), transparent 35rem),
    var(--paper);
  line-height: 1.6;
}

button, input, select { font: inherit; }

button, select, input[type="number"] { min-height: 44px; }

button {
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.5; }

:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 3px;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #4d3024, #815a3b 60%, #67432d);
  color: #fff8ed;
}

.header-inner, main, .site-footer { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }

.header-inner { padding: 48px 0 40px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--brass);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.site-header .eyebrow { color: #f0c985; }

h1, h2, p { overflow-wrap: anywhere; }
h1, h2 { font-family: Georgia, "Times New Roman", "Yu Mincho", serif; line-height: 1.18; }
h1 { max-width: none; margin: 0; font-size: clamp(2.15rem, 6vw, 4.4rem); letter-spacing: -0.04em; word-break: keep-all; }
h2 { margin: 0; font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
p { margin: 0; }
.lede { max-width: 44rem; margin-top: 18px; color: #f7e8d4; font-size: 1.05rem; }

main { padding: 28px 0 64px; }

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 22px;
  align-items: start;
}

.control-column, .display-column { display: grid; gap: 18px; min-width: 0; }
.card, .info-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 251, 244, 0.85);
  box-shadow: var(--shadow);
}

.card { padding: clamp(20px, 3vw, 30px); }
.section-heading { margin-bottom: 24px; }
.section-heading > p:last-child { margin-top: 8px; color: var(--muted); }
.compact-heading { margin-bottom: 16px; }

.field { min-width: 0; }
.field label, .field-label-row label { display: block; margin-bottom: 7px; font-weight: 800; }
.field-label-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.field-label-row output { color: var(--wood); font-weight: 800; }

input[type="number"], select {
  width: 100%;
  border: 1px solid rgba(71, 44, 27, 0.3);
  border-radius: 9px;
  padding: 8px 11px;
  background: #fffdf9;
  color: var(--ink);
  font-size: 1rem;
}

input[type="range"] { width: 100%; margin: 13px 0 7px; accent-color: var(--brass); }
.tempo-entry { display: flex; align-items: center; gap: 10px; }
.tempo-entry input { max-width: 180px; font-size: 1.15rem; font-weight: 800; }
.tempo-entry span { color: var(--muted); font-weight: 800; }
.field-help { margin-top: 9px; color: var(--muted); font-size: 0.87rem; }

.step-actions, .action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.step-actions { margin-top: 4px; }
.secondary-button, .tap-button, .stop-button { padding: 8px 13px; }
.secondary-button { background: var(--paper-deep); border-color: rgba(72, 45, 27, 0.16); color: var(--wood-dark); }
.tap-button { background: #fffdf9; border-color: var(--wood); color: var(--wood); }
.settings-grid, .progression-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.progression-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 18px; font-weight: 700; }
.check-row input { width: 20px; height: 20px; accent-color: var(--brass); }
.input-suffix { display: block; margin-top: 5px; color: var(--muted); font-size: 0.82rem; }
.progression-status, .progression-live { margin-top: 16px; color: var(--muted); font-size: 0.9rem; }

.tuner-card { background: linear-gradient(150deg, #fffaf2, #efe2cf); }
.tuner-intro { margin-top: 12px; color: var(--muted); font-size: 0.92rem; }
.tuner-display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  align-items: center;
  margin: 20px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.76);
}
.tuner-note { grid-row: span 2; font-family: Georgia, serif; font-size: clamp(3rem, 8vw, 5rem); line-height: 1; color: var(--wood-dark); }
.tuner-frequency, .tuner-cents { justify-self: end; font-variant-numeric: tabular-nums; font-weight: 800; }
.tuner-status { grid-column: 1 / -1; margin-top: 10px; color: var(--muted); font-weight: 700; }
.tuner-actions { margin-top: 8px; }
.tuner-error { margin-top: 12px; color: var(--danger); font-weight: 700; }

.action-card { background: var(--wood-dark); color: #fff8ed; }
.primary-button, .stop-button { min-width: 132px; padding: 10px 20px; font-size: 1rem; }
.primary-button { background: var(--brass-light); color: #39251a; }
.stop-button { background: transparent; border-color: rgba(255, 248, 237, 0.45); color: #fff8ed; }
.status-line { margin-top: 14px; color: #f5ddbb; font-size: 0.9rem; }
.error-message { margin-top: 12px; padding: 10px 12px; border-left: 3px solid #f1a39a; background: rgba(120, 35, 28, 0.34); color: #ffe1dc; }

.beat-card { background: linear-gradient(145deg, #fffaf2, #eadbc6); }
.beat-card-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.state-pill { display: inline-flex; align-items: center; min-height: 30px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 0.8rem; font-weight: 800; white-space: nowrap; }
.state-pill.is-running { border-color: #6d8b57; background: #e5efda; color: #36502a; }
.beat-visual { display: grid; place-items: center; padding: 28px 0 20px; }
.beat-orb { display: grid; place-items: center; width: clamp(150px, 28vw, 220px); aspect-ratio: 1; border: 13px solid rgba(181, 122, 55, 0.25); border-radius: 50%; background: radial-gradient(circle at 35% 28%, #fff6d9, #c18b4b 78%); color: var(--wood-dark); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.65), 0 12px 30px rgba(104, 69, 47, 0.18); }
.beat-orb span { font-family: Georgia, serif; font-size: clamp(3.2rem, 9vw, 5.7rem); font-weight: 700; }
.beat-orb.is-pulse { animation: pulse 170ms ease-out; }
.beat-orb.is-downbeat { border-color: rgba(104, 69, 47, 0.65); }
.beat-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 20px; }
.beat-dot { width: 13px; height: 13px; border: 2px solid var(--wood); border-radius: 50%; background: transparent; }
.beat-dot.is-current { background: var(--brass); box-shadow: 0 0 0 4px rgba(181, 122, 55, 0.2); }
.session-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding-top: 18px; border-top: 1px solid var(--line); }
.session-stats div { min-width: 0; }
.session-stats dt { color: var(--muted); font-size: 0.78rem; }
.session-stats dd { margin: 3px 0 0; font-family: Georgia, serif; font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 700; }

.visual-card { overflow: hidden; padding: 0; }
.visual-card img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.visual-caption { padding: 18px 22px 22px; }
.visual-caption p:last-child { color: var(--muted); }

.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
.info-card { padding: 22px; box-shadow: none; }
.info-card h2 { font-size: 1.2rem; }
.info-card p, .info-card li { margin-top: 11px; color: var(--muted); font-size: 0.9rem; }
.info-card ul, .info-card ol { margin: 0; padding-left: 1.15rem; }
.article-index { margin: 30px 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 250, 242, 0.84); }
.article-index .section-heading { margin-bottom: 18px; }
.article-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.article-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.article-card h3 { font-size: 1rem; line-height: 1.55; }
.article-card a { color: var(--wood-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.article-card p { margin-top: 9px; color: var(--muted); font-size: 0.88rem; }
.site-footer { padding: 0 0 32px; color: var(--muted); font-size: 0.82rem; }

[aria-invalid="true"] { border-color: var(--danger) !important; box-shadow: 0 0 0 2px rgba(150, 63, 53, 0.14); }

@keyframes pulse { from { transform: scale(0.96); } to { transform: scale(1); } }

@media (max-width: 900px) {
  .practice-layout { grid-template-columns: 1fr; }
  .display-column { grid-template-columns: minmax(0, 1fr) minmax(0, 0.78fr); align-items: start; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .header-inner, main, .site-footer { width: min(100% - 24px, 1180px); }
  .header-inner { padding: 34px 0 30px; }
  main { padding-top: 16px; }
  .card { padding: 18px; border-radius: 14px; }
  .settings-grid, .progression-grid, .display-column, .info-grid, .article-cards { grid-template-columns: 1fr; }
  .tempo-entry input { max-width: none; }
  .step-actions > button { flex: 1 1 65px; }
  .step-actions .tap-button { flex-basis: 100%; }
  .primary-button, .stop-button { flex: 1 1 120px; }
  .visual-card img { max-height: 210px; }
  .tuner-display { grid-template-columns: 1fr; }
  .tuner-note { grid-row: auto; }
  .tuner-frequency, .tuner-cents { justify-self: start; }
}

@media (max-width: 340px) {
  .header-inner, main, .site-footer { width: calc(100% - 20px); }
  .card { padding: 15px; }
  .primary-button, .stop-button { min-width: 0; }
  .field-label-row { display: block; }
  .field-label-row output { display: block; margin-top: 3px; }
  .session-stats { gap: 5px; }
  .session-stats dd { font-size: 1.15rem; }
}

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


/* Stage A: compact first view */
.stage-a-hero h1 { word-break: auto-phrase; }
.stage-a-hero .stage-a-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 16px; margin: 1rem 0 0.85rem; padding: 0; list-style: none; counter-reset: stage-a-step; }
.stage-a-hero .stage-a-steps li { display: flex; min-width: 0; gap: 0.5rem; align-items: baseline; counter-increment: stage-a-step; font-size: 0.9rem; line-height: 1.45; }
.stage-a-hero .stage-a-steps li::before { content: counter(stage-a-step, decimal-leading-zero); flex: none; font-size: 0.74rem; font-weight: 800; }
.stage-a-cta { display: inline-flex; min-height: 44px; max-width: 100%; align-items: center; justify-content: center; padding: 0.65rem 1.15rem; border: 1px solid #26383d; border-radius: 999px; background: #fff; color: #18272d; font-weight: 750; line-height: 1.25; text-align: center; text-decoration: none; white-space: nowrap; }
.site-header.stage-a-hero .header-inner { padding-block: clamp(24px, 3.5vw, 38px); }
.site-header.stage-a-hero h1 { max-width: none; margin: 0; font-size: clamp(2rem, 4.2vw, 3.35rem); line-height: 1.12; }
.site-header.stage-a-hero .lede { margin: 0.6rem 0 0; line-height: 1.5; }
@media (max-width: 640px) {
  .site-header.stage-a-hero .header-inner { padding-block: 20px 22px; }
  .site-header.stage-a-hero h1 { font-size: clamp(1.6rem, 8vw, 2.15rem); line-height: 1.16; }
  .site-header.stage-a-hero .lede { font-size: 0.92rem; line-height: 1.45; }
  .stage-a-hero .stage-a-steps { grid-template-columns: minmax(0, 1fr); gap: 4px; margin-block: 0.75rem; }
  .stage-a-hero .stage-a-steps li { font-size: 0.86rem; }
  .stage-a-hero .stage-a-cta { min-width: 12rem; }
  .settings-card > .section-heading { margin-bottom: 0.75rem; }
  .settings-card > .section-heading > .eyebrow { display: none; }
  .settings-card > .section-heading h2 { margin: 0 0 0.3rem; font-size: 1.25rem; line-height: 1.25; }
  .settings-card > .section-heading p { margin: 0; font-size: 0.88rem; line-height: 1.4; }
}
