/* ========================================
   Admin Panel — Light Minimal Redesign
   Clean SaaS-style with warm accents & icons
   Overrides layout.css defaults
   ======================================== */

/* --- Sidebar: Distinct warm panel --- */
.admin-sidebar {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    box-shadow: none;
    position: relative;
}

.admin-nav-group {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-light);
}

/* Group labels: accent colored — primary structural element */
.admin-nav-label {
    color: var(--color-accent);
    font-size: 11px;
    letter-spacing: 0.06em;
}

/* Nav links with icons */
.admin-nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-text);
    padding: 1px 10px;
}

.admin-nav-link i {
    width: 18px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.admin-nav-link:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
}

.admin-nav-link:hover i {
    color: var(--color-text-secondary);
}

/* Active: accent text + light accent bg */
.admin-nav-link--active {
    color: var(--color-accent);
    background: var(--color-accent-light);
    font-weight: var(--weight-semibold);
}

.admin-nav-link--active i {
    color: var(--color-accent);
}

/* --- Content Area --- */
.admin-content {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* --- Header --- */
.admin-header {
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-xl);
}

.admin-header h1 {
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
}

/* --- Stat Cards --- */
.admin-page .stat-card {
    border: 1px solid var(--color-border-light);
    box-shadow: none;
    transition: box-shadow var(--transition-fast);
}

.admin-page .stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: none;
}

/* --- Tables: Uppercase headers, subtle zebra --- */
.admin-page .table td {
    font-size: var(--text-sm);
}

.admin-page .table thead {
    background: var(--color-bg);
}

.admin-page .table thead th {
    padding-top: var(--space-md);
    padding-bottom: var(--space-md);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    font-weight: var(--weight-semibold);
}

.admin-page .table tbody tr:nth-child(even) {
    background: var(--color-bg);
}

.admin-page .table tbody tr:hover {
    background: var(--color-surface-hover);
}

/* --- Section headings --- */
.admin-section h2 {
    font-weight: var(--weight-bold);
    letter-spacing: -0.01em;
}

/* --- Mobile --- */
@media (max-width: 767px) {
    .admin-sidebar {
        background: var(--color-bg-alt);
        box-shadow: none;
        padding: var(--space-sm);
    }

    .admin-nav {
        background: none;
    }

    .admin-nav-link {
        color: var(--color-text-secondary);
    }

    .admin-nav-link:hover {
        color: var(--color-text);
        background: var(--color-surface-hover);
    }

    .admin-nav-link--active {
        background: var(--color-accent-light);
        color: var(--color-accent);
        font-weight: var(--weight-semibold);
    }

    .admin-nav-group {
        border-top: none;
        margin-top: var(--space-sm);
        padding-top: 0;
    }

    .admin-nav-label {
        color: var(--color-accent);
    }
}

/* ========================================
   Admin-specific component overrides
   ======================================== */

.comment-preview {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- View toggle buttons --- */
.admin-view-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.admin-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 34px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    text-decoration: none;
    transition: background var(--transition-base), color var(--transition-base);
}

.admin-view-btn:hover {
    color: var(--color-text);
    background: var(--color-bg-alt);
}

.admin-view-btn.active {
    color: var(--color-primary);
    background: var(--color-bg-alt);
}

.admin-view-btn + .admin-view-btn {
    border-left: 1px solid var(--color-border);
}

