/* ==========================================================================
   French Audio Studio - Study & Shadowing Module Styles
   Adheres strictly to the Global Design Foundation (style.css)
   ========================================================================== */

/* Global Hidden Guard */
[hidden] {
    display: none !important;
}

/* Deck Launcher */
.nav-deck-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
}

.nav-deck-btn svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.deck-badge {
    background: var(--primary);
    color: var(--surface);
    font-size: 11px;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.4;
    min-width: 18px;
    text-align: center;
    transition: all 0.2s ease;
}

/* Input Panel Customization */
.study-input-panel {
    height: auto;
    min-height: 220px;
    margin-bottom: 0;
}

.study-input-panel textarea {
    min-height: 140px;
}

/* Collapsed Input Bar (Post-analysis) */
.input-collapsed-bar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(28, 40, 33, 0.04);
}

.input-collapsed-bar[hidden] {
    display: none !important;
}

.collapsed-bar-content {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    min-width: 0;
}

.collapsed-bar-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 700;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.collapsed-bar-badge svg {
    width: 14px;
    height: 14px;
}

.collapsed-bar-text {
    margin: 0;
    font-size: 13.5px;
    color: var(--ink);
    font-weight: 550;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collapsed-bar-actions {
    flex-shrink: 0;
}

/* Study Deck (Section 02) */
.study-deck-section {
    margin-top: 10px;
    border-top: 1px solid var(--line);
    padding-top: 24px;
}

.deck-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.deck-title-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex-wrap: nowrap;
}

.deck-title-row h2 {
    margin: 0;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

/* Clickable words in the French sentence */
.interactive-word {
    display: inline;
    cursor: pointer;
    border-radius: 3px;
    padding: 0 1px;
    margin: 0;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: text;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.interactive-word:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.interactive-word:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    background: rgba(var(--primary-rgb), 0.12);
    border-radius: 3px;
}

.interactive-word.is-active-word {
    background: rgba(var(--primary-rgb), 0.16);
    color: var(--primary);
    font-weight: 600;
    border-radius: 3px;
}

/* Shadowing & Scoring Panel */
.shadowing-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 16px 20px;
}

.shadowing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
}

.shadowing-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ink);
}

.shadowing-title svg {
    width: 17px;
    height: 17px;
    color: var(--danger);
}

.shadowing-guide {
    font-size: 12.5px;
    color: var(--muted);
}

.shadowing-body {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-record {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--surface);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-record:hover {
    background: var(--danger-soft);
}

.btn-record.recording {
    background: var(--danger);
    color: var(--surface);
    animation: recordPulse 1.4s infinite;
}

.btn-record svg {
    width: 16px;
    height: 16px;
}

@keyframes recordPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(169, 54, 42, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(169, 54, 42, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(169, 54, 42, 0);
    }
}

/* Score Result Card */
.score-result-card {
    margin-top: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.score-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.score-badge-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-number-pill {
    font-size: 20px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 6px;
    line-height: 1.2;
}

.score-number-pill.excellent {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid var(--success-line);
}

.score-number-pill.good {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-line);
}

.score-number-pill.pass {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-line);
}

.score-number-pill.needs-work {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger-line);
}

.score-rating-text {
    font-weight: 700;
    font-size: 14px;
    color: var(--ink);
}

.score-metrics {
    display: flex;
    gap: 14px;
    font-size: 12.5px;
    color: var(--muted);
}

.score-metrics strong {
    color: var(--ink);
}

/* Diff output */
.diff-result-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 15px;
    line-height: 1.8;
}

.diff-word {
    display: inline-block;
    padding: 2px 7px;
    margin: 2px 4px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.diff-word:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
}

.diff-word.correct {
    background: var(--success-soft);
    color: var(--success);
}

.diff-word.acceptable {
    background: var(--accent-soft);
    color: var(--accent);
}

.diff-word.missed {
    background: var(--danger-soft);
    color: var(--danger);
    border-bottom: 2px solid var(--danger);
    border-radius: 4px;
}

.diff-legend {
    display: flex;
    gap: 14px;
    font-size: 12px;
    color: var(--muted);
}

