body {
    font-family: Inter, sans-serif;
}

.auth-shell {
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 1)),
        #020617;
}

.auth-card {
    animation-delay: 80ms;
}

.field-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 3.25rem;
    border: 1px solid rgba(71, 85, 105, 0.72);
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.82);
    padding: 0 1rem;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.field-wrap:focus-within {
    border-color: rgba(129, 140, 248, 0.92);
    background: rgba(15, 23, 42, 0.96);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.field-wrap i {
    width: 1rem;
    color: rgb(148, 163, 184);
}

.field-wrap input {
    width: 100%;
    min-width: 0;
    background: transparent;
    color: white;
    outline: none;
}

.field-wrap input::placeholder {
    color: rgb(100, 116, 139);
}

.auth-button {
    display: inline-flex;
    width: 100%;
    min-height: 3.25rem;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, rgb(79, 70, 229), rgb(14, 165, 233));
    font-weight: 700;
    color: white;
    transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
    box-shadow: 0 18px 36px rgba(37, 99, 235, 0.22);
}

.auth-button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 22px 42px rgba(37, 99, 235, 0.3);
}

.auth-button:active {
    transform: translateY(0);
}

.animate-rise {
    animation: riseIn 520ms ease both;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

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

@media (prefers-reduced-motion: reduce) {
    .animate-rise,
    .auth-card {
        animation: none;
    }

    .auth-button {
        transition: none;
    }
}

.docu-card {
    display: grid;
    gap: 0;
    border: 1px solid rgb(51 65 85);
    border-radius: 1rem;
    overflow: hidden;
    background: rgb(15 23 42);
}

.docu-card.docu-card-gradient {
    border: 2px solid transparent;
    background:
        linear-gradient(rgb(15 23 42), rgb(15 23 42)) padding-box,
        linear-gradient(135deg, var(--slide-border-a), var(--slide-border-b)) border-box;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.24);
}

@media (min-width: 1024px) {
    .docu-card {
        grid-template-columns: 240px 1fr;
    }
}

.docu-thumb {
    position: relative;
    background: rgb(2 6 23);
    border-right: 1px solid rgb(51 65 85);
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

.docu-thumb img {
    max-height: 250px;
    width: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
}

.docu-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    border-radius: 999px;
    border: 1px solid rgb(71 85 105);
    background: rgb(15 23 42 / 0.92);
    color: rgb(203 213 225);
    padding: 0.15rem 0.6rem;
    font-size: 0.72rem;
}

.docu-content {
    padding: 1rem;
}

.docu-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.docu-text {
    width: 100%;
    min-height: 180px;
    background: rgb(2 6 23);
    border: 1px solid rgb(51 65 85);
    border-radius: 0.75rem;
    color: rgb(226 232 240);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    resize: vertical;
}

.docu-btn {
    border-radius: 0.75rem;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
    border: 1px solid transparent;
}

.docu-btn-main {
    background: rgb(8 145 178);
    color: white;
}

.docu-btn-subtle {
    border-color: rgb(71 85 105);
    color: rgb(203 213 225);
    background: rgb(15 23 42);
}

.docu-btn-danger {
    border-color: rgb(127 29 29);
    color: rgb(252 165 165);
    background: rgb(69 10 10);
}

#pipeline-status {
    box-shadow: inset 0 0 0 1px rgba(71, 85, 105, 0.15);
}

/* Global polish */
.rounded-2xl.border.bg-slate-900,
.rounded-2xl.border.bg-slate-900\/80,
.rounded-2xl.border.bg-slate-900.p-5 {
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.28);
    transition: box-shadow 180ms ease, transform 180ms ease;
}

.rounded-2xl.border.bg-slate-900:hover,
.rounded-2xl.border.bg-slate-900\/80:hover,
.rounded-2xl.border.bg-slate-900.p-5:hover {
    box-shadow: 0 14px 32px rgba(2, 6, 23, 0.34);
}

button,
a[class*="rounded"] {
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, background-color 160ms ease;
}

button:hover,
a[class*="rounded"]:hover {
    transform: translateY(-1px);
}

button:active,
a[class*="rounded"]:active {
    transform: translateY(0);
}

.docu-btn {
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.15);
}

.docu-btn:hover {
    box-shadow: 0 8px 16px rgba(2, 6, 23, 0.2);
}

