/* Typing Song — 余白を多めにとった、音楽アプリらしいシンプルなダークテーマ */

:root {
    --bg: #0d0e1a;
    --surface: #161829;
    --surface-raised: #1d2036;
    --surface-sunken: #0f1122;
    --border: #2b2f4f;
    --text: #eceaff;
    --text-muted: #a4a6c9;
    --accent: #8f7dff;
    --accent-strong: #b0a3ff;
    --accent-ink: #120f2b;
    --melody: #3fd6c3;
    --playhead: #ffd166;
    --warn: #ffa071;
    --danger: #ff7b93;
    --pause-fill: rgba(255, 160, 113, 0.14);
    --pause-line: rgba(255, 160, 113, 0.5);
    --radius-lg: 20px;
    --radius-md: 12px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 520px at 8% -12%, rgba(143, 125, 255, 0.2), transparent 62%),
        radial-gradient(900px 480px at 108% 4%, rgba(63, 214, 195, 0.12), transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-strong);
}

h1,
h2,
h3 {
    margin: 0 0 0.6em;
    line-height: 1.35;
    letter-spacing: 0.01em;
}

h1 {
    font-size: clamp(1.5rem, 2.6vw + 0.8rem, 2.2rem);
}

h2 {
    margin-top: 2rem;
    font-size: 1.15rem;
}

p {
    margin: 0 0 1em;
}

h1:focus {
    outline: none;
}

/* 日本語を文節の切れ目で折り返す（「ドラ／ム」のように単語の途中で切らない）。対応していないブラウザでは通常の折り返しになる */
h1,
h2,
h3,
p,
dt,
dd,
li,
.strip-labels span {
    word-break: auto-phrase;
}

/* レイアウト */

.app-shell {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 20px 48px;
}

.site-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 0 30px;
}

