/**
 * SoftIP · 站车广播词实训（Broadcast Trainer）
 * Cupertino glass + tokens；深色模式跟随 data-theme / prefers-color-scheme
 */

#view-broadcast {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg);
    color: var(--text);
}

#view-broadcast.active {
    display: flex;
}

#broadcastTrainerRoot {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.bc-ambient {
    pointer-events: none;
    position: absolute;
    inset: 0;
    background:
        radial-gradient(900px 420px at 12% -10%, var(--ambient-a), transparent 60%),
        radial-gradient(700px 380px at 92% 8%, var(--ambient-b), transparent 55%),
        linear-gradient(180deg, var(--bg-warm), var(--bg));
    opacity: 0.95;
    z-index: 0;
}

.bc-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    gap: 16px;
    height: 100%;
    min-height: 0;
    padding: 16px 18px 20px;
    box-sizing: border-box;
}

.bc-sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px 14px;
    border-radius: var(--softip-radius, var(--radius));
    background: var(--glass-strong);
    border: var(--hairline);
    box-shadow: var(--shadow-soft);
    backdrop-filter: var(--glass-blur-soft);
    -webkit-backdrop-filter: var(--glass-blur-soft);
}

.bc-side-head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.bc-side-head p {
    margin: 4px 0 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.bc-scene-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}

.bc-scene-card {
    appearance: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border: var(--hairline);
    border-radius: var(--radius-sm);
    background: var(--fill-quaternary);
    color: var(--text);
    padding: 12px 12px 10px;
    display: grid;
    gap: 2px;
    transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.bc-scene-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    background: var(--surface-2);
}

.bc-scene-card.is-active {
    border-color: rgba(0, 122, 255, 0.35);
    background: var(--primary-light);
    box-shadow: var(--shadow-press);
}

.bc-scene-cat {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.02em;
}

.bc-scene-title {
    font-size: 14px;
    font-weight: 700;
}

.bc-scene-en {
    font-size: 11px;
    color: var(--text-muted);
}

.bc-scene-meta {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-tertiary);
}

.bc-side-empty {
    font-size: 13px;
    color: var(--text-muted);
    padding: 20px 8px;
    text-align: center;
}

.bc-side-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 10px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
    color: var(--danger, #d92c20);
}
.bc-side-error p {
    margin: 0;
}

.bc-main {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    padding: 4px 2px 8px;
}

.bc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.bc-writing-link {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-text, #0e8f7e);
    text-decoration: none;
    white-space: nowrap;
}

.bc-writing-link:hover {
    text-decoration: underline;
}

.bc-mode-seg {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--radius-pill);
    background: var(--fill-tertiary);
    border: var(--hairline);
    gap: 2px;
}

.bc-seg,
.bc-chip {
    appearance: none;
    font: inherit;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-pill);
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.18s var(--ease-spring), color 0.18s var(--ease-spring), transform 0.18s var(--ease-spring);
}

.bc-seg.is-active,
.bc-chip.is-active {
    background: var(--surface-2);
    color: var(--text);
    box-shadow: var(--shadow-segment);
}

.bc-seg:hover,
.bc-chip:hover {
    color: var(--text);
}

.bc-compare-opts {
    display: inline-flex;
    gap: 6px;
}

.bc-chip {
    border: var(--hairline);
    background: var(--fill-quaternary);
    padding: 6px 12px;
    font-size: 12px;
}

.bc-workspace {
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: bc-in 0.35s var(--ease-spring) both;
}

@keyframes bc-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bc-meta h3 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -0.03em;
}

.bc-tips {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}

.bc-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bc-scripts {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bc-scripts.is-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.bc-script-card {
    background: var(--glass-strong);
    border: var(--hairline);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-soft);
}

.bc-script-card header {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.bc-script-zh,
.bc-script-en {
    margin: 0;
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    white-space: pre-wrap;
}

.bc-script-en {
    font-size: 14.5px;
    letter-spacing: 0.01em;
}

.bc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

/* 本模块用 [hidden] 控制空状态 / 停止键 / 对照选项 / 评分卡的显隐，
   而下面这些规则都显式写了 display，会盖掉 UA 的 [hidden]{display:none}。 */
#view-broadcast [hidden] {
    display: none !important;
}

.bc-kb {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--glass-strong);
    border: var(--hairline);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.bc-kb-tip {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.bc-kb-input {
    width: 100%;
    resize: vertical;
    min-height: 72px;
    font: inherit;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    background: transparent;
    border: var(--hairline);
    border-radius: 10px;
    padding: 10px 12px;
}

.bc-kb-input:focus {
    outline: none;
    border-color: var(--primary);
}

.bc-kb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.bc-btn {
    appearance: none;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 650;
    border: var(--hairline);
    transition: transform 0.18s var(--ease-spring), background 0.18s var(--ease-spring), opacity 0.18s ease;
}

.bc-btn:active {
    transform: scale(0.98);
}

.bc-btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    border-color: transparent;
}

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

.bc-btn-primary.is-listening {
    background: var(--danger);
    animation: bc-pulse 1.2s ease-in-out infinite;
}

