﻿* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: #fff;
    color: #172033;
    overflow: hidden;
}

body.ai-manim-library-mode {
    overflow: hidden;
}

.ai-manim-page {
    --manim-page-side-padding: max(20px, calc((100vw - 1480px) / 2 + 20px));
    position: fixed;
    top: var(--site-nav-height, 54px);
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 10px var(--manim-page-side-padding) 28px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
}

body.ai-manim-library-mode .ai-manim-page {
    height: auto;
    min-height: 0;
    overflow: hidden;
}

body.ai-manim-modal-open .ai-manim-page {
    overflow: hidden;
}

.ai-manim-shell {
    --manim-library-toolbar-offset: 690px;
    --manim-tabs-row-height: 35px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

body.ai-manim-library-mode .ai-manim-shell {
    height: 100%;
    min-height: 0;
}

.ai-manim-page-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

body.ai-manim-library-mode .ai-manim-page-toolbar {
    flex: 0 0 auto;
}

.ai-manim-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0;
    width: fit-content;
    margin-bottom: 0;
    padding: 3px;
    background: #f1f5f9;
    border: 0;
    border-radius: 8px;
}

body.ai-manim-library-mode .ai-manim-tabs {
    align-self: flex-start;
    width: fit-content;
    max-width: 100%;
}

.ai-manim-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    height: auto;
    border: 0;
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    background: transparent;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-manim-tab:hover {
    color: #3b82f6;
    background: rgba(255, 255, 255, 0.5);
}

.ai-manim-tab.active {
    background: #fff;
    color: #1d4ed8;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.ai-manim-tab i {
    font-size: 0.9rem;
    opacity: 0.9;
}

.ai-credit-purchase-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.ai-credit-purchase-btn:hover {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.ai-manim-tab-panel {
    display: none;
}

.ai-manim-tab-panel.active {
    display: block;
}

body.ai-manim-library-mode .ai-manim-tab-panel.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.ai-manim-workspace {
    display: grid;
    grid-template-columns: minmax(380px, 0.76fr) minmax(640px, 1.24fr);
    gap: 14px;
    align-items: stretch;
}

.ai-manim-hidden {
    display: none !important;
}

.ai-manim-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    min-width: 0;
    padding: 16px;
}

.ai-manim-form-panel {
    padding: 14px 16px;
}

.ai-manim-panel h1 {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 14px;
    color: #0f172a;
    font-size: 1.35rem;
    line-height: 1.2;
}

.ai-manim-form-panel h1 {
    gap: 8px;
    margin-bottom: 12px;
    font-size: 1.18rem;
}

.ai-manim-panel h1 i,
.ai-manim-panel h2 i {
    color: #2563eb;
}

.ai-manim-panel h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    color: #0f172a;
    font-size: 1.05rem;
    line-height: 1.2;
}

.ai-manim-panel label {
    display: block;
    margin: 14px 0 8px;
    color: #1f2937;
    font-size: 0.88rem;
    font-weight: 700;
}

.ai-manim-form-panel label {
    margin: 10px 0 6px;
    font-size: 0.8rem;
}