.brand {
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.brand-mark {
    margin-right: 6px;
    color: var(--melody);
}

.brand-tag {
    padding: 0 8px;
    border-radius: 999px;
    background: var(--accent-strong);
    color: var(--accent-ink);
    font-size: 0.7rem;
    font-weight: 700;
}

/* 上の帯の右端の、言語の切り替え。今の言語は押した状態（aria-pressed）で示す */
.language-switch {
    display: inline-flex;
    margin-left: auto;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.language-switch button {
    padding: 4px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.language-switch button:hover {
    color: var(--text);
}

.language-switch button[aria-pressed="true"] {
    background: var(--surface-raised);
    color: var(--text);
    cursor: default;
}

.language-switch button:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
}

.site-footer {
    margin-top: 56px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.panel {
    margin-bottom: 24px;
    padding: clamp(20px, 4vw, 36px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel > h2:first-child {
    margin-top: 0;
}

.eyebrow {
    margin-bottom: 0.4em;
    color: var(--accent-strong);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.lead-text {
    color: var(--text-muted);
    font-size: 1.02rem;
}

/* 選んだ設定・曲の情報（ジャンル・BPM・調など）を、区切り記号で並べる代わりに 1 つずつのタグにする */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.tags li {
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(143, 125, 255, 0.14);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.caption {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.hint {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.status {
    margin-top: 20px;
    color: var(--text-muted);
}

.error {
    padding: 10px 14px;
    border: 1px solid rgba(255, 123, 147, 0.4);
    border-radius: var(--radius-md);
    background: rgba(255, 123, 147, 0.1);
    color: var(--danger);
}

/* ボタン */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible,
.choice-option:focus-within,
.lyrics-input:focus-visible {
    outline: 3px solid var(--melody);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover {
    background: var(--accent-strong);
}

.btn-secondary {
    border-color: var(--border);
    background: var(--surface-raised);
    color: var(--text);
}

.btn-secondary:hover {
    border-color: var(--accent);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text);
}

.btn-large {
    padding: 14px 34px;
    font-size: 1.08rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

/* 結果画面: 動画の保存（作っている間の進み具合、保存したあとの案内と控えめな応援リンク）と、
   スマホで曲の音を先に作っている間の進み具合 */
.video-progress,
.sound-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
}

.video-progress p,
.sound-progress p {
    margin: 0;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* 曲の音を先に作る理由と「この画面のまま」の案内は、進み具合の下に出す */
.sound-progress .hint {
    flex-basis: 100%;
}

/* スマホ（タッチの画面）でだけ見せるもの。PC では出さない */
.touch-only {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    .touch-only {
        display: block;
    }
}

/* 動画を作っている間の「この画面のまま」の案内は、進み具合の下に 1 行で出す */
.video-progress .touch-only {
    flex-basis: 100%;
}

/*
 * 作っている間に流れる音符。1 拍（--beat）ごとに 1 つずつ左から入り、拍に合わせて揺れながら右へ流れ、消えていく。
 * 動かすのは translate・rotate・scale・opacity だけにする。ブラウザが画面の処理とは別に描くので、
 * 動画の書き出しで処理が混んでもカクつかない。動きを減らす設定の人には出さない（下の @media の外では display: none）。
 */
.saving-notes {
    display: none;
    position: relative;
    flex-basis: 100%;
    height: 80px;
    overflow: hidden;
    container-type: inline-size;
    pointer-events: none;
}

.saving-note {
    position: absolute;
    top: var(--lane);
    left: 0;
    font-family: "Segoe UI Symbol", var(--font);
    font-size: var(--size);
    line-height: 1;
    opacity: 0;
    text-shadow: 0 0 12px currentColor;
}

.saving-note > span {
    display: inline-block;
}

/* 色はアプリの使い分け（メロディの青緑・打鍵の紫・再生位置の黄）を順にくり返す */
.saving-note:nth-child(3n + 1) {
    color: var(--melody);
}

.saving-note:nth-child(3n + 2) {
    color: var(--accent-strong);
}

.saving-note:nth-child(3n) {
    color: var(--playhead);
}

/* 音符ごとの高さと大きさ（メロディのように上下させる） */
.saving-note:nth-child(1) { --lane: 30px; --size: 1.7rem; }
.saving-note:nth-child(2) { --lane: 14px; --size: 1.35rem; }
.saving-note:nth-child(3) { --lane: 36px; --size: 1.5rem; }
.saving-note:nth-child(4) { --lane: 8px; --size: 1.8rem; }
.saving-note:nth-child(5) { --lane: 26px; --size: 1.4rem; }
.saving-note:nth-child(6) { --lane: 40px; --size: 1.6rem; }
.saving-note:nth-child(7) { --lane: 16px; --size: 1.3rem; }
.saving-note:nth-child(8) { --lane: 32px; --size: 1.75rem; }

@media (prefers-reduced-motion: no-preference) {
    .saving-notes {
        display: block;
    }

    /* 8 拍かけて流れる。i 番目の音符は i 拍ぶん先に出発させ、最初から帯の全体に散らばった状態で始める。 */
    .saving-note {
        animation: saving-note-flow calc(var(--beat) * 8) linear calc(var(--beat) * var(--i) * -1) infinite;
    }

    /* 1 拍ごとに左右へ傾き、上下に弾む（隣どうしは逆向き）。 */
    .saving-note > span {
        animation: saving-note-dance var(--beat) ease-in-out calc(var(--beat) * var(--i) * -1) infinite alternate;
    }
}

@keyframes saving-note-flow {
    from {
        opacity: 0;
        translate: 0 0;
        scale: 0.6;
    }

    12% {
        opacity: 1;
        scale: 1;
    }

    70% {
        opacity: 1;
        scale: 1;
    }

    to {
        opacity: 0;
        translate: 90cqw -10px;
        scale: 0.5;
    }
}

@keyframes saving-note-dance {
    from {
        translate: 0 -6px;
        rotate: -14deg;
    }

    to {
        translate: 0 6px;
        rotate: 12deg;
    }
}

.video-saved {
    margin: 14px 0 0;
}

.support {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* トップ */

.hero {
    padding: 12px 0 8px;
}

/* 見出しの 1 文（15 文字）がスマートフォンの幅でも 1 行に収まる大きさにする */
.hero h1 {
    margin-bottom: 0.5em;
    font-size: clamp(1.35rem, 5.4vw, 2.9rem);
}

.hero .lead-text {
    max-width: 40em;
    margin: 0 0 24px;
    font-size: 1.05rem;
}

/* トップの使い方: 曲づくりの画面の進行（1. 設定 2. タイピング 3. 曲）と同じ見た目の番号付きの名前を、3 列に並べる */
.concept-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0;
    padding: 0;
    list-style: none;
    counter-reset: concept-step;
}

.concept-steps li {
    display: flex;
    flex-direction: column;
    gap: 6px;
    counter-increment: concept-step;
}

.concept-step-name {
    width: fit-content;
    padding: 2px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.concept-step-name::before {
    content: counter(concept-step) ". ";
}

.concept-step-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.device-note {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.privacy-note {
    max-width: 42em;
    margin: 32px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* トップの図: 打鍵（上段・紫）がメロディ（下段・青緑）になる例。色と描き方は結果画面の対応図と同じ */
.rhythm-strip {
    margin: 0;
}

.rhythm-strip svg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
}

.strip-pause {
    fill: var(--pause-fill);
    stroke: var(--pause-line);
    stroke-dasharray: 4 4;
}

.strip-key {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linecap: round;
}

.strip-divider {
    stroke: var(--border);
}

.strip-note {
    fill: var(--melody);
}

.strip-playhead {
    stroke: var(--playhead);
    stroke-width: 2.5;
    opacity: 0;
}

/* 図の下の名前は、図の区間（一定・連打・休止・ゆっくり）と同じ幅の列に置く */
.strip-labels {
    display: grid;
    grid-template-columns: 185fr 120fr 140fr 195fr;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.strip-labels span {
    padding-left: 6px;
}

/* 読み込み時に一度だけ、再生位置が左から右へ通り、通った打鍵と音符が光る */
@media (prefers-reduced-motion: no-preference) {
    .strip-key,
    .strip-note {
        animation: 0.7s ease-out calc(var(--at) * 3s + 0.4s) both;
    }

    .strip-key {
        animation-name: strip-key;
    }

    .strip-note {
        animation-name: strip-note;
    }

    .strip-playhead {
        animation: strip-sweep 3s linear 0.4s both;
    }
}

@keyframes strip-key {
    from {
        opacity: 0.3;
        stroke: var(--accent);
    }

    25% {
        opacity: 1;
        stroke: var(--playhead);
    }

    to {
        opacity: 1;
        stroke: var(--accent);
    }
}

@keyframes strip-note {
    from {
        opacity: 0.3;
        fill: var(--melody);
    }

    25% {
        opacity: 1;
        fill: var(--playhead);
    }

    to {
        opacity: 1;
        fill: var(--melody);
    }
}

@keyframes strip-sweep {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    92% {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateX(640px);
    }
}

/* 進行状況 */

.steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    list-style: none;
    counter-reset: step;
}

.steps li {
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    counter-increment: step;
}

.steps li::before {
    content: counter(step) ". ";
}

.steps li.current {
    border-color: var(--accent);
    background: rgba(143, 125, 255, 0.14);
    color: var(--text);
}

.steps li.done {
    color: var(--text);
}

/* 設定 */

.choice-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}

.choice-picker legend {
    margin-bottom: 10px;
    padding: 0;
    font-weight: 700;
}

.choice-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    cursor: pointer;
}

.choice-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-option.selected {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-option.disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.choice-name {
    font-weight: 700;
}

.choice-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* タイピング */

.timer {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 18px 0 8px;
    font-variant-numeric: tabular-nums;
}

.timer-value {
    font-size: clamp(3rem, 8vw, 4.5rem);
    font-weight: 800;
    line-height: 1;
}

.timer-value:empty::before {
    content: attr(data-initial);
}

.timer-unit {
    color: var(--text-muted);
}

.timer.running .timer-value {
    color: var(--accent-strong);
}

.progress-track {
    height: 6px;
    margin-bottom: 18px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-raised);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--melody));
    transform-origin: left center;
}

.lyrics-input {
    width: 100%;
    min-height: 9em;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
    color: var(--text);
    font: inherit;
    font-size: 1.15rem;
    line-height: 1.8;
    resize: vertical;
}

.lyrics-input:read-only {
    opacity: 0.7;
}

.lyrics-input:focus {
    border-color: var(--accent);
}

/* スマホ（タッチの画面）で記録している間は、画面のキーボードの上に、残り時間・バー・入力欄だけを収める。PC には当てはまらない */
@media (hover: none) and (pointer: coarse) {
    .typing-panel.recording .tags,
    .typing-panel.recording h1,
    .typing-panel.recording .hint {
        display: none;
    }

    /* 入力欄にフォーカスすると、ブラウザは入力欄が見えるようにスクロールする。そのとき残り時間が画面の外へ出ないよう、上に貼り付ける */
    .typing-panel.recording .typing-clock {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--surface);
    }

    .typing-panel.recording .timer {
        margin-top: 0;
    }

    /* 3 行ほど。高さは行数（rows）より CSS を優先させる */
    .typing-panel.recording .lyrics-input {
        min-height: 0;
        height: calc(3 * 1.8em + 34px);
    }
}

/* 結果 */

.player {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 20px 0 8px;
}

.volume-note {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 楽器: メロディ（選んだ楽器＋相方）と伴奏 */
.instruments {
    display: grid;
    gap: 12px;
    margin: 22px 0 0;
}

.instruments > div {
    display: grid;
    grid-template-columns: 4.5em minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
}

.instruments dt {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.instruments dd {
    margin: 0;
}

.melody-combo {
    display: block;
    margin-bottom: 8px;
    color: var(--melody);
    font-weight: 700;
}

/* メロディの楽器の切り替え */
.lead-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.chip:hover {
    border-color: var(--melody);
}

.chip.selected {
    border-color: var(--melody);
    box-shadow: inset 0 0 0 1px var(--melody);
    color: var(--melody);
}

.chip:focus-visible {
    outline: 3px solid var(--melody);
    outline-offset: 2px;
}

/* 打ち方 → 曲 の対応（dt が打ち方、dd が曲）。打ち方は打鍵の色（紫）、曲はメロディの色（青緑）で、対応図と同じ色分けにする */
.mapping {
    margin: 0;
}

.mapping > div {
    display: grid;
    grid-template-columns: minmax(0, 16em) minmax(0, 1fr);
    gap: 0 14px;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.mapping > div:last-child {
    border-bottom: 0;
}

/* 打ち方は右寄せにして、矢印を軸に左右へ読めるようにする（矢印は飾りなので読み上げない） */
.mapping dt {
    color: var(--accent-strong);
    text-align: right;
}

.mapping dt::after {
    margin-left: 14px;
    color: var(--text-muted);
    content: "→";
    content: "→" / "";
}

.mapping dd {
    margin: 0;
    color: var(--melody);
}

.more {
    margin-top: 14px;
}

.more summary {
    width: fit-content;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
}

.more summary:hover {
    color: var(--text);
}

.more summary:focus-visible {
    border-radius: 4px;
    outline: 3px solid var(--melody);
    outline-offset: 2px;
}

.more[open] summary {
    margin-bottom: 12px;
}

.more h3 {
    margin: 22px 0 10px;
    font-size: 0.95rem;
}

.explanations {
    margin: 0;
    padding-left: 1.2em;
    font-size: 0.92rem;
}

.explanations li {
    margin-bottom: 0.4em;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin: 0;
}

.stats div {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
}

.stats dt {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.stats dd {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stats dd small {
    margin-left: 2px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 400;
}

.lyrics {
    margin-top: 28px;
}

.lyrics h2 {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.lyrics-text,
.lyrics-empty {
    margin: 0 0 8px;
    padding: 16px 20px;
    border-left: 3px solid var(--melody);
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
}

.lyrics-text {
    font-size: 1.15rem;
    line-height: 1.9;

    /* 改行（Enter）をそのまま見せ、長い英数字の連続でも枠からはみ出さないようにする */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.lyrics-empty {
    color: var(--text-muted);
}

/* タイムライン */

.timeline {
    margin: 28px 0 0;
}


.timeline-sections {
    display: grid;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.timeline-sections span {
    padding: 2px 6px;
    overflow: hidden;
    border-left: 1px solid var(--border);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-sections .energy-high {
    color: var(--melody);
}

.timeline-svg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
}

.tl-section {
    fill: transparent;
}

.tl-section.alt {
    fill: rgba(255, 255, 255, 0.025);
}

.tl-ending {
    fill: rgba(143, 125, 255, 0.08);
}

.tl-pause {
    fill: var(--pause-fill);
    stroke: var(--pause-line);
    stroke-dasharray: 4 4;
}

.tl-burst {
    fill: var(--accent-strong);
}

.tl-key {
    stroke: var(--accent);
    stroke-width: 1.4;
}

.tl-key.back {
    stroke: var(--warn);
}

.tl-divider {
    stroke: var(--border);
}

.tl-note {
    fill: var(--melody);
}

/* 再生中の位置（audio-player.js が動かす）。その拍の打鍵と、鳴っているメロディの音を同じ色で光らせ、対応を追えるようにする */
.tl-playhead {
    display: none;
    stroke: var(--playhead);
    stroke-width: 2.5;
}

.timeline-svg.playing .tl-playhead {
    display: inline;
}

.timeline-svg.playing .tl-key.active {
    stroke: var(--playhead);
    stroke-width: 3;
}

.timeline-svg.playing .tl-note.active {
    fill: var(--playhead);
}

.timeline-axis {
    position: relative;
    height: 1.5em;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.timeline-axis span {
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    white-space: nowrap;
}

.timeline-axis span:first-child {
    transform: none;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 8px 0 0;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    list-style: none;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    border-radius: 3px;
    vertical-align: -1px;
}

.swatch-key {
    background: var(--accent);
}

.swatch-back {
    background: var(--warn);
}

.swatch-pause {
    background: rgba(255, 160, 113, 0.35);
}

.swatch-burst {
    background: var(--accent-strong);
}

.swatch-note {
    background: var(--melody);
}

.swatch-playhead {
    background: var(--playhead);
}

/* 試聴ページ（開発用） */

.tuning {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.tuning fieldset {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.tuning legend {
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tuning label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.9rem;
}

.tuning input {
    width: 6.5em;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-sunken);
    color: var(--text);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.style-select {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-weight: 600;
}

.style-select select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-sunken);
    color: var(--text);
    font: inherit;
}

.fixed-seed {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.9rem;
}

.sample-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sample-header h2 {
    margin: 0;
}

.sample-summary {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 共通 */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .app-shell {
        padding: 0 16px 40px;
    }

    /* 打ち方 → 曲 は 2 行にする（1 行目に打ち方、2 行目に「→ 曲」） */
    .mapping > div {
        grid-template-columns: minmax(0, 1fr);
    }

    .mapping dt {
        text-align: left;
    }

    .mapping dt::after {
        content: none;
    }

    .mapping dd::before {
        margin-right: 8px;
        color: var(--text-muted);
        content: "→";
    content: "→" / "";
    }

    .btn-large {
        width: 100%;
    }

    .strip-labels {
        font-size: 0.7rem;
    }

    .concept-steps {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }
}

/*
 * スマホ（タッチの画面）: 狭い画面で 1 行に 1〜2 個ずつ並んでいた小さな項目を、横に詰めて並べる。
 * 縦に長くなりすぎるため（開発者の要望）。上の幅の狭い画面の決まりより後に書いて、こちらを優先させる。PC は変えない。
 */
@media (hover: none) and (pointer: coarse) {
    /* 設定: ジャンル・雰囲気のカードは 1 行に 2 枚 */
    .choice-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .choice-option {
        padding: 10px 12px;
    }

    /*
     * トップ: 見出しは少し大きくし、説明の文は少し小さくする（開発者の要望）。
     * 見出しは句点を取って 14 文字になったので、空いた 1 文字分だけ大きくして 1 行に収める（画面の幅 − 左右の余白 32px を 14 文字で割る）。
     */
    .hero h1 {
        font-size: min(calc((100vw - 32px) / 14.2), 2.9rem);
    }

    .hero .lead-text {
        font-size: 0.95rem;
    }

    /* 幅が半分になって説明が折り返すので、日本語は文節の切れ目で折り返す（「鍵盤とドラムの軽 / 快な曲」のように語の途中で切らない） */
    .choice-desc {
        word-break: auto-phrase;
    }

    /* メロディの楽器: 見出しを上に出し、ボタンを横幅いっぱいに並べる（伴奏の行は見出しを左のままにする） */
    .instruments > div:has(.lead-picker) {
        grid-template-columns: minmax(0, 1fr);
        gap: 6px;
    }

    .chip {
        padding: 4px 9px;
    }

    /* 打鍵の記録: 2 列 */
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stats div {
        padding: 8px 12px;
    }

    /* 打ち方 → 曲: 入る長さなら 1 組 1 行。入らなければ「→ 曲」を次の行に送る */
    .mapping > div {
        display: flex;
        flex-wrap: wrap;
        column-gap: 8px;
    }

    /*
     * タイトルの帯と「1. 設定 2. タイピング 3. 曲」は、スクロールしても画面の上に残す（開発者の要望）。
     * いつも画面の上を使うので、帯の上下の余白を詰める（89px → 52px）。下を流れる中身が透けて読みにくくならないよう、
     * ぼかした背景を敷き、いちばん下に細い線を引く。フォーカスやスクロールで出す要素が、帯の下に隠れないようにする。
     */
    :root {
        --sticky-header-height: 52px;
    }

    html {
        scroll-padding-top: calc(var(--sticky-header-height) + 48px);
    }

    .site-header,
    .steps {
        position: sticky;
        z-index: 10;
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        backdrop-filter: blur(10px);
    }

    .site-header {
        top: 0;
        height: var(--sticky-header-height);
        padding: 0;
        border-bottom: 1px solid var(--border);
    }

    .steps {
        top: var(--sticky-header-height);
        margin-bottom: 14px;
        padding: 0 0 10px;
        border-bottom: 1px solid var(--border);
    }

    /* 「1. 2. 3.」があるときは、線をその下だけに引く（帯と「1. 2. 3.」をひと続きに見せる） */
    .app-shell:has(.steps) .site-header {
        border-bottom: 0;
    }

    /* 記録中は固定しない。画面のキーボードが開いても、残り時間と入力欄を出す場所を減らさないため（帯は上へ流れる） */
    .app-shell:has(.typing-panel.recording) .site-header,
    .app-shell:has(.typing-panel.recording) .steps {
        position: static;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
    }
}

/* Blazor の既定（読み込み表示・エラー表示） */

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 1000;
    display: none;
    width: 100%;
    padding: 0.6rem 1.25rem 0.7rem;
    background: #3a1d2a;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    color: var(--text);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
}

/* 起動前に出る文言は、index.html で両方の言語を持ち、<html lang>（起動前にスクリプトが決める）に合うほうだけを出す */
html[lang="en"] #blazor-error-ui [lang="ja"],
html[lang="ja"] #blazor-error-ui [lang="en"] {
    display: none;
}

.blazor-error-boundary {
    padding: 1rem;
    border-radius: var(--radius-md);
    background: #b32121;
    color: white;
}

.blazor-error-boundary::after {
    content: "エラーが発生しました。";
}

html[lang="en"] .blazor-error-boundary::after {
    content: "An error has occurred.";
}

.loading-progress {
    position: absolute;
    inset: 20vh 0 auto 0;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--surface-raised);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: var(--text-muted);
    font-weight: bold;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "読み込み中");
}

html[lang="en"] .loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}