/* Light theme */
body.theme-light {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

body.theme-light .bg-slate-950 {
    background-color: #f1f5f9 !important;
}

body.theme-light .bg-slate-900,
body.theme-light .bg-slate-900\/80 {
    background-color: #ffffff !important;
}

body.theme-light .bg-slate-950\/60,
body.theme-light .bg-slate-950\/90 {
    background-color: #f8fafc !important;
}

body.theme-light .border-slate-800,
body.theme-light .border-slate-700 {
    border-color: #cbd5e1 !important;
}

body.theme-light .text-white,
body.theme-light .text-slate-100,
body.theme-light .text-slate-200,
body.theme-light .text-slate-300 {
    color: #0f172a !important;
}

body.theme-light .text-slate-400,
body.theme-light .text-slate-500 {
    color: #475569 !important;
}

body.theme-light .hover\:bg-slate-800:hover {
    background-color: #e2e8f0 !important;
}

body.theme-light .docu-card,
body.theme-light .docu-thumb,
body.theme-light .docu-content,
body.theme-light .docu-text {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

body.theme-light .docu-card.docu-card-gradient {
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        linear-gradient(135deg, var(--slide-border-a), var(--slide-border-b)) border-box !important;
    border: 2px solid transparent !important;
}

body.theme-light #preview-screen {
    background: #e2e8f0 !important;
}

/* Light theme: auth/login specific */
body.theme-light .auth-shell {
    background:
        linear-gradient(135deg, rgba(241, 245, 249, 0.96), rgba(226, 232, 240, 0.92)),
        #f1f5f9 !important;
}

body.theme-light .auth-card {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12) !important;
}

body.theme-light .field-wrap {
    border-color: rgba(148, 163, 184, 0.7);
    background: rgba(255, 255, 255, 0.96);
}

body.theme-light .field-wrap:focus-within {
    border-color: rgba(79, 70, 229, 0.72);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

body.theme-light .field-wrap i {
    color: #64748b;
}

body.theme-light .field-wrap input {
    color: #0f172a;
}

body.theme-light .field-wrap input::placeholder {
    color: #94a3b8;
}

body.theme-light .border-white\/10 {
    border-color: rgba(148, 163, 184, 0.35) !important;
}

body.theme-light .bg-white\/5 {
    background-color: rgba(148, 163, 184, 0.12) !important;
}

/* Responsive refinements for all screens */
#theme-toggle {
    max-width: calc(100vw - 1.5rem);
    background-image: linear-gradient(135deg, #facc15, #f59e0b) !important;
    color: #111827 !important;
    border-color: transparent !important;
    box-shadow: 0 12px 24px rgba(245, 158, 11, 0.28) !important;
}

#theme-toggle:hover {
    filter: brightness(1.06) !important;
}

body.theme-light #theme-toggle {
    background-image: linear-gradient(135deg, #111827, #000000) !important;
    color: #f8fafc !important;
    border-color: transparent !important;
    box-shadow: 0 12px 24px rgba(2, 6, 23, 0.28) !important;
}

@media (max-width: 1024px) {
    .docu-card {
        grid-template-columns: 1fr;
    }

    .docu-thumb {
        border-right: 0;
        border-bottom: 1px solid rgb(51 65 85);
        min-height: 180px;
    }
}

@media (max-width: 768px) {
    #theme-toggle {
        top: auto;
        right: 0.75rem;
        bottom: 0.75rem;
        border-radius: 999px;
        padding: 0.6rem 0.9rem;
        box-shadow: 0 14px 24px rgba(2, 6, 23, 0.3);
    }

    #theme-toggle-label {
        font-size: 0.72rem;
    }

    .auth-card {
        border-radius: 1.1rem !important;
        padding: 1rem !important;
    }

    .docu-content {
        padding: 0.85rem;
    }

    .docu-row {
        gap: 0.4rem;
    }

    .docu-btn {
        font-size: 0.78rem;
        padding: 0.42rem 0.68rem;
    }

    .docu-text {
        min-height: 150px;
        font-size: 0.9rem;
    }

    table {
        min-width: 860px;
    }
}

@media (max-width: 640px) {
    h1 {
        line-height: 1.25;
    }

    .rounded-2xl {
        border-radius: 0.95rem !important;
    }

    .docu-thumb img {
        max-height: 180px;
    }

    .docu-badge {
        font-size: 0.68rem;
        padding: 0.12rem 0.5rem;
    }

    .field-wrap {
        min-height: 3rem;
        padding: 0 0.85rem;
    }

    .auth-button {
        min-height: 3rem;
        font-size: 0.95rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px;
    }

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

    .grid.grid-cols-3 > :last-child {
        grid-column: span 2 / span 2;
    }

    .flex.items-center.gap-2 {
        flex-wrap: wrap;
        justify-content: center;
    }

    .mb-4.flex.flex-wrap.items-center.gap-3 {
        justify-content: center;
        align-items: stretch;
    }

    .mb-4.flex.flex-wrap.items-center.gap-3 > button,
    .mb-4.flex.flex-wrap.items-center.gap-3 > a,
    .mb-4.flex.flex-wrap.items-center.gap-3 > select {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 140px;
        justify-content: center;
        text-align: center;
    }

    .mb-4.flex.flex-wrap.items-center.gap-3 > select {
        width: 100%;
    }
}

/* Colorful icon + gradient button treatment */
i.fa-solid,
i.fa-regular {
    color: currentColor;
    display: inline-block;
}

button.rounded-xl,
a.rounded-xl,
.docu-btn-main,
.auth-button {
    background-image: linear-gradient(135deg, #06b6d4, #3b82f6, #6366f1) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.28);
}

button.rounded-xl:hover,
a.rounded-xl:hover,
.docu-btn-main:hover,
.auth-button:hover {
    filter: brightness(1.06) saturate(1.05);
    box-shadow: 0 14px 26px rgba(59, 130, 246, 0.34);
}

.docu-btn-subtle {
    background-image: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(99, 102, 241, 0.12));
    border-color: rgba(99, 102, 241, 0.35);
}