.ai-manim-panel input,
.ai-manim-panel select,
.ai-manim-panel textarea {
    width: 100%;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-manim-form-panel input,
.ai-manim-form-panel select,
.ai-manim-form-panel textarea {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.86rem;
}

.ai-manim-panel input:focus,
.ai-manim-panel select:focus,
.ai-manim-panel textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-manim-form-panel input:disabled,
.ai-manim-form-panel textarea:disabled,
.ai-manim-form-panel button:disabled {
    cursor: not-allowed;
    color: #94a3b8;
    background: #f8fafc;
    border-color: #e2e8f0;
    box-shadow: none;
}

.ai-manim-form-panel textarea:disabled {
    resize: none;
}

.ai-manim-panel textarea {
    min-height: 180px;
    resize: vertical;
    line-height: 1.65;
    font-size: 0.92rem;
}

.ai-manim-form-panel textarea {
    min-height: 154px;
    line-height: 1.55;
    font-size: 0.86rem;
}

.ai-manim-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.ai-manim-control-row {
    display: grid;
    grid-template-columns: minmax(132px, 0.62fr) minmax(96px, 0.45fr) minmax(240px, 1.28fr);
    gap: 8px;
    align-items: end;
    margin-top: 12px;
}

.ai-manim-model-native,
.ai-manim-choice-native {
    display: none !important;
}

.ai-manim-choice-select {
    position: relative;
    min-width: 0;
}

.ai-manim-choice-trigger {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 10px;
    color: #111827;
    background: #fff;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-manim-choice-trigger:hover {
    border-color: #93c5fd;
}

.ai-manim-choice-select.open .ai-manim-choice-trigger {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-manim-choice-trigger span {
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-choice-arrow {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 0.7rem;
    transition: transform 0.18s ease;
}

.ai-manim-choice-select.open .ai-manim-choice-arrow {
    transform: rotate(180deg);
}

.ai-manim-choice-panel {
    display: none;
    position: fixed;
    overflow-y: auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    z-index: 10080;
}

.ai-manim-choice-panel.show {
    display: block;
    animation: aiManimModelPanelIn 0.14s ease;
}

.ai-manim-choice-opt {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    padding: 0 12px;
    color: #334155;
    background: #fff;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.ai-manim-voice-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #fff;
    font-size: 0.72rem;
}

.ai-manim-voice-icon.female {
    background: #ec4899;
}

.ai-manim-voice-icon.male {
    background: #2563eb;
}

.ai-manim-voice-icon.child-girl {
    background: #f97316;
}

.ai-manim-voice-icon.child-boy {
    background: #06b6d4;
}

.ai-manim-voice-icon.elder-female {
    background: #8b5cf6;
}

.ai-manim-voice-icon.elder-male {
    background: #64748b;
}

.ai-manim-choice-opt span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-choice-opt:hover {
    background: #f8fafc;
}

.ai-manim-choice-opt.selected {
    color: #1d4ed8;
    background: #eff6ff;
}

.ai-manim-model-select {
    position: relative;
    min-width: 0;
}

.ai-manim-model-trigger {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 10px;
    color: #111827;
    background: #fff;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ai-manim-model-trigger:hover {
    border-color: #93c5fd;
}

.ai-manim-model-select.open .ai-manim-model-trigger {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-manim-model-trigger-name {
    min-width: 0;
    overflow: hidden;
    color: #111827;
    font-size: 0.86rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-model-trigger-stars {
    flex: 0 0 auto;
    color: #f59e0b;
    font-size: 0.72rem;
    letter-spacing: 0;
    white-space: nowrap;
}

.ai-manim-model-trigger-stars .dim,
.ai-manim-model-opt-stars .dim {
    opacity: 0.22;
}

.ai-manim-model-trigger-credits {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.ai-manim-model-trigger-arrow {
    flex: 0 0 auto;
    margin-left: auto;
    color: #64748b;
    font-size: 0.7rem;
    transition: transform 0.18s ease;
}

.ai-manim-model-select.open .ai-manim-model-trigger-arrow {
    transform: rotate(180deg);
}

.ai-manim-model-panel {
    display: none;
    position: fixed;
    min-width: min(340px, calc(100vw - 16px));
    overflow-y: auto;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18);
    z-index: 10080;
}

.ai-manim-model-panel.show {
    display: block;
    animation: aiManimModelPanelIn 0.14s ease;
}

@keyframes aiManimModelPanelIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-manim-model-opt-head,
.ai-manim-model-opt {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 48px;
    align-items: center;
    gap: 8px;
}

.ai-manim-model-opt-head {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 7px 12px;
    border-bottom: 1px solid #e5e7eb;
    color: #64748b;
    background: #f8fafc;
    font-size: 0.72rem;
    font-weight: 800;
}

.ai-manim-model-opt-head span:nth-child(2),
.ai-manim-model-opt-stars {
    text-align: center;
}

.ai-manim-model-opt-head span:last-child,
.ai-manim-model-opt-credits {
    text-align: right;
}

.ai-manim-model-opt {
    width: 100%;
    min-height: 30px;
    border: 0;
    border-bottom: 1px solid #f1f5f9;
    padding: 3px 12px;
    background: #fff;
    color: #334155;
    font: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ai-manim-model-opt:hover {
    background: #f8fafc;
}

.ai-manim-model-opt.selected {
    background: #eff6ff;
}

.ai-manim-model-opt-name {
    min-width: 0;
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-model-opt.selected .ai-manim-model-opt-name {
    color: #1d4ed8;
}

.ai-manim-model-opt-name .text-only {
    margin-left: 4px;
    color: #dc2626;
    font-size: 0.66rem;
    font-weight: 800;
}

.ai-manim-model-opt-stars {
    color: #f59e0b;
    font-size: 0.76rem;
    letter-spacing: 0;
    white-space: nowrap;
}

.ai-manim-model-opt-credits {
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.ai-manim-orientation-row {
    display: grid;
    grid-template-columns: auto repeat(2, minmax(132px, 1fr));
    gap: 7px;
    align-items: center;
    margin-top: 12px;
    padding: 7px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
}

.ai-manim-orientation-label {
    color: #1f2937;
    font-size: 0.8rem;
    font-weight: 800;
    white-space: nowrap;
}

.ai-manim-orientation-option {
    position: relative;
    margin: 0 !important;
    cursor: pointer;
}

.ai-manim-orientation-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ai-manim-orientation-option span {
    min-height: 38px;
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 7px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
    color: #475569;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.ai-manim-orientation-option i {
    color: #64748b;
}

.ai-manim-orientation-option strong {
    font-size: 0.82rem;
}

.ai-manim-orientation-option small {
    justify-self: end;
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 900;
}

.ai-manim-orientation-option input:checked + span {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-manim-orientation-option input:checked + span i,
.ai-manim-orientation-option input:checked + span small {
    color: #2563eb;
}

.ai-manim-submit-cell {
    grid-column: 1 / 2;
    display: flex;
    align-items: end;
}

.ai-manim-submit-cell .ai-manim-btn {
    width: 100%;
    min-height: 38px;
}

.ai-manim-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 22px;
    margin-top: 10px;
}

.ai-manim-reference-block {
    margin-top: 12px;
    padding: 10px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #f8fafc;
}

.ai-manim-reference-block.disabled {
    opacity: 0.62;
}

.ai-manim-reference-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.ai-manim-reference-label {
    margin: 0 !important;
}

.ai-manim-reference-head span,
.ai-manim-reference-hint {
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 700;
}

.ai-manim-reference-drop {
    min-height: 58px;
    display: grid !important;
    place-items: center;
    gap: 5px;
    margin: 0 !important;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    padding: 9px 10px;
    color: #334155 !important;
    background: #fff;
    text-align: center;
    cursor: pointer;
}

.ai-manim-reference-block.disabled .ai-manim-reference-drop {
    cursor: not-allowed;
}

.ai-manim-reference-drop input {
    display: none;
}

.ai-manim-reference-drop i {
    color: #2563eb;
    font-size: 1.12rem;
}

.ai-manim-reference-drop span {
    font-size: 0.76rem;
    line-height: 1.45;
}

.ai-manim-reference-hint {
    margin-top: 7px;
    line-height: 1.5;
}

.ai-manim-reference-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.ai-manim-reference-item {
    min-width: 0;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 26px;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

.ai-manim-reference-item img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    background: #e5e7eb;
}

.ai-manim-reference-item span {
    min-width: 0;
    overflow: hidden;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-reference-item button {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
}

.ai-manim-reference-item button:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.ai-manim-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    padding: 0 14px;
    color: #1d4ed8;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

.ai-manim-btn-primary {
    background: #2563eb;
    color: #fff;
}

.ai-manim-btn-primary:hover {
    background: #1d4ed8;
}

.ai-manim-btn-ghost {
    background: #eef2ff;
    color: #1d4ed8;
}

.ai-manim-btn-ghost:hover {
    background: #dbeafe;
}

.ai-manim-muted {
    color: #6b7280;
    font-size: 13px;
}

.ai-manim-current-panel {
    display: grid;
    grid-template-rows: auto auto;
    gap: 12px;
    align-content: start;
    min-height: 0;
}

.ai-manim-current-box {
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto auto;
}

.ai-manim-current-screen {
    position: relative;
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
    background: #0f172a;
}

.ai-manim-current-screen.is-portrait {
    width: 100%;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
}

.ai-manim-current-screen video {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    object-fit: contain;
    background: #0f172a;
}

.ai-manim-current-empty {
    min-height: 100%;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 24px;
    color: #cbd5e1;
    text-align: center;
}

.ai-manim-current-screen .ai-manim-current-empty {
    height: 100%;
}

.ai-manim-current-empty i {
    color: #60a5fa;
    font-size: 34px;
}

.ai-manim-current-empty p {
    margin: 0;
    color: #cbd5e1;
    font-weight: 700;
}

.ai-manim-current-progress {
    min-height: 64px;
    padding: 12px;
    border-bottom: 1px solid #dbe3ef;
    background: #f8fafc;
    color: #334155;
}

.ai-manim-current-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 0.82rem;
    font-weight: 800;
}

.ai-manim-current-progress-head span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-manim-current-progress progress {
    width: 100%;
    height: 8px;
    margin: 0;
    display: block;
    accent-color: #2563eb;
}

.ai-manim-current-info {
    display: grid;
    gap: 8px;
    padding: 12px;
    background: #fff;
}

.ai-manim-current-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-manim-current-actions-download {
    justify-content: flex-start;
}

.ai-manim-current-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    min-width: 148px;
    padding: 0 14px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    color: #1d4ed8;
    background: #eff6ff;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.ai-manim-current-download:hover {
    background: #dbeafe;
}

.ai-manim-current-download:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    background: #f8fafc;
    border-color: #dbe3ef;
    color: #64748b;
}

.ai-manim-history-panel {
    padding: 0;
    overflow: hidden;
}

.ai-manim-history {
    min-width: 0;
}

.ai-manim-history summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    min-height: 56px;
    padding: 0 16px;
    color: #0f172a;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.ai-manim-history summary::-webkit-details-marker {
    display: none;
}

.ai-manim-history summary span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-manim-history summary i {
    color: #2563eb;
}

.ai-manim-history summary small {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 700;
}

.ai-manim-history summary::after {
    content: "\f078";
    color: #64748b;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    transition: transform 0.18s ease;
}

.ai-manim-history[open] summary {
    border-bottom: 1px solid #e5e7eb;
}

.ai-manim-history[open] summary::after {
    transform: rotate(180deg);
}

.ai-manim-history-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px 0;
}

.ai-manim-history-list {
    display: grid;
    gap: 0;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.ai-manim-history-list > .ai-manim-muted {
    padding: 14px;
}

.ai-manim-login-required {
    grid-column: 1 / -1;
    min-height: 180px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    padding: 28px 18px;
    color: #64748b;
    text-align: center;
}

.ai-manim-login-required i {
    color: #2563eb;
    font-size: 28px;
}

.ai-manim-login-required p {
    margin: 0;
    font-weight: 700;
}

.ai-manim-divider {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

.ai-manim-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 50%;
    background: #94a3b8;
}

.ai-manim-dot.ok {
    background: #059669;
}

.ai-manim-dot.bad {
    background: #dc2626;
}

.ai-manim-job {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 11px;
    margin-bottom: 10px;
    background: #f8fafc;
}

.ai-manim-history-list .ai-manim-job {
    margin-bottom: 0;
}

.ai-manim-job-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.ai-manim-job-row:last-child {
    border-bottom: 0;
}

.ai-manim-job-main {
    min-width: 0;
}

.ai-manim-job-meta {
    margin-top: 5px;
    color: #64748b;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-manim-job-side {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-manim-job-progress {
    width: 112px;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
}

.ai-manim-job-progress progress {
    width: 100%;
    height: 6px;
    margin-top: 4px;
    display: block;
}

.ai-manim-history-link {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 7px;
    padding: 0 10px;
    background: #eef2ff;
    color: #1d4ed8;
    font-size: 0.8rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    border: 0;
    cursor: pointer;
}

.ai-manim-history-link:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.ai-manim-history-more {
    display: flex;
    justify-content: center;
    padding: 12px;
    background: #f8fafc;
}

.ai-manim-history-retry {
    background: #ecfdf5;
    color: #047857;
}

.ai-manim-job-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    color: #0f172a;
    font-weight: 800;
}

.ai-manim-status {
    font-size: 12px;
    color: #fff;
    background: #64748b;
    border-radius: 999px;
    padding: 2px 8px;
    white-space: nowrap;
}

.ai-manim-status.success {
    background: #059669;
}

.ai-manim-status.failed {
    background: #dc2626;
}

.ai-manim-status.stalled {
    background: #b45309;
}

.ai-manim-status.processing {
    background: #2563eb;
}

.ai-manim-status.planning,
.ai-manim-status.queued {
    background: #2563eb;
}

.ai-manim-panel progress {
    width: 100%;
    height: 10px;
    margin-top: 9px;
}

.ai-manim-panel video {
    width: 100%;
    margin-top: 10px;
    border-radius: 8px;
    background: #111827;
}

.ai-manim-error {
    margin-top: 10px;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

.ai-manim-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.ai-manim-section-head h1 {
    margin: 0;
}

.ai-manim-public-library {
    min-width: 0;
}

.public-gallery-section {
    margin-top: 0;
}

body.ai-manim-library-mode .public-gallery-section,
body.ai-manim-library-mode .image-library-shell {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.image-library-shell {
    display: grid;
    gap: 8px;
}

body.ai-manim-library-mode .image-library-shell {
    grid-template-rows: auto minmax(0, 1fr);
}

.image-library-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
    gap: 18px;
    align-items: center;
    padding: 12px;
    border: 1px solid #e3eaf4;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.image-library-heading {
    min-width: 0;
}

.image-library-kicker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 5px;
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 900;
}

.image-library-heading h1 {
    margin: 0;
    color: #0f172a;
    font-size: 1.1rem;
    line-height: 1.1;
}

.ai-manim-tab-panel[data-manim-panel="public"] .ai-manim-library-hero,
.ai-manim-tab-panel[data-manim-panel="mine"] .ai-manim-library-hero {
    width: calc(100% - var(--manim-library-toolbar-offset));
    height: var(--manim-tabs-row-height);
    min-height: var(--manim-tabs-row-height);
    margin: calc(-1 * (var(--manim-tabs-row-height) + 14px)) 0 14px var(--manim-library-toolbar-offset);
    padding: 4px 12px;
    box-sizing: border-box;
    grid-template-columns: 150px minmax(360px, 1fr);
    gap: 14px;
    align-items: center;
}

.ai-manim-tab-panel[data-manim-panel="public"] .image-library-shell,
.ai-manim-tab-panel[data-manim-panel="mine"] .image-library-shell {
    gap: 0;
}

.ai-manim-tab-panel[data-manim-panel="public"] .image-library-heading h1,
.ai-manim-tab-panel[data-manim-panel="mine"] .image-library-heading h1 {
    font-size: 1rem;
    line-height: 1;
}

.ai-manim-tab-panel[data-manim-panel="public"] .image-library-kicker,
.ai-manim-tab-panel[data-manim-panel="mine"] .image-library-kicker {
    display: none;
}

.ai-manim-tab-panel[data-manim-panel="public"] .image-library-search,
.ai-manim-tab-panel[data-manim-panel="mine"] .image-library-search {
    height: 36px;
}

.ai-manim-tab-panel[data-manim-panel="public"] .image-library-refresh,
.ai-manim-tab-panel[data-manim-panel="mine"] .image-library-refresh {
    min-height: 36px;
}

.image-library-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.image-library-layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

body.ai-manim-library-mode .image-library-layout {
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

.image-library-sidebar {
    position: sticky;
    top: 78px;
    display: grid;
    gap: 10px;
    align-self: start;
    padding: 12px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid #e3eaf4;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

body.ai-manim-library-mode .image-library-sidebar {
    position: static;
    max-height: 100%;
    overflow-y: auto;
}

.image-library-sidebar-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 6px;
    border-bottom: 1px solid #edf2f7;
}

.image-library-sidebar-head span {
    color: #0f172a;
    font-size: 0.9rem;
    font-weight: 900;
}

.image-library-sidebar-head small {
    color: #94a3b8;
    font-size: 0.74rem;
    font-weight: 700;
}

.image-library-sidebar-head small strong {
    color: #2563eb;
    font-size: 0.9rem;
    font-weight: 900;
}

.image-library-total {
    color: #334155;
    font-size: 0.9rem;
}

.image-library-total strong {
    color: #0f172a;
    font-size: 1.15rem;
}

.image-library-search {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 13px;
    border: 1px solid #d9e4f2;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
}

.image-library-search:focus-within {
    border-color: #2563eb;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.image-library-search input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: none;
    color: #0f172a;
    font-size: 0.9rem;
    background: transparent;
}

.image-library-filters {
    display: grid;
    gap: 4px;
}

.image-filter-chip {
    position: relative;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 0 8px;
    background: transparent;
    color: #475569;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    text-align: left;
}

.image-filter-chip i {
    width: 18px;
    color: #64748b;
    text-align: center;
}

.image-filter-count {
    min-width: 24px;
    height: 20px;
    margin-left: auto;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef2f7;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 900;
}

.image-filter-chip:hover {
    background: #f3f7fd;
    color: #1d4ed8;
}

.image-filter-chip.active {
    border-color: #c9ddff;
    background: #edf5ff;
    color: #1d4ed8;
}

.image-filter-chip.active::before {
    content: "";
    width: 3px;
    height: 18px;
    border-radius: 999px;
    background: #2563eb;
}

.image-filter-chip.active i {
    color: #2563eb;
}

.image-filter-chip.active .image-filter-count {
    background: #dbeafe;
    color: #1d4ed8;
}

.image-library-refresh {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid #d9e4f2;
    border-radius: 8px;
    background: #fff;
    color: #334155;
    font-weight: 800;
    cursor: pointer;
}

.image-library-refresh:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    background: #eff6ff;
}

.ai-manim-library-content {
    min-width: 0;
    height: calc(100vh - 145px);
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

body.ai-manim-library-mode .ai-manim-library-content {
    height: auto;
    min-height: 0;
    overflow: hidden;
}

.ai-manim-library-content .ai-manim-video-grid {
    flex: 1 1 auto;
    min-height: 0;
    align-content: start;
    overflow-y: auto;
    padding: 1px 4px 72px 1px;
}

.ai-manim-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
    align-items: start;
}

.ai-manim-video-card {
    --video-card-height: 308px;
    --video-thumb-ratio: 52%;
    min-width: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: grid;
    grid-template-rows: var(--video-thumb-ratio) calc(100% - var(--video-thumb-ratio));
    height: var(--video-card-height);
}

.ai-manim-video-card-manage {
    --video-card-height: 326px;
    --video-thumb-ratio: 46%;
}

.ai-manim-video-thumb {
    position: relative;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
}

.ai-manim-video-featured-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 16px rgba(146, 64, 14, 0.22);
    pointer-events: none;
}

.ai-manim-video-featured-badge i {
    font-size: 10px;
}

.ai-manim-video-thumb video {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    object-fit: contain;
    background: #0f172a;
}

.ai-manim-video-cover {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    background: #0f172a;
    cursor: pointer;
}

.ai-manim-video-cover img,
.ai-manim-video-cover-placeholder {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    object-fit: contain;
    background: #0f172a;
    color: #cbd5e1;
}

.ai-manim-video-cover img {
    display: block;
}

.ai-manim-video-cover-placeholder i {
    font-size: 2rem;
    opacity: 0.72;
}

.ai-manim-video-play-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.92);
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.92);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
    transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.ai-manim-video-card:hover .ai-manim-video-play-badge,
.ai-manim-video-card:focus-within .ai-manim-video-play-badge {
    opacity: 1;
    background: #2563eb;
    transform: translate(-50%, -50%) scale(1.05);
}

.ai-manim-video-body {
    padding: 10px 12px;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: 34px 18px 22px 1fr;
    align-content: start;
    gap: 6px;
}

.ai-manim-video-card video {
    height: 100%;
    object-fit: contain;
}

.ai-manim-video-title {
    color: #111827;
    font-size: 1rem;
    line-height: 1.28;
    font-weight: 700;
    min-height: 34px;
    max-height: 34px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ai-manim-video-id-row {
    min-height: 18px;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
}

.ai-manim-video-id {
    display: inline-block;
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
    font-family: Consolas, Monaco, monospace;
    vertical-align: middle;
    white-space: nowrap;
}

.ai-manim-video-file-type {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #ecfdf5;
    color: #047857;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.ai-manim-video-orientation {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.ai-manim-video-orientation.landscape {
    background: #dbeafe;
    color: #1d4ed8;
}

.ai-manim-video-public-state {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.ai-manim-video-public-state.public {
    background: #e0f2fe;
    color: #0369a1;
}

.ai-manim-video-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    color: #64748b;
    font-size: 0.76rem;
    line-height: 1.2;
}

.ai-manim-video-meta-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.ai-manim-video-author {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 58%;
    min-width: 0;
    overflow: hidden;
}

.ai-manim-video-author span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-manim-video-author i {
    color: #94a3b8;
    flex-shrink: 0;
}

.ai-manim-video-subject {
    padding: 2px 7px;
    border-radius: 8px;
    background: #6a9fa8;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-manim-video-subject[data-subject="灏忓鏁板"],
.ai-manim-video-subject[data-subject="primary-math"] {
    background: #7fa87f;
}

.ai-manim-video-subject[data-subject="鍒濅腑鏁板"],
.ai-manim-video-subject[data-subject="junior-math"] {
    background: #6b8cae;
}

.ai-manim-video-subject[data-subject="楂樹腑鏁板"],
.ai-manim-video-subject[data-subject="senior-math"] {
    background: #9585a8;
}

.ai-manim-video-subject[data-subject="鍒濅腑鐗╃悊"],
.ai-manim-video-subject[data-subject="junior-physics"] {
    background: #c9a86c;
}

.ai-manim-video-subject[data-subject="楂樹腑鐗╃悊"],
.ai-manim-video-subject[data-subject="senior-physics"] {
    background: #b87b7b;
}

.ai-manim-video-subject[data-subject="澶у鏁板"],
.ai-manim-video-subject[data-subject="college-math"] {
    background: #7c6fb0;
}

.ai-manim-video-subject[data-subject="澶у鐗╃悊"],
.ai-manim-video-subject[data-subject="college-physics"] {
    background: #4f8f9f;
}

.ai-manim-video-subject[data-subject="璇枃"],
.ai-manim-video-subject[data-subject="chinese"] {
    background: #b7791f;
}

.ai-manim-video-subject[data-subject="鑻辫"],
.ai-manim-video-subject[data-subject="english"] {
    background: #3b82f6;
}

.ai-manim-video-subject[data-subject="骞垮憡"],
.ai-manim-video-subject[data-subject="advertising"] {
    background: #db2777;
}

.ai-manim-video-downloads {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #10b981;
    flex-shrink: 0;
}

.ai-manim-video-extra-meta {
    color: #94a3b8;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-manim-video-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 32px;
    gap: 7px;
    margin-top: 0;
    align-self: end;
}

.ai-manim-video-actions.with-delete {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ai-manim-modal-open {
    overflow: hidden;
}

.ai-manim-video-modal[hidden] {
    display: none;
}

.ai-manim-video-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: grid;
    place-items: center;
    padding: 24px;
}

.ai-manim-video-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.ai-manim-video-modal-dialog {
    position: relative;
    width: min(1080px, 94vw);
    max-height: 92vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.42);
}

.ai-manim-video-modal-dialog.is-portrait {
    width: min(480px, 94vw);
}

.ai-manim-video-modal-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px 0 16px;
    color: #f8fafc;
    background: #111827;
}

.ai-manim-video-modal-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
}

