:root {
  --bg: #e7f0fa;
  --card: #ffffff;
  --ink: #172033;
  --muted: #526277;
  --line: #d3dfed;
  --accent: #134e9a;
  --accent-dark: #0e3f7d;
  --accent-soft: #e7f1fc;
  --good: #0d7a45;
  --good-bg: #e5f6ed;
  --bad: #a61b22;
  --bad-bg: #fdeceb;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.06);
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 1.0625rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
}

button, input { font: inherit; }

button { touch-action: manipulation; cursor: pointer; }

button:disabled { cursor: default; }

a { color: var(--accent-dark); }

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

.wrap {
  width: min(44rem, calc(100% - 1.5rem));
  margin-inline: auto;
}

.top {
  padding: calc(0.8rem + env(safe-area-inset-top)) 0 0.4rem;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.92rem;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

h2 { margin: 0 0 0.55rem; font-size: 1.18rem; }

h3 {
  margin: 1.1rem 0 0.3rem;
  font-size: 1rem;
}

main {
  display: grid;
  gap: 0.9rem;
  padding-bottom: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1rem 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.note {
  margin: 0.2rem 0 0.85rem;
  color: var(--muted);
}

.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.primary, .secondary, .answer, .chip, .quiet {
  user-select: none;
}

.primary {
  width: 100%;
  min-height: 4.25rem;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  font-size: 1.28rem;
  font-weight: 800;
}

.primary:disabled { background: #8ea4bd; }

.play-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.secondary, .quiet {
  min-height: 3.6rem;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: white;
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 1.02rem;
}

.secondary:disabled, .quiet:disabled {
  border-color: #c5d3e4;
  color: #7d8da3;
  background: #f7fafc;
}

.answers {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.answer {
  min-height: 4.6rem;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.25;
}

.answer small, .chip small {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
}

.answer:disabled { opacity: 0.72; }

.answer.is-correct {
  opacity: 1;
  border-color: var(--good);
  background: var(--good-bg);
}

.answer.is-wrong {
  opacity: 1;
  border-color: var(--bad);
  background: var(--bad-bg);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.6rem;
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 3.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  line-height: 1.25;
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.chip[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.86); }

details.later {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

details.later summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 800;
  cursor: pointer;
}

.later-help { margin-top: 0.7rem; }

.feedback {
  margin-top: 0.9rem;
}

.feedback:empty { display: none; }

.feedback p { margin: 0.35rem 0; }

.feedback-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.feedback.good {
  background: var(--good-bg);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
}

.feedback.bad {
  background: var(--bad-bg);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
}

.feedback .notes {
  font-size: 1.12rem;
  font-weight: 800;
}

.letters { white-space: nowrap; }

.feedback a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 800;
}

.stat-overall {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0.2rem 0;
  letter-spacing: 0.01em;
}

.stat-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.8rem;
}

.stat-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.stat-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.bar {
  display: block;
  height: 0.4rem;
  margin-top: 0.35rem;
  background: #e6eef6;
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.quiet {
  width: 100%;
  border-color: var(--line);
  color: var(--ink);
}

.toc-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
}

.toc {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.55rem 0 0.7rem;
}

.toc a {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.9rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
}

.prose h2 { margin-top: 1.2rem; }

.prose p, .prose li { margin: 0.35rem 0 0.7rem; }

.prose ul { padding-left: 1.2rem; }

.degree-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0.8rem;
}

.degree-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}

.degree-list strong { min-width: 2.4rem; }

.formula {
  margin: 0.2rem 0 0.35rem;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.example-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  margin: 0.8rem 0;
  font-size: 1.12rem;
  font-weight: 800;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
}

.tone {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.deg {
  min-width: 2.2rem;
  font-weight: 800;
  color: var(--accent-dark);
}

.chord-card { scroll-margin-top: 4.4rem; }

.footer-nav { margin: 0.4rem 0 1rem; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.footer-nav.site-nav { justify-content: flex-start; }

.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

a.term {
  font-weight: 800;
  text-underline-offset: 0.18em;
}

.similar a { white-space: nowrap; }

.group-title {
  margin: 0.4rem 0 0;
  scroll-margin-top: 4.4rem;
}

.term-card { scroll-margin-top: 4.4rem; }

.term-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.28rem;
}

.term-fact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.7rem;
  align-items: baseline;
  margin: 0.3rem 0 0.7rem;
}

.term-fact span {
  color: var(--muted);
  font-weight: 700;
}

.kb {
  position: relative;
  display: flex;
  height: 7.4rem;
  margin: 0.8rem 0 0.2rem;
  user-select: none;
}

.kb-white {
  position: relative;
  z-index: 0;
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  margin-left: -1px;
  padding: 0 0 0.28rem;
  border: 1px solid #c5d4e6;
  border-radius: 0 0 7px 7px;
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.kb-white:first-child { margin-left: 0; }

.kb-white.is-on {
  background: #d7e8fb;
  color: var(--accent-dark);
}

.kb-blacks {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.kb-black {
  position: absolute;
  top: 0;
  width: 7.2%;
  height: 58%;
  border-radius: 0 0 4px 4px;
  background: #243044;
  transform: translateX(-50%);
}

.kb-black.is-on { background: var(--accent); }

@media (min-width: 640px) {
  .answers:not(.is-pair) { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  .answers.is-pair { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  body { font-size: 1.125rem; }
  .wrap { width: min(48rem, calc(100% - 3rem)); }
  .card { padding: 1.25rem 1.4rem 1.4rem; }
  h1 { font-size: 1.9rem; }
}

@media (max-width: 359px) {
  .type-grid, .play-row { grid-template-columns: 1fr; }
  .wrap { width: min(44rem, calc(100% - 1rem)); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
