@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #2f6fed;
    --primary-strong: #1f56c5;
    --primary-soft: #e8f0ff;
    --bg-color: #f3f6fb;
    --bg-veil: #eef2f8;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --muted-text: #5d6875;
    --border-color: #e1e7f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.12);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
}

body {
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    background: linear-gradient(180deg, #f4f7fc 0%, #eef2f8 100%);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    background-color: var(--card-bg);
    padding: 0 30px 30px 30px; /* 顶部 padding 设为 0，交给 topbar 处理 */
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 600px;
    position: relative;
    overflow: hidden;
}

/* 顶部切换 / 配置 */
.topbar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 -30px 24px -30px;
    padding: 12px 30px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
    box-sizing: border-box;
}

.topbar-admin {
    justify-content: space-between;
    padding-right: 0;
}

.admin-title {
    margin: 0;
    font-size: 20px;
    color: var(--primary-color);
}

.config-toggle {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f4f6fb;
    color: var(--muted-text);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-toggle:hover {
    background: #e8edf7;
    transform: translateY(-50%) scale(1.03);
    box-shadow: var(--shadow-sm);
}

.config-toggle .gear-icon {
    font-size: 0.9rem;
}

.config-toggle.icon-ghost {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.config-toggle.minimal {
    width: 28px;
    height: 28px;
    padding: 0;
    justify-content: center;
    background: #f4f6fb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--muted-text);
}

.config-toggle.minimal:hover {
    background: #e8edf7;
}

/* 并行任务栏 */
.task-dock {
    margin: 0 -30px 20px -30px;
    padding: 16px 20px;
    background: linear-gradient(180deg, #f7f9ff 0%, #eef3fb 100%);
    border-bottom: 1px solid var(--border-color);
}

.task-dock-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.task-dock-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #2f3a4a;
}

.task-dock-count {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--muted-text);
}

.task-dock-toggle {
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--muted-text);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-dock-toggle:hover {
    color: #1f2937;
    box-shadow: var(--shadow-sm);
}

.task-list {
    margin-top: 12px;
    display: grid;
    gap: 12px;
}

.task-empty {
    font-size: 0.85rem;
    color: var(--muted-text);
    padding: 8px 2px;
}

.task-dock.collapsed .task-list {
    display: none;
}

.task-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
}

.task-card.running {
    border-left: 4px solid #f59e0b;
}

.task-card.success {
    border-left: 4px solid #22c55e;
}

.task-card.error {
    border-left: 4px solid #ef4444;
}

.task-card.canceled {
    border-left: 4px solid #94a3b8;
    opacity: 0.85;
}

.task-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.task-pill.azure {
    background: #e8f0fe;
    color: #1a73e8;
}

.task-pill.gemini {
    background: #fef3c7;
    color: #92400e;
}

.task-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1f2937;
}

.task-status {
    font-size: 0.8rem;
    color: var(--muted-text);
}

.task-text {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--muted-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-progress {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #2563eb;
    display: none;
}

.task-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.task-btn {
    border: 1px solid var(--border-color);
    background: #ffffff;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 0.78rem;
    cursor: pointer;
}

.task-btn.ghost {
    color: #ef4444;
    border-color: #fecaca;
    background: #fff5f5;
}

.task-btn:hover {
    box-shadow: var(--shadow-sm);
}

.task-audio {
    margin-top: 10px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
}

.task-download-row {
    margin-top: 6px;
    text-align: right;
}

.task-download-link {
    text-decoration: none;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* 历史记录按钮 */
.history-toggle-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1001;
    transition: all 0.3s;
}

.history-toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 1rem;
    transition: all 0.3s;
}

.history-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
}

body.history-open .history-toggle-wrap {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
}

.history-help-btn {
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--primary-strong);
    background: var(--primary-color);
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.history-help-btn:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.2);
    background: var(--primary-strong);
}

.history-toggle-icon {
    font-size: 1.25rem;
}

.history-toggle-btn .badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ffffff;
    color: var(--primary-strong);
    font-size: 0.78rem;
    min-width: 34px;
    padding: 4px 8px;
    border-radius: 999px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(47, 111, 237, 0.25);
    box-shadow: 0 4px 10px rgba(47, 111, 237, 0.18);
}

.history-toggle-btn .badge.show {
    display: flex;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-top: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #3c4450;
}

.hint {
    font-size: 0.8rem;
    color: var(--muted-text);
    margin-top: 4px;
    font-weight: normal;
}