.ai-manim-video-modal-close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
}

.ai-manim-video-modal-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.ai-manim-video-modal video {
    display: block;
    width: 100%;
    max-height: calc(92vh - 48px);
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #000;
}

.ai-manim-video-modal-dialog.is-portrait video {
    aspect-ratio: 9 / 16;
}

.ai-manim-current-prompt-btn {
    width: fit-content;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.ai-manim-current-prompt-btn:hover {
    border-color: #2563eb;
    color: #1d4ed8;
}

.ai-manim-prompt-modal[hidden] {
    display: none;
}

.ai-manim-prompt-modal {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: grid;
    place-items: center;
    padding: 24px;
}

.ai-manim-prompt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.ai-manim-prompt-modal-dialog {
    position: relative;
    width: min(760px, 94vw);
    max-height: 82vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(17, 24, 39, 0.28);
}

.ai-manim-prompt-modal-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
    background: #fff;
}

.ai-manim-prompt-modal-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
}

.ai-manim-prompt-modal-close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    color: #334155;
    background: #f1f5f9;
    cursor: pointer;
}

.ai-manim-prompt-modal-close:hover {
    background: #e2e8f0;
}

.ai-manim-prompt-modal-content {
    max-height: calc(82vh - 48px);
    margin: 0;
    padding: 16px;
    overflow: auto;
    color: #1f2937;
    background: #fff;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-manim-action-modal[hidden] {
    display: none;
}

