:root {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #111827;
    --panel-border: rgba(148, 163, 184, 0.18);
    --text: #e5eef9;
    --muted: #9aa9bd;
    --accent: #38bdf8;
    --accent-2: #22c55e;
    --danger: #fb7185;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top, rgba(56, 189, 248, 0.16), transparent 30%),
        linear-gradient(180deg, #020617, #111827 45%, #020617);
    color: var(--text);
}

img {
    display: block;
    max-width: 100%;
}

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

.app-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.hero,
.panel {
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    backdrop-filter: blur(18px);
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.32);
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}

.hero h1,
.panel h2,
.panel h3 {
    margin: 0;
}

.hero h1 {
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.1;
    max-width: 820px;
}

.lead {
    color: var(--muted);
    font-size: 17px;
    line-height: 1.6;
    max-width: 760px;
    margin: 16px 0 0;
}

.hero-note {
    min-width: 220px;
    align-self: flex-start;
    padding: 16px 18px;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 14px;
    display: grid;
    gap: 8px;
}

.hero-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hero-metrics span {
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.18);
    font-size: 12px;
    color: #d7e5f5;
}

.panel {
    padding: 22px;
}

.workspace {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 22px;
    margin-top: 22px;
}

.panel-header,
.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.status-chip {
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(148, 163, 184, 0.12);
    color: var(--muted);
    font-size: 13px;
    border: 1px solid transparent;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.status-chip.status-busy-highlight {
    color: #d9ffe7;
    background: rgba(57, 255, 20, 0.18);
    border-color: rgba(57, 255, 20, 0.95);
    box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.35), 0 0 12px rgba(57, 255, 20, 0.45), 0 0 24px rgba(57, 255, 20, 0.22);
    animation: busyPulse 0.9s ease-in-out infinite;
}

@keyframes busyPulse {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 1px rgba(57, 255, 20, 0.35), 0 0 12px rgba(57, 255, 20, 0.45), 0 0 24px rgba(57, 255, 20, 0.22);
    }

    50% {
        transform: scale(1.03);
        box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.55), 0 0 18px rgba(57, 255, 20, 0.65), 0 0 34px rgba(57, 255, 20, 0.32);
    }
}

.upload-form {
    display: flex;
    gap: 16px;
    align-items: stretch;
    flex-wrap: wrap;
}

.upload-box {
    flex: 1 1 280px;
    min-height: 120px;
    display: grid;
    place-content: center;
    gap: 8px;
    border: 1px dashed rgba(56, 189, 248, 0.5);
    border-radius: 18px;
    text-align: center;
    cursor: pointer;
    background: rgba(2, 132, 199, 0.08);
}

.upload-box input {
    display: none;
}

.upload-box span {
    font-size: 18px;
    font-weight: 700;
}

.upload-box small {
    color: var(--muted);
}

.controls-grid {
    display: grid;
    gap: 16px;
}

.controls-grid label {
    display: grid;
    gap: 10px;
}

.controls-grid label > span:first-child {
    font-weight: 700;
}

.controls-grid input[type="range"],
.controls-grid select {
    width: 100%;
}

.controls-grid output {
    color: var(--accent);
    font-weight: 700;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.primary-button,
.ghost-link {
    border: 0;
    border-radius: 12px;
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
}

.primary-button {
    color: #02131d;
    background: linear-gradient(135deg, var(--accent), #67e8f9);
}

.primary-button:hover,
.ghost-link:hover {
    transform: translateY(-1px);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.download-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.result-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.result-badge {
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: #cceeff;
    font-size: 12px;
    font-weight: 700;
}

.ghost-link {
    padding: 10px 14px;
    background: rgba(148, 163, 184, 0.12);
    color: var(--text);
}

.ghost-link.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.hidden {
    display: none !important;
}

body.security-lockdown {
    overflow: hidden;
}

body.security-lockdown .app-shell {
    pointer-events: none;
    user-select: none;
    filter: blur(4px) saturate(0.6);
}

.security-lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(2, 6, 23, 0.92);
}

.security-lock-card {
    width: min(680px, 100%);
    padding: 28px;
    border-radius: 20px;
    border: 1px solid rgba(251, 113, 133, 0.35);
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(15, 23, 42, 0.98));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.security-lock-eyebrow {
    margin: 0 0 10px;
    color: var(--danger);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    font-weight: 700;
}

.security-lock-copy {
    margin: 14px 0 18px;
    color: var(--muted);
    line-height: 1.6;
}

.security-lock-details {
    margin: 0;
    padding: 16px;
    border-radius: 14px;
    overflow: auto;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: #f8fafc;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.preview-grid figure {
    margin: 0;
    display: grid;
    gap: 10px;
}

.preview-grid figcaption {
    color: var(--muted);
    font-weight: 700;
}

.preview-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: rgba(148, 163, 184, 0.08);
    border-radius: 16px;
    border: 1px solid var(--panel-border);
}

.result-actions {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.result-action-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.85), rgba(2, 6, 23, 0.75));
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.result-action-card h3 {
    margin: 0 0 8px;
}

.result-action-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.retention-alert {
    display: grid;
    gap: 6px;
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(251, 191, 36, 0.32);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.12), rgba(251, 113, 133, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.retention-alert strong {
    color: #fde68a;
    font-size: 15px;
}

.retention-alert span {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.result-expiry {
    color: #fcd34d;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.viewer-wrap,
.metadata-box {
    margin-top: 18px;
    padding: 18px;
    background: rgba(2, 6, 23, 0.45);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
}

#viewerCanvas {
    width: 100%;
    height: 420px;
    display: block;
    border-radius: 14px;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.12), rgba(2, 6, 23, 0.9));
}

.metadata-box pre {
    margin: 0;
    white-space: pre-wrap;
    color: #c9d8ea;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(8px);
}

.loading-card {
    width: min(420px, 100%);
    padding: 28px 24px;
    border-radius: 22px;
    border: 1px solid rgba(56, 189, 248, 0.22);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.98));
    box-shadow: 0 26px 60px rgba(2, 6, 23, 0.45);
    text-align: center;
}

.loading-spinner {
    width: 68px;
    height: 68px;
    margin: 0 auto 18px;
    border-radius: 50%;
    border: 6px solid rgba(148, 163, 184, 0.16);
    border-top-color: var(--accent);
    border-right-color: #67e8f9;
    animation: loadingSpin 0.9s linear infinite;
}

.loading-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.loading-copy {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

@keyframes loadingSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

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

    .result-actions {
        grid-template-columns: 1fr;
    }

    .hero {
        flex-direction: column;
    }
}