textarea, select, input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
    transition: border 0.2s, box-shadow 0.2s;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

textarea:focus, select:focus {
    border-color: var(--primary-color);
    outline: 2px solid rgba(47, 111, 237, 0.18);
    box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.08);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    accent-color: var(--primary-color);
}

.mini-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    color: #3c4450;
    user-select: none;
}

.mini-toggle.ghost {
    background: #f4f6fb;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
}

.mini-toggle input {
    display: none;
}

.mini-toggle-slider {
    position: relative;
    width: 38px;
    height: 20px;
    background: #e1e6f0;
    border-radius: 999px;
    transition: background 0.2s ease;
}

.mini-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
    transition: transform 0.2s ease;
}

.mini-toggle input:checked + .mini-toggle-slider {
    background: var(--primary-color);
}

.mini-toggle input:checked + .mini-toggle-slider::after {
    transform: translateX(18px);
}

.mini-toggle-text {
    white-space: nowrap;
}

.controls {
    display: flex;
    gap: 10px;
}

button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

#generateBtn {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

#generateBtn:hover {
    background-color: var(--primary-strong);
    transform: translateY(-1px);
}

#generateBtn:disabled {
    background-color: #e6ebf2;
    color: #9aa4b2;
    cursor: not-allowed;
    box-shadow: none;
}

#cancelBtn {
    background-color: #f2f4f8;
    color: #3c4450;
    flex: 0 0 100px;
    display: none; /* 默认隐藏 */
}

#cancelBtn:hover {
    background-color: #e6ebf2;
}

.status-bar {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    display: none;
}

.status-bar.loading {
    display: block;
    background-color: var(--primary-soft);
    color: var(--primary-strong);
}

.status-bar.error {
    display: block;
    background-color: #fceceb;
    color: #b42318;
}

.result-area {
    margin-top: 25px;
    display: none;
    background: #f6f8fc;
    padding: 15px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
}

.inline-controls {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.inline-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 260px;
}

.inline-counter {
    font-size: 0.85rem;
    color: var(--muted-text);
}

.inline-mode {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

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

.pipe-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f4f6fb;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 600;
    color: #3c4450;
}

.lead-pause-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 4px;
    background: #f4f7fb;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px 8px;
    margin: 6px 0 10px;
}

.lead-pause-row label {
    margin: 0;
    white-space: nowrap;
    font-weight: 600;
}

.lead-pause-row .range-container {
    margin: 0;
}

.lead-pause-row input[type="range"] {
    height: 4px;
}

.lead-pause-row .hint {
    margin: 0;
    grid-column: 1 / -1;
    color: var(--muted-text);
    font-size: 0.85rem;
}

.multi-dialog-roles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
    padding: 12px;
    border-radius: 14px;
    background: #f6f8fc;
    border: 1px solid var(--border-color);
}

.az-role-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) 200px;
    column-gap: 14px;
    row-gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.az-role-row:hover {
    border-color: rgba(47, 111, 237, 0.35);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

.az-role-label {
    font-weight: 700;
    border-radius: 999px;
    padding: 6px 10px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    letter-spacing: 0.2px;
}

.az-role-select-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    min-width: 0;
    align-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.az-role-select-wrap select {
    min-width: 0;
    max-width: 100%;
    background: #fff;
    border-color: var(--border-color);
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.az-role-rate {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    background: #f4f6fb;
    border: 1px solid var(--border-color);
    font-weight: 600;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.az-role-rate-label {
    font-size: 0.8rem;
    color: var(--muted-text);
    padding-left: 2px;
    white-space: nowrap;
}

.az-role-rate-range {
    width: 100%;
    height: 4px;
    accent-color: var(--primary-color);
    min-width: 0;
}

.az-role-rate-value {
    font-size: 0.85rem;
    color: #3c4450;
    white-space: nowrap;
    text-align: right;
    min-width: 38px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
    .az-role-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .az-role-label {
        justify-content: flex-start;
        padding: 8px 12px;
    }
}

.az-align-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 10px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #f4f7fb;
}

.az-align-button {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    background: var(--primary-color);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.az-align-button:disabled {
    background: #e6ebf2;
    color: #9aa4b2;
    cursor: not-allowed;
    box-shadow: none;
}

.az-align-select {
    width: auto;
    min-width: 190px;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
}

.az-mini-action {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: #e8eefb;
    color: #2f6fed;
    border: 1px solid #c7d4f1;
    box-shadow: none;
    cursor: pointer;
}

.az-mini-action:hover {
    background: #dfe8fb;
}

.az-align-status {
    font-size: 0.85rem;
    color: var(--muted-text);
}

.az-align-status.success {
    color: #166534;
}

.az-align-status.error {
    color: #b42318;
}

.az-align-status.loading {
    color: var(--primary-strong);
}


/* 侧边栏遮罩层 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 历史记录侧边栏 */
.history-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.16);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}

.history-sidebar.active {
    transform: translateX(0);
}

.history-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-color);
    color: white;
    position: relative;
}