.ai-manim-action-modal {
    position: fixed;
    inset: 0;
    z-index: 10070;
    display: grid;
    place-items: center;
    padding: 20px;
}

.ai-manim-action-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.ai-manim-action-modal-dialog {
    position: relative;
    width: min(460px, 94vw);
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.ai-manim-action-modal-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.ai-manim-action-modal-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #2563eb;
    background: #eff6ff;
    font-size: 1.05rem;
}

.ai-manim-action-modal-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.ai-manim-action-modal-title {
    display: block;
    color: #0f172a;
    font-size: 1.02rem;
    font-weight: 900;
    line-height: 1.35;
}

.ai-manim-action-modal-subtitle {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.86rem;
    line-height: 1.45;
}

.ai-manim-action-modal-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    color: #475569;
    background: #f1f5f9;
    cursor: pointer;
}

.ai-manim-action-modal-close:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.ai-manim-action-modal-body {
    display: grid;
    gap: 14px;
    padding: 16px 18px 18px;
}

.ai-manim-action-modal-message {
    margin: 0;
    color: #1f2937;
    font-size: 0.94rem;
    line-height: 1.65;
}

.ai-manim-action-modal-note {
    border-left: 3px solid #38bdf8;
    padding: 9px 11px;
    color: #475569;
    background: #f8fafc;
    font-size: 0.86rem;
    line-height: 1.55;
}