.diff-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.diff-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.diff-dot.dot-green { background: var(--success); }
.diff-dot.dot-yellow { background: var(--accent); }
.diff-dot.dot-red { background: var(--danger); }

.shadow-audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.btn-audio-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 650;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-audio-pill:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.btn-audio-pill.playing {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.2);
}

.btn-audio-pill.playing svg {
    color: var(--primary);
    stroke: var(--primary);
}

.btn-audio-pill:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-audio-pill svg {
    width: 15px;
    height: 15px;
}

/* Three-Column Table */
.table-wrapper {
    overflow-x: auto;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.breakdown-table th {
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
}

.breakdown-table th:first-child { width: 36%; }
.breakdown-table th:nth-child(2) { width: 32%; }
.breakdown-table th:nth-child(3) { width: 32%; }

.breakdown-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--surface-muted);
    vertical-align: top;
    line-height: 1.5;
}

.breakdown-table tr:last-child td {
    border-bottom: none;
}

.breakdown-table tr:hover td {
    background: var(--surface-subtle);
}

.token-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.token-main-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.token-actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.token-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 11.5px;
}

.pos-tag {
    background: var(--surface-muted);
    color: var(--muted);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--line);
    font-family: ui-monospace, monospace;
    font-weight: 600;
}

.phonetic-tag {
    color: var(--muted);
}

.lemma-tag {
    color: var(--primary);
    font-weight: 600;
}

.explanation-en-cell {
    color: var(--muted);
    font-size: 13.5px;
}

.explanation-cn-cell {
    color: var(--ink);
    font-weight: 550;
    font-size: 13.5px;
}

/* ==========================================================================
   Modals (history, account)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 26, 22, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-dialog {
    width: 100%;
    max-width: 640px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(18, 26, 22, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface-muted);
    border-bottom: 1px solid var(--line);
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-title-group h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
}

.modal-icon {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 6px;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
}

.modal-close-btn:hover {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--page);
}

/* Rating Footer & Grading Buttons */

.btn-grade {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.15s ease;
    gap: 2px;
    outline: none;
}

.btn-grade:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(28, 40, 33, 0.08);
}

.btn-grade .grade-name {
    font-size: 13px;
    font-weight: 700;
}

.btn-grade .grade-interval {
    font-size: 11px;
    opacity: 0.75;
}

/* 1: Again (Red) */
.btn-grade.grade-1 {
    color: var(--danger);
    border-color: var(--danger-line);
    background: var(--danger-soft);
}
.btn-grade.grade-1:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

/* 2: Hard (Amber/Orange) */
.btn-grade.grade-2 {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}
.btn-grade.grade-2:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* 3: Good (Green) */
.btn-grade.grade-3 {
    color: var(--success);
    border-color: var(--success-line);
    background: var(--success-soft);
}
.btn-grade.grade-3:hover {
    background: var(--success-soft);
    border-color: var(--success);
}

/* 4: Easy (Teal / Primary) */
.btn-grade.grade-4 {
    color: var(--primary);
    border-color: var(--primary-line);
    background: var(--primary-soft);
}
.btn-grade.grade-4:hover {
    background: var(--primary-soft);
    border-color: var(--primary-line);
}

/* Completion Screen */

.empty-icon-box {
    font-size: 42px;
    line-height: 1;
}

@media (max-width: 768px) {
    .breakdown-table th:first-child,
    .breakdown-table th:nth-child(2),
    .breakdown-table th:nth-child(3) {
        width: auto;
    }
}

/* ==========================================================================
   User Authentication & Trial System
   ========================================================================== */
/* Signed in: the account button is an icon; the email is in its tooltip */
.user-auth-btn.is-signed-in #user-auth-status-text {
    display: none;
}

.user-auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    font-size: 13px;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.trial-badge {
    background: linear-gradient(135deg, var(--primary), var(--primary));
    color: var(--surface);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.2px;
}

.count-badge {
    background: var(--surface-subtle);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--primary-soft);
}

.modal-auth-dialog {
    max-width: 480px;
}

.auth-modal-body {
    padding: 20px 24px 24px;
}

.auth-notice {
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink);
    margin-bottom: 16px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-error-msg {
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
}