/* --- Sort select --- */
.admin-sort-select {
    padding: 6px 10px;
    font-size: var(--text-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

/* --- Clickable table rows --- */
.admin-clickable-row {
    cursor: pointer;
}

.admin-clickable-row:hover td {
    background: var(--color-bg-alt);
}

/* --- Podcast thumbnail in table --- */
/* Override reset.css: img { max-width:100%; height:auto } */
.admin-page .table img.admin-podcast-thumb {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    height: 64px;
    max-height: 64px;
    border-radius: var(--radius-md);
    object-fit: cover;
    vertical-align: middle;
}

/* --- Admin podcast grid cards (extends .podcast-card from components.css) --- */
.admin-podcast-card {
    cursor: default;
}

.admin-podcast-card:hover {
    transform: none;
}

.admin-podcast-card-title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.admin-podcast-card-title:hover {
    color: var(--color-primary);
}

.admin-podcast-card-stats {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

.admin-podcast-card-listens {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.admin-podcast-card-cost {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.admin-podcast-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border);
}

/* ========================================
   Language Tabs (multi-language chapters)
   ======================================== */

.lang-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.lang-tabs__list {
    display: flex;
    gap: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.lang-tab {
    padding: 6px 16px;
    border: none;
    background: var(--color-surface);
    cursor: pointer;
    font-size: var(--text-sm);
    font-family: var(--font-heading);
    font-weight: var(--weight-medium);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.lang-tab:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

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

.lang-tab__remove {
    margin-left: 6px;
    opacity: 0.6;
    font-size: 12px;
    cursor: pointer;
}

.lang-tab__remove:hover {
    opacity: 1;
}

.lang-chapter-panel {
    display: none;
}

.lang-chapter-panel.active {
    display: block;
}

.lang-add-wrap {
    position: relative;
}

.lang-add-btn {
    padding: 6px 12px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: none;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.lang-add-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.lang-add-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    margin-top: 4px;
    padding: var(--space-xs) 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    max-height: 240px;
    overflow-y: auto;
}

.lang-add-option {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    text-align: left;
    font-size: var(--text-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.lang-add-option:hover {
    background: var(--color-bg-alt);
}

.lang-add-option:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ========================================
   OpenAlex Search Page
   ======================================== */

/* --- Search form --- */
.oa-search-form {
    margin-bottom: var(--space-lg);
}

.oa-search-bar {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.oa-search-bar .form-input {
    flex: 1;
}

.oa-filters {
    margin-top: var(--space-sm);
}

.oa-filters summary {
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    user-select: none;
}

.oa-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    padding: var(--space-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

/* --- Status bar --- */
.oa-status {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
}

/* --- Result cards --- */
.oa-result {
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    cursor: pointer;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
    background: var(--color-surface);
}

.oa-result:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.oa-result-title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-xs);
    line-height: 1.4;
}

.oa-result-authors {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.oa-result-journal {
    font-size: var(--text-sm);
    color: var(--color-primary);
    font-style: italic;
    margin-bottom: var(--space-xs);
}

.oa-result-abstract {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
    line-height: 1.5;
}

.oa-result-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* --- Modal overlay --- */
.oa-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.oa-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.oa-modal-card {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg, 12px);
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: var(--space-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.oa-modal-close {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
}

.oa-modal-close:hover {
    color: var(--color-text);
    background: var(--color-bg-alt);
}

.oa-modal-title {
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    line-height: 1.3;
    margin: 0 0 var(--space-sm);
    padding-right: var(--space-lg);
}

.oa-modal-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: var(--space-md);
}

.oa-modal-section {
    margin-bottom: var(--space-md);
    font-size: var(--text-sm);
    line-height: 1.5;
}

.oa-modal-section strong {
    display: block;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.oa-modal-abstract {
    margin: 0;
    color: var(--color-text-muted);
    line-height: 1.6;
}

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

.oa-author-list li {
    padding: 2px 0;
}

.oa-author-inst {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.oa-orcid {
    font-size: var(--text-xs);
    margin-left: 4px;
}

.oa-classification {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: var(--text-sm);
}

.oa-modal-actions {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
}

/* --- Pagination --- */
.oa-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
}

.oa-page-info {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* --- Badge variants for OpenAlex --- */
.badge--accent {
    background: var(--color-primary);
    color: #fff;
}

.badge--success {
    background: #16a34a;
    color: #fff;
}

.badge--info {
    background: #0891b2;
    color: #fff;
}

.badge--danger {
    background: #dc2626;
    color: #fff;
}

.badge--secondary {
    background: var(--color-text-muted);
    color: #fff;
}

.badge--purple {
    background: #7c3aed;
    color: #fff;
}

/* ========================================
   Script Generation Workflow
   ======================================== */

.gen-section {
    margin-bottom: var(--space-lg);
}

.gen-panel {
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
}

.gen-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-sm, 4px);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.02em;
}

.gen-badge--pending {
    background: #fef3c7;
    color: #92400e;
}

.gen-badge--ready {
    background: #dbeafe;
    color: #1e40af;
}

.gen-badge--approved {
    background: #ccfbf1;
    color: #115e59;
}

.gen-badge--generating {
    background: #fff7ed;
    color: #c2410c;
    animation: gen-pulse 2s ease-in-out infinite;
}

.gen-badge--complete {
    background: #dcfce7;
    color: #166534;
}

.gen-badge--failed {
    background: #fee2e2;
    color: #991b1b;
}

@keyframes gen-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.gen-progress-bar-wrap {
    height: 8px;
    background: var(--color-bg-alt);
    border-radius: 4px;
    overflow: hidden;
}

.gen-progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.gen-progress-bar--indeterminate {
    width: 30%;
    animation: gen-indeterminate 1.5s ease-in-out infinite;
}

.gen-progress-bar--queued {
    width: 100%;
    background: var(--color-text-secondary);
    opacity: 0.3;
    animation: gen-queued-pulse 2s ease-in-out infinite;
}

@keyframes gen-queued-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.4; }
}

@keyframes gen-indeterminate {
    0% { margin-left: 0; width: 30%; }
    50% { margin-left: 35%; width: 30%; }
    100% { margin-left: 70%; width: 30%; }
}

/* ========================================
   Pipeline Stepper
   ======================================== */

.pipeline-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    padding: var(--space-lg) var(--space-md) var(--space-sm);
    margin-bottom: var(--space-sm);
}

.pipeline-stepper__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 6px;
    transition: opacity var(--transition-fast);
    position: relative;
}

.pipeline-stepper__step:hover {
    opacity: 0.75;
}

.pipeline-stepper__circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    transition: all var(--transition-base);
}

.pipeline-stepper__step--done .pipeline-stepper__circle {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

.pipeline-stepper__step--active .pipeline-stepper__circle {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

.pipeline-stepper__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.pipeline-stepper__step--done .pipeline-stepper__label {
    color: #16a34a;
}

.pipeline-stepper__step--active .pipeline-stepper__label {
    color: #2563eb;
}

.pipeline-stepper__connector {
    flex: 1;
    height: 2px;
    min-width: 24px;
    max-width: 80px;
    background: var(--color-border);
    margin-top: 17px; /* vertically center with 36px circles */
    transition: background var(--transition-base);
}

.pipeline-stepper__connector--done {
    background: #16a34a;
}

/* ========================================
   Collapsible Form Sections
   ======================================== */

.form-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    background: var(--color-surface);
    overflow: hidden;
}

.form-section__summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background var(--transition-fast);
}

.form-section__summary::-webkit-details-marker {
    display: none;
}

.form-section__summary::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(-45deg);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.form-section[open] > .form-section__summary::before {
    transform: rotate(45deg);
}

.form-section__summary:hover {
    background: var(--color-bg-alt);
}

.form-section__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    white-space: nowrap;
    flex-shrink: 0;
}

.form-section__summary-text {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

/* Hide summary text when section is open */
.form-section[open] .form-section__summary-text {
    display: none;
}

.form-section__body {
    padding: 0 var(--space-lg) var(--space-lg);
}

/* ========================================
   Pipeline Accordion
   (rendered by pipeline.js — accordion cards)
   ======================================== */

.pipeline-accordion {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.pipeline-accordion__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-xs);
}

.pipeline-accordion__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    margin: 0;
}

.pipeline-accordion__actions {
    display: flex;
    gap: var(--space-xs);
}

/* --- Accordion Card --- */
.pl-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    overflow: hidden;
}

