:root {
    --bg: #f3ede4;
    --paper: rgba(255, 251, 245, 0.94);
    --paper-strong: #fffdf8;
    --ink: #1f1914;
    --muted: #6f665d;
    --muted-soft: #9a8e82;
    --accent: #ba4b31;
    --accent-deep: #842f1d;
    --accent-soft: rgba(186, 75, 49, 0.08);
    --support: #24455f;
    --line: rgba(31, 25, 20, 0.1);
    --line-strong: rgba(31, 25, 20, 0.18);
    --shadow: 0 24px 60px rgba(55, 40, 26, 0.08);
    --shadow-soft: 0 12px 30px rgba(55, 40, 26, 0.06);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --gallery-gap: 20px;
    --template-preview-scale: 0.18;
    --heading-font: "Noto Serif SC", "Playfair Display", "Noto Serif SC", serif;
    --body-font: "Inter", "Noto Sans SC", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: var(--body-font);
    background:
        radial-gradient(circle at top left, rgba(186, 75, 49, 0.08), transparent 26%),
        radial-gradient(circle at bottom right, rgba(36, 69, 95, 0.12), transparent 24%),
        linear-gradient(180deg, #efe7dd 0%, #f7f2ea 48%, #f2ebdf 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(31, 25, 20, 0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(31, 25, 20, 0.02) 1px, transparent 1px);
    background-size: 26px 26px;
    pointer-events: none;
    opacity: 0.4;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1400px, calc(100vw - 48px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px 0 44px;
}

.topbar,
.topbar-actions,
.section-head,
.modal-head,
.form-footer,
.card-actions,
.history-item,
.card-meta,
.gallery-actions,
.hero-metrics,
.brand-block,
.workflow-steps,
.field-grid,
.spec-list li,
.toggle-field,
.selected-template-banner {
    display: flex;
}

.content-stack {
    display: grid;
    gap: 22px;
}

.content-stack > * {
    min-width: 0;
}

.topbar {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.brand-block {
    flex-direction: column;
    gap: 0;
}

.brand-head-row {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-actions {
    align-items: center;
    gap: 10px;
}

.brand-mark,
.eyebrow,
.metric-label,
.banner-label {
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.brand-mark {
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 700;
}

.brand-subtitle,
.hero-text,
.metric-label,
.field-help,
.card-meta,
.result-time,
.spec-list span,
.workflow-steps p,
.banner-meta,
.compact-state p {
    color: var(--muted);
}

.brand-subtitle,
.hero-text,
.field-help,
.workflow-steps p,
.compact-state p {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.7;
}

/* Commercial wordmark — used on every page topbar via _topbar_brand.html */
.brand-wordmark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}
.brand-wordmark:hover { text-decoration: none; }
.brand-wordmark-mark {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #c4522a 0%, #e08a4b 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: 0 6px 16px rgba(196, 82, 42, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    flex: 0 0 auto;
}
.brand-wordmark-logo {
    object-fit: cover;
    object-position: center;
}
.brand-wordmark-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.brand-wordmark-title {
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #2a221b;
    background: linear-gradient(90deg, #2a221b 0%, #5a4633 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-wordmark-sub {
    margin-top: 1px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: #a08c72;
    text-transform: uppercase;
}

.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
    color: var(--muted);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 650;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}
.theme-switch:hover {
    border-color: var(--accent);
    background: var(--paper-strong);
    color: var(--accent);
    transform: translateY(-1px);
}
.theme-switch-icon {
    font-size: 0.92rem;
    line-height: 1;
}
@media (max-width: 640px) {
    .brand-wordmark-mark { width: 30px; height: 30px; font-size: 0.9rem; border-radius: 9px; }
    .brand-wordmark-title { font-size: 1.05rem; }
    .brand-head-row { gap: 8px; }
    .theme-switch { padding: 0 8px; }
    .theme-switch [data-theme-label] { display: none; }
}

.reveal-card,
.modal-dialog {
    background: var(--paper);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-panel,
.gallery-panel,
.editor-panel,
.side-card,
.modal-dialog {
    border-radius: var(--radius-xl);
}

.hero-panel,
.gallery-panel,
.editor-panel,
.side-card {
    padding: 24px;
}

.hero-panel {
    display: block;
}

.hero-panel h1 {
    max-width: 12ch;
    font-size: clamp(1.7rem, 2.5vw, 2.6rem);
}

.hero-panel .hero-text {
    max-width: 60ch;
    font-size: 0.92rem;
    line-height: 1.65;
}

.eyebrow,
.metric-label,
.banner-label {
    margin: 0 0 10px;
    font-size: 0.74rem;
    color: var(--muted-soft);
    font-weight: 700;
}

h1,
h2,
h3 {
    font-family: var(--heading-font);
    margin: 0;
    font-weight: 700;
    line-height: 1.08;
}

h1 {
    font-size: clamp(2.4rem, 4vw, 4.6rem);
    max-width: 11ch;
}

h2 {
    font-size: clamp(1.6rem, 2.2vw, 2.4rem);
}

h3 {
    font-size: 1.45rem;
}

.hero-copy {
    display: grid;
    gap: 14px;
}

.inline-form {
    margin: 0;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--line);
}

.user-pill-label {
    color: var(--muted-soft);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Shared commercial account utility used by every application header. */
.topbar-utility {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.account-menu-wrap {
    position: relative;
    z-index: 120;
}

.account-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 42px;
    padding: 3px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.account-trigger:hover,
.account-menu-wrap.is-open .account-trigger,
.account-menu-wrap:focus-within .account-trigger {
    border-color: transparent;
    background: var(--accent-soft);
    transform: translateY(-1px);
}

.account-avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--accent) 0%, var(--accent-deep) 100%);
    border: 2px solid var(--paper-strong);
    color: #fff;
    font-size: .95rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
    box-shadow: 0 0 0 1px var(--line-strong), 0 5px 14px rgba(31, 25, 20, .14);
}

.account-avatar-large {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    font-size: 1rem;
}

.account-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(306px, calc(100vw - 28px));
    padding: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: var(--paper-strong);
    box-shadow: 0 20px 55px rgba(31, 25, 20, .18);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transform: translateY(-5px) scale(.98);
    transform-origin: top right;
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}

.account-menu-wrap:hover .account-menu,
.account-menu-wrap:focus-within .account-menu,
.account-menu-wrap.is-open .account-menu {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.account-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 12px;
}

.account-menu-identity {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.account-menu-identity strong {
    overflow: hidden;
    color: var(--ink);
    font-size: .92rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu-identity small,
.account-menu-item small {
    color: var(--muted-soft);
    font-size: .75rem;
}

.account-menu-divider {
    height: 1px;
    margin: 3px 0;
    background: var(--line);
}

.account-menu-form {
    margin: 0;
}

.account-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: .87rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
    outline: 0;
    background: var(--accent-soft);
}

.account-menu-item.is-disabled,
.account-menu-item.is-disabled:hover {
    color: var(--muted-soft);
    background: transparent;
    cursor: not-allowed;
}

.account-menu-logout {
    color: var(--danger, #b64732);
}

@media (max-width: 720px) {
    .topbar-utility {
        gap: 5px;
    }

    .account-trigger {
        width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .account-avatar {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }
}

.message-stack {
    display: grid;
    gap: 10px;
}

.auth-panel {
    padding: 24px;
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.auth-form {
    display: grid;
    gap: 14px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(250, 243, 233, 0.84));
    border: 1px solid rgba(31, 25, 20, 0.08);
    box-shadow: var(--shadow-soft);
}

.auth-card-title {
    font-size: 1.3rem;
}

.auth-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

.flash {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.96rem;
}

.flash-success {
    background: rgba(72, 131, 92, 0.1);
    border-color: rgba(72, 131, 92, 0.18);
}

.flash-error,
.flash-warning {
    background: rgba(186, 75, 49, 0.12);
    border-color: rgba(186, 75, 49, 0.22);
}

.flash-ppt-generation-queued {
    color: #a63d2b;
    background: rgba(186, 75, 49, 0.1);
    border-color: rgba(186, 75, 49, 0.28);
    font-weight: 700;
}

.flash-ppt-generation-queued strong {
    font-weight: 800;
}

.flash-action-link {
    margin: 0 2px;
    padding: 0;
    color: #a63d2b;
    font: inherit;
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.flash-action-link:hover,
.flash-action-link:focus-visible {
    color: #7d2d20;
}

.section-head {
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head.compact {
    margin-bottom: 20px;
}

.gallery-actions,
.card-actions,
.history-actions {
    gap: 10px;
}

.gallery-actions {
    align-items: center;
    flex-wrap: wrap;
}

.gallery-layout-toggle,
.gallery-nav-actions,
.gallery-type-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.gallery-layout-toggle,
.gallery-type-toggle {
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--line);
}

.gallery-layout-toggle .button,
.gallery-type-toggle .button {
    min-height: 38px;
    padding: 0 16px;
}

.gallery-layout-toggle .button.is-active,
.gallery-type-toggle .button.is-active {
    color: #fff8f4;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(132, 47, 29, 0.16);
}

.card-actions {
    align-items: center;
}

.card-actions .button {
    height: 44px;
}

.button,
.text-button {
    border: 0;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    font-weight: 600;
}

.button:hover,
.text-button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #fff8f4;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    box-shadow: 0 14px 28px rgba(132, 47, 29, 0.18);
    border: 1px solid transparent;
}

.button-ghost {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--line);
}

.button-large {
    padding: 0 24px;
}

.template-gallery {
    display: flex;
    gap: var(--gallery-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
}

.gallery-panel[data-gallery-layout="grid"] .gallery-nav-actions {
    display: none;
}

.template-gallery[data-layout="grid"] {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-auto-rows: 196px;
    gap: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: none;
    align-content: start;
    padding-right: 6px;
    padding-bottom: 0;
    max-height: calc(196px * 3 + 14px * 2);
    contain: layout paint;
}

.template-gallery::-webkit-scrollbar {
    height: 10px;
}

.template-gallery[data-layout="grid"]::-webkit-scrollbar {
    width: 10px;
    height: auto;
}

.template-gallery::-webkit-scrollbar-thumb {
    background: rgba(132, 47, 29, 0.2);
    border-radius: 999px;
}

.template-card {
    position: relative;
    flex: 0 0 calc((100% - 3 * var(--gallery-gap)) / 4);
    min-width: 270px;
    scroll-snap-align: start;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(250, 244, 235, 0.82));
    border: 1px solid rgba(31, 25, 20, 0.08);
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 14px;
    overflow: hidden;
    isolation: isolate;
    transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, background 220ms ease, opacity 220ms ease, filter 220ms ease;
    content-visibility: auto;
    contain-intrinsic-size: 218px;
}

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

.template-gallery[data-layout="grid"] .template-card {
    flex: none;
    min-width: 0;
    height: 196px;
    padding: 12px;
    gap: 10px;
    cursor: pointer;
}

.template-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 2px rgba(186, 75, 49, 0.26);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms ease;
}

.template-selected-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(186, 75, 49, 0.96), rgba(132, 47, 29, 0.96));
    color: #fff8f4;
    box-shadow: 0 16px 26px rgba(132, 47, 29, 0.24);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(-10px) scale(0.94);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
}

.template-selected-badge::before {
    content: "";
    width: 6px;
    height: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
}

.template-card.is-selected {
    background:
        radial-gradient(circle at top right, rgba(255, 150, 80, 0.35), transparent 40%),
        linear-gradient(180deg, rgba(255, 240, 226, 1), rgba(255, 228, 210, 1));
    border-color: rgba(186, 75, 49, 0.8);
    box-shadow: 0 24px 52px rgba(132, 47, 29, 0.3);
    transform: translateY(-6px);
}

.template-gallery[data-layout="grid"] .template-card.is-selected {
    transform: none;
}

.template-gallery:has(.template-card.is-selected) .template-card:not(.is-selected) {
    opacity: 0.76;
    filter: saturate(0.86);
}

.template-gallery[data-layout="grid"]:has(.template-card.is-selected) .template-card:not(.is-selected) {
    opacity: 0.88;
    filter: saturate(0.94);
}

.template-card.is-selected::before {
    opacity: 1;
}

.template-card.is-selected .template-selected-badge {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.template-card.is-selected .card-cover {
    background: linear-gradient(180deg, rgba(255, 250, 243, 1), rgba(255, 241, 230, 1));
}

.template-card.is-selected .template-preview-shell {
    border-color: rgba(186, 75, 49, 0.36);
    box-shadow: 0 12px 24px rgba(132, 47, 29, 0.12);
}

.template-card.is-selected h3 {
    color: var(--accent-deep);
}

.template-card [data-template-select] {
    width: 112px;
    flex: 0 0 112px;
    white-space: nowrap;
    transition: all 220ms ease;
}

.template-card.is-selected [data-template-select] {
    background: linear-gradient(135deg, #c95d36, #8b301d);
    box-shadow: 0 18px 34px rgba(132, 47, 29, 0.24);
}

.card-browser {
    display: flex;
    gap: 6px;
}

.template-gallery[data-layout="grid"] .card-browser,
.template-gallery[data-layout="grid"] .template-selected-badge,
.template-gallery[data-layout="grid"] .card-cover p {
    display: none;
}

.template-gallery[data-layout="grid"] .card-actions {
    position: absolute;
    top: 22px;
    right: 22px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 0;
}

.template-gallery[data-layout="grid"] .card-actions [data-template-select] {
    display: none;
}

.template-gallery[data-layout="grid"] .template-preview-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    flex: 0 0 30px;
    padding: 0;
    border-radius: 50%;
    color: transparent;
    font-size: 0;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(31, 25, 20, 0.12);
    box-shadow: 0 10px 20px rgba(55, 40, 26, 0.08);
}

.template-gallery[data-layout="grid"] .template-preview-button::before,
.template-gallery[data-layout="grid"] .template-preview-button::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.template-gallery[data-layout="grid"] .template-preview-button::before {
    top: 7px;
    left: 7px;
    width: 9px;
    height: 9px;
    border: 1.8px solid var(--accent-deep);
    border-radius: 50%;
}

.template-gallery[data-layout="grid"] .template-preview-button::after {
    top: 17px;
    left: 17px;
    width: 7px;
    height: 2px;
    background: var(--accent-deep);
    transform: rotate(45deg);
    transform-origin: left center;
    border-radius: 999px;
}

.template-gallery[data-layout="grid"] .template-preview-button:hover {
    background: #fffaf4;
}

.card-browser span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(31, 25, 20, 0.18);
}

.card-browser span:first-child {
    background: rgba(186, 75, 49, 0.6);
}

.card-cover {
    min-height: 0;
    padding: 16px;
    border-radius: 20px;
    background:
        linear-gradient(160deg, rgba(36, 69, 95, 0.1), transparent 50%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 243, 233, 0.86));
    border: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    overflow: hidden;
}

