/* Music tools site. Design: DESIGN.md (ElevenLabs-inspired). */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: optional; src: url(/fonts/inter-latin.woff2) format('woff2'); }
@font-face { font-family: 'Newsreader'; font-style: normal; font-weight: 300 400; font-display: optional; src: url(/fonts/newsreader-latin.woff2) format('woff2'); }

:root {
  --canvas: #f5f5f5; --card: #ffffff; --strong: #f0efed; --ink: #0c0a09; --primary: #292524; --on-primary: #ffffff;
  --body: #4e4e4e; --muted: #6b655e; --line: #e7e5e4; --line-strong: #d6d3d1; --display: #0c0a09; --on-display: #ffffff;
  --display-soft: #a8a29e; --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --family: #f4c5a8;
  --board: #efe6da; --fret: #bcae9c; --shadow: 0 4px 16px rgba(0, 0, 0, .04);
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --canvas: #0c0a09; --card: #1c1917; --strong: #292524; --ink: #f5f5f4; --primary: #f5f5f4; --on-primary: #0c0a09;
  --body: #c7c2bd; --muted: #a8a29e; --line: #2e2a27; --line-strong: #44403c; --display: #000000;
  --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --board: #2b241d; --fret: #5c5146; --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0c0a09; --card: #1c1917; --strong: #292524; --ink: #f5f5f4; --primary: #f5f5f4; --on-primary: #0c0a09;
    --body: #c7c2bd; --muted: #a8a29e; --line: #2e2a27; --line-strong: #44403c; --display: #000000;
    --ok: #22c55e; --warn: #f59e0b; --bad: #f87171; --board: #2b241d; --fret: #5c5146; --shadow: none;
    color-scheme: dark;
  }
}
.fam-keys { --family: #f4c5a8; } .fam-chords { --family: #e8b8c4; } .fam-tuners { --family: #a7e5d3; }
.fam-voice { --family: #c8b8e0; } .fam-winds { --family: #eadba6; } .fam-rhythm { --family: #a8c8e8; } .fam-sound { --family: #cfe3a3; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--body); font: 400 16px/1.6 var(--sans); letter-spacing: .01em; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* top bar */
.top { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 400 22px/1 var(--serif); letter-spacing: -.01em; white-space: nowrap; }
.brand img { display: block; }
.top nav:not(.langs) { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav:not(.langs) a { text-decoration: none; color: var(--body); font-weight: 500; font-size: 15px; padding: 8px 12px; border-radius: 9999px; white-space: nowrap; }
.top nav:not(.langs) a:hover, .top nav:not(.langs) a[aria-current] { background: var(--strong); color: var(--ink); }
.theme-btn { border: 1px solid var(--line-strong); background: transparent; border-radius: 9999px; width: 40px; height: 40px; cursor: pointer; flex: none; }
@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 4px 12px; padding-top: 8px; }
  .top nav:not(.langs) { order: 3; width: 100%; margin: 0 -16px; padding: 0 16px 6px; }
  .theme-btn { margin-left: auto; }
}

/* headings */
h1, h2, h3 { color: var(--ink); font-family: var(--serif); font-weight: 300; letter-spacing: -.02em; }
h1 { font-size: 44px; line-height: 1.08; margin: 20px 0 6px; }
h2 { font-size: 28px; line-height: 1.2; margin: 40px 0 10px; }
h3 { font-size: 21px; line-height: 1.25; margin: 26px 0 8px; font-weight: 400; }
.lede { margin: 0 0 18px; font-size: 17px; max-width: 720px; }
@media (max-width: 640px) { h1 { font-size: 32px; margin-top: 12px; } h2 { font-size: 24px; } .lede { font-size: 16px; } }

/* tool card */
.tool { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: var(--shadow); isolation: isolate; }
.tool::before { content: ''; position: absolute; z-index: -1; width: 520px; height: 520px; right: -200px; top: -300px; border-radius: 50%;
  background: radial-gradient(circle, var(--family) 0%, transparent 65%); opacity: .55; pointer-events: none; }
:root[data-theme="dark"] .tool::before { opacity: .16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tool::before { opacity: .16; } }
@media (max-width: 640px) { .tool { padding: 14px; border-radius: 20px; margin: 0 -6px; } }
.tool + .tool { margin-top: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }

/* controls */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row + .row { margin-top: 10px; }
.spread { justify-content: space-between; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: 9999px;
  border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary); font-weight: 500; font-size: 15px; cursor: pointer; text-decoration: none; line-height: 1.1; }
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--strong); filter: none; }
.btn.big { min-height: 56px; padding: 14px 28px; font-size: 17px; }
.btn[disabled] { opacity: .45; cursor: default; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 9999px; border: 1px solid transparent;
  background: var(--strong); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; line-height: 1.1; }