.docu-btn-danger {
    background-image: linear-gradient(135deg, #ef4444, #f97316) !important;
    color: #fff !important;
    border-color: transparent !important;
}

/* Action-specific gradients */
form[action*="logout"] button {
    background-image: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    color: #fff !important;
    border-color: transparent !important;
}

#choose-files {
    background-image: linear-gradient(135deg, #fb923c, #f97316) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

#play-all {
    background-image: linear-gradient(135deg, #22c55e, #15803d) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

#export-video {
    background-image: linear-gradient(135deg, #facc15, #f59e0b) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

body.theme-light #choose-files,
body.theme-light #play-all {
    color: #ffffff !important;
}

body.theme-light #export-video {
    color: #ffffff !important;
}

body.theme-light i.fa-solid,
body.theme-light i.fa-regular {
    color: currentColor;
    display: inline-block;
}

/* Icon follows text color in all contexts */
button i.fa-solid,
button i.fa-regular,
a.rounded-xl i.fa-solid,
a.rounded-xl i.fa-regular,
.docu-btn i.fa-solid,
.docu-btn i.fa-regular {
    color: #ffffff !important;
}

button,
button *,
a.rounded-xl,
a.rounded-xl *,
.docu-btn,
.docu-btn * {
    color: #ffffff !important;
}

/* Modal close buttons keep neutral style */
button[data-close-modal] {
    background-image: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    border-color: transparent !important;
    color: #ffffff !important;
    box-shadow: 0 10px 20px rgba(185, 28, 28, 0.28) !important;
}

button[data-close-modal]:hover {
    filter: brightness(1.06) !important;
    color: #ffffff !important;
}

body.theme-light button.rounded-xl,
body.theme-light button.rounded-xl *,
body.theme-light a.rounded-xl,
body.theme-light a.rounded-xl *,
body.theme-light .docu-btn,
body.theme-light .docu-btn * {
    color: #ffffff !important;
}

/* Slide action buttons in light mode */
body.theme-light .docu-btn-subtle {
    background-image: none !important;
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

body.theme-light [data-action="preview"].docu-btn-subtle {
    background-color: #dbeafe !important;
    border-color: #93c5fd !important;
    color: #1e3a8a !important;
}

body.theme-light [data-action="remove"].docu-btn-danger {
    background-image: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
}

body.theme-light [data-action="rerun"].docu-btn-subtle {
    background-color: #fef3c7 !important;
    border-color: #fcd34d !important;
    color: #92400e !important;
}

body.theme-light [data-action="retry-audio"].docu-btn-main {
    background-image: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: #ffffff !important;
}

body.theme-light [data-action="move-up"].docu-btn-subtle,
body.theme-light [data-action="move-down"].docu-btn-subtle,
body.theme-light [data-action="drag-handle"].docu-btn-subtle {
    background-color: #ecfeff !important;
    border-color: #67e8f9 !important;
    color: #155e75 !important;
}

body.theme-light [data-action="tts"].docu-btn-main {
    background-image: linear-gradient(135deg, #06b6d4, #2563eb) !important;
    color: #ffffff !important;
}

body.theme-light [data-action="toggle-play"].docu-btn-main {
    background-image: linear-gradient(135deg, #22c55e, #15803d) !important;
    color: #ffffff !important;
}

body.theme-light .docu-btn-main {
    background-image: linear-gradient(135deg, #0ea5e9, #2563eb) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

body.theme-light .docu-btn-danger {
    background-image: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

@media (max-width: 640px) {
    #choose-files,
    #append-files {
        font-size: 0.72rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        gap: 0.3rem !important;
        white-space: nowrap;
    }

    #upload-state {
        min-height: 180px;
        padding: 1.25rem !important;
    }
}

/* User management button palette */
button.btn-add.rounded-xl,
button.btn-add.rounded-xl *,
a.btn-add.rounded-xl,
a.btn-add.rounded-xl * {
    background-image: linear-gradient(135deg, #fb923c, #f97316) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

button.btn-edit.rounded-xl,
button.btn-edit.rounded-xl *,
a.btn-edit.rounded-xl,
a.btn-edit.rounded-xl * {
    background-image: linear-gradient(135deg, #22c55e, #15803d) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

button.btn-delete.rounded-xl,
button.btn-delete.rounded-xl *,
a.btn-delete.rounded-xl,
a.btn-delete.rounded-xl * {
    background-image: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

button.btn-default.rounded-xl,
button.btn-default.rounded-xl *,
a.btn-default.rounded-xl,
a.btn-default.rounded-xl * {
    background-image: linear-gradient(135deg, #111827, #000000) !important;
    color: #ffffff !important;
    border-color: transparent !important;
}

/* Drag & drop upload zone */
#upload-state {
    transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#upload-state.drop-active {
    border-color: #22d3ee !important;
    background-color: rgba(34, 211, 238, 0.08) !important;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}