.template-gallery[data-layout="grid"] .card-cover {
    height: 100%;
    padding: 10px;
    gap: 8px;
    justify-content: flex-start;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(249, 241, 232, 0.88));
}

.template-preview-shell {
    position: relative;
    width: 100%;
    flex: 0 0 auto;
    overflow: visible;
}

.template-preview-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #ffffff;
}

.template-card[data-template-type="desktop"] .template-preview-shell {
    aspect-ratio: 16 / 9;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(249, 243, 235, 0.86));
    border: 1px solid rgba(31, 25, 20, 0.08);
    box-shadow: 0 14px 28px rgba(45, 34, 24, 0.08);
}

.template-card[data-template-type="desktop"] .template-preview-viewport {
    inset: 0;
    border-radius: 18px;
    border: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-shell {
    aspect-ratio: 16 / 9;
    border-radius: 16px;
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-viewport {
    border-radius: 16px;
}

.template-card[data-template-type="mobile"] .template-preview-shell {
    width: min(208px, 52%);
    margin: 0 auto;
    aspect-ratio: 9 / 18.5;
    border-radius: 28px;
    background: linear-gradient(180deg, #1e232c, #11161d);
    border: 1px solid rgba(17, 22, 29, 0.5);
    box-shadow:
        0 18px 36px rgba(17, 22, 29, 0.18),
        inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.template-card[data-template-type="mobile"] .template-preview-shell::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 32%;
    height: 4px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    z-index: 3;
}

.template-card[data-template-type="mobile"] .template-preview-viewport {
    inset: 10px 8px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="mobile"] .template-preview-shell {
    width: min(112px, 60%);
    aspect-ratio: 9 / 18;
    border-radius: 22px;
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="mobile"] .template-preview-shell::before {
    top: 7px;
    height: 3px;
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="mobile"] .template-preview-viewport {
    inset: 8px 6px 10px;
    border-radius: 15px;
}

.template-type-chip {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 250, 244, 0.9);
    border: 1px solid rgba(31, 25, 20, 0.08);
    box-shadow: 0 8px 18px rgba(31, 25, 20, 0.08);
    color: #24455f;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
}

.template-gallery[data-layout="grid"] .template-type-chip {
    top: 8px;
    left: 8px;
    min-height: 24px;
    padding: 0 8px;
    font-size: 0.68rem;
}

.template-card[data-template-type="mobile"] .template-type-chip {
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
}

.template-gallery[data-layout="grid"] .template-card[data-template-type="mobile"] .template-type-chip {
    top: 10px;
}

.template-preview-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100% / var(--template-preview-scale));
    height: calc(100% / var(--template-preview-scale));
    border: 0;
    transform: scale(var(--template-preview-scale));
    transform-origin: top left;
    pointer-events: none;
}

.template-preview-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}

.card-cover p,
.result-highlight p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.card-cover h3 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7rem;
    font-size: 1.1rem;
    line-height: 1.26;
    letter-spacing: -0.02em;
}

.template-gallery[data-layout="grid"] .card-cover h3 {
    min-height: 0;
    font-size: 0.9rem;
    line-height: 1.24;
    letter-spacing: -0.015em;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.template-card[data-template-type="mobile"] .card-cover h3,
.template-card[data-template-type="mobile"] .card-cover p {
    text-align: center;
}

.card-cover p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.9rem;
}

.workspace-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
}

.home-builder-layout {
    display: grid;
    grid-template-columns: minmax(360px, 0.78fr) minmax(0, 1.22fr);
    gap: 22px;
    align-items: start;
}

.home-builder-layout > .workspace-grid {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
}

.home-builder-layout > .gallery-panel {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 100%;
}

.home-builder-layout .template-gallery[data-layout="grid"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 218px;
    max-height: calc(218px * 4 + 14px * 3);
}

.home-builder-layout .template-gallery[data-layout="grid"] .template-card {
    height: 218px;
}

.editor-form,
.workflow-steps,
.settings-form,
.spec-list {
    display: grid;
    gap: 18px;
}

.selected-template-banner {
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 249, 242, 0.96), rgba(249, 241, 233, 0.82));
    border: 1px solid rgba(186, 75, 49, 0.14);
    margin-bottom: 20px;
}

.selected-template-banner strong {
    font-size: 1.2rem;
}

.ppt-generator-page .layout-with-sidebar {
    gap: 18px;
}

.ppt-generator-area .content-stack,
.ppt-generator-page .home-builder-layout {
    gap: 18px;
}

/* ================= PPT 生成页 · 紧凑化 ================= */
.ppt-generator-page .home-builder-layout {
    gap: 12px;
}

.ppt-generator-page .gallery-panel,
.ppt-generator-page .editor-panel {
    padding: 12px 14px;
}

.ppt-generator-page .section-head {
    margin-bottom: 10px;
    gap: 10px;
}

.ppt-generator-page .section-head .eyebrow {
    margin-bottom: 4px;
    font-size: 0.62rem;
}

.ppt-generator-page .section-head h2 {
    font-size: 1.05rem;
}

.ppt-generator-page .gallery-actions,
.ppt-generator-page .card-actions {
    gap: 6px;
}