.ai-manim-action-modal-field {
    display: grid;
    gap: 8px;
}

.ai-manim-action-modal-field[hidden] {
    display: none;
}

.ai-manim-action-modal-field span {
    color: #111827;
    font-size: 0.88rem;
    font-weight: 800;
}

.ai-manim-action-modal-field select {
    width: 100%;
    height: 42px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    padding: 0 12px;
    color: #111827;
    background: #fff;
    font: inherit;
    font-weight: 700;
    outline: none;
}

.ai-manim-action-modal-field select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.ai-manim-action-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 18px 18px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}

.ai-manim-action-modal-btn {
    min-width: 96px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0 14px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 900;
    cursor: pointer;
}

.ai-manim-action-modal-btn.secondary {
    border: 1px solid #cbd5e1;
    color: #334155;
    background: #fff;
}

.ai-manim-action-modal-btn.secondary:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.ai-manim-action-modal-btn.primary {
    border: 1px solid #2563eb;
    color: #fff;
    background: #2563eb;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.ai-manim-action-modal-btn.primary:hover {
    background: #1d4ed8;
}

@media (max-width: 560px) {
    .ai-manim-action-modal {
        padding: 12px;
    }

    .ai-manim-action-modal-head {
        padding: 16px 14px 12px;
    }

    .ai-manim-action-modal-body {
        padding: 14px;
    }

    .ai-manim-action-modal-actions {
        grid-template-columns: 1fr;
        display: grid;
        padding: 12px 14px 14px;
    }

    .ai-manim-action-modal-btn {
        width: 100%;
    }
}

