/* Listen (ear trainer) */
.ear-view { display: none; }
.ear-view.active { display: block; }

.ear-intro { color: var(--text-muted); margin: 0 0 var(--space-md); line-height: 1.5; }
.ear-section-title { font-weight: 600; margin: var(--space-md) 0 var(--space-xs); }
.ear-error { color: var(--danger, #f85149); }

.ear-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem var(--space-sm);
    margin-bottom: var(--space-xs);
    cursor: pointer;
}
.ear-group:has(input:checked) { border-color: var(--primary); }
.ear-group input { width: 1.2rem; height: 1.2rem; flex: none; accent-color: var(--primary); }
.ear-group-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.ear-group-title { font-weight: 600; }
.ear-group-count { color: var(--text-muted); font-weight: 400; font-size: 0.8rem; margin-left: 0.4rem; }
.ear-group-desc { color: var(--text-muted); font-size: 0.85rem; font-family: var(--font-japanese); }
.ear-group-score { color: var(--accent); font-size: 0.8rem; white-space: nowrap; }

.ear-start-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-md) 0; }
.ear-start-row select {
    background: var(--bg-card); color: var(--text-light);
    border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; font-size: 1rem;
}
.ear-setup-msg { color: var(--accent); }

.ear-reference-box { margin-top: var(--space-md); }
.ear-reference-box > summary { cursor: pointer; color: var(--text-muted); padding: var(--space-xs) 0; }
.ear-ref-group { margin: var(--space-md) 0 var(--space-xs); color: var(--accent); font-size: 0.95rem; }
.ear-ref-row {
    display: flex; gap: var(--space-sm); align-items: flex-start;
    padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.ear-ref-play {
    flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%;
    border: 2px solid var(--border); background: transparent; color: var(--text-light); cursor: pointer;
}
.ear-ref-play:hover { border-color: var(--primary); color: var(--primary); }
.ear-ref-head { font-weight: 600; }
.ear-ref-acc { color: var(--accent); font-weight: 400; font-size: 0.8rem; margin-left: 0.4rem; }
.ear-ref-note { color: var(--text-muted); font-size: 0.85rem; line-height: 1.45; margin: 0.15rem 0; }
.ear-ref-ex { font-family: var(--font-japanese); font-size: 1.05rem; line-height: 2; }
.ear-ref-en { color: var(--text-muted); font-size: 0.85rem; font-family: var(--font-system); margin-left: 0.4rem; }

/* Session */
.ear-progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.ear-progress-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.3s ease; }
.ear-session-meta {
    display: flex; justify-content: space-between; color: var(--text-muted);
    font-size: 0.9rem; margin-top: var(--space-xs);
}

.ear-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    transition: border-color 0.2s ease;
}
.ear-card.correct { border-color: var(--success, #3fb950); }
.ear-card.incorrect { border-color: var(--danger, #f85149); }

.ear-play-row { display: flex; flex-direction: column; align-items: center; gap: var(--space-xs); }
.ear-play-btn {
    width: 5rem; height: 5rem; border-radius: 50%; border: none;
    background: var(--primary); color: white; font-size: 2rem; cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.ear-play-btn:hover { transform: scale(1.05); }
.ear-play-btn.playing { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0.25); }
.ear-audio-msg { color: var(--accent); font-size: 0.85rem; min-height: 1.2em; }
.ear-question { text-align: center; font-weight: 600; margin: var(--space-xs) 0 var(--space-sm); }

.ear-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
.ear-choice {
    display: flex; align-items: center; gap: 0.6rem; text-align: left;
    background: transparent; color: var(--text-light);
    border: 2px solid var(--border); border-radius: var(--radius-sm);
    padding: 0.75rem; font-size: 1rem; line-height: 1.35; cursor: pointer; min-height: 3.5rem;
}
.ear-choice:hover:not(:disabled) { border-color: var(--primary); }
.ear-choice:disabled { cursor: default; opacity: 0.55; }
.ear-choice.right { border-color: var(--success, #3fb950); background: rgba(63, 185, 80, 0.12); opacity: 1; }
.ear-choice.wrong { border-color: var(--danger, #f85149); background: rgba(248, 81, 73, 0.12); opacity: 1; }
.ear-choice-key {
    flex: none; width: 1.5rem; height: 1.5rem; border-radius: 4px; background: var(--border);
    color: var(--text-muted); font-size: 0.75rem; display: inline-flex; align-items: center; justify-content: center;
}

.ear-reveal:not(:empty) { margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px solid var(--border); }
.ear-reveal-ja { font-family: var(--font-japanese); font-size: 1.6rem; line-height: 2.2; text-align: center; }
.ear-parts { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 0.35rem; margin: var(--space-xs) 0; }
.ear-part {
    display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
    background: rgba(255, 255, 255, 0.05); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem;
}
.ear-part-ja { font-family: var(--font-japanese); font-size: 1.1rem; line-height: 1.9; }
.ear-part-gloss { color: var(--accent); font-size: 0.8rem; text-align: center; max-width: 11rem; }
.ear-part-plus { color: var(--text-muted); align-self: center; }
.ear-reveal-en { text-align: center; color: var(--text-light); margin: var(--space-xs) 0; }
.ear-note { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; margin: var(--space-sm) 0; }
.ear-note strong { color: var(--text-light); margin-right: 0.3rem; }
.ear-reveal-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); justify-content: center; }
.ear-reveal-actions .btn { padding: 0.6rem 1rem; }

.ear-session-footer { text-align: center; }
.ear-end-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; text-decoration: underline; padding: var(--space-xs); }

/* Results */
.ear-results-title { text-align: center; margin: var(--space-sm) 0 var(--space-md); }
.ear-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-xs); }
.ear-result-row {
    display: flex; justify-content: space-between; gap: var(--space-xs);
    background: var(--bg-card); border-left: 4px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.5rem 0.75rem;
}
.ear-result-row.good { border-left-color: var(--success, #3fb950); }
.ear-result-row.mid { border-left-color: var(--accent); }
.ear-result-row.bad { border-left-color: var(--danger, #f85149); }
.ear-results-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); justify-content: center; margin: var(--space-md) 0; }

@media (max-width: 768px) {
    .ear-view { padding: var(--space-sm); }
    .ear-choices { grid-template-columns: 1fr; }
    .ear-choice-key { display: none; }
    .ear-reveal-ja { font-size: 1.35rem; }
}

.ear-guide-link {
    display: block; width: 100%; text-align: left; margin-top: var(--space-sm);
    background: rgba(251, 191, 36, 0.08); color: var(--accent);
    border: 1px dashed var(--accent); border-radius: var(--radius-sm);
    padding: 0.6rem var(--space-sm); font-size: 0.95rem; cursor: pointer;
}
.ear-guide-link:hover { background: rgba(251, 191, 36, 0.15); }