.pl-card__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background var(--transition-fast);
}

.pl-card__header::-webkit-details-marker {
    display: none;
}

.pl-card__header:hover {
    background: var(--color-bg-alt);
}

/* Chevron */
.pl-card__chevron {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(-45deg);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.pl-card[open] > .pl-card__header .pl-card__chevron {
    transform: rotate(45deg);
}

/* Status icon (circle) */
.pl-card__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
}

.pl-card__icon--done {
    background: #16a34a;
    color: #fff;
}

.pl-card__icon--active {
    background: var(--color-primary);
    color: #fff;
}

.pl-card__icon--action {
    background: #f59e0b;
    color: #fff;
}

.pl-card__icon--failed {
    background: #dc2626;
    color: #fff;
}

.pl-card__icon--queued {
    background: var(--color-bg-alt);
    border: 2px solid var(--color-text-secondary);
    color: var(--color-text-secondary);
}

.pl-card__icon--waiting {
    background: var(--color-bg-alt);
    border: 2px solid var(--color-border);
    color: var(--color-text-muted);
}

/* Label + summary in header */
.pl-card__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.pl-card__label {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
}

.pl-card__summary {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* Status badge (right side) */
.pl-card__badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-sm, 4px);
    font-size: 11px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

.pl-card__badge--done { background: #dcfce7; color: #166534; }
.pl-card__badge--active { background: #dbeafe; color: #1e40af; animation: gen-pulse 2s ease-in-out infinite; }
.pl-card__badge--queued { background: #f3f4f6; color: #6b7280; }
.pl-card__badge--action { background: #fef3c7; color: #92400e; }
.pl-card__badge--failed { background: #fee2e2; color: #991b1b; }
.pl-card__badge--waiting { background: #f9fafb; color: #9ca3af; }

/* State-specific card border highlight */
.pl-card--active { border-color: var(--color-primary); }
.pl-card--failed { border-color: #dc2626; }
.pl-card--action { border-color: #f59e0b; }

/* State-specific label colors */
.pl-card--done .pl-card__label { color: #16a34a; }
.pl-card--active .pl-card__summary { color: var(--color-primary); }
.pl-card--action .pl-card__summary { color: #f59e0b; font-weight: var(--weight-semibold); }
.pl-card--failed .pl-card__summary { color: #dc2626; }
.pl-card--queued .pl-card__summary { color: var(--color-text-secondary); font-style: italic; }

/* Card body */
.pl-card__body {
    padding: 0 var(--space-lg) var(--space-lg);
}

/* Spinner inside icon */
.pl-card__spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pl-spin 0.8s linear infinite;
}

@keyframes pl-spin {
    to { transform: rotate(360deg); }
}

.pl-card__circle-empty {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
}

/* Progress text inside body */
.pl-card__progress-text {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

/* Review panel inside card */
.pl-card__review-meta {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.pl-card__review-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-top: var(--space-sm);
}

/* Error message inside failed card */
.pl-card__error {
    padding: var(--space-sm) var(--space-md);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm, 4px);
    color: #991b1b;
    font-size: var(--text-sm);
    margin-bottom: var(--space-sm);
}

/* Button row inside card body */
.pl-card__buttons {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-top: var(--space-sm);
}

/* ---- Mobile responsive ---- */
@media (max-width: 480px) {
    .pipeline-stepper {
        gap: 0;
        padding: var(--space-sm) 0;
    }

    .pipeline-stepper__circle {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    .pipeline-stepper__label {
        font-size: 9px;
    }

    .pipeline-stepper__connector {
        min-width: 12px;
        margin-top: 13px;
    }

    .form-section__summary {
        padding: var(--space-sm) var(--space-md);
        flex-wrap: wrap;
    }

    .form-section__summary-text {
        flex-basis: 100%;
        text-align: left;
        margin-top: 2px;
        padding-left: 18px; /* align with title past chevron */
    }

    .form-section__body {
        padding: 0 var(--space-md) var(--space-md);
    }

    .pl-card__header {
        padding: var(--space-sm) var(--space-md);
    }

    .pl-card__body {
        padding: 0 var(--space-md) var(--space-md);
    }

    .pipeline-accordion__header {
        flex-wrap: wrap;
        gap: var(--space-xs);
    }
}

/* ========================================
   Cost Overview (podcast form)
   ======================================== */

.cost-overview {
    margin-top: var(--space-xl);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    overflow: hidden;
}

.cost-overview__title {
    font-size: var(--text-base);
    font-weight: 600;
    padding: var(--space-md) var(--space-lg);
    margin: 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--color-text);
}

.cost-overview__title i {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.cost-overview__summary {
    padding: var(--space-md) var(--space-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-xl);
}

.cost-overview__total {
    display: flex;
    flex-direction: column;
    min-width: 100px;
}

.cost-overview__total-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.cost-overview__total-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.cost-overview__breakdown {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.cost-overview__item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
}

.cost-overview__item-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

.cost-overview__item-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cost-overview__item-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.cost-overview__item-meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.cost-overview__item-cost {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

/* Call log (collapsible) */
.cost-overview__log {
    border-top: 1px solid var(--color-border);
}

.cost-overview__log summary {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.cost-overview__log summary:hover {
    color: var(--color-text);
}

.cost-overview__table {
    margin: 0;
    border-radius: 0;
    font-size: var(--text-sm);
}

.cost-overview__table code {
    font-size: var(--text-xs);
    word-break: break-all;
}

.cost-overview__row--failed {
    background: color-mix(in srgb, var(--color-danger) 5%, transparent);
}

@media (max-width: 480px) {
    .cost-overview__summary {
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-md);
    }

    .cost-overview__title {
        padding: var(--space-sm) var(--space-md);
    }

    .cost-overview__log summary {
        padding: var(--space-sm) var(--space-md);
    }

    .cost-overview__table {
        font-size: var(--text-xs);
    }
}

/* ========================================
   Pipeline Automation Toggles
   ======================================== */

.pipeline-automation {
    margin-bottom: var(--space-md);
}

.pipeline-automation__toggles {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
}

.pipeline-automation__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: var(--space-xs);
    white-space: nowrap;
}

.pipeline-automation__label i {
    font-size: 11px;
}

@media (max-width: 480px) {
    .pipeline-automation__toggles {
        gap: var(--space-xs) var(--space-sm);
    }
}

/* ========================================
   Cover Gallery
   ======================================== */

/* --- Image prompt display in pipeline --- */
.pipeline-step__image-prompt {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border-light);
}

.pipeline-step__image-prompt-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.pipeline-step__image-prompt-text {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
    margin: 0;
}

.cover-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.cover-gallery__item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 2px solid var(--color-border);
    transition: border-color var(--transition-fast);
}

.cover-gallery__item:hover {
    border-color: var(--color-primary);
    z-index: 10;
}

.cover-gallery__hover-preview {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    border: 2px solid var(--color-border);
    pointer-events: none;
    z-index: 100;
    background: var(--color-bg);
    overflow: hidden;
}

.cover-gallery__item:hover .cover-gallery__hover-preview {
    display: block;
}

.cover-gallery__hover-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-gallery__item:not(.cover-gallery__item--hero) .cover-gallery__hover-preview {
    width: 240px;
    height: 240px;
}

.cover-gallery__item--hero .cover-gallery__hover-preview {
    width: 360px;
    height: auto;
}

.cover-gallery__item--hero .cover-gallery__hover-preview img {
    height: auto;
}

.cover-gallery__item--active {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.3);
}

.cover-gallery__item > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--radius-md) - 2px);
}

.cover-gallery__badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.cover-gallery__active-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #16a34a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.cover-gallery__item--hero {
    width: 160px;
    height: 54px;
}

.form-preview-image--hero {
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 240px;
    object-fit: contain;
}

/* ========================================
   Toggle Switch
   ======================================== */

.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch__track {
    position: relative;
    width: 32px;
    height: 18px;
    background: var(--color-border);
    border-radius: 9px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-switch__track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-switch__track {
    background: #16a34a;
}

.toggle-switch input:checked + .toggle-switch__track::after {
    transform: translateX(14px);
}

.toggle-switch input:focus-visible + .toggle-switch__track {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.toggle-switch__text {
    font-size: var(--text-sm);
    color: var(--color-text);
    white-space: nowrap;
}

/* --- Secret field (write-only API keys) --- */
.secret-display {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.secret-mask {
    padding: 6px 10px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    letter-spacing: 0.5px;
}

/* ========================================
   Settings Tabs (APIs page)
   ======================================== */

.settings-tabs__nav {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--color-border-light);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-text-muted);
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.settings-tab:hover {
    color: var(--color-text);
}

.settings-tab.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
    font-weight: var(--weight-semibold);
}

.settings-tab i {
    font-size: 13px;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

/* ========================================
   Auto-save Status Indicator
   ======================================== */

.autosave-status {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    margin-left: var(--space-xs);
    vertical-align: middle;
    transition: opacity 0.3s ease;
}

.autosave-status:empty {
    display: none;
}

.autosave-status--saving {
    color: var(--color-text-muted);
}

.autosave-status--saved {
    color: #16a34a;
}

.autosave-status--error {
    color: #dc2626;
}

@media (max-width: 767px) {
    .settings-tabs__nav {
        gap: 0;
    }

    .settings-tab {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-xs);
    }
}