.ppt-generator-page .gallery-type-toggle .button,
.ppt-generator-page .gallery-layout-toggle .button {
    padding: 4px 10px;
    font-size: 0.68rem;
    min-height: 26px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 158px;
    gap: 10px;
    max-height: calc(158px * 4 + 10px * 3);
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-card {
    height: 158px;
    padding: 7px;
    gap: 6px;
    border-radius: 12px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .card-cover {
    padding: 6px;
    gap: 5px;
    border-radius: 10px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-shell {
    border-radius: 9px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-viewport {
    border-radius: 9px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .card-cover h3 {
    font-size: 0.74rem;
    line-height: 1.2;
    margin: 0;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-type-chip {
    top: 5px;
    left: 5px;
    min-height: 17px;
    padding: 0 6px;
    font-size: 0.56rem;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .card-actions {
    top: 9px;
    right: 9px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-preview-button {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    flex: 0 0 24px;
    transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-preview-button::before {
    top: 5.5px;
    left: 5.5px;
    width: 7px;
    height: 7px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-preview-button::after {
    top: 13.5px;
    left: 13.5px;
    width: 6px;
    height: 1.8px;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-preview-button:hover {
    transform: scale(1.12) rotate(-8deg);
    background: #fffaf4;
    box-shadow: 0 12px 24px rgba(132, 47, 29, 0.2);
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-preview-button:active {
    transform: scale(0.96);
}

.ppt-generator-page .selected-template-banner {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
}

.ppt-generator-page .selected-template-banner strong {
    font-size: 0.85rem;
}

.ppt-generator-page .selected-template-banner .banner-meta {
    font-size: 0.66rem;
}

.ppt-generator-page .editor-form {
    gap: 10px;
}

.ppt-generator-page .field {
    gap: 5px;
}

.ppt-generator-page .field label,
.ppt-generator-page .toggle-field span {
    font-size: 0.76rem;
}

.ppt-generator-page .field input,
.ppt-generator-page .field textarea,
.ppt-generator-page .field select {
    border-radius: 9px;
    padding: 8px 11px;
    font-size: 0.8rem;
}

.ppt-generator-page .field textarea {
    min-height: 200px;
    line-height: 1.6;
}

.ppt-generator-page .field-help {
    font-size: 0.66rem;
    margin-top: 0;
}

.ppt-generator-page .toggle-field {
    min-height: 40px;
    padding: 0 11px;
    border-radius: 9px;
}

.ppt-generator-page .toggle-field span small {
    font-size: 0.68rem;
    margin-top: 2px;
}

.ppt-generator-page .form-footer {
    gap: 8px;
    margin-top: 0;
}

.ppt-generator-page .form-footer .button-large {
    padding: 0 20px;
    min-height: 36px;
    font-size: 0.84rem;
}

.ppt-generator-page .ppt-title-suggest,
.ppt-generator-page [data-ppt-script-source] {
    padding: 4px 9px;
    font-size: 0.66rem;
}

.ppt-generator-page .field-label-row {
    gap: 8px;
}

.ppt-generator-page .field-label-row label {
    margin-bottom: 0;
}

/* PPT 语音生成设置 */
.ppt-speech-card {
    margin: 18px 0 22px;
    padding: 14px 16px;
    border: 1px solid rgba(186, 75, 49, 0.16);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 249, 243, 0.92), rgba(252, 243, 235, 0.72));
}

.ppt-speech-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ppt-speech-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    cursor: pointer;
}

.ppt-speech-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.ppt-speech-toggle-copy {
    display: grid;
    gap: 3px;
}

.ppt-speech-toggle-copy strong {
    font-size: 0.92rem;
}

.ppt-speech-toggle-copy small {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 400;
}

.ppt-speech-badge {
    padding: 4px 8px;
    border: 1px solid rgba(186, 75, 49, 0.18);
    border-radius: 999px;
    color: var(--accent);
    font-size: 0.68rem;
    white-space: nowrap;
}

.ppt-speech-settings {
    display: grid;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(186, 75, 49, 0.12);
}

.ppt-speech-voice-field {
    margin: 0;
}

.ppt-speech-voice-field select,
.ppt-tts-advanced select,
.ppt-tts-advanced input {
    width: 100%;
}

.ppt-tts-advanced {
    border-top: 1px solid rgba(31, 25, 20, 0.08);
    padding-top: 10px;
}

.ppt-tts-advanced summary {
    color: var(--accent);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    list-style-position: inside;
}

.ppt-tts-advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 620px) {
    .ppt-tts-advanced-grid {
        grid-template-columns: 1fr;
    }
}

/* ================= PPT 生成历史 · 紧凑弹窗 ================= */
.ppt-history-dialog {
    width: min(980px, calc(100vw - 48px));
}

.ppt-history-body {
    max-height: min(70vh, 620px);
    overflow-y: auto;
    padding: 4px 4px 14px;
}

.ppt-history-list {
    gap: 8px;
}

.ppt-history-item {
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 14px;
}

.ppt-history-item .task-time-block {
    padding-right: 8px;
}

.ppt-history-item .task-time-primary {
    font-size: 0.98rem;
}

.ppt-history-item .task-time-secondary {
    font-size: 0.74rem;
}

.ppt-history-item .task-main {
    gap: 4px;
}

.ppt-history-item .task-headline h3 {
    font-size: 0.95rem;
}

.ppt-history-item .task-meta {
    font-size: 0.74rem;
    line-height: 1.4;
}

.ppt-history-item .task-status {
    min-width: 58px;
    padding: 3px 8px;
    font-size: 0.7rem;
}

.ppt-history-item .task-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.ppt-history-item .task-actions .button {
    padding: 4px 10px;
    font-size: 0.7rem;
    white-space: nowrap;
}

.ppt-history-item .task-error {
    font-size: 0.72rem;
    line-height: 1.4;
}

/* 更多下拉菜单（生成视频 / 录制视频） */
.ppt-more-menu {
    position: relative;
    flex-shrink: 0;
}

.ppt-more-dropdown {
    position: fixed;
    inset: auto;
    z-index: 150;
    min-width: 132px;
    padding: 4px;
    background: #fff;
    border: 1px solid rgba(31, 25, 20, 0.12);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(31, 25, 20, 0.16);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ppt-more-dropdown[hidden] {
    display: none;
}

.ppt-more-dropdown a,
.ppt-more-dropdown button {
    display: block;
    width: 100%;
    padding: 7px 11px;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    font-size: 0.72rem;
    color: var(--ink);
    border-radius: 7px;
    cursor: pointer;
    text-decoration: none;
}

.ppt-more-dropdown a:hover,
.ppt-more-dropdown button:hover {
    background: rgba(186, 75, 49, 0.08);
    color: var(--accent-deep);
}

.ppt-title-label-row,
.ppt-script-source-head {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ppt-title-label-row label,
.ppt-script-source-head label {
    margin-bottom: 0;
}

.ppt-title-suggest {
    flex-shrink: 0;
    color: var(--accent);
    border-color: rgba(186, 75, 49, 0.2);
}

.ppt-title-status {
    min-height: 1.2em;
    font-size: 0.76rem;
}

.ppt-title-status.is-success {
    color: #4b8662;
}

.ppt-title-status.is-error {
    color: var(--accent);
}

.ppt-script-source-tabs {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ppt-script-source-tabs .button.is-active,
.ppt-script-source-tabs .button:hover {
    color: var(--accent);
    border-color: rgba(186, 75, 49, 0.28);
    background: rgba(186, 75, 49, 0.08);
}

.ppt-script-selection {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid rgba(186, 75, 49, 0.16);
    border-radius: var(--radius-sm);
    background: rgba(255, 247, 238, 0.82);
}

.ppt-script-selection-label,
.ppt-script-option-kicker {
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ppt-script-selection strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.84rem;
}

.ppt-script-picker-dialog {
    width: min(1380px, calc(100vw - 40px));
    max-height: min(900px, calc(100vh - 28px));
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ppt-script-picker-dialog .modal-head {
    flex: 0 0 auto;
    margin: 0;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--line);
}

.ppt-script-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--line);
}

.ppt-script-subject-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 6px 18px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}

.ppt-script-subject-filter::-webkit-scrollbar {
    display: none;
}

.ppt-script-subject-tag {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.88);
    color: var(--muted);
    font: inherit;
    font-size: 0.76rem;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.ppt-script-subject-tag:hover {
    border-color: rgba(186, 75, 49, 0.35);
    color: var(--accent);
    transform: translateY(-1px);
}

.ppt-script-subject-tag.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 10px rgba(186, 75, 49, 0.18);
}

.ppt-script-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: rgba(255, 253, 248, 0.88);
    color: var(--muted-soft);
}

.ppt-script-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.ppt-script-picker-count {
    flex-shrink: 0;
    color: var(--muted-soft);
    font-size: 0.76rem;
}

.ppt-script-picker-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    overflow: auto;
    padding: 12px 18px 18px;
}

.ppt-script-option {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 8px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 253, 248, 0.78);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.ppt-script-option:hover {
    border-color: rgba(186, 75, 49, 0.34);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}

.ppt-script-option-head,
.ppt-script-option-foot {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.ppt-script-option-head {
    align-items: flex-start;
}

.ppt-script-option-head > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.ppt-script-option-head h3 {
    margin: 3px 0 0;
    min-width: 0;
    font-size: 0.94rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
}

.ppt-script-option-date {
    display: none;
}

.ppt-script-option-foot {
    align-items: center;
    margin-top: auto;
}

.ppt-script-option-foot > span {
    min-width: 0;
    overflow: hidden;
    flex: 1 1 auto;
    color: var(--muted-soft);
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ppt-script-option-foot .button {
    flex: 0 0 auto;
    min-width: 72px;
    height: 26px;
    padding: 0 10px;
    line-height: 1;
    font-size: 0.7rem;
    border-radius: 8px;
    white-space: nowrap;
}

.ppt-script-option p {
    display: -webkit-box;
    min-height: 4.65em;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.ppt-script-picker-empty {
    grid-column: 1 / -1;
    padding: 50px 20px;
    color: var(--muted-soft);
    text-align: center;
}

.ppt-script-picker-tabs {
    display: flex;
    gap: 0;
    padding: 0 26px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.ppt-script-picker-tab {
    padding: 10px 18px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted-soft);
    cursor: pointer;
    border: 0;
    background: transparent;
    border-bottom: 2px solid transparent;
    transition: all .16s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ppt-script-picker-tab:hover {
    color: var(--muted);
}

.ppt-script-picker-tab.is-active {
    color: var(--accent-deep);
    border-bottom-color: var(--accent);
}

.ppt-script-picker-tab .badge {
    font-size: .6rem;
    background: var(--line);
    color: var(--muted-soft);
    padding: 1px 6px;
    border-radius: 999px;
    font-weight: 700;
}

.ppt-script-picker-tab.is-active .badge {
    background: rgba(224, 119, 47, 0.12);
    color: var(--accent);
}

@media (max-width: 1280px) {
    .template-gallery[data-layout="grid"] {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1080px) {
    .template-gallery[data-layout="grid"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.auth-required {
    display: grid;
    gap: 8px;
    padding: 22px;
    border-radius: var(--radius-lg);
    background: rgba(255, 253, 249, 0.84);
    border: 1px dashed rgba(31, 25, 20, 0.16);
}

.auth-required h3,
.auth-required p {
    margin: 0;
}

.auth-required p {
    color: var(--muted);
    line-height: 1.6;
}

.login-note-list {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.login-note-list span {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--muted);
    line-height: 1.6;
}

.login-note-list span::before {
    content: "";
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    margin-top: 0.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--support));
}

.field {
    display: grid;
    gap: 10px;
}

.field-grid {
    gap: 14px;
}

.field-grid > * {
    flex: 1 1 0;
}

.field-grid-tight {
    align-items: center;
}

.field label,
.toggle-field span {
    font-size: 0.92rem;
    font-weight: 600;
}

.toggle-field span small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 400;
    line-height: 1.55;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid rgba(31, 25, 20, 0.14);
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(255, 253, 250, 0.92);
    color: var(--ink);
}

.field textarea {
    min-height: 360px;
    resize: vertical;
    line-height: 1.7;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: 2px solid rgba(186, 75, 49, 0.18);
    border-color: rgba(186, 75, 49, 0.3);
}

.toggle-field {
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 0 14px;
    border: 1px solid rgba(31, 25, 20, 0.14);
    border-radius: 16px;
    background: rgba(255, 253, 250, 0.92);
}

.toggle-field input {
    width: 18px;
    height: 18px;
}

.toggle-field-rich {
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background:
        radial-gradient(circle at top right, rgba(186, 75, 49, 0.08), transparent 34%),
        rgba(255, 253, 250, 0.92);
}

.toggle-field-rich input {
    margin-top: 4px;
}

.form-footer {
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.form-footer p {
    margin: 0;
    max-width: 48ch;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.6;
}

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

.spec-list li {
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(31, 25, 20, 0.08);
}

.spec-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.spec-list strong,
.result-highlight h3,
.history-item strong,
.workflow-steps strong {
    font-size: 1rem;
}

.workflow-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.workflow-steps div {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(31, 25, 20, 0.08);
    background: rgba(255, 253, 249, 0.9);
}

.workflow-steps span {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: 50%;
    background: rgba(36, 69, 95, 0.1);
    color: var(--support);
    font-size: 0.88rem;
    font-weight: 700;
}

.result-highlight {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 250, 245, 0.96), rgba(249, 242, 233, 0.86));
    border: 1px solid rgba(186, 75, 49, 0.16);
    display: grid;
    gap: 10px;
}

.result-panel {
    display: grid;
    gap: 14px;
}

.task-banner {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(36, 69, 95, 0.08);
    border: 1px solid rgba(36, 69, 95, 0.14);
}

.task-banner strong,
.task-banner p,
.task-meta,
.task-note,
.task-error,
.task-action-placeholder {
    margin: 0;
}

.task-banner p,
.task-meta,
.task-note,
.task-action-placeholder {
    color: var(--muted);
    line-height: 1.6;
}

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

.task-item {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 250, 245, 0.96), rgba(249, 242, 233, 0.86));
    border: 1px solid rgba(31, 25, 20, 0.08);
}

.task-item-running,
.task-item-pending {
    border-color: rgba(36, 69, 95, 0.18);
    box-shadow: inset 0 0 0 1px rgba(36, 69, 95, 0.08);
}

.task-item-failed {
    border-color: rgba(186, 75, 49, 0.24);
}

.task-time-block {
    display: grid;
    gap: 2px;
    align-content: start;
    padding-right: 10px;
    border-right: 1px solid rgba(31, 25, 20, 0.08);
}

.task-time-primary {
    font-family: var(--heading-font);
    font-size: 1.25rem;
    line-height: 1.1;
}

.task-time-secondary {
    color: var(--muted-soft);
    font-size: 0.92rem;
    font-weight: 600;
}

.task-main {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.task-headline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.task-headline h3 {
    font-size: 1.18rem;
}

.task-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.task-status-pending {
    color: var(--support);
    background: rgba(36, 69, 95, 0.1);
}

.task-status-running {
    color: #2d5b7c;
    background: rgba(45, 91, 124, 0.12);
}

.task-status-succeeded {
    color: #2b6d46;
    background: rgba(72, 131, 92, 0.12);
}

.task-status-failed {
    color: var(--accent-deep);
    background: rgba(186, 75, 49, 0.12);
}

.task-error {
    color: var(--accent-deep);
    line-height: 1.6;
}

.task-actions {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.task-action-placeholder {
    font-size: 0.92rem;
    font-weight: 600;
}

.result-time {
    font-size: 0.84rem;
}

.text-button {
    background: transparent;
    padding: 0;
    color: var(--accent-deep);
    font-weight: 600;
}

.form-errors,
.field-error {
    color: var(--accent-deep);
}

.form-errors {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(186, 75, 49, 0.1);
    border: 1px solid rgba(186, 75, 49, 0.18);
}

.form-errors p,
.field-error {
    margin: 0;
    font-size: 0.9rem;
}

.empty-state {
    padding: 32px;
    border-radius: var(--radius-lg);
    background: rgba(255, 253, 249, 0.8);
    border: 1px dashed rgba(31, 25, 20, 0.16);
}

.compact-state {
    padding: 18px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(23, 18, 13, 0.44);
}

.modal[hidden] {
    display: none;
}

.modal-dialog {
    width: min(780px, 100%);
    padding: 24px;
}

.modal-dialog-wide {
    width: min(1240px, 100%);
}

.login-modal-dialog {
    width: min(468px, 100%);
    padding: 0;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 252, 247, 0.99), rgba(248, 243, 235, 0.99));
    border-color: rgba(77, 58, 35, 0.08);
    box-shadow: 0 32px 90px rgba(35, 25, 17, 0.16);
    border-radius: 30px;
}

.login-modal-head {
    margin-bottom: 0;
    padding: 26px 26px 6px;
}

.login-modal-head .eyebrow,
.login-modal-head h2,
.login-modal-shell .field label {
    color: #211c17;
}

.login-modal-head .eyebrow {
    letter-spacing: 0.14em;
    font-size: 0.74rem;
}

.login-modal-head h2 {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.login-modal-subtitle {
    margin: 8px 0 0;
    color: rgba(64, 52, 39, 0.58);
    font-size: 0.95rem;
    line-height: 1.5;
}

.login-modal-shell {
    padding: 18px 26px 26px;
}

.login-modal-form {
    display: grid;
    gap: 18px;
    background: transparent;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

.login-modal-form .field input {
    border-color: rgba(93, 72, 47, 0.12);
    background: #ffffff;
    color: #201b16;
    min-height: 56px;
    border-radius: 18px;
    padding-inline: 18px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.login-modal-form .field input::placeholder {
    color: rgba(74, 60, 44, 0.42);
}

.login-modal-form .field input:focus {
    border-color: rgba(196, 104, 50, 0.34);
    outline-color: rgba(196, 104, 50, 0.12);
    background: #fffdfa;
    box-shadow:
        0 0 0 4px rgba(214, 124, 73, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.login-modal-form .form-errors {
    color: #a63f52;
    background: rgba(240, 207, 214, 0.34);
    border-color: rgba(198, 91, 116, 0.18);
    border-radius: 16px;
}

.login-modal-form .field-error {
    color: #b04b5f;
    margin-top: 8px;
}

.login-modal-submit {
    width: 100%;
    min-height: 56px;
    border-radius: 18px;
    font-weight: 700;
}

.login-modal-form-single {
    gap: 20px;
}

.login-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
}

.login-code-input {
    min-width: 0;
}

.login-async-message {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
    line-height: 1.5;
    border: 1px solid rgba(31, 25, 20, 0.08);
    background: rgba(255, 255, 255, 0.72);
}

.login-async-message.is-success {
    color: #1f6b45;
    background: rgba(225, 244, 233, 0.9);
    border-color: rgba(77, 160, 106, 0.2);
}

.login-async-message.is-error {
    color: #a63f52;
    background: rgba(240, 207, 214, 0.4);
    border-color: rgba(198, 91, 116, 0.18);
}

.login-code-button {
    min-height: 56px;
    padding-inline: 16px;
    align-self: end;
    white-space: nowrap;
    border-radius: 16px;
    font-weight: 600;
}

.login-code-button:disabled {
    cursor: not-allowed;
    color: rgba(31, 25, 20, 0.46);
    background: rgba(239, 233, 224, 0.92);
    border-color: rgba(31, 25, 20, 0.08);
    box-shadow: none;
    transform: none;
}

.login-modal-dialog .button-ghost[data-close-dialog] {
    min-height: 42px;
    padding-inline: 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border-color: rgba(77, 58, 35, 0.08);
}

.login-modal-dialog .button-ghost[data-close-dialog]:hover,
.login-code-button:hover {
    background: rgba(247, 240, 230, 0.92);
}

.modal-head {
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.preview-modal-hint {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.preview-modal-actions,
.preview-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.preview-zoom-controls {
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(31, 25, 20, 0.08);
}

.preview-zoom-button {
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
}

.preview-frame-shell {
    overflow: auto;
    border-radius: 26px;
    border: 1px solid rgba(31, 25, 20, 0.08);
    background:
        radial-gradient(circle at top, rgba(36, 69, 95, 0.08), transparent 30%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 241, 233, 0.92));
    height: min(78vh, 900px);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-device-shell {
    --preview-content-width: 1600;
    --preview-content-height: 900;
    --preview-render-scale: 1;
    flex: 0 0 auto;
    position: relative;
    width: calc(var(--preview-content-width) * 1px * var(--preview-render-scale));
    height: calc(var(--preview-content-height) * 1px * var(--preview-render-scale));
    transition: width 180ms ease, height 180ms ease;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(31, 25, 20, 0.08);
    box-shadow: 0 24px 60px rgba(45, 34, 24, 0.12);
    overflow: hidden;
}

.preview-device-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #ffffff;
    border-radius: inherit;
}

.preview-device-shell iframe {
    position: absolute;
    inset: 0;
    width: calc(var(--preview-content-width) * 1px);
    height: calc(var(--preview-content-height) * 1px);
    border: 0;
    background: white;
    transform: scale(var(--preview-render-scale));
    transform-origin: top left;
}

.preview-frame-shell::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.preview-frame-shell::-webkit-scrollbar-thumb {
    background: rgba(132, 47, 29, 0.18);
    border-radius: 999px;
}

.modal-footer {
    margin-top: 6px;
}

body.auth-page {
    min-height: 100vh;
    color: #eef4ff;
    background:
        radial-gradient(circle at top left, rgba(21, 179, 247, 0.18), transparent 26%),
        radial-gradient(circle at bottom right, rgba(61, 112, 244, 0.2), transparent 30%),
        linear-gradient(180deg, #0c1018 0%, #090d14 100%);
    overflow-x: hidden;
}

body.auth-page::before {
    background:
        radial-gradient(circle at center, rgba(10, 14, 22, 0.08) 0%, rgba(10, 14, 22, 0.32) 52%, rgba(10, 14, 22, 0.88) 100%),
        linear-gradient(180deg, rgba(9, 13, 21, 0.08), rgba(9, 13, 21, 0.72));
    background-size: cover;
    opacity: 1;
}

.auth-page-shell {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.auth-backdrop {
    position: absolute;
    inset: -14% -10%;
    display: grid;
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    gap: 24px;
    transform: rotate(-16deg) scale(1.08);
    transform-origin: center;
    opacity: 0.56;
    pointer-events: none;
}

.auth-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 10%, rgba(8, 12, 20, 0.34) 42%, rgba(8, 12, 20, 0.92) 84%);
}

.auth-poster {
    position: relative;
    min-height: 216px;
    padding: 20px;
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.36);
    color: rgba(255, 255, 255, 0.94);
    font-family: "Bebas Neue", "Noto Sans SC", sans-serif;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-poster::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 36%),
        linear-gradient(180deg, transparent 34%, rgba(2, 4, 10, 0.6) 100%),
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.16), transparent 30%);
}

.auth-poster span {
    position: relative;
    z-index: 1;
}

.auth-poster:nth-child(4n + 1) {
    background: linear-gradient(145deg, #5d1f2a, #1b2434 56%, #111824);
}

.auth-poster:nth-child(4n + 2) {
    background: linear-gradient(145deg, #133c67, #1a1f38 58%, #100f19);
}

.auth-poster:nth-child(4n + 3) {
    background: linear-gradient(145deg, #274524, #12202d 58%, #0f1018);
}

.auth-poster:nth-child(4n + 4) {
    background: linear-gradient(145deg, #73472a, #251d2d 58%, #10131a);
}

.auth-poster-wide {
    grid-column: span 2;
}

.auth-poster-tall {
    min-height: 284px;
}

.auth-stage {
    position: relative;
    z-index: 2;
    width: min(1040px, calc(100vw - 48px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 36px 0 48px;
    display: grid;
    align-content: center;
    gap: 18px;
}

.auth-return-link {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    color: rgba(238, 244, 255, 0.88);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
}

.auth-return-link::before {
    content: "<";
    font-size: 0.92rem;
}

.auth-console {
    display: grid;
    gap: 22px;
    padding: 34px 36px 36px;
    border-radius: 30px;
    background: rgba(20, 24, 34, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(24px);
}

.auth-console-intro {
    display: grid;
    gap: 8px;
    max-width: 540px;
}

.auth-console-kicker,
.auth-pane-kicker {
    margin: 0;
    color: #1dc1ff;
    font-size: 0.92rem;
    font-weight: 700;
}

.auth-console h1 {
    margin: 0;
    max-width: none;
    color: #ffffff;
    font-family: "Bebas Neue", "Noto Sans SC", sans-serif;
    font-size: clamp(2.8rem, 5vw, 3.7rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
}

.auth-console-note {
    margin: 0;
    color: rgba(226, 234, 247, 0.78);
    font-size: 1rem;
    line-height: 1.7;
}

.auth-message-stack {
    gap: 12px;
}

.auth-console-frame {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
    gap: 22px;
    align-items: stretch;
}

.auth-pane {
    display: grid;
    align-content: start;
    gap: 18px;
    padding: 24px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-pane-login {
    background: rgba(15, 18, 27, 0.82);
}

.auth-pane-register {
    background: linear-gradient(180deg, rgba(22, 29, 43, 0.92), rgba(14, 18, 28, 0.86));
}

.auth-pane-head {
    display: grid;
    gap: 8px;
}

.auth-pane-title {
    color: #ffffff;
    font-family: "Inter", "Noto Sans SC", sans-serif;
    font-size: 1.4rem;
    line-height: 1.2;
}

.auth-page .auth-note {
    color: rgba(223, 232, 245, 0.72);
    font-size: 0.94rem;
    line-height: 1.7;
}

.auth-register-points {
    display: grid;
    gap: 10px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-register-points span {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: rgba(231, 238, 249, 0.78);
    font-size: 0.92rem;
    line-height: 1.6;
}

.auth-register-points span::before {
    content: "";
    width: 8px;
    height: 8px;
    margin-top: 0.44rem;
    flex: 0 0 8px;
    border-radius: 50%;
    background: linear-gradient(90deg, #14bcf8, #4c7af7);
    box-shadow: 0 0 0 4px rgba(20, 188, 248, 0.14);
}

.auth-page .auth-form {
    gap: 14px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.auth-form-console {
    display: grid;
}

.auth-page .field {
    gap: 8px;
}

.auth-page .field label {
    color: rgba(233, 240, 251, 0.9);
    font-size: 0.94rem;
    font-weight: 600;
}

.auth-page .field input {
    min-height: 46px;
    border-radius: 8px;
    padding: 13px 14px;
    background: rgba(61, 66, 79, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f5f8ff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.auth-page .field input::placeholder {
    color: rgba(209, 217, 232, 0.34);
}

.auth-page .field input:focus {
    background: rgba(67, 72, 87, 0.96);
    border-color: rgba(31, 193, 255, 0.42);
    outline: 2px solid rgba(31, 193, 255, 0.18);
}

.auth-page .button-primary {
    color: #f8fbff;
    background: linear-gradient(90deg, #18b4f7 0%, #3d73f4 100%);
    box-shadow: 0 18px 36px rgba(27, 108, 255, 0.22);
}

.auth-page .button-ghost {
    color: #ebf1fb;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.auth-submit {
    width: 100%;
    min-height: 56px;
    margin-top: 8px;
    border-radius: 8px;
    font-size: 1.15rem;
    font-weight: 700;
}

.auth-page .form-errors {
    color: #ffcad4;
    background: rgba(163, 48, 71, 0.2);
    border-color: rgba(255, 112, 142, 0.24);
}

.auth-page .field-error {
    color: #ffc5d1;
}

.auth-page .flash {
    color: #f3f7ff;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.auth-page .flash-success {
    color: #dcecff;
    background: rgba(39, 122, 245, 0.16);
    border-color: rgba(39, 122, 245, 0.22);
}

.auth-page .flash-error,
.auth-page .flash-warning {
    color: #ffd4dc;
    background: rgba(168, 50, 75, 0.18);
    border-color: rgba(255, 115, 145, 0.2);
}

@media (max-width: 980px) {
    .auth-backdrop {
        inset: -12% -24%;
        grid-template-columns: repeat(3, minmax(160px, 1fr));
        transform: rotate(-12deg) scale(1.02);
    }

    .auth-console-frame {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1220px) {
    .template-card {
        flex-basis: calc((100% - var(--gallery-gap)) / 2);
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1080px) {
    .home-builder-layout {
        grid-template-columns: 1fr;
    }

    .home-builder-layout > .workspace-grid,
    .home-builder-layout > .gallery-panel {
        grid-column: 1;
        grid-row: auto;
    }

    .home-builder-layout > .workspace-grid {
        order: 1;
    }

    .home-builder-layout > .gallery-panel {
        order: 2;
    }
}

@media (max-width: 820px) {
    .page-shell {
        width: min(100vw - 24px, 100%);
        padding-top: 18px;
        padding-bottom: 28px;
    }

    .topbar,
    .topbar-actions,
    .section-head,
    .modal-head,
    .form-footer,
    .field-grid,
    .workflow-steps,
    .auth-grid,
    .card-actions,
    .gallery-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .auth-grid {
        grid-template-columns: 1fr;
    }

    .template-card {
        flex-basis: 100%;
    }

    .task-item,
    .task-headline {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .task-item {
        gap: 12px;
    }

    .task-time-block {
        padding-right: 0;
        padding-bottom: 10px;
        border-right: 0;
        border-bottom: 1px solid rgba(31, 25, 20, 0.08);
    }

    .task-actions {
        justify-items: stretch;
    }

    .workflow-steps {
        grid-template-columns: 1fr;
    }

    .hero-panel,
    .gallery-panel,
    .editor-panel,
    .side-card,
    .modal-dialog {
        padding: 20px;
    }

    .login-modal-dialog {
        padding: 0;
        border-radius: 24px;
    }

    .login-modal-shell,
    .login-modal-head {
        padding-inline: 20px;
    }

    .login-modal-shell {
        padding: 16px 20px 20px;
    }

    .ppt-script-source-head,
    .ppt-script-picker-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .ppt-script-source-tabs {
        justify-content: flex-start;
    }

    .ppt-script-picker-list {
        grid-template-columns: 1fr;
        padding-inline: 20px;
    }

    .ppt-script-picker-dialog {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 16px);
        padding: 0;
    }

    .ppt-script-picker-dialog .modal-head,
    .ppt-script-picker-toolbar,
    .ppt-script-subject-filter {
        padding-inline: 20px;
    }

    .login-code-row {
        grid-template-columns: 1fr;
    }

    .auth-stage {
        width: min(100vw - 24px, 100%);
        padding-top: 22px;
        padding-bottom: 30px;
    }

    .auth-console {
        padding: 22px;
    }

    .auth-backdrop {
        inset: -8% -40%;
        grid-template-columns: repeat(2, minmax(160px, 1fr));
        gap: 16px;
        transform: rotate(-8deg) scale(0.98);
    }

    .auth-poster-wide {
        grid-column: span 1;
    }

    .auth-poster,
    .auth-poster-tall {
        min-height: 180px;
    }
}

/* ---- PPT Generator compact layout ---- */
.ppt-generator-page .editor-panel,
.ppt-generator-page .side-card,
.ppt-generator-page .gallery-panel {
    padding: 16px 20px;
}

.ppt-generator-page .section-head.compact {
    margin-bottom: 12px;
}

.ppt-generator-page .section-head h2 {
    font-size: 1.05rem;
}

.ppt-generator-page .eyebrow {
    margin: 0 0 6px;
    font-size: .66rem;
}

.ppt-generator-page .editor-form {
    gap: 10px;
}

.ppt-generator-page .selected-template-banner {
    padding: 10px 14px;
    margin-bottom: 12px;
}

.ppt-generator-page .selected-template-banner strong {
    font-size: 1rem;
}

.ppt-generator-page .workspace-grid {
    gap: 14px;
}

.ppt-generator-page .home-builder-layout {
    gap: 14px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 180px;
    max-height: calc(180px * 4 + 10px * 3);
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-card {
    height: 180px;
}

/* Keep the first paint identical to the post-JS grid layout. The gallery used
   to begin as a carousel and reflow after app.js loaded, which caused a visible
   card expansion while preview iframes were still loading. */
.ppt-generator-page .template-gallery[data-layout="grid"] {
    contain: layout paint;
}

.ppt-generator-page .template-gallery[data-layout="grid"] .template-card {
    min-height: 180px;
}

.ppt-generator-page .template-card {
    padding: 12px;
    gap: 10px;
}

.ppt-generator-page .field:not(.field-large) {
    margin-bottom: 0;
}

.ppt-generator-page .field-help {
    font-size: .68rem;
    margin-top: 3px;
}

.ppt-generator-page .field label {
    font-size: .8rem;
    margin-bottom: 3px;
}

.ppt-generator-page .field input,
.ppt-generator-page .field textarea,
.ppt-generator-page .field select {
    padding: 8px 12px;
    font-size: .88rem;
}

.ppt-generator-page .field textarea {
    min-height: 100px;
}

.ppt-generator-page .form-footer {
    margin-top: 4px;
}

.ppt-generator-page .task-item {
    padding: 10px 14px;
}

.ppt-generator-page .task-item h3 {
    font-size: .9rem;
}

/* ---- Record Video Modal ---- */
.record-video-dialog {
    max-width: 520px;
}

.record-video-body {
    padding: 0 24px 24px;
}

.record-video-desc {
    color: #888;
    font-size: 13px;
    margin: 0 0 20px;
}

.record-video-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.record-video-row {
    display: flex;
    gap: 16px;
}

.record-video-row .field {
    flex: 1;
    min-width: 0;
}

.record-video-row .field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.record-video-row .props-select,
.record-video-row .props-input {
    width: 100%;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 14px;
    padding: 10px 12px;
    box-sizing: border-box;
}

.record-video-row .props-select:focus,
.record-video-row .props-input:focus {
    border-color: #4fc3f7;
    outline: none;
    box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.2);
}

.record-video-status {
    margin-bottom: 20px;
}

.record-progress-bar {
    height: 6px;
    background: #1a1a2e;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.record-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

#record-status-text {
    font-size: 13px;
    color: #aaa;
    margin: 0;
}

.record-video-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-record-video {
    color: #4fc3f7 !important;
    border-color: rgba(79, 195, 247, 0.3) !important;
}

.btn-record-video:hover {
    background: rgba(79, 195, 247, 0.1) !important;
}

/* ---- PPT Recording Overlay ---- */
.ppt-recording-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ppt-recording-overlay[hidden] {
    display: none !important;
}

.ppt-recording-overlay iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ---- Recording Indicator (bottom bar, shown during capture) ---- */
.ppt-recording-indicator {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    height: 28px;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #ccc;
    font-size: 12px;
    backdrop-filter: blur(4px);
}

.ppt-recording-indicator[hidden] {
    display: none !important;
}

.ppt-recording-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4444;
    animation: ppt-recording-pulse 1.2s infinite;
}

@keyframes ppt-recording-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ================= PPT 生成页 · 最终紧凑覆盖（置于文件末尾保证优先级） ================= */
.ppt-generator-page .gallery-panel,
.ppt-generator-page .editor-panel {
    padding: 12px 14px;
}

.ppt-generator-page .section-head,
.ppt-generator-page .section-head.compact {
    margin-bottom: 10px;
    gap: 10px;
}

.ppt-generator-page .section-head h2 {
    font-size: 1.05rem;
}

.ppt-generator-page .section-head .eyebrow {
    margin-bottom: 4px;
    font-size: 0.62rem;
}

.ppt-generator-page .home-builder-layout {
    gap: 12px;
}

.ppt-generator-page .gallery-type-toggle .button,
.ppt-generator-page .gallery-layout-toggle .button {
    padding: 4px 10px;
    font-size: 0.68rem;
    min-height: 26px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] {
    grid-auto-rows: 158px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    max-height: calc(158px * 4 + 10px * 3);
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-card {
    height: 158px;
    min-height: 158px;
    padding: 7px;
    gap: 6px;
    border-radius: 12px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .card-cover {
    padding: 6px;
    gap: 5px;
    border-radius: 10px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .card-cover h3 {
    font-size: 0.74rem;
    line-height: 1.2;
    margin: 0;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-shell {
    border-radius: 9px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-card[data-template-type="desktop"] .template-preview-viewport {
    border-radius: 9px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-type-chip {
    top: 5px;
    left: 5px;
    min-height: 17px;
    padding: 0 6px;
    font-size: 0.56rem;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .card-actions {
    top: 9px;
    right: 9px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-preview-button {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    flex: 0 0 24px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-preview-button::before {
    top: 5.5px;
    left: 5.5px;
    width: 7px;
    height: 7px;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] .template-preview-button::after {
    top: 13.5px;
    left: 13.5px;
    width: 6px;
    height: 1.8px;
}

.ppt-generator-page .selected-template-banner {
    gap: 8px;
    padding: 7px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
}

.ppt-generator-page .selected-template-banner strong {
    font-size: 0.85rem;
}

.ppt-generator-page .selected-template-banner .banner-meta {
    font-size: 0.66rem;
}

.ppt-generator-page .editor-form {
    gap: 10px;
}

.ppt-generator-page .field {
    gap: 5px;
}

.ppt-generator-page .field label,
.ppt-generator-page .toggle-field span {
    font-size: 0.76rem;
}

.ppt-generator-page .field input,
.ppt-generator-page .field textarea,
.ppt-generator-page .field select {
    border-radius: 9px;
    padding: 8px 11px;
    font-size: 0.8rem;
}

.ppt-generator-page .field textarea {
    min-height: 150px;
    line-height: 1.6;
}

.ppt-generator-page .field-help {
    font-size: 0.66rem;
    margin-top: 0;
}

.ppt-generator-page .toggle-field {
    min-height: 40px;
    padding: 0 11px;
    border-radius: 9px;
}

.ppt-generator-page .toggle-field span small {
    font-size: 0.68rem;
    margin-top: 2px;
}

.ppt-generator-page .form-footer {
    gap: 8px;
    margin-top: 0;
}

.ppt-generator-page .form-footer .button-large {
    padding: 0 20px;
    min-height: 36px;
    font-size: 0.84rem;
}

.ppt-generator-page .ppt-title-suggest,
.ppt-generator-page [data-ppt-script-source] {
    padding: 4px 9px;
    font-size: 0.66rem;
}

.ppt-generator-page .field-label-row {
    gap: 8px;
}

.ppt-generator-page .field-label-row label {
    margin-bottom: 0;
}

/* ================= PPT 生成页 · 按钮与选择组件紧凑化 ================= */
.ppt-generator-page .button {
    min-height: 32px;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 0.78rem;
}

.ppt-generator-page .button-small {
    min-height: 26px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 0.7rem;
}

.ppt-generator-page .button-large {
    min-height: 36px;
    padding: 0 20px;
    border-radius: 11px;
}

.ppt-generator-page .ppt-script-selection {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px 10px;
    margin: 0 0 8px;
    padding: 6px 10px;
    border-radius: 10px;
}

.ppt-generator-page .ppt-script-selection .ppt-script-selection-label {
    font-size: 0.66rem;
}

.ppt-generator-page .ppt-script-selection strong {
    font-size: 0.76rem;
}

/* 预览弹窗始终置顶：从历史弹窗等其它模态框内打开预览时不被遮挡 */
.modal#preview-modal {
    z-index: 40;
}

/* ================= PPT 生成页 · 表单优先布局 =================
   生成表单是主要操作区，模板选择作为辅助区收窄展示；在 1080px
   以下仍由上面的响应式规则切换为上下布局。 */
.ppt-generator-page .home-builder-layout {
    grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.78fr);
    align-items: stretch;
}

.ppt-generator-page .home-builder-layout > .workspace-grid,
.ppt-generator-page .home-builder-layout > .gallery-panel {
    min-width: 0;
}

.ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
    .ppt-generator-page .home-builder-layout {
        grid-template-columns: 1fr;
    }

    .ppt-generator-page .home-builder-layout .template-gallery[data-layout="grid"] {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* ================= Shadcn Admin 主题预览 =================
   这是一个纯 CSS 主题层，不引入 React、Tailwind 或运行时组件依赖。
   通过 CSS Variables 和较高的选择器优先级覆盖现有页面，便于随时切回咕泡暖色主题。 */
html[data-theme="shadcn"] {
    --bg: #f8fafc;
    --paper: rgba(255, 255, 255, 0.98);
    --paper-strong: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --muted-soft: #94a3b8;
    --accent: #2563eb;
    --accent-deep: #1d4ed8;
    --support: #0f766e;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --heading-font: "Inter", "Noto Sans SC", "PingFang SC", sans-serif;
}

html[data-theme="shadcn"] body,
html[data-theme="shadcn"] body.creative-page {
    background: #f8fafc;
    color: var(--ink);
}

html[data-theme="shadcn"] body::before {
    display: none;
}

html[data-theme="shadcn"] .page-shell,
html[data-theme="shadcn"] .sidebar-page .page-shell {
    padding-top: 16px;
}

html[data-theme="shadcn"] .topbar {
    margin-bottom: 16px;
}

html[data-theme="shadcn"] .brand-wordmark-mark {
    background: var(--accent);
    box-shadow: 0 5px 14px rgba(37, 99, 235, 0.22);
}

html[data-theme="shadcn"] .brand-wordmark-title {
    color: var(--ink);
    background: none;
    -webkit-text-fill-color: currentColor;
}

html[data-theme="shadcn"] .brand-wordmark-sub {
    color: var(--muted-soft);
}

html[data-theme="shadcn"] .theme-switch {
    background: #fff;
    border-color: var(--line);
    color: var(--muted);
}

html[data-theme="shadcn"] .user-pill,
html[data-theme="shadcn"] .button-ghost,
html[data-theme="shadcn"] .gallery-layout-toggle,
html[data-theme="shadcn"] .gallery-type-toggle {
    background: #fff;
    border-color: var(--line);
}

html[data-theme="shadcn"] .button,
html[data-theme="shadcn"] .button:hover,
html[data-theme="shadcn"] .text-button:hover {
    transform: none;
}

html[data-theme="shadcn"] .button {
    min-height: 38px;
    border-radius: 8px;
    font-weight: 600;
}

html[data-theme="shadcn"] .button-primary,
html[data-theme="shadcn"] .gallery-layout-toggle .button.is-active,
html[data-theme="shadcn"] .gallery-type-toggle .button.is-active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: none;
}

html[data-theme="shadcn"] .button-primary:hover,
html[data-theme="shadcn"] .gallery-layout-toggle .button.is-active:hover,
html[data-theme="shadcn"] .gallery-type-toggle .button.is-active:hover {
    background: var(--accent-deep);
}

html[data-theme="shadcn"] .reveal-card,
html[data-theme="shadcn"] .modal-dialog,
html[data-theme="shadcn"] .hero-panel,
html[data-theme="shadcn"] .gallery-panel,
html[data-theme="shadcn"] .editor-panel,
html[data-theme="shadcn"] .side-card,
html[data-theme="shadcn"] .studio-card,
html[data-theme="shadcn"] .sidebar {
    border-color: var(--line);
    background: #fff;
    box-shadow: var(--shadow-soft);
    backdrop-filter: none;
}

html[data-theme="shadcn"] .sidebar {
    border-radius: 14px;
}

html[data-theme="shadcn"] .sidebar-item:hover {
    background: #f1f5f9;
    color: var(--ink);
}

html[data-theme="shadcn"] .sidebar-item.is-active {
    background: #eff6ff;
    color: var(--accent-deep);
}

html[data-theme="shadcn"] input,
html[data-theme="shadcn"] textarea,
html[data-theme="shadcn"] select,
html[data-theme="shadcn"] .studio-input,
html[data-theme="shadcn"] .studio-textarea {
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
}

html[data-theme="shadcn"] input:focus,
html[data-theme="shadcn"] textarea:focus,
html[data-theme="shadcn"] select:focus,
html[data-theme="shadcn"] .studio-input:focus,
html[data-theme="shadcn"] .studio-textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
    outline: none;
}

/* AI 创作台已有独立变量，这里只替换色板，不破坏它的布局和交互。 */
html[data-theme="shadcn"] body.ai-studio-page {
    --as-background-50: #f8fafc;
    --as-background-100: #f1f5f9;
    --as-background-200: #e2e8f0;
    --as-background-300: #cbd5e1;
    --as-primary-50: #eff6ff;
    --as-primary-100: #dbeafe;
    --as-primary-200: #bfdbfe;
    --as-primary-300: #93c5fd;
    --as-primary-400: #60a5fa;
    --as-primary-500: #2563eb;
    --as-primary-600: #1d4ed8;
    --as-primary-700: #1e40af;
    --as-secondary-50: #f8fafc;
    --as-secondary-100: #f1f5f9;
    --as-secondary-200: #e2e8f0;
    --as-secondary-300: #cbd5e1;
    --as-foreground-500: #64748b;
    --as-foreground-600: #475569;
    --as-foreground-700: #334155;
    --as-foreground-800: #1e293b;
    --as-foreground-950: #0f172a;
}

/* 数字人和抖音榜单使用 oklch 变量，单独提供对应的中性色和蓝色主色。 */
html[data-theme="shadcn"] body.digital-human-page,
html[data-theme="shadcn"] body.billboard-page {
    --background-50: 0.985 0.003 247;
    --background-100: 0.97 0.005 247;
    --background-200: 0.93 0.01 247;
    --background-300: 0.87 0.015 247;
    --background-400: 0.78 0.018 247;
    --background-500: 0.68 0.02 247;
    --primary-50: 0.97 0.025 252;
    --primary-100: 0.93 0.055 252;
    --primary-200: 0.86 0.1 252;
    --primary-300: 0.76 0.15 252;
    --primary-400: 0.66 0.19 252;
    --primary-500: 0.55 0.22 252;
    --primary-600: 0.48 0.2 252;
    --primary-700: 0.4 0.17 252;
    --primary-800: 0.33 0.14 252;
    --foreground-500: 0.56 0.025 250;
    --foreground-600: 0.45 0.03 250;
    --foreground-700: 0.36 0.035 250;
    --foreground-800: 0.27 0.035 250;
    --foreground-900: 0.2 0.035 250;
    --foreground-950: 0.14 0.03 250;
}

html[data-theme="shadcn"] .bb-main,
html[data-theme="shadcn"] .bb-board-nav,
html[data-theme="shadcn"] .bb-date-filter,
html[data-theme="shadcn"] .bb-topbar-btn {
    border-color: #e2e8f0;
    background: #fff;
    box-shadow: none;
}

html[data-theme="shadcn"] .bb-nav-card {
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: none;
}

html[data-theme="shadcn"] .bb-nav-card-label,
html[data-theme="shadcn"] .bb-nav-card-check {
    color: var(--ink);
}

html[data-theme="shadcn"] .bb-nav-card-icon {
    background: #eff6ff;
    color: var(--accent);
}

html[data-theme="shadcn"] .bb-nav-card.is-active {
    outline-color: #93c5fd;
}

@media (max-width: 640px) {
    html[data-theme="shadcn"] .brand-head-row {
        width: 100%;
        justify-content: space-between;
    }
}

/* ================= 主题扩展：深夜蓝 / 薄荷青 =================
   主题只替换颜色、边框和阴影，不改变各业务页面的布局与交互。页面没有共享
   顶部导航时，theme.js 会自动补一个右下角的紧凑切换按钮，避免编辑器和登录页漏掉主题入口。 */
.theme-switch-floating {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 120;
    box-shadow: 0 10px 28px rgba(31, 25, 20, 0.14);
}

html[data-theme="midnight"] {
    --bg: #0b1120;
    --paper: #111827;
    --paper-strong: #172236;
    --ink: #e5eefc;
    --muted: #9aaac0;
    --muted-soft: #71839c;
    --accent: #60a5fa;
    --accent-deep: #3b82f6;
    --support: #2dd4bf;
    --line: rgba(148, 163, 184, 0.2);
    --line-strong: rgba(148, 163, 184, 0.34);
    --shadow: 0 24px 60px rgba(2, 6, 23, 0.42);
    --shadow-soft: 0 12px 30px rgba(2, 6, 23, 0.28);
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
    --heading-font: "Inter", "Noto Sans SC", "PingFang SC", sans-serif;
}

html[data-theme="midnight"] body,
html[data-theme="midnight"] body.creative-page,
html[data-theme="midnight"] body.detail-page,
html[data-theme="midnight"] body.html-document-page {
    background: #0b1120;
    color: var(--ink);
}

html[data-theme="midnight"] body::before {
    display: none;
}

html[data-theme="midnight"] .page-shell,
html[data-theme="midnight"] .sidebar-page .page-shell {
    padding-top: 16px;
}

html[data-theme="midnight"] .brand-wordmark-mark {
    background: linear-gradient(135deg, #2563eb, #38bdf8);
    box-shadow: 0 5px 16px rgba(37, 99, 235, 0.36);
}

html[data-theme="midnight"] .brand-wordmark-title {
    color: #f8fafc;
    background: none;
    -webkit-text-fill-color: currentColor;
}

html[data-theme="midnight"] .brand-wordmark-sub,
html[data-theme="midnight"] .brand-subtitle {
    color: #71839c;
}

html[data-theme="midnight"] .theme-switch,
html[data-theme="midnight"] .user-pill,
html[data-theme="midnight"] .button-ghost,
html[data-theme="midnight"] .gallery-layout-toggle,
html[data-theme="midnight"] .gallery-type-toggle {
    border-color: #334155;
    background: #111827;
    color: #cbd5e1;
}

html[data-theme="midnight"] .theme-switch:hover,
html[data-theme="midnight"] .button-ghost:hover {
    border-color: #60a5fa;
    background: #172236;
    color: #bfdbfe;
}

html[data-theme="midnight"] .button,
html[data-theme="midnight"] .button:hover,
html[data-theme="midnight"] .text-button:hover {
    transform: none;
}

html[data-theme="midnight"] .button-primary,
html[data-theme="midnight"] .gallery-layout-toggle .button.is-active,
html[data-theme="midnight"] .gallery-type-toggle .button.is-active {
    color: #eff6ff;
    background: #2563eb;
    border-color: #2563eb;
    box-shadow: none;
}

html[data-theme="midnight"] .button-primary:hover,
html[data-theme="midnight"] .gallery-layout-toggle .button.is-active:hover,
html[data-theme="midnight"] .gallery-type-toggle .button.is-active:hover {
    background: #3b82f6;
}

html[data-theme="midnight"] .reveal-card,
html[data-theme="midnight"] .modal-dialog,
html[data-theme="midnight"] .hero-panel,
html[data-theme="midnight"] .gallery-panel,
html[data-theme="midnight"] .editor-panel,
html[data-theme="midnight"] .side-card,
html[data-theme="midnight"] .studio-card,
html[data-theme="midnight"] .sidebar,
html[data-theme="midnight"] .html-document-panel {
    border-color: #26364d;
    background: #111827;
    box-shadow: var(--shadow-soft);
    backdrop-filter: none;
}

html[data-theme="midnight"] .sidebar-item:hover {
    background: #172236;
    color: var(--ink);
}

html[data-theme="midnight"] .sidebar-item.is-active {
    background: #172f5b;
    color: #bfdbfe;
}

html[data-theme="midnight"] input,
html[data-theme="midnight"] textarea,
html[data-theme="midnight"] select,
html[data-theme="midnight"] .studio-input,
html[data-theme="midnight"] .studio-textarea {
    border-color: #334155;
    background: #0f172a;
    color: var(--ink);
}

html[data-theme="midnight"] input::placeholder,
html[data-theme="midnight"] textarea::placeholder {
    color: #64748b;
}

html[data-theme="midnight"] input:focus,
html[data-theme="midnight"] textarea:focus,
html[data-theme="midnight"] select:focus,
html[data-theme="midnight"] .studio-input:focus,
html[data-theme="midnight"] .studio-textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
    outline: none;
}

html[data-theme="midnight"] body.ai-studio-page {
    --as-background-50: #0f172a;
    --as-background-100: #111827;
    --as-background-200: #1e293b;
    --as-background-300: #334155;
    --as-primary-50: #172f5b;
    --as-primary-100: #1e3a8a;
    --as-primary-200: #1d4ed8;
    --as-primary-300: #3b82f6;
    --as-primary-400: #60a5fa;
    --as-primary-500: #3b82f6;
    --as-primary-600: #2563eb;
    --as-primary-700: #1d4ed8;
    --as-secondary-50: #0f172a;
    --as-secondary-100: #172236;
    --as-secondary-200: #26364d;
    --as-secondary-300: #334155;
    --as-foreground-500: #94a3b8;
    --as-foreground-600: #cbd5e1;
    --as-foreground-700: #dbeafe;
    --as-foreground-800: #e5eefc;
    --as-foreground-950: #f8fafc;
}

html[data-theme="midnight"] body.digital-human-page,
html[data-theme="midnight"] body.billboard-page {
    --background-50: 0.19 0.025 250;
    --background-100: 0.23 0.03 250;
    --background-200: 0.31 0.035 250;
    --background-300: 0.4 0.035 250;
    --background-400: 0.5 0.03 250;
    --background-500: 0.6 0.025 250;
    --primary-50: 0.25 0.055 250;
    --primary-100: 0.32 0.09 250;
    --primary-200: 0.42 0.14 250;
    --primary-300: 0.54 0.18 250;
    --primary-400: 0.65 0.19 250;
    --primary-500: 0.7 0.18 250;
    --primary-600: 0.62 0.2 250;
    --primary-700: 0.54 0.19 250;
    --primary-800: 0.46 0.15 250;
    --foreground-400: 0.62 0.025 250;
    --foreground-500: 0.7 0.025 250;
    --foreground-600: 0.78 0.02 250;
    --foreground-700: 0.85 0.018 250;
    --foreground-800: 0.9 0.015 250;
    --foreground-900: 0.94 0.01 250;
    --foreground-950: 0.98 0.005 250;
}

html[data-theme="midnight"] .bb-main,
html[data-theme="midnight"] .bb-board-nav,
html[data-theme="midnight"] .bb-date-filter,
html[data-theme="midnight"] .bb-topbar-btn,
html[data-theme="midnight"] .bb-nav-card {
    border-color: #334155;
    background: #111827;
    box-shadow: none;
}

html[data-theme="midnight"] .bb-nav-card-label,
html[data-theme="midnight"] .bb-nav-card-check {
    color: #e5eefc;
}

html[data-theme="midnight"] .bb-nav-card-icon {
    background: #172f5b;
    color: #93c5fd;
}

html[data-theme="midnight"] .bb-nav-card.is-active {
    outline-color: #60a5fa;
}

html[data-theme="midnight"] .ppt-editor-body {
    background: #0b1120;
    color: #e5eefc;
}

html[data-theme="midnight"] .editor-topbar,
html[data-theme="midnight"] .editor-props-pane {
    background: #111827;
    border-color: #334155;
}

html[data-theme="midnight"] .editor-preview-pane {
    background: #080d19;
}

html[data-theme="midnight"] .editor-title,
html[data-theme="midnight"] .props-field label,
html[data-theme="midnight"] .props-label {
    color: #cbd5e1;
}

html[data-theme="midnight"] .props-section,
html[data-theme="midnight"] .editor-shortcut-hint {
    border-color: #334155;
    background: #172236;
    color: #cbd5e1;
}

html[data-theme="midnight"] .props-textarea,
html[data-theme="midnight"] .props-input,
html[data-theme="midnight"] .props-select,
html[data-theme="midnight"] .props-toggle,
html[data-theme="midnight"] .props-align-btn,
html[data-theme="midnight"] .props-tag-name {
    border-color: #334155;
    background: #0f172a;
    color: #e5eefc;
}

html[data-theme="midnight"] .props-toggle.active,
html[data-theme="midnight"] .props-align-btn.active,
html[data-theme="midnight"] #btn-save {
    background: #2563eb;
    border-color: #2563eb;
    color: #eff6ff;
}

html[data-theme="midnight"] .login-page {
    background: #0b1120;
}

html[data-theme="midnight"] .login-card {
    border: 1px solid #334155;
    background: #111827;
    box-shadow: var(--shadow);
}

html[data-theme="midnight"] .login-card input[type="email"],
html[data-theme="midnight"] .login-card input[type="text"],
html[data-theme="midnight"] .login-code-button {
    border-color: #334155;
    background: #0f172a;
    color: #e5eefc;
}

html[data-theme="sage"] {
    --bg: #eff6f1;
    --paper: rgba(255, 255, 255, 0.96);
    --paper-strong: #ffffff;
    --ink: #20352b;
    --muted: #60756a;
    --muted-soft: #8aa095;
    --accent: #2f8f63;
    --accent-deep: #216745;
    --support: #286a7e;
    --line: #dbe9df;
    --line-strong: #c4d9cb;
    --shadow: 0 24px 60px rgba(41, 91, 63, 0.1);
    --shadow-soft: 0 12px 30px rgba(41, 91, 63, 0.07);
    --radius-xl: 20px;
    --radius-lg: 15px;
    --radius-md: 11px;
    --radius-sm: 9px;
    --heading-font: "Inter", "Noto Sans SC", "PingFang SC", sans-serif;
}

html[data-theme="sage"] body,
html[data-theme="sage"] body.creative-page,
html[data-theme="sage"] body.detail-page,
html[data-theme="sage"] body.html-document-page {
    background: linear-gradient(180deg, #edf6ef 0%, #f7fbf8 50%, #edf5ef 100%);
    color: var(--ink);
}

html[data-theme="sage"] body::before {
    background-image: linear-gradient(rgba(47, 143, 99, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(47, 143, 99, 0.025) 1px, transparent 1px);
}

html[data-theme="sage"] .page-shell,
html[data-theme="sage"] .sidebar-page .page-shell {
    padding-top: 16px;
}

html[data-theme="sage"] .brand-wordmark-mark {
    background: linear-gradient(135deg, #2f8f63, #6bbb85);
    box-shadow: 0 5px 16px rgba(47, 143, 99, 0.26);
}

html[data-theme="sage"] .brand-wordmark-title {
    color: #20352b;
    background: none;
    -webkit-text-fill-color: currentColor;
}

html[data-theme="sage"] .brand-wordmark-sub,
html[data-theme="sage"] .brand-subtitle {
    color: #7b9786;
}

html[data-theme="sage"] .theme-switch,
html[data-theme="sage"] .user-pill,
html[data-theme="sage"] .button-ghost,
html[data-theme="sage"] .gallery-layout-toggle,
html[data-theme="sage"] .gallery-type-toggle {
    border-color: #cfe1d4;
    background: #ffffff;
    color: #557263;
}

html[data-theme="sage"] .theme-switch:hover,
html[data-theme="sage"] .button-ghost:hover {
    border-color: #65ad82;
    background: #f4fbf6;
    color: #216745;
}

html[data-theme="sage"] .button,
html[data-theme="sage"] .button:hover,
html[data-theme="sage"] .text-button:hover {
    transform: none;
}

html[data-theme="sage"] .button-primary,
html[data-theme="sage"] .gallery-layout-toggle .button.is-active,
html[data-theme="sage"] .gallery-type-toggle .button.is-active {
    color: #f7fff9;
    background: #2f8f63;
    border-color: #2f8f63;
    box-shadow: none;
}

html[data-theme="sage"] .button-primary:hover,
html[data-theme="sage"] .gallery-layout-toggle .button.is-active:hover,
html[data-theme="sage"] .gallery-type-toggle .button.is-active:hover {
    background: #216745;
}

html[data-theme="sage"] .reveal-card,
html[data-theme="sage"] .modal-dialog,
html[data-theme="sage"] .hero-panel,
html[data-theme="sage"] .gallery-panel,
html[data-theme="sage"] .editor-panel,
html[data-theme="sage"] .side-card,
html[data-theme="sage"] .studio-card,
html[data-theme="sage"] .sidebar,
html[data-theme="sage"] .html-document-panel {
    border-color: #dbe9df;
    background: #ffffff;
    box-shadow: var(--shadow-soft);
    backdrop-filter: none;
}

html[data-theme="sage"] .sidebar-item:hover {
    background: #f0f8f2;
    color: var(--ink);
}

html[data-theme="sage"] .sidebar-item.is-active {
    background: #e5f4e9;
    color: #216745;
}

html[data-theme="sage"] input,
html[data-theme="sage"] textarea,
html[data-theme="sage"] select,
html[data-theme="sage"] .studio-input,
html[data-theme="sage"] .studio-textarea {
    border-color: #cfe1d4;
    background: #ffffff;
    color: var(--ink);
}

html[data-theme="sage"] input:focus,
html[data-theme="sage"] textarea:focus,
html[data-theme="sage"] select:focus,
html[data-theme="sage"] .studio-input:focus,
html[data-theme="sage"] .studio-textarea:focus {
    border-color: #65ad82;
    box-shadow: 0 0 0 3px rgba(47, 143, 99, 0.14);
    outline: none;
}

html[data-theme="sage"] body.ai-studio-page {
    --as-background-50: #ffffff;
    --as-background-100: #f5faf6;
    --as-background-200: #e7f2ea;
    --as-background-300: #cfe1d4;
    --as-primary-50: #e5f4e9;
    --as-primary-100: #d1ebd9;
    --as-primary-200: #b1dbbe;
    --as-primary-300: #8bc69d;
    --as-primary-400: #65ad82;
    --as-primary-500: #2f8f63;
    --as-primary-600: #286f4e;
    --as-primary-700: #216745;
    --as-secondary-50: #f7fbf8;
    --as-secondary-100: #edf6ef;
    --as-secondary-200: #dbe9df;
    --as-secondary-300: #c4d9cb;
    --as-foreground-500: #7b9786;
    --as-foreground-600: #60756a;
    --as-foreground-700: #486453;
    --as-foreground-800: #304b3a;
    --as-foreground-950: #20352b;
}

html[data-theme="sage"] body.digital-human-page,
html[data-theme="sage"] body.billboard-page {
    --background-50: 0.99 0.006 150;
    --background-100: 0.97 0.012 150;
    --background-200: 0.93 0.025 150;
    --background-300: 0.87 0.04 150;
    --background-400: 0.78 0.055 150;
    --background-500: 0.68 0.06 150;
    --primary-50: 0.96 0.045 155;
    --primary-100: 0.91 0.09 155;
    --primary-200: 0.83 0.13 155;
    --primary-300: 0.73 0.16 155;
    --primary-400: 0.63 0.17 155;
    --primary-500: 0.53 0.16 155;
    --primary-600: 0.46 0.14 155;
    --primary-700: 0.39 0.12 155;
    --primary-800: 0.32 0.09 155;
    --foreground-400: 0.57 0.03 150;
    --foreground-500: 0.5 0.035 150;
    --foreground-600: 0.42 0.04 150;
    --foreground-700: 0.34 0.045 150;
    --foreground-800: 0.27 0.045 150;
    --foreground-900: 0.21 0.04 150;
    --foreground-950: 0.16 0.035 150;
}

html[data-theme="sage"] .bb-main,
html[data-theme="sage"] .bb-board-nav,
html[data-theme="sage"] .bb-date-filter,
html[data-theme="sage"] .bb-topbar-btn,
html[data-theme="sage"] .bb-nav-card {
    border-color: #dbe9df;
    background: #ffffff;
    box-shadow: none;
}

html[data-theme="sage"] .bb-nav-card-label,
html[data-theme="sage"] .bb-nav-card-check {
    color: #304b3a;
}

html[data-theme="sage"] .bb-nav-card-icon {
    background: #e5f4e9;
    color: #2f8f63;
}

html[data-theme="sage"] .bb-nav-card.is-active {
    outline-color: #65ad82;
}

html[data-theme="sage"] .ppt-editor-body {
    background: #eff6f1;
    color: #20352b;
}

html[data-theme="sage"] .editor-topbar,
html[data-theme="sage"] .editor-props-pane {
    background: #ffffff;
    border-color: #cfe1d4;
}

html[data-theme="sage"] .editor-preview-pane {
    background: #e7f2ea;
}

html[data-theme="sage"] .editor-title,
html[data-theme="sage"] .props-field label,
html[data-theme="sage"] .props-label {
    color: #486453;
}

html[data-theme="sage"] .props-section,
html[data-theme="sage"] .editor-shortcut-hint {
    border-color: #dbe9df;
    background: #f5faf6;
    color: #486453;
}

html[data-theme="sage"] .props-textarea,
html[data-theme="sage"] .props-input,
html[data-theme="sage"] .props-select,
html[data-theme="sage"] .props-toggle,
html[data-theme="sage"] .props-align-btn,
html[data-theme="sage"] .props-tag-name {
    border-color: #cfe1d4;
    background: #ffffff;
    color: #20352b;
}

html[data-theme="sage"] .props-toggle.active,
html[data-theme="sage"] .props-align-btn.active,
html[data-theme="sage"] #btn-save {
    background: #2f8f63;
    border-color: #2f8f63;
    color: #f7fff9;
}

html[data-theme="sage"] .login-page {
    background: #eff6f1;
}

html[data-theme="sage"] .login-card {
    border: 1px solid #dbe9df;
    background: #ffffff;
    box-shadow: var(--shadow);
}

html[data-theme="sage"] .login-card input[type="email"],
html[data-theme="sage"] .login-card input[type="text"],
html[data-theme="sage"] .login-code-button {
    border-color: #cfe1d4;
    background: #f8fcf9;
    color: #20352b;
}

/* 编辑器之外的几个独立页面有少量内联/专属色值，这里统一收口，避免切换后出现一块暖色孤岛。 */
html[data-theme="midnight"] .ex-page-tabs,
html[data-theme="midnight"] .html-input-mode-tabs {
    border-color: #334155;
    background: #172236;
}

html[data-theme="midnight"] .ex-page-tab.is-active,
html[data-theme="midnight"] .html-input-mode-button.is-active {
    background: #2563eb;
    color: #eff6ff;
    box-shadow: none;
}

html[data-theme="midnight"] .ex-plaza-card,
html[data-theme="midnight"] .ex-plaza-thumb,
html[data-theme="midnight"] .html-template-card,
html[data-theme="midnight"] .library-modal-card {
    border-color: #334155;
    background: #111827;
    box-shadow: none;
}

html[data-theme="midnight"] .ex-plaza-thumb,
html[data-theme="midnight"] .ex-plaza-thumb .ex-plaza-loading,
html[data-theme="midnight"] .html-template-cover {
    background: #0f172a;
}

html[data-theme="midnight"] .ex-plaza-title,
html[data-theme="midnight"] .html-template-card-copy strong,
html[data-theme="midnight"] .library-modal-card-body h3 {
    color: #e5eefc;
}

html[data-theme="midnight"] .ex-plaza-meta,
html[data-theme="midnight"] .ex-plaza-empty,
html[data-theme="midnight"] .html-template-card-copy small,
html[data-theme="midnight"] .library-modal-card-summary {
    color: #94a3b8;
}

html[data-theme="midnight"] .ex-plaza-mine {
    border-color: #3b82f6;
    background: #172f5b;
    color: #bfdbfe;
}

html[data-theme="sage"] .ex-page-tabs,
html[data-theme="sage"] .html-input-mode-tabs {
    border-color: #dbe9df;
    background: #edf6ef;
}

html[data-theme="sage"] .ex-page-tab.is-active,
html[data-theme="sage"] .html-input-mode-button.is-active {
    background: #ffffff;
    color: #216745;
    box-shadow: 0 4px 12px rgba(47, 143, 99, 0.1);
}

html[data-theme="sage"] .ex-plaza-card,
html[data-theme="sage"] .ex-plaza-thumb,
html[data-theme="sage"] .html-template-card,
html[data-theme="sage"] .library-modal-card {
    border-color: #dbe9df;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(41, 91, 63, 0.06);
}

html[data-theme="sage"] .ex-plaza-thumb,
html[data-theme="sage"] .ex-plaza-thumb .ex-plaza-loading,
html[data-theme="sage"] .html-template-cover {
    background: #f5faf6;
}

html[data-theme="sage"] .ex-plaza-title,
html[data-theme="sage"] .html-template-card-copy strong,
html[data-theme="sage"] .library-modal-card-body h3 {
    color: #20352b;
}

html[data-theme="sage"] .ex-plaza-meta,
html[data-theme="sage"] .ex-plaza-empty,
html[data-theme="sage"] .html-template-card-copy small,
html[data-theme="sage"] .library-modal-card-summary {
    color: #7b9786;
}

html[data-theme="sage"] .ex-plaza-mine {
    border-color: #b1dbbe;
    background: #e5f4e9;
    color: #216745;
}

html[data-theme="midnight"] .creative-page .mode-option,
html[data-theme="midnight"] .creative-page .strategy-option,
html[data-theme="midnight"] .creative-page .mode-variable-editor,
html[data-theme="midnight"] .creative-page .mode-variable-row,
html[data-theme="midnight"] .creative-page .style-preview,
html[data-theme="midnight"] .creative-page .fixed-prompt-fields,
html[data-theme="midnight"] .creative-page .selected-material-card {
    border-color: #334155;
    background: #172236;
    color: #cbd5e1;
}

html[data-theme="midnight"] .creative-page .mode-option:hover,
html[data-theme="midnight"] .creative-page .strategy-option:hover,
html[data-theme="midnight"] .creative-page .mode-option.is-selected,
html[data-theme="midnight"] .creative-page .strategy-option.is-selected {
    border-color: #60a5fa;
    background: #1e3a5f;
}

html[data-theme="midnight"] .creative-page .mode-option strong,
html[data-theme="midnight"] .creative-page .strategy-option span,
html[data-theme="midnight"] .creative-page .mode-variable-field > span {
    color: #e5eefc;
}

html[data-theme="sage"] .creative-page .mode-option,
html[data-theme="sage"] .creative-page .strategy-option,
html[data-theme="sage"] .creative-page .mode-variable-editor,
html[data-theme="sage"] .creative-page .mode-variable-row,
html[data-theme="sage"] .creative-page .style-preview,
html[data-theme="sage"] .creative-page .fixed-prompt-fields,
html[data-theme="sage"] .creative-page .selected-material-card {
    border-color: #dbe9df;
    background: #f5faf6;
    color: #486453;
}

html[data-theme="sage"] .creative-page .mode-option:hover,
html[data-theme="sage"] .creative-page .strategy-option:hover,
html[data-theme="sage"] .creative-page .mode-option.is-selected,
html[data-theme="sage"] .creative-page .strategy-option.is-selected {
    border-color: #65ad82;
    background: #e5f4e9;
}

html[data-theme="sage"] .creative-page .mode-option strong,
html[data-theme="sage"] .creative-page .strategy-option span,
html[data-theme="sage"] .creative-page .mode-variable-field > span {
    color: #304b3a;
}

@media (max-width: 640px) {
    .theme-switch-floating {
        right: 12px;
        bottom: 12px;
    }
}

/* 继续覆盖独立色板页面：Agent、动效、封面和小红书拆解页不再沿用默认暖色。 */
html[data-theme="midnight"] body.agent-page,
html[data-theme="midnight"] body.billboard-page,
html[data-theme="midnight"] body.digital-human-page {
    --background-50: 0.19 0.025 250;
    --background-100: 0.23 0.03 250;
    --background-200: 0.31 0.035 250;
    --background-300: 0.4 0.035 250;
    --background-400: 0.5 0.03 250;
    --background-500: 0.6 0.025 250;
    --background-600: 0.68 0.025 250;
    --background-700: 0.76 0.02 250;
    --background-800: 0.84 0.015 250;
    --background-900: 0.91 0.01 250;
    --background-950: 0.97 0.005 250;
    --primary-50: 0.25 0.055 250;
    --primary-100: 0.32 0.09 250;
    --primary-200: 0.42 0.14 250;
    --primary-300: 0.54 0.18 250;
    --primary-400: 0.65 0.19 250;
    --primary-500: 0.7 0.18 250;
    --primary-600: 0.62 0.2 250;
    --primary-700: 0.54 0.19 250;
    --primary-800: 0.46 0.15 250;
    --primary-900: 0.38 0.12 250;
    --primary-950: 0.3 0.09 250;
    --secondary-50: 0.22 0.025 260;
    --secondary-100: 0.28 0.03 260;
    --secondary-200: 0.36 0.035 260;
    --secondary-300: 0.44 0.035 260;
    --secondary-800: 0.9 0.015 250;
    --foreground-400: 0.62 0.025 250;
    --foreground-500: 0.7 0.025 250;
    --foreground-600: 0.78 0.02 250;
    --foreground-700: 0.85 0.018 250;
    --foreground-800: 0.9 0.015 250;
    --foreground-900: 0.94 0.01 250;
    --foreground-950: 0.98 0.005 250;
}

html[data-theme="sage"] body.agent-page,
html[data-theme="sage"] body.billboard-page,
html[data-theme="sage"] body.digital-human-page {
    --background-50: 0.99 0.006 150;
    --background-100: 0.97 0.012 150;
    --background-200: 0.93 0.025 150;
    --background-300: 0.87 0.04 150;
    --background-400: 0.78 0.055 150;
    --background-500: 0.68 0.06 150;
    --background-600: 0.6 0.055 150;
    --background-700: 0.5 0.05 150;
    --background-800: 0.4 0.045 150;
    --background-900: 0.3 0.04 150;
    --background-950: 0.22 0.03 150;
    --primary-50: 0.96 0.045 155;
    --primary-100: 0.91 0.09 155;
    --primary-200: 0.83 0.13 155;
    --primary-300: 0.73 0.16 155;
    --primary-400: 0.63 0.17 155;
    --primary-500: 0.53 0.16 155;
    --primary-600: 0.46 0.14 155;
    --primary-700: 0.39 0.12 155;
    --primary-800: 0.32 0.09 155;
    --primary-900: 0.25 0.07 155;
    --primary-950: 0.19 0.05 155;
    --secondary-50: 0.98 0.008 150;
    --secondary-100: 0.95 0.018 150;
    --secondary-200: 0.9 0.03 150;
    --secondary-300: 0.84 0.04 150;
    --secondary-800: 0.35 0.06 150;
    --foreground-400: 0.57 0.03 150;
    --foreground-500: 0.5 0.035 150;
    --foreground-600: 0.42 0.04 150;
    --foreground-700: 0.34 0.045 150;
    --foreground-800: 0.27 0.045 150;
    --foreground-900: 0.21 0.04 150;
    --foreground-950: 0.16 0.035 150;
}

html[data-theme="shadcn"] body.mp-page,
html[data-theme="sage"] body.mp-page {
    --mp-page-bg: #f5f8fb;
    --mp-surface-1: rgba(255, 255, 255, .96);
    --mp-surface-2: #f8fafc;
    --mp-surface-dark: rgba(15, 23, 42, .04);
    --mp-overlay-bg: rgba(255, 255, 255, .94);
    --mp-overlay-bg-2: rgba(255, 255, 255, .96);
    --mp-overlay-bg-3: rgba(248, 250, 252, .96);
    --mp-text-1: #0f172a;
    --mp-text-2: #475569;
    --mp-text-3: #64748b;
    --mp-text-dim: #94a3b8;
    --mp-text-dim2: #94a3b8;
    --mp-accent: #2563eb;
    --mp-accent-rgb: 37, 99, 235;
    --mp-accent-light: rgba(37, 99, 235, .1);
    --mp-accent-mid: rgba(37, 99, 235, .18);
    --mp-accent-fade: rgba(37, 99, 235, .12);
    --mp-accent-mini: rgba(37, 99, 235, .04);
    --mp-accent-glow: rgba(37, 99, 235, .22);
    --mp-accent-soft: rgba(37, 99, 235, .06);
    --mp-accent-bg: rgba(37, 99, 235, .08);
    --mp-accent-pale: rgba(37, 99, 235, .05);
    --mp-border: #e2e8f0;
    --mp-border-light: #edf2f7;
    --mp-border-mini: #f1f5f9;
    --mp-border-dark: #cbd5e1;
    --mp-box-bg: #f8fafc;
    --mp-box-bg-2: #f1f5f9;
    --mp-box-bg-3: #ffffff;
    --mp-box-bg-4: #f8fafc;
    --mp-white-bg: rgba(15, 23, 42, .04);
    --mp-preview-bg: linear-gradient(135deg, #e2e8f0, #f8fafc);
    --mp-popover-bg: #ffffff;
    --mp-popover-border: #cbd5e1;
    --mp-timeline-bg: #f8fafc;
    --mp-timeline-track-bg: #e2e8f0;
    --mp-input-bg: #ffffff;
}

html[data-theme="sage"] body.mp-page {
    --mp-page-bg: #eff6f1;
    --mp-accent: #2f8f63;
    --mp-accent-rgb: 47, 143, 99;
    --mp-accent-light: rgba(47, 143, 99, .1);
    --mp-accent-mid: rgba(47, 143, 99, .18);
    --mp-accent-fade: rgba(47, 143, 99, .12);
    --mp-accent-glow: rgba(47, 143, 99, .22);
    --mp-popover-border: #cfe1d4;
}

html[data-theme="midnight"] body.mp-page {
    --mp-page-bg: #0b1120;
    --mp-surface-1: #111827;
    --mp-surface-2: #172236;
    --mp-surface-dark: rgba(2, 6, 23, .28);
    --mp-overlay-bg: rgba(15, 23, 42, .96);
    --mp-overlay-bg-2: rgba(17, 24, 39, .98);
    --mp-overlay-bg-3: rgba(23, 34, 54, .98);
    --mp-text-1: #f8fafc;
    --mp-text-2: #cbd5e1;
    --mp-text-3: #94a3b8;
    --mp-text-dim: #64748b;
    --mp-text-dim2: #71839c;
    --mp-accent: #60a5fa;
    --mp-accent-rgb: 96, 165, 250;
    --mp-accent-light: rgba(96, 165, 250, .14);
    --mp-accent-mid: rgba(96, 165, 250, .24);
    --mp-accent-fade: rgba(96, 165, 250, .18);
    --mp-accent-mini: rgba(96, 165, 250, .06);
    --mp-accent-glow: rgba(96, 165, 250, .32);
    --mp-accent-soft: rgba(96, 165, 250, .1);
    --mp-accent-bg: rgba(96, 165, 250, .14);
    --mp-accent-pale: rgba(96, 165, 250, .08);
    --mp-border: #334155;
    --mp-border-light: #26364d;
    --mp-border-mini: #1e293b;
    --mp-border-dark: #475569;
    --mp-box-bg: #172236;
    --mp-box-bg-2: #1e293b;
    --mp-box-bg-3: #0f172a;
    --mp-box-bg-4: #111827;
    --mp-white-bg: rgba(255, 255, 255, .08);
    --mp-preview-bg: linear-gradient(135deg, #0f172a, #1e293b);
    --mp-popover-bg: #111827;
    --mp-popover-border: #334155;
    --mp-timeline-bg: #0f172a;
    --mp-timeline-track-bg: #1e293b;
    --mp-input-bg: #0f172a;
}

html[data-theme="midnight"] body.cover-generator-page,
html[data-theme="midnight"] body.xhs-analysis-page {
    background: #0b1120;
}

html[data-theme="shadcn"] body.agent-page {
    --background-50: 0.985 0.003 247;
    --background-100: 0.97 0.005 247;
    --background-200: 0.93 0.01 247;
    --background-300: 0.87 0.015 247;
    --background-400: 0.78 0.018 247;
    --background-500: 0.68 0.02 247;
    --background-600: 0.58 0.02 247;
    --background-700: 0.48 0.02 247;
    --background-800: 0.38 0.02 247;
    --background-900: 0.28 0.02 247;
    --background-950: 0.18 0.02 247;
    --primary-50: 0.97 0.025 252;
    --primary-100: 0.93 0.055 252;
    --primary-200: 0.86 0.1 252;
    --primary-300: 0.76 0.15 252;
    --primary-400: 0.66 0.19 252;
    --primary-500: 0.55 0.22 252;
    --primary-600: 0.48 0.2 252;
    --primary-700: 0.4 0.17 252;
    --primary-800: 0.33 0.14 252;
    --secondary-50: 0.98 0.003 247;
    --secondary-100: 0.95 0.005 247;
    --secondary-200: 0.9 0.01 247;
    --secondary-300: 0.84 0.015 247;
    --secondary-800: 0.36 0.03 247;
    --foreground-400: 0.62 0.02 247;
    --foreground-500: 0.56 0.025 250;
    --foreground-600: 0.45 0.03 250;
    --foreground-700: 0.36 0.035 250;
    --foreground-800: 0.27 0.035 250;
    --foreground-900: 0.2 0.035 250;
    --foreground-950: 0.14 0.03 250;
}

html[data-theme="shadcn"] body.cover-generator-page {
    --cover-paper: #ffffff;
    --cover-surface: #ffffff;
    --cover-soft: #f1f5f9;
    --cover-line: #e2e8f0;
    --cover-accent: #2563eb;
    --cover-accent-deep: #1d4ed8;
    --cover-teal: #0f766e;
    --cover-ink: #0f172a;
    --cover-muted: #64748b;
    --cover-faint: #94a3b8;
    background: #f8fafc;
}

html[data-theme="shadcn"] body.cover-generator-page .cover-panel {
    background: #ffffff;
}

html[data-theme="midnight"] body.cover-generator-page {
    --cover-paper: #111827;
    --cover-surface: #0f172a;
    --cover-soft: #172236;
    --cover-line: #334155;
    --cover-accent: #60a5fa;
    --cover-accent-deep: #3b82f6;
    --cover-teal: #2dd4bf;
    --cover-ink: #e5eefc;
    --cover-muted: #94a3b8;
    --cover-faint: #71839c;
}

html[data-theme="sage"] body.cover-generator-page {
    --cover-paper: #ffffff;
    --cover-surface: #f8fcf9;
    --cover-soft: #edf6ef;
    --cover-line: #dbe9df;
    --cover-accent: #2f8f63;
    --cover-accent-deep: #216745;
    --cover-teal: #2f8f63;
    --cover-ink: #20352b;
    --cover-muted: #60756a;
    --cover-faint: #8aa095;
    background: #eff6f1;
}

html[data-theme="shadcn"] body.xhs-analysis-page {
    background: #f8fafc;
}

html[data-theme="sage"] body.xhs-analysis-page {
    background: #eff6f1;
}

html[data-theme="shadcn"] body.xhs-analysis-page,
html[data-theme="midnight"] body.xhs-analysis-page,
html[data-theme="sage"] body.xhs-analysis-page {
    --xhs-ink: var(--ink);
    --xhs-muted: var(--muted);
    --xhs-soft: var(--paper-strong);
    --xhs-line: var(--line-strong);
    --xhs-accent: var(--accent);
    --xhs-accent-dark: var(--accent-deep);
    --cp-primary-50: var(--accent);
    --cp-primary-100: var(--accent);
    --cp-primary-200: var(--accent);
    --cp-primary-300: var(--accent);
    --cp-primary-400: var(--accent);
    --cp-primary-500: var(--accent);
    --cp-primary-600: var(--accent-deep);
    --cp-primary-700: var(--accent-deep);
    --cp-accent-50: var(--support);
    --cp-accent-100: var(--support);
    --cp-accent-200: var(--support);
    --cp-accent-500: var(--support);
    --cp-accent-600: var(--support);
    --cp-accent-700: var(--support);
    --cp-background-50: var(--paper);
    --cp-background-100: var(--paper-strong);
    --cp-background-200: var(--line);
    --cp-background-300: var(--line-strong);
    --cp-foreground-400: var(--muted-soft);
    --cp-foreground-500: var(--muted);
    --cp-foreground-600: var(--muted);
    --cp-foreground-700: var(--ink);
    --cp-foreground-800: var(--ink);
    --cp-foreground-900: var(--ink);
}

html[data-theme="midnight"] .xhs-tabs,
html[data-theme="midnight"] .xhs-note-type-option,
html[data-theme="midnight"] .xhs-material-card,
html[data-theme="midnight"] .xhs-analysis-result,
html[data-theme="midnight"] .xhs-rewrite-result,
html[data-theme="midnight"] .xhs-rewrite-form,
html[data-theme="midnight"] .xhs-report-table {
    border-color: #334155;
    background: #111827;
}

html[data-theme="midnight"] .xhs-url-row input,
html[data-theme="midnight"] .xhs-rewrite-form textarea,
html[data-theme="midnight"] .xhs-rewrite-result textarea,
html[data-theme="midnight"] .xhs-report-search {
    border-color: #334155;
    background: #0f172a;
    color: #e5eefc;
}

html[data-theme="shadcn"] .xhs-tabs,
html[data-theme="shadcn"] .xhs-note-type-option,
html[data-theme="shadcn"] .xhs-material-card,
html[data-theme="shadcn"] .xhs-analysis-result,
html[data-theme="shadcn"] .xhs-rewrite-result,
html[data-theme="shadcn"] .xhs-rewrite-form,
html[data-theme="shadcn"] .xhs-report-table {
    border-color: #e2e8f0;
    background: #ffffff;
}

html[data-theme="shadcn"] .xhs-url-row input,
html[data-theme="shadcn"] .xhs-rewrite-form textarea,
html[data-theme="shadcn"] .xhs-rewrite-result textarea,
html[data-theme="shadcn"] .xhs-report-search {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
}

html[data-theme="sage"] .xhs-tabs,
html[data-theme="sage"] .xhs-note-type-option,
html[data-theme="sage"] .xhs-material-card,
html[data-theme="sage"] .xhs-analysis-result,
html[data-theme="sage"] .xhs-rewrite-result,
html[data-theme="sage"] .xhs-rewrite-form,
html[data-theme="sage"] .xhs-report-table {
    border-color: #dbe9df;
    background: #ffffff;
}

html[data-theme="sage"] .xhs-url-row input,
html[data-theme="sage"] .xhs-rewrite-form textarea,
html[data-theme="sage"] .xhs-rewrite-result textarea,
html[data-theme="sage"] .xhs-report-search {
    border-color: #cfe1d4;
    background: #f8fcf9;
    color: #20352b;
}

/* ================= 深夜蓝主题 · 通用高对比状态色 =================
   部分业务页仍有独立 CSS 色值，统一把危险、错误和强调文字提升到深色背景
   可读的玫红/蓝色，不改变暖色、Shadcn 或薄荷主题。 */
html[data-theme="midnight"] .brand-mark,
html[data-theme="midnight"] .text-button,
html[data-theme="midnight"] .task-error,
html[data-theme="midnight"] .form-errors,
html[data-theme="midnight"] .field-error,
html[data-theme="midnight"] .persona-message.error,
html[data-theme="midnight"] .cover-toast,
html[data-theme="midnight"] .analytics-error-text {
    color: #fda4af;
}

html[data-theme="midnight"] .form-errors,
html[data-theme="midnight"] .persona-message.error,
html[data-theme="midnight"] .cover-toast {
    border-color: rgba(251, 113, 133, 0.42);
    background: rgba(190, 24, 93, 0.18);
}

html[data-theme="midnight"] .button-danger,
html[data-theme="midnight"] .button-danger:hover {
    border-color: rgba(251, 113, 133, 0.52);
    background: rgba(190, 24, 93, 0.2);
    color: #fecdd3;
}

html[data-theme="midnight"] .task-status-failed,
html[data-theme="midnight"] .status-failed,
html[data-theme="midnight"] .task-status-sm.status-failed,
html[data-theme="midnight"] .xdh-st.failed {
    border-color: rgba(251, 113, 133, 0.42);
    background: rgba(190, 24, 93, 0.2);
    color: #fecdd3;
}

html[data-theme="midnight"] .studio-status.is-error .status-dot {
    background: #fb7185;
    box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.2);
}

html[data-theme="midnight"] body.ai-studio-page .astm-btn-primary,
html[data-theme="midnight"] body.ai-studio-page .astm-filters button.is-active {
    color: #ffffff;
}