.history-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 12px;
}

.history-pill {
    border: none;
    font-size: 0.9rem;
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 999px;
    transition: all 0.2s;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    color: #1f2937;
    background: #fdfdfd;
    min-height: 40px;
    white-space: nowrap;
}

.history-pill.ghost {
    background: rgba(255,255,255,0.18);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.35);
    box-shadow: none;
}

.history-pill.danger {
    background: #feeceb;
    color: #b42318;
    border: 1px solid #f8c7c4;
}

.history-pill:hover {
    transform: translateY(-1px);
}

.history-close-btn {
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: background 0.2s, transform 0.2s;
}

.history-close-btn:hover {
    background: rgba(255, 255, 255, 0.26);
    transform: translateY(-1px);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-empty {
    text-align: center;
    color: var(--muted-text);
    padding: 40px 20px;
    font-size: 0.95rem;
}

.price-info {
    background: #f1f5ff;
    padding: 10px 12px;
    margin: 8px 15px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--primary-strong);
    border-left: 3px solid var(--primary-color);
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.price-info.count-info {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    text-align: center;
}

.history-item {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 14px 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.history-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.history-summary {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.summary-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.summary-time {
    color: #3c4450;
    font-weight: 600;
    white-space: nowrap;
}

.summary-meta {
    color: var(--muted-text);
    font-size: 0.9rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-text {
    font-size: 0.92rem;
    color: #1f2937;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    font-weight: 600;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

.pill-azure { background: #e8f0fe; color: #1a73e8; }
.pill-flash { background: #e8f0fe; color: #1a4fb8; }
.pill-pro { background: #e8f0fe; color: #1f56c5; }

.history-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-select-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #fff;
    font-size: 0.85rem;
    color: #3c4450;
    cursor: pointer;
    user-select: none;
}

.history-select-pill input {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color);
}

.history-select-pill.disabled {
    color: #9aa4b2;
    background: #f3f4f6;
    border-style: dashed;
    cursor: not-allowed;
}

.history-toggle {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-sm);
}

.history-toggle .chevron {
    display: inline-block;
    transition: transform 0.2s;
}

.history-item.expanded .history-toggle .chevron {
    transform: rotate(180deg);
}

.history-body {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.history-item.collapsed .history-body {
    display: none;
}

.history-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--muted-text);
    margin-top: 10px;
    word-break: break-word;
}

.history-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 10px;
}

.history-actions a {
    text-decoration: none;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.history-delete-btn {
    background: #f2f4f8;
    border: none;
    color: #b42318;
    font-size: 0.9rem;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 600;
}

.history-delete-btn:hover {
    background: #feeceb;
    transform: translateY(-1px);
}

.history-download-link.disabled {
    color: #9aa4b2;
    cursor: not-allowed;
}

.history-audio-placeholder {
    background: #f6f8fc;
    border: 1px dashed var(--border-color);
    color: var(--muted-text);
    padding: 12px;
    border-radius: 8px;
}

.config-toggle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #f4f6fb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--muted-text);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.config-block.hidden {
    display: none;
}

.config-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn-save {
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
}

.btn-save:disabled {
    background: #e6ebf2;
    color: #9aa4b2;
    cursor: not-allowed;
}
audio {
    width: 100%;
    margin-top: 10px;
    outline: none;
}

.download-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ==================== 多平台：Provider Switch + Azure Panel ==================== */
.provider-switch {
    display: flex;
    gap: 4px;
    background: #f4f6fb;
    padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    height: 40px;
    box-sizing: border-box;
}

.provider-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-radius: 999px;
    border: none;
    background: transparent;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--muted-text);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    height: 100%;
}

.provider-pill:hover {
    color: #1f2937;
}

.provider-pill input {
    display: none;
}

.provider-pill.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.col {
    flex: 1;
    min-width: 220px;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.value-display {
    display: inline-block;
    width: 58px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted-text);
    font-weight: 600;
}

.mode-select {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.mode-select select {
    min-width: 160px;
}

.pipe-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f4f6fb;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    color: #3c4450;
    cursor: pointer;
}

.pipe-toggle input {
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.lead-pause-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 10px;
    row-gap: 4px;
    background: #f4f7fb;
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    border-radius: 10px;
    margin: 6px 0 10px;
}

.lead-pause-row label {
    margin: 0;
    white-space: nowrap;
    font-weight: 600;
}

.lead-pause-row .range-container {
    margin: 0;
}

.lead-pause-row input[type="range"] {
    height: 4px;
}

.lead-pause-row .hint {
    margin: 0;
    grid-column: 1 / -1;
    color: var(--muted-text);
    font-size: 0.85rem;
}

.azure-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    display: none;
    border: 1px solid var(--border-color);
    background: #f6f8fc;
    color: #3c4450;
    white-space: pre-wrap;
}