@keyframes bc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.82; }
}

.bc-btn-secondary {
    background: var(--surface-2);
    color: var(--text);
}

.bc-btn-secondary.is-playing {
    color: var(--primary);
    border-color: rgba(0, 122, 255, 0.35);
}

.bc-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.bc-live {
    background: var(--fill-quaternary);
    border: var(--hairline);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.bc-live-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.bc-live-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    min-height: 1.6em;
}

.bc-score {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px 20px;
    align-items: center;
    background: var(--glass-strong);
    border: var(--hairline);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-soft);
    animation: bc-in 0.4s var(--ease-spring) both;
}

.bc-score-ring {
    --bc-score: 0;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at center, var(--surface-2) 58%, transparent 59%),
        conic-gradient(var(--primary) calc(var(--bc-score) * 1%), var(--fill-tertiary) 0);
    box-shadow: var(--shadow);
}

.bc-score-ring span {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.05;
}

.bc-score-ring b {
    font-size: 26px;
    font-weight: 780;
    letter-spacing: -0.04em;
    line-height: 1;
}

.bc-score-ring small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
}

.bc-score-metrics {
    display: flex;
    gap: 22px;
}

.bc-score-metrics div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bc-score-metrics b {
    font-size: 20px;
    font-weight: 750;
    letter-spacing: -0.03em;
}

.bc-score-metrics span {
    font-size: 12px;
    color: var(--text-secondary);
}

.bc-score-tips {
    grid-column: 1 / -1;
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.bc-score-tips li + li {
    margin-top: 4px;
}

/* ——— 英文跟读轨 ——— */

.bc-target-opts {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bc-target-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin-right: 2px;
    white-space: nowrap;
}

.bc-target-opts .bc-chip[data-target='en'].is-active {
    color: #0b5c3c;
    border-color: rgba(16, 160, 105, 0.4);
    background: rgba(16, 160, 105, 0.14);
}

.bc-score[data-lang='en'] .bc-score-ring {
    background:
        radial-gradient(circle at center, var(--surface-2) 58%, transparent 59%),
        conic-gradient(rgb(16, 160, 105) calc(var(--bc-score) * 1%), var(--fill-tertiary) 0);
}

.bc-score-diff {
    grid-column: 1 / -1;
    margin-top: 2px;
    padding: 10px 12px;
    border-radius: 12px;
    border: var(--hairline);
    background: var(--fill-quaternary);
}

.bc-diff-head {
    margin: 0 0 6px;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.bc-diff-body {
    margin: 0;
    font-size: 13px;
    line-height: 1.9;
    word-break: break-word;
}

.bc-diff-word {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 6px;
}

.bc-diff-word.is-hit {
    color: var(--text-secondary);
    background: rgba(16, 160, 105, 0.12);
}

.bc-diff-word.is-miss {
    color: #b02a2a;
    background: rgba(220, 60, 60, 0.14);
    font-weight: 650;
}

/* 手机 / iPad 共用：侧栏改顶、主操作沉底（不用 fixed，避开毛玻璃包含块） */
@media (max-width: 1180px) {
    .bc-layout {
        grid-template-columns: 1fr;
        padding: 12px 16px calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
    }
    .bc-sidebar {
        max-height: 148px;
        padding: 12px 12px 10px;
    }
    .bc-scene-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 8px;
        padding-right: 0;
        -webkit-overflow-scrolling: touch;
    }
    .bc-scene-card {
        flex: 0 0 min(220px, 72vw);
        min-width: 180px;
    }
    .bc-scripts.is-side,
    .bc-score {
        grid-template-columns: 1fr;
        justify-items: start;
    }
    .bc-target-opts {
        width: 100%;
    }
    .bc-target-opts .bc-chip {
        flex: 1 1 auto;
    }
    .bc-main {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .bc-empty,
    .bc-workspace {
        order: 1;
        flex: 1 1 auto;
        min-height: 0;
    }
    .bc-workspace {
        display: flex;
        flex-direction: column;
    }
    .bc-workspace .bc-actions {
        order: 8;
        margin-top: auto;
        position: sticky;
        bottom: calc(52px + env(safe-area-inset-bottom, 0px));
        z-index: 6;
        padding: 8px 0 6px;
        background: linear-gradient(180deg, transparent, var(--bg) 40%);
    }
    .bc-toolbar {
        order: 9;
        position: sticky;
        bottom: 0;
        z-index: 7;
        gap: 8px;
        margin: 0;
        padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
        background: var(--bg);
    }
    .bc-mode-seg,
    .bc-compare-opts {
        width: 100%;
        justify-content: stretch;
    }
    .bc-seg,
    .bc-chip {
        flex: 1;
        text-align: center;
        min-height: 40px;
    }
    .bc-btn {
        display: inline-flex;
        align-items: center;
        min-height: 48px;
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bc-workspace,
    .bc-score,
    .bc-scene-card,
    .bc-btn-primary.is-listening {
        animation: none !important;
        transition: none !important;
    }
}