.auth-actions {
    margin-top: 6px;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 650;
}

/* User Profile in Auth Modal */
.profile-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-avatar svg {
    width: 24px;
    height: 24px;
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.profile-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.profile-actions {
    margin-top: 6px;
}

.profile-devices h5 {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.device-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.device-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.device-list .device-meta {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.device-list .btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

/* ==========================================================================
   Query History Drawer / Modal
   ========================================================================== */
.modal-history-dialog {
    max-width: 680px;
    max-height: 85vh;
}

.history-modal-body {
    padding: 16px 20px 24px;
    max-height: 65vh;
    overflow-y: auto;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--primary);
    box-shadow: 0 3px 8px rgba(0,0,0,0.04);
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
}

.history-time-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-stats-group {
    display: flex;
    gap: 8px;
}

.history-stat-tag {
    background: var(--surface-subtle);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    color: var(--ink);
}

.history-snippet {
    font-family: var(--font-serif);
    font-size: 14.5px;
    color: var(--ink);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    background: var(--surface-subtle);
    padding: 8px 12px;
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
}

.history-item-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.history-empty h4 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
}

.history-empty p {
    margin: 0;
    font-size: 13.5px;
    color: var(--muted);
    max-width: 420px;
    line-height: 1.6;
}

/* ==========================================================================
   Schema V2: English-first Sentence Analysis & Breakdown Enhancements
   ========================================================================== */

/* 3. Sentence Build-up (一层一层搭句子) */
.buildup-section {
    background: var(--surface);
}

/* ==================== FEYNMAN BLIND MODE & BUILDUP HEADER ==================== */
.buildup-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.feynman-mode-switch {
    display: inline-flex;
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px;
    gap: 3px;
}

.btn-feynman-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-feynman-toggle:hover {
    color: var(--ink);
}

.btn-feynman-toggle.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-feynman-toggle[data-mode="blind"].active {
    color: var(--primary);
}

.feynman-tip-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    color: var(--primary);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 12px;
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.feynman-tip-banner[hidden] {
    display: none !important;
}

.feynman-tip-banner .btn-reveal-all {
    background: var(--surface);
    border: 1px solid var(--primary-line);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.feynman-tip-banner .btn-reveal-all:hover {
    background: var(--primary-soft);
}

/* Blind Mode Clozes */
.is-blind-mode .buildup-new-token {
    background: var(--line) !important;
    color: transparent !important;
    text-shadow: 0 0 12px rgba(100, 116, 139, 0.6) !important;
    border-bottom: 2px dashed var(--primary) !important;
    cursor: pointer !important;
    user-select: none !important;
    padding: 1px 8px !important;
    border-radius: 4px !important;
    position: relative !important;
    transition: all 0.2s ease !important;
    display: inline-block;
    min-width: 2.2em;
    text-align: center;
}

/* A plain "?" never overflows onto neighbouring words and needs no translation */
.is-blind-mode .buildup-new-token::after {
    content: "?";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    text-shadow: none;
    white-space: nowrap;
    pointer-events: none;
}

.is-blind-mode .buildup-new-token.revealed {
    background: var(--primary-soft) !important;
    color: var(--primary) !important;
    text-shadow: none !important;
    border-bottom: 2px solid var(--primary) !important;
}

.is-blind-mode .buildup-new-token.revealed::after {
    display: none !important;
}

/* Step 1 base text in blind mode */
.is-blind-mode .buildup-step-row:first-child:not(.step-revealed) .buildup-fr-text {
    color: transparent !important;
    text-shadow: 0 0 14px rgba(100, 116, 139, 0.5) !important;
    background: var(--line);
    border-radius: 4px;
    padding: 2px 8px;
    border-bottom: 2px dashed var(--primary);
    cursor: pointer;
    user-select: none;
    position: relative;
    display: inline-block;
}

.is-blind-mode .buildup-step-row:first-child:not(.step-revealed) .buildup-fr-text::after {
    content: "?";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-shadow: none;
    white-space: nowrap;
    pointer-events: none;
}

.is-blind-mode .buildup-step-row:first-child.step-revealed .buildup-fr-text {
    background: transparent;
    color: var(--ink) !important;
    text-shadow: none !important;
    border-bottom: none;
}

.buildup-steps-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Steps read as a numbered list: dividers, no boxes */
.buildup-step-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.buildup-step-row:last-child {
    border-bottom: 0;
}

.buildup-step-badge {
    flex-shrink: 0;
    width: 48px;
    margin-top: 3px;
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 600;
}

.buildup-step-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.buildup-fr-row {
    display: flex;
    align-items: center;
    gap: 8px 10px;
    flex-wrap: wrap;
}

.buildup-action-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-buildup-speak {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    border: 1px solid var(--primary-line);
    background: var(--primary-soft);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    width: auto;
    height: auto;
}

.btn-buildup-speak:hover {
    background: var(--primary-soft);
    border-color: var(--primary-line);
    color: var(--primary);
    transform: scale(1.04);
}

.btn-buildup-speak.playing {
    background: var(--primary);
    color: var(--surface);
    border-color: var(--primary);
}

.btn-buildup-speak svg {
    width: 12px;
    height: 12px;
}

.buildup-fr-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.4;
}

.buildup-en-text {
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.4;
}

.buildup-new-note {
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

/* Build-up Step Shadowing & Scoring */
.btn-buildup-record {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    border: 1px solid var(--danger);
    background: var(--surface);
    color: var(--danger);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-left: 0;
    flex-shrink: 0;
}

.btn-buildup-record:hover {
    background: var(--danger-soft);
    transform: scale(1.04);
}

.btn-buildup-record.recording {
    background: var(--danger);
    color: var(--surface);
    animation: recordPulse 1.4s infinite;
}

.btn-buildup-record svg {
    width: 12px;
    height: 12px;
}

.buildup-score-card {
    margin-top: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    animation: fadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.buildup-score-card[hidden] {
    display: none !important;
}

.buildup-score-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 6px;
}

.buildup-score-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.score-number-pill.sm {
    font-size: 12.5px;
    padding: 2px 7px;
    border-radius: 5px;
    min-width: 32px;
    text-align: center;
}

.score-rating-text.sm {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
}

.buildup-score-metrics {
    font-size: 11.5px;
    color: var(--muted);
    margin-left: 2px;
}

.buildup-audio-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-mini-audio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-mini-audio:hover:not(:disabled) {
    background: var(--surface-muted);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-mini-audio.playing {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
    font-weight: 700;
}

.btn-mini-audio:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-mini-audio svg {
    width: 13px;
    height: 13px;
}

.diff-result-box.sm {
    font-size: 13.5px;
    line-height: 1.7;
    margin-top: 4px;
    padding: 6px 10px;
    background: var(--surface-subtle);
    border-radius: 6px;
    border: 1px solid var(--surface-muted);
}

/* 5. Grammar & Memory Hooks */
.grammar-section {
    background: var(--surface-subtle);
}

.grammar-points-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grammar-point-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.grammar-point-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
}

.grammar-bullet {
    font-size: 13px;
}

.grammar-point-title {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ink);
}

.grammar-point-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.grammar-point-exp {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink);
}