.azure-status.error {
    display: block;
    background: #feeceb;
    color: #b42318;
    border-color: #f8c7c4;
}

.azure-status.success {
    display: block;
    background: #e8f5ed;
    color: #166534;
    border-color: #cfe8d9;
}

.azure-status.normal {
    display: block;
    background: #f1f5ff;
    color: var(--primary-strong);
    border-color: #d8e4ff;
}

/* 面板切换动画 */
#panelGemini, #panelAzure {
    animation-duration: 0.4s;
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

#panelGemini.fade-in, #panelAzure.fade-in {
    animation-name: fadeInUp;
}

#panelGemini.fade-out, #panelAzure.fade-out {
    animation-name: fadeOut;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Auth + admin UI */
.auth-gate {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 19, 30, 0.55);
    backdrop-filter: blur(6px);
    z-index: 9999;
}

.auth-gate.hidden {
    display: none;
}

.auth-card {
    width: min(420px, 90vw);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
}

.auth-header h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.auth-header p {
    margin: 0 0 16px;
    color: var(--muted-text);
    font-size: 13px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.auth-tab {
    flex: 1;
    border: 1px solid var(--border-color);
    background: #f6f8fc;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.auth-tab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

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

.auth-form label {
    font-size: 12px;
    color: var(--muted-text);
}

.auth-form input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.auth-form.hidden {
    display: none;
}

.auth-submit {
    margin-top: 8px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.auth-error {
    color: #b42318;
    font-size: 12px;
    min-height: 14px;
}

.user-badge {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.user-badge-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f6f8fc;
    padding: 4px 4px 4px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    height: 40px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.user-badge-inner:hover {
    background: #eff3f8;
    border-color: #d7dde8;
}

.user-badge span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-text);
}

.logout-btn {
    border: none;
    background: #ffffff;
    color: #b42318;
    padding: 0 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    height: 30px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    border: 1px solid #f4c7c3;
}

.logout-btn:hover {
    background: #feeceb;
    border-color: #f1b3ad;
}

.admin-entry-btn {
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: none; /* 仅对管理员显示 */
}

.admin-entry-btn:hover {
    background: var(--primary-strong);
}

.admin-body {
    background-color: var(--bg-color);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
}

.admin-body .container {
    max-width: 100%;
    width: 100%;
    padding: 20px;
}

.admin-no-permission {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #fff4d6;
    color: #8a5a00;
    border: 1px solid #f7d28b;
    font-size: 0.9rem;
}

.admin-no-permission.hidden {
    display: none;
}

.admin-panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.admin-panel.hidden {
    display: none;
}

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

.admin-header h2 {
    margin: 0;
    font-size: 18px;
}

.admin-actions {
    display: flex;
    gap: 8px;
}

.admin-actions input {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.admin-actions button {
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.admin-table {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
}

.admin-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: auto;
    min-width: 1600px;
}

.admin-table th,
.admin-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.admin-table th {
    color: var(--muted-text);
    font-weight: 600;
}

/* 为前面的列设置最小宽度 */
.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
    min-width: 50px;
    width: 50px;
}

.admin-table th:nth-child(2),
.admin-table td:nth-child(2) {
    min-width: 130px;
    width: 130px;
}

.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
    min-width: 120px;
    width: 120px;
}

.admin-table th:nth-child(4),
.admin-table td:nth-child(4) {
    min-width: 90px;
    width: 90px;
}

.admin-table th:nth-child(5),
.admin-table td:nth-child(5) {
    min-width: 90px;
    width: 90px;
}

.admin-table th:nth-child(6),
.admin-table td:nth-child(6) {
    min-width: 110px;
    width: 110px;
}

.admin-table input,
.admin-table select {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    width: 100%;
    box-sizing: border-box;
}

.admin-table button {
    border: none;
    background: #2563eb;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
}

.admin-table .ip-cell {
    min-width: 120px;
    white-space: nowrap;
    word-break: keep-all;
}

.admin-usage {
    margin-top: 16px;
}

.admin-usage h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.admin-usage-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.admin-usage-actions input {
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 12px;
}

.admin-usage-actions button {
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
}

.admin-config {
    margin-bottom: 20px;
    padding: 16px;
    background: #f6f8fc;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.admin-config h3 {
    margin: 0 0 12px;
    font-size: 14px;
    color: #1f2937;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-item label {
    min-width: 140px;
    font-size: 12px;
    color: #374151;
    font-weight: 500;
}

.config-item input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 12px;
}