.gallery-pagination-container {
    flex: 0 0 auto;
    position: fixed;
    bottom: 0;
    left: max(268px, calc((100vw - 1480px) / 2 + 268px));
    right: max(20px, calc((100vw - 1480px) / 2 + 20px));
    z-index: 30;
    padding: 10px 0 12px;
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    backdrop-filter: blur(8px);
}

body.ai-manim-library-mode .gallery-pagination-container {
    position: relative;
    inset: auto;
    z-index: 1;
    padding: 10px 0 0;
    margin-top: 0;
}

.gallery-pagination-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gallery-pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gallery-pagination-btn:hover:not(:disabled) {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.gallery-pagination-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.gallery-pagination-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    opacity: 1;
}

.gallery-pagination-ellipsis,
.gallery-pagination-info {
    color: #94a3b8;
    font-size: 13px;
}

.gallery-pagination-info {
    margin: 0 8px;
}

.gallery-pagination-jump-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #64748b;
    font-size: 13px;
}

.gallery-pagination-jump-inline input {
    width: 52px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #334155;
    font-size: 13px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.gallery-pagination-jump-inline input::-webkit-outer-spin-button,
.gallery-pagination-jump-inline input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.gallery-pagination-jump-inline input:focus {
    border-color: #2563eb;
}

.gallery-jump-btn {
    height: 30px;
    padding: 0 12px;
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.ai-manim-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    border: 0;
    border-radius: 7px;
    padding: 0 10px;
    background: #eef2ff;
    color: #1d4ed8;
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.ai-manim-link-btn:hover {
    background: #dbeafe;
}

.ai-manim-link-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-manim-link-btn.ai-manim-danger {
    background: #fef2f2;
    color: #b91c1c;
}

.ai-manim-link-btn.ai-manim-danger:hover:not(:disabled) {
    background: #fee2e2;
}

.ai-manim-link-btn.ai-manim-warn {
    background: #fff7ed;
    color: #c2410c;
}

.ai-manim-link-btn.ai-manim-warn:hover:not(:disabled) {
    background: #ffedd5;
}

.ai-manim-badge {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 2px 8px;
    background: #ecfdf5;
    color: #047857;
    font-size: 12px;
    font-weight: 700;
}

.ai-manim-dev {
    max-width: 760px;
    margin: 0 auto;
    text-align: center;
    padding: 44px 28px;
}

.ai-manim-dev-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: #eef2ff;
    color: #2563eb;
    font-size: 24px;
}

.ai-manim-dev p {
    margin: 8px 0 0;
    color: #64748b;
    line-height: 1.7;
}

@media (max-width: 1280px) {
    .ai-manim-video-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 1120px) {
    .ai-manim-workspace {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .ai-manim-current-panel {
        min-height: 0;
    }

    .ai-manim-current-box {
        min-height: 0;
    }

    .ai-manim-current-screen {
        aspect-ratio: 16 / 9;
    }

    .ai-manim-current-screen.is-portrait {
        width: 100%;
        aspect-ratio: 16 / 9;
    }

    .ai-manim-control-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-manim-video-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .ai-manim-tab-panel[data-manim-panel="public"] .ai-manim-library-hero,
    .ai-manim-tab-panel[data-manim-panel="mine"] .ai-manim-library-hero {
        width: 100%;
        height: auto;
        min-height: var(--manim-tabs-row-height);
        margin: 0 0 14px;
        grid-template-columns: minmax(160px, 0.5fr) minmax(360px, 1fr);
    }

    .ai-manim-tab-panel[data-manim-panel="public"] .image-library-shell,
    .ai-manim-tab-panel[data-manim-panel="mine"] .image-library-shell {
        gap: 8px;
    }
}

@media (max-width: 900px) {
    .ai-manim-page {
        --manim-page-side-padding: 16px;
        padding-top: 8px;
        padding-bottom: 16px;
    }

    .ai-manim-page-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .ai-manim-tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
    }

    .ai-manim-tab span {
        display: none;
    }

    .ai-manim-tab i {
        font-size: 14px;
    }

    .ai-credit-purchase-btn,
    .ai-manim-guide-entry {
        width: 100%;
        margin-left: 0;
    }

    .ai-manim-row {
        grid-template-columns: 1fr;
    }

    .ai-manim-control-row {
        grid-template-columns: 1fr;
    }

    .ai-manim-orientation-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-manim-orientation-label {
        grid-column: 1 / -1;
    }

    .ai-manim-section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .image-library-layout {
        grid-template-columns: 1fr;
    }

    .image-library-hero {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .image-library-sidebar {
        position: static;
    }

    .ai-manim-library-content {
        height: calc(100vh - 190px);
        min-height: 360px;
    }

    .gallery-pagination-container {
        left: 16px;
        right: 16px;
    }

    .image-library-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .ai-manim-tab {
        flex: 1 1 0;
        min-width: 0;
    }

    .ai-manim-video-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .ai-manim-video-card {
        --video-card-height: 252px;
        --video-thumb-ratio: 44%;
    }

    .ai-manim-video-card-manage {
        --video-card-height: 272px;
        --video-thumb-ratio: 40%;
    }

    .ai-manim-video-body {
        padding: 8px;
        grid-template-rows: 32px 17px 20px 1fr;
        gap: 5px;
    }

    .ai-manim-video-title {
        font-size: 0.82rem;
        min-height: 32px;
        max-height: 32px;
    }

    .ai-manim-video-id,
    .ai-manim-video-file-type,
    .ai-manim-video-orientation,
    .ai-manim-video-public-state,
    .ai-manim-video-subject {
        font-size: 9px;
    }

    .ai-manim-video-meta,
    .ai-manim-video-extra-meta {
        font-size: 0.68rem;
    }

    .ai-manim-video-author {
        max-width: 52%;
    }

    .ai-manim-video-actions,
    .ai-manim-video-actions.with-delete {
        grid-auto-rows: 28px;
        gap: 5px;
    }

    .image-library-toolbar {
        grid-template-columns: 1fr;
    }

    .ai-manim-job-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .ai-manim-job-side {
        justify-content: space-between;
    }
}

/* ========== AI 瑙嗛鎿嶄綔姝ラ鎸囧紩 ========== */
.ai-manim-guide-entry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.ai-manim-guide-entry:hover {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1e40af;
}

.ai-manim-guide-focus {
    position: fixed;
    z-index: 10020;
    pointer-events: none;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    box-shadow:
        0 0 0 9999px rgba(15, 23, 42, 0.66),
        0 0 0 6px rgba(251, 191, 36, 0.18),
        0 16px 42px rgba(15, 23, 42, 0.26);
    transition: left 0.22s ease, top 0.22s ease, width 0.22s ease, height 0.22s ease;
}

.ai-manim-guide-popover {
    position: fixed;
    z-index: 10030;
    padding: 16px;
    color: #172033;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.32);
    line-height: 1.6;
}

.ai-manim-guide-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.ai-manim-guide-close:hover {
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
}

.ai-manim-guide-kicker {
    padding-right: 28px;
    font-size: 12px;
    font-weight: 800;
    color: #2563eb;
}

.ai-manim-guide-progress {
    height: 5px;
    margin: 8px 0 12px;
    overflow: hidden;
    background: #e5e7eb;
    border-radius: 999px;
}

.ai-manim-guide-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #f59e0b);
    border-radius: inherit;
    transition: width 0.2s ease;
}

.ai-manim-guide-popover h3 {
    margin: 0 0 8px;
    color: #0f172a;
    font-size: 17px;
    line-height: 1.35;
    letter-spacing: 0;
}

.ai-manim-guide-popover p {
    margin: 0;
    color: #475569;
    font-size: 14px;
}

.ai-manim-guide-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.ai-manim-guide-btn {
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.ai-manim-guide-btn:hover:not(:disabled) {
    border-color: #2563eb;
    color: #1d4ed8;
}

.ai-manim-guide-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.ai-manim-guide-btn.primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.ai-manim-guide-btn.primary:hover {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
}

.ai-manim-guide-btn.ghost {
    border-color: transparent;
    color: #64748b;
}

.ai-manim-guide-btn.ghost:hover {
    background: #f8fafc;
    color: #334155;
}

@media (max-width: 760px) {
    .ai-manim-page-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .ai-manim-tabs,
    .ai-manim-guide-entry,
    .ai-credit-purchase-btn {
        width: 100%;
        margin-left: 0;
    }

    .ai-manim-guide-popover {
        padding: 14px;
    }

    .ai-manim-guide-actions {
        justify-content: stretch;
    }

    .ai-manim-guide-btn {
        flex: 1 1 auto;
    }
}