.grammar-hook-inline {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    border-radius: 5px;
    padding: 3px 8px;
    margin-top: 4px;
    width: fit-content;
}

.grammar-hook-inline.feynman-hook-pill {
    background: var(--primary-soft);
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--ink);
    margin-top: 6px;
}

.grammar-hook-inline.feynman-hook-pill strong {
    color: var(--ink);
}

.grammar-hook-inline .hook-icon {
    flex-shrink: 0;
    font-size: 13px;
}

/* 6. Pronunciation Tips */
.pronunciation-section {
    background: var(--surface);
}

.pronunciation-tips-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pronunciation-tip-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ink);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.pronunciation-tip-item:hover {
    background: var(--surface-muted);
    border-color: var(--line-strong);
}

.tip-audio-col {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.tip-content-col {
    flex: 1;
    min-width: 180px;
    color: var(--ink);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.tip-explanation-text {
    display: inline;
    line-height: 1.6;
}

.btn-tip-audio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
    flex-shrink: 0;
}

.btn-tip-audio:hover {
    background: var(--primary-soft);
    border-color: var(--primary-line);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.12);
}

.btn-tip-audio:active {
    transform: translateY(0);
}

.btn-tip-audio.playing {
    background: var(--primary);
    color: var(--surface);
    border-color: var(--primary);
    animation: pulse-tip-btn 1.2s infinite;
}