.chip[aria-pressed="true"], .chip.on { background: var(--primary); color: var(--on-primary); }
.chip:hover { border-color: var(--line-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
label.field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--body); }
select, input[type="number"], input[type="text"] { min-height: 40px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); }
input[type="range"] { accent-color: var(--primary); }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 12px; text-align: center; background: var(--card); color: var(--ink); }

/* display panel (readings) */
.display { background: var(--display); color: var(--on-display); border-radius: 20px; padding: 18px; text-align: center; position: relative; }
.display .big { font: 600 72px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.display .mid { font: 600 28px/1.2 var(--sans); font-variant-numeric: tabular-nums; }
.display .soft { color: var(--display-soft); font-size: 14px; }
.display .ok { color: #4ade80; } .display .warn { color: #fbbf24; } .display .bad { color: #f87171; }
@media (max-width: 640px) { .display .big { font-size: 56px; } }

/* piano keyboard */
.kb { position: relative; height: 180px; user-select: none; -webkit-user-select: none; touch-action: none; margin: 12px 0 4px; }
.kb .w, .kb .b { position: absolute; top: 0; border-radius: 0 0 8px 8px; cursor: pointer; }
.kb .w { height: 100%; background: #fff; border: 1px solid #d6d3d1; z-index: 1; }
.kb .b { height: 62%; background: #1c1917; z-index: 2; border: 1px solid #0c0a09; border-top: 0; box-shadow: inset 0 -4px 0 rgba(255,255,255,.08); }
.kb .w.on { background: var(--family); } .kb .b.on { background: #57534e; }
.kb .w.mark::after, .kb .b.mark::after { content: ''; position: absolute; left: 50%; bottom: 12px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--primary); }
:root[data-theme="dark"] .kb .w.mark::after { background: #0c0a09; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kb .w.mark::after { background: #0c0a09; } }
.kb .b.mark::after { background: #fff; bottom: 10px; }
.kb .w.mark2::after, .kb .b.mark2::after { background: var(--ok); }
.kb .lbl { position: absolute; left: -4px; right: -4px; bottom: 6px; text-align: center; font-size: 11px; color: #6b655e; pointer-events: none; line-height: 1.1; white-space: nowrap; }
.kb .b .lbl { color: #d6d3d1; bottom: 4px; font-size: 10px; }
.kb .w.mark .lbl { bottom: 30px; } .kb .b.mark .lbl { bottom: 28px; }
.kb .hint { position: absolute; bottom: 26px; left: 0; right: 0; text-align: center; font: 600 11px var(--sans); color: #a8a29e; pointer-events: none; }
.kb .b .hint { bottom: 8px; color: #78716c; }
.kb-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.kb-scroll .kb { min-width: 640px; }
@media (max-width: 640px) { .kb { height: 150px; } }

/* fretboard */
.fb-wrap { overflow-x: auto; padding-bottom: 6px; }
.fb { display: block; min-width: 640px; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.fb .board { fill: var(--board); } .fb .fret { stroke: var(--fret); stroke-width: 2; } .fb .nut { stroke: var(--ink); stroke-width: 6; }
.fb .string { stroke: #8a7f73; } .fb .inlay { fill: var(--fret); opacity: .7; }
.fb .dot { fill: var(--primary); pointer-events: none; } .fb .dot-text { fill: var(--on-primary); font: 600 12px var(--sans); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fb .dot.root { fill: #b45309; } :root[data-theme="dark"] .fb .dot.root { fill: #f59e0b; }
.fb .hit { fill: transparent; cursor: pointer; } .fb .hit:hover { fill: rgba(0,0,0,.06); }
.fb .fnum { fill: var(--muted); font: 500 11px var(--sans); text-anchor: middle; }
.fb .sname { fill: var(--muted); font: 600 12px var(--sans); text-anchor: middle; dominant-baseline: central; }
.fb .mute { fill: var(--muted); font: 600 14px var(--sans); text-anchor: middle; dominant-baseline: central; }

/* chord diagrams */
.diagrams { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.diagram { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 10px 6px; text-align: center; cursor: pointer; }
.diagram:hover { border-color: var(--line-strong); }
.diagram svg { width: 100%; height: auto; }
.diagram .cap { font-size: 13px; color: var(--muted); }
.cd .grid { stroke: var(--ink); stroke-width: 1.4; } .cd .nutline { stroke: var(--ink); stroke-width: 5; }
.cd .fdot { fill: var(--primary); } .cd .ftxt { fill: var(--on-primary); font: 600 10px var(--sans); text-anchor: middle; dominant-baseline: central; }
.cd .open { fill: none; stroke: var(--ink); stroke-width: 1.4; } .cd .x { stroke: var(--ink); stroke-width: 1.4; }
.cd .base { fill: var(--muted); font: 500 11px var(--sans); } .cd .nlab { fill: var(--muted); font: 500 10px var(--sans); text-anchor: middle; }

/* prose */
.prose { max-width: 760px; margin-top: 12px; }
.prose p, .prose li { color: var(--body); }
.prose ul, .prose ol { padding-left: 22px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 12px 0; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { color: var(--ink); font-weight: 600; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.faq details p { margin: 8px 0 0; }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; list-style: none; padding: 0 !important; }
.related a { display: block; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; font-weight: 500; }
.related a:hover { border-color: var(--line-strong); }

/* hub */
.hub .fam { margin: 28px 0; }
.hub .fam h2 { margin-top: 0; }
.hub ul { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.hub li a { display: block; height: 100%; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; position: relative; overflow: hidden; isolation: isolate; }
.hub li a::before { content: ''; position: absolute; z-index: -1; width: 160px; height: 160px; right: -70px; top: -90px; border-radius: 50%; background: radial-gradient(circle, var(--family) 0%, transparent 65%); opacity: .6; }
.hub li b { display: block; color: var(--ink); font-weight: 600; }
.hub li span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }

/* footer */
.foot { margin-top: 64px; border-top: 1px solid var(--line); padding: 32px 0 40px; font-size: 14px; }
.fgroups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 20px; }
.fgroups h3 { font: 600 13px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.fgroups ul { list-style: none; padding: 0; margin: 0; }
.fgroups li { margin: 3px 0; }
.fgroups a, .finfo a { color: var(--body); text-decoration: none; }
.fgroups a:hover, .finfo a:hover { color: var(--ink); text-decoration: underline; }
.foot p { color: var(--muted); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--primary); color: var(--on-primary); padding: 10px 18px; border-radius: 9999px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }

/* notice (mic states etc.) */
.notice { border-radius: 12px; padding: 10px 14px; background: var(--strong); color: var(--ink); font-size: 14px; }
.notice.bad { background: #fde8e8; color: #7f1d1d; }
:root[data-theme="dark"] .notice.bad { background: #3b1414; color: #fecaca; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* instrument cluster links */
.cluster { margin: 28px 0 0; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; font-size: 15px; line-height: 1.8; }
.cluster + .cluster { margin-top: 10px; }
.cluster b { color: var(--ink); font-weight: 600; margin-right: 4px; }

/* language switch */
.langs { display: flex; gap: 2px; flex: none; }
.langs a { text-decoration: none; color: var(--body); font-size: 14px; font-weight: 600; padding: 7px 9px; border-radius: 9999px; white-space: nowrap; }
.langs a:hover, .langs a[aria-current] { background: var(--strong); color: var(--ink); }
.langs a span { font-size: 16px; }
.langs a .lc { display: none; }                   /* 4 languages: flags only (name in aria-label/title) */
@media (max-width: 720px) {
  .langs { margin-left: auto; gap: 0; }
  .langs a { padding: 6px 7px; }
  .langs a .lc { display: none; }                 /* phones: flags only (name in aria-label/title) */
  .theme-btn { margin-left: 0; width: 36px; height: 36px; }
  .top { column-gap: 6px; }                         /* 4 flags + menu + theme fit on one line at 375px */
  .langs a { padding: 6px 4px; }
}
@media (max-width: 380px) {
  .brand { font-size: 19px; gap: 6px; }
  .brand img { width: 24px; height: 24px; }
  .menu > summary { width: 36px; height: 36px; }
}

/* Japanese: system Japanese fonts (the self-hosted Latin fonts have no kana or kanji); Mincho for the light editorial
   headings, Gothic for UI and body; no extra letter-spacing, looser line height for body text */
/* system fonts only: a late-loading Latin web font re-flows Japanese lines (measured CLS 0.36 before this) */
:lang(ja) body, body:lang(ja) { font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', YuGothic, Meiryo, 'Noto Sans JP', system-ui, sans-serif; letter-spacing: 0; line-height: 1.8; }
:lang(ja) h1, :lang(ja) h2, :lang(ja) h3 { font-family: 'Hiragino Mincho ProN', 'Yu Mincho', YuMincho, 'Noto Serif JP', serif; letter-spacing: 0; }
:root:lang(ja) { --sans: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', YuGothic, Meiryo, 'Noto Sans JP', system-ui, sans-serif;
  --serif: 'Hiragino Mincho ProN', 'Yu Mincho', YuMincho, 'Noto Serif JP', serif; }
:lang(ja) .brand { font-family: 'Newsreader', Georgia, serif; }
:lang(ja) h1 { font-size: 38px; line-height: 1.25; }
@media (max-width: 640px) { :lang(ja) h1 { font-size: 28px; } }

/* cookie consent (GA4 loads only after Accept) */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 560px; margin: 0 auto; background: var(--card); color: var(--body);
  border: 1px solid var(--line-strong); border-radius: 16px; padding: 14px 16px; box-shadow: 0 8px 28px rgba(0,0,0,.14); font-size: 14px; }
.consent p { margin: 0 0 10px; } .consent b { color: var(--ink); }
.consent-btns { display: flex; gap: 8px; justify-content: flex-end; }
.consent .btn { min-height: 40px; padding: 8px 18px; }

/* footer: five links per family, then "See all" */
.fgroups h3 a { color: inherit; text-decoration: none; }
.fgroups h3 a:hover { color: var(--ink); }
.fgroups .fmore a { color: var(--ink); font-weight: 600; }
.hub .fam { scroll-margin-top: 16px; }

/* tools menu (header): dropdown on desktop, full screen on phones */
/* Sticky header: always visible at the top (phones lost the nav mid-page).
   With the menu open it rises above the cookie notice, as before. */
.top{position:sticky;top:0;z-index:30;background:var(--canvas);border-image:linear-gradient(var(--canvas),var(--canvas)) fill 0/0/0 100vmax}
@media print{.top{position:static}}
.top:has(.menu[open]) { z-index: 70; }
.menu { position: static; flex: none; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9999px;
  font-weight: 500; font-size: 15px; color: var(--body); white-space: nowrap; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--strong); color: var(--ink); }
.menu-ico { position: relative; width: 16px; height: 2px; background: currentColor; border-radius: 2px; box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor; margin: 0 1px; }
.menu-panel { position: absolute; left: 16px; right: 16px; top: calc(100% + 4px); max-height: min(80vh, 760px); overflow: auto;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: 0 16px 48px rgba(0,0,0,.18); padding: 16px 18px 18px; z-index: 70; }
.menu-top { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.menu-top input { flex: 1; min-width: 0; min-height: 44px; border-radius: 9999px; padding: 8px 16px; font-size: 16px; }
.menu-hub { font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.menu-close { display: none; border: 1px solid var(--line-strong); background: transparent; border-radius: 9999px; width: 44px; height: 44px; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink); flex: none; }
.menu-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px 16px; }
.menu-fam h3, :lang(ja) .menu-fam h3 { font: 600 12px/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 2px 0 6px; padding-left: 8px; border-left: 3px solid var(--family); }
.menu-fam ul { list-style: none; padding: 0; margin: 0; }
.menu-fam a { display: block; padding: 7px 8px; border-radius: 10px; text-decoration: none; color: var(--ink); font-size: 15px; line-height: 1.3; }
.menu-fam a:hover, .menu-fam a:focus-visible { background: var(--strong); }
.menu-fam a[aria-current] { font-weight: 600; background: var(--strong); }
.menu-empty { margin: 8px; }
@media (max-width: 720px) {
  .top nav:not(.langs) { display: none; }
  .menu > summary { padding: 0; width: 40px; height: 40px; justify-content: center; border: 1px solid var(--line-strong); }
  .menu-lbl { display: none; }
  .menu-panel { position: fixed; inset: 0; left: 0; right: 0; top: 0; width: auto; max-height: none; border-radius: 0; border: 0; padding: 12px 16px 32px; }
  .menu-close { display: inline-block; }
  .menu-hub { display: none; }
  .menu-groups { grid-template-columns: 1fr 1fr; gap: 16px 12px; }
  .menu-fam a { padding: 9px 8px; font-size: 14px; }
  body.menu-open { overflow: hidden; }
}
@media (max-width: 330px) { .menu-groups { grid-template-columns: 1fr; } }

/* tools are revealed once their scripts have drawn them (html.tl is removed on DOMContentLoaded), so nothing inside
   a tool visibly moves while it is built; the block's height is reserved per page by build.py (no layout shift) */
.tl main .tool { visibility: hidden; }
@media (min-width: 721px) and (max-width: 1100px) {
  .top nav:not(.langs) { display: none; }          /* tablets: the four shortcuts do not fit; the tools menu covers them */
  .top .menu { margin-left: auto; }
}