.config-toggle-visibility {
    border: none;
    background: #e5e7eb;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    min-width: 40px;
}

.config-toggle-visibility:hover {
    background: #d1d5db;
}

.config-save-btn {
    margin-top: 8px;
    border: none;
    background: var(--primary-color);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    align-self: flex-start;
}

.config-save-btn:hover {
    background: var(--primary-strong);
}

.config-message {
    margin-top: 8px;
    font-size: 12px;
    min-height: 16px;
}

.config-message.success {
    color: #166534;
}

.config-message.error {
    color: #b42318;
}

.admin-usage-list {
    max-height: 240px;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    font-size: 12px;
    background: #f6f8fc;
}

.admin-usage-item {
    padding: 6px 4px;
    border-bottom: 1px dashed #e3e8f0;
    color: #3c4450;
}

.admin-usage-item:last-child {
    border-bottom: none;
}

.site-footer {
    margin: 24px auto 40px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted-text);
    letter-spacing: 0.02em;
}

.help-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.help-modal.active {
    display: flex;
}

.help-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 18, 32, 0.45);
}

.help-modal-card {
    position: relative;
    width: min(720px, 92vw);
    max-height: 90vh;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 24px 28px 28px;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}

.help-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #1f2937;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.help-modal-close {
    border: none;
    background: #f2f4f8;
    color: #3c4450;
    border-radius: 999px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 0;
}

.help-modal-close:hover {
    background: #e9eef6;
    box-shadow: var(--shadow-sm);
}

.help-modal-body {
    margin-top: 12px;
    color: #3c4450;
    line-height: 1.6;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.help-modal-body ol {
    margin: 0;
    padding-left: 18px;
}

.help-modal-body li {
    margin: 8px 0;
}

.help-modal-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.help-modal-ok {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
}

/* 帮助内容优化样式 */
.help-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    min-height: 0;
}

.help-content h4 {
    margin: 0 0 20px 0;
    font-size: 1.3rem;
    color: #1f2937;
    font-weight: 600;
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.help-section {
    margin: 20px 0;
}

.help-section:first-of-type {
    margin-top: 0;
}

.help-section h5 {
    margin: 0 0 12px 0;
    font-size: 1.05rem;
    color: #1f2937;
    font-weight: 600;
}

.help-section p {
    margin: 8px 0;
    color: #4b5563;
    line-height: 1.7;
}

.help-subsection {
    margin: 16px 0 16px 12px;
    padding-left: 8px;
    border-left: 2px solid #e5e7eb;
}

.help-subsection h6 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: #374151;
    font-weight: 600;
}

.help-section ul,
.help-subsection ul {
    margin: 8px 0;
    padding-left: 24px;
    list-style-type: disc;
}

.help-section ul ul {
    margin: 4px 0;
    padding-left: 20px;
    list-style-type: circle;
}

.help-section li,
.help-subsection li {
    margin: 6px 0;
    color: #4b5563;
    line-height: 1.7;
}

.help-section strong {
    color: #1f2937;
    font-weight: 600;
}

.help-section em {
    color: #6b7280;
    font-style: italic;
}

/* 滚动条样式优化 */
.help-content::-webkit-scrollbar {
    width: 6px;
}

.help-content::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 3px;
}

.help-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.help-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