.btn-tip-audio svg {
    width: 14px;
    height: 14px;
    color: inherit;
    flex-shrink: 0;
}

.btn-tip-audio .tip-target-text {
    font-size: 13px;
    font-weight: 700;
    color: inherit;
    letter-spacing: 0.2px;
}

.btn-tip-audio .tip-badge-listen {
    font-size: 10.5px;
    font-weight: 500;
    background: rgba(var(--primary-rgb), 0.1);
    color: inherit;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

.btn-tip-audio.playing .tip-badge-listen {
    background: rgba(255, 255, 255, 0.25);
    color: var(--surface);
}

.btn-tip-audio.icon-only {
    padding: 5px 9px;
}

.chip-tip-audio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    margin: 0 2px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    vertical-align: baseline;
    transition: all 0.12s ease;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.chip-tip-audio:hover {
    background: var(--surface-subtle);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.chip-tip-audio:active {
    transform: translateY(0);
}

.chip-tip-audio.playing {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.chip-tip-audio svg {
    width: 12px;
    height: 12px;
    color: var(--primary);
    flex-shrink: 0;
}

@keyframes pulse-tip-btn {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(var(--primary-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0);
    }
}

/* 7. History Modal Schema Badges & Re-analyze Button */

.btn-reanalyze-v2 {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 5px;
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-reanalyze-v2:hover {
    background: var(--primary);
    color: var(--surface);
}

.btn-reanalyze-v2 svg {
    width: 13px;
    height: 13px;
}

/* Responsive Overrides */
@media (max-width: 768px) {

    .buildup-step-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* Grammar Card Star Save Button */
.btn-grammar-star {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted-dark);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-grammar-star:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-grammar-star.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.btn-grammar-star svg {
    width: 13px;
    height: 13px;
    color: var(--muted);
    transition: all 0.15s ease;
}

.btn-grammar-star:hover svg {
    color: var(--accent);
}

.btn-grammar-star.active svg {
    color: var(--accent);
    fill: var(--accent);
}

/* ==================== STAGE 2: VISUAL OPTIMIZATIONS ==================== */

/* 2A. Build-up Step Diff Highlighting */
.buildup-new-token {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    border-radius: 4px;
    padding: 1px 4px;
    border-bottom: 2px solid var(--primary);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* ==========================================================================
   Today's review banner
   ========================================================================== */
.today-review-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid var(--primary);
    background: var(--primary-soft);
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow);
}

.today-review-banner > svg {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.today-review-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.today-review-text strong {
    font-size: 16px;
}

.today-review-text span {
    color: var(--muted);
    font-size: 13px;
}

.today-review-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--primary);
    color: var(--surface);
    font-weight: 700;
    font-size: 14px;
}

.today-review-cta svg {
    width: 16px;
    height: 16px;
}

a.nav-deck-btn {
    text-decoration: none;
}

@media (max-width: 640px) {

    .today-review-banner {
        flex-wrap: wrap;
    }

    .today-review-cta {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   Feynman self-test: learner explains, AI points out gaps
   ========================================================================== */
.feynman-input,
.feynman-variation {
    width: 100%;
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
}

.feynman-input {
    resize: vertical;
    line-height: 1.5;
}

.feynman-input:focus,
.feynman-variation:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.feynman-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-feynman-mic,
.btn-feynman-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 7px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.btn-feynman-mic {
    border: 1px solid var(--primary-line);
    background: var(--surface);
    color: var(--primary);
}

.btn-feynman-mic.recording {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-feynman-check {
    border: 1px solid var(--primary);
    background: var(--primary);
    color: var(--surface);
}

.btn-feynman-check:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn-feynman-mic svg,
.btn-feynman-check svg {
    width: 15px;
    height: 15px;
}

.feynman-feedback {
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--surface);
    border: 1px solid var(--primary-line);
    font-size: 14px;
    line-height: 1.55;
}

.feynman-feedback p {
    margin: 0 0 6px;
}

.feynman-feedback ul {
    margin: 0 0 6px;
    padding: 0;
    list-style: none;
}

.feynman-feedback li {
    display: flex;
    gap: 6px;
    margin-bottom: 3px;
}

.fb-mark {
    flex-shrink: 0;
    font-weight: 800;
}

.fb-right .fb-mark { color: var(--success); }
.fb-gaps .fb-mark { color: var(--accent); }

.fb-verdict {
    font-weight: 800;
}

.verdict-solid { color: var(--success); }
.verdict-partial { color: var(--accent); }
.verdict-missing { color: var(--danger); }

.fb-variation.ok { color: var(--success); }
.fb-variation.fix { color: var(--accent); }

.fb-followup {
    padding: 6px 8px;
    border-radius: 5px;
    background: var(--primary-soft);
    color: var(--ink);
}

.fb-followup-hint {
    color: var(--muted);
    font-size: 12px;
}

.fb-loading {
    color: var(--muted);
}

.fb-error {
    color: var(--danger);
}

/* Ask the tutor (follow-up questions under the Feynman self-test) */
.feynman-ask {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ask-thread {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ask-thread:empty {
    display: none;
}

.ask-bubble {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.ask-learner {
    align-self: flex-end;
    background: var(--primary);
    color: var(--surface);
}

.ask-tutor {
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--primary-line);
    color: var(--ink);
}

.ask-tutor.is-pending {
    color: var(--muted);
}

.ask-tutor.is-error {
    color: var(--danger);
}

.ask-row {
    display: flex;
    gap: 8px;
}

.ask-input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    border: 1px solid var(--primary-line);
    border-radius: 6px;
    background: var(--surface);
    font: inherit;
    font-size: 14px;
    padding: 0 10px;
}

.ask-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.btn-ask {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    border: 1px solid var(--primary);
    border-radius: 7px;
    background: var(--surface);
    color: var(--primary);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.btn-ask:disabled {
    opacity: 0.6;
    cursor: wait;
}

.btn-ask svg {
    width: 15px;
    height: 15px;
}

/* Server-side dictation status + mic in the ask row */
.feynman-actions {
    align-items: center;
}

.dictation-status {
    flex: 1;
    min-width: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.dictation-status.is-error {
    color: var(--danger);
}

.btn-ask.recording,
.btn-feynman-mic.recording {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-feynman-mic:disabled,
.btn-ask-mic:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Repeat-all playback: the sentence being read */
.sentence-french-text.is-reading {
    background: var(--primary-soft);
    border-radius: 6px;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

/* Play all + Repeat next to the sentence count */
.deck-playback {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.deck-playback .btn {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

#play-all-btn.is-playing {
    border-color: var(--danger);
    color: var(--danger);
}

/* ==========================================================================
   Sentence cards: one header per sentence, the same open or closed, and a
   flat body (spacing and dividers, no boxes inside boxes).
   Type scale: sentence 20 / word 16 / text 15 / notes 13.
   ========================================================================== */
.sentences-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sentence-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.sentence-card.is-open {
    border-color: var(--line-strong);
}

.sentence-head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-radius: calc(var(--radius-md) - 1px);
}

.sentence-head:has(.sentence-toggle) {
    cursor: pointer;
}

.sentence-card:not(.is-open) .sentence-head:hover {
    background: var(--surface-subtle);
}

.sentence-toggle {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin: 2px -6px 0 -8px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.sentence-toggle:hover {
    background: var(--surface-muted);
    color: var(--ink);
}

.sentence-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.15s ease;
}

.sentence-card.is-open .sentence-toggle svg {
    transform: rotate(90deg);
}

.sentence-head-text {
    flex: 1;
    min-width: 0;
}

/* Answer option letter (A, B, C…) in front of the sentence it marks */
.sentence-label {
    float: left;
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    margin: 2px 10px 0 0;
    padding: 0 6px;
    border: 1px solid var(--primary-line);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: var(--text-sm);
    font-weight: 700;
}

.sentence-french-text {
    margin: 0;
    color: var(--ink);
    font-size: var(--text-lg);
    font-weight: 600;
    line-height: 1.5;
}

/* Words always pronounce; the arrow and empty heading space open/close the card. */

.sentence-translation {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.5;
}

.sentence-head-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sentence-position {
    margin-right: var(--space-1);
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.btn-speak-round {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--primary);
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-contrast);
    cursor: pointer;
}

.btn-speak-round:hover {
    background: var(--primary-hover);
}

.btn-speak-round svg {
    width: 18px;
    height: 18px;
}

/* One filled button per open sentence; closed lines stay quiet */
.sentence-card:not(.is-open) .btn-speak-round {
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--primary);
}

.sentence-card:not(.is-open) .btn-speak-round:hover {
    background: var(--surface-muted);
}

.btn-sentence-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.btn-sentence-save:hover {
    background: var(--surface-muted);
}

.btn-sentence-save.active {
    border-color: var(--primary-line);
    background: var(--primary-soft);
    color: var(--primary);
}

.btn-sentence-save svg {
    width: 16px;
    height: 16px;
}

.sentence-card:not(.is-open) .btn-sentence-save {
    display: none;
}

/* Body: indented under the French text so it reads as part of that sentence */
.sentence-body {
    padding: 0 var(--space-6) var(--space-6) calc(var(--space-6) + 34px);
}

.sentence-card:not(:has(.sentence-toggle)) .sentence-body {
    padding-left: var(--space-6);
}

/* Word by word: the one tinted block in the Words tab, French over English */
.interlinear-gloss {
    margin-bottom: var(--space-2);
    padding: var(--space-3) var(--space-4) var(--space-4);
    border: 1px solid var(--primary-line);
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
}

.gloss-label {
    margin: 0 0 var(--space-2);
    color: var(--primary);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.gloss-track {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-6);
}

.gloss-pair {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
}

.gloss-fr {
    color: var(--ink);
    font-size: var(--text-base);
    font-weight: 600;
    /* A tap opens the word popover, like a word in the sentence title */
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s ease, color 0.15s ease;
}

.gloss-fr:hover,
.gloss-fr.is-active-word {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.gloss-en {
    color: var(--primary);
    font-size: var(--text-sm);
    /* A drag across the French words selects only the French line */
    user-select: none;
}

.gloss-order-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--primary-line);
    color: var(--ink);
    font-size: var(--text-sm);
}

.gloss-order-note svg {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    margin-top: 3px;
    color: var(--primary);
}

/* One line at the top of a panel that says what the panel is for */
.panel-hint {
    margin: 0 0 var(--space-3);
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: 1.5;
}

/* Explain it: the learner writes first, the AI points out gaps */
.feynman-selftest {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.feynman-selftest .panel-hint {
    margin-bottom: 0;
}

.buildup-section-header .panel-hint {
    flex: 1;
    min-width: 220px;
    margin: 0;
}

.feynman-variation-box > summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: var(--primary);
    font-size: var(--text-sm);
    font-weight: 600;
    list-style: none;
    cursor: pointer;
}

.feynman-variation-box > summary::-webkit-details-marker {
    display: none;
}

.feynman-variation-box > summary::before {
    content: '+';
    width: 14px;
    font-size: 17px;
    line-height: 1;
    text-align: center;
}

.feynman-variation-box[open] > summary::before {
    content: '−';
}

.feynman-variation-box[open] > .feynman-variation {
    margin-top: var(--space-2);
}

.feynman-ask {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
}

.ask-save {
    align-self: flex-start;
    margin: -2px 0 var(--space-2);
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ask-save:hover:not(:disabled) {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ask-save:disabled {
    color: var(--muted);
    cursor: default;
}

.ask-save.is-saved {
    color: var(--success);
}

.feynman-ask-label {
    margin: 0 0 var(--space-2);
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Tabs: underlined labels, no boxes */
.card-tabs-bar {
    display: flex;
    gap: var(--space-6);
    margin-top: var(--space-3);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.card-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
    padding: 10px 0;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.card-tab-btn:hover {
    color: var(--ink);
}

.card-tab-btn.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.card-tab-panel {
    padding-top: var(--space-4);
}

.card-tab-panel[hidden] {
    display: none !important;
}

.card-tab-panel > .study-card-section {
    padding: 0;
    border: 0;
    background: none;
}

/* Words: a divided list, two columns when there is room */
.word-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    column-gap: var(--space-8);
}

.word-list[hidden] {
    display: none;
}

.word-item {
    min-width: 0;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
}

.word-item p {
    margin: 0;
}

.word-item-head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.word-item-title {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    min-width: 0;
}

.token-word {
    color: var(--ink);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
}

.token-word:hover {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.word-ipa {
    color: var(--muted);
    font-size: 13px;
}

.word-item-actions {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 2px;
    margin-top: -3px;
}

.btn-token-speak,
.btn-token-star {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.btn-token-speak:hover,
.btn-token-star:hover {
    background: var(--surface-muted);
    color: var(--primary);
}

.btn-token-star.active {
    color: var(--primary);
}

.btn-token-star.active svg {
    fill: currentColor;
}

.btn-token-speak svg,
.btn-token-star svg {
    width: 16px;
    height: 16px;
}

.word-meta {
    color: var(--muted);
    font-size: 13px;
}

.word-item .word-meaning {
    margin-top: 4px;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
}

.word-meaning-zh {
    color: var(--muted);
    font-size: var(--text-sm);
}

.word-item .word-why {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.word-item .word-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.word-link svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.word-item .word-link.is-false-friend {
    color: var(--danger);
}

.small-words-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 0;
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
}

.small-words-label {
    color: var(--ink);
    font-weight: 600;
}

.small-words-preview {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.small-words-action {
    color: var(--primary);
    font-weight: 600;
}

.small-words-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
    transition: transform 0.15s ease;
}

.small-words-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.small-words-toggle:hover .small-words-action {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .sentence-head {
        gap: var(--space-2);
        padding: var(--space-3) var(--space-4);
    }

    .sentence-toggle {
        margin: 0 -2px 0 -8px;
    }

    .sentence-french-text {
        font-size: 18px;
    }

    .sentence-position {
        display: none;
    }

    .btn-sentence-save {
        justify-content: center;
        width: 38px;
        padding: 0;
    }

    .btn-sentence-save .sentence-save-label {
        display: none;
    }

    .sentence-body,
    .sentence-card:not(:has(.sentence-toggle)) .sentence-body {
        padding: 0 var(--space-4) var(--space-4);
    }

    .card-tabs-bar {
        gap: 14px;
    }

    .card-tab-btn {
        font-size: 13px;
    }

    .ask-row .btn-ask > span {
        display: none;
    }
}

/* Steps on a phone: the French line selects like normal text (WebKit needs the prefix),
   and a highlighted chunk is a tap target that opens the word popover (study.js) */
.buildup-steps-list:not(.is-blind-mode) .buildup-fr-text,
.buildup-steps-list:not(.is-blind-mode) .buildup-new-token {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}
.buildup-steps-list:not(.is-blind-mode) .buildup-new-token {
    cursor: pointer;
    padding: 1px 0;
    transition: background 0.15s ease;
}
.buildup-steps-list:not(.is-blind-mode) .buildup-new-token:hover,
.buildup-steps-list:not(.is-blind-mode) .buildup-new-token.is-active-word {
    background: rgba(var(--primary-rgb), 0.18);
}

/* Per-step Repeat: an icon-only copy of the shared Repeat switch (playback.js), next to Listen */
.btn-repeat-toggle.btn-step-repeat {
    width: 30px;
    min-width: 30px;
    height: 26px;
    min-height: 26px;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
    flex-shrink: 0;
}
.btn-repeat-toggle.btn-step-repeat > span { display: none; }
.btn-repeat-toggle.btn-step-repeat svg { width: 14px; height: 14px; }
@media (pointer: coarse) {
    .btn-repeat-toggle.btn-step-repeat { width: 38px; min-width: 38px; height: 32px; min-height: 32px; }
}

/* Step words use the same single-tap pronunciation as the sentence heading. */
.buildup-fr-text .interactive-word { touch-action: manipulation; }
.is-blind-mode .buildup-fr-text .interactive-word {
    color: inherit !important;
    background: transparent !important;
    text-shadow: inherit;
}
