:root {
    color-scheme: dark light;
    font-family: "Segoe UI", Roboto, sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    padding: 1.5rem 2rem 1.25rem;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.6);
}

.top-bar h1 {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
}

.top-bar p {
    margin: 0;
    max-width: 720px;
    color: #cbd5f5;
}

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(640px, 1fr);
    gap: 1.5rem;
    padding: 1.5rem 2rem 2.5rem;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.controls h2,
.controls h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

select,
button {
    font: inherit;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background-color: rgba(15, 23, 42, 0.85);
    color: inherit;
    cursor: pointer;
    transition: transform 80ms ease, background-color 120ms ease;
}

select:focus,
button:focus {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}

button.primary {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    border-color: transparent;
    color: #0f172a;
    font-weight: 600;
}

button.secondary {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(59, 130, 246, 0.5);
}

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

.control-row {
    display: flex;
    gap: 0.75rem;
}

.step-list ol {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.download-card {
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-card p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.9rem;
}

.download-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    color: #0f172a;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.25);
    transition: transform 80ms ease, box-shadow 120ms ease;
}

.download-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35);
}

.download-button::before {
    content: "⇩";
    font-size: 1rem;
}

.metrics-panel {
    padding: 1rem;
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(59, 130, 246, 0.25);
    backdrop-filter: blur(6px);
}

.metrics-panel dl {
    margin: 0;
    display: grid;
    gap: 0.5rem 1rem;
}

.metrics-panel dt {
    font-weight: 600;
}

.metrics-panel dd {
    margin: 0.1rem 0 0.35rem;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.95rem;
    color: #fbbf24;
}

.snapshots {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.snapshot-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.status-line {
    font-size: 0.85rem;
    color: #94a3b8;
}

#snapshot-list {
    display: grid;
    gap: 0.75rem;
}

.snapshot {
    position: relative;
    margin: 0;
    padding: 0.5rem;
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.snapshot canvas {
    width: 100%;
    border-radius: 0.5rem;
    display: block;
}

.snapshot figcaption {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.snapshot button.remove {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.viewer {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-wrapper {
    position: relative;
    background: #000;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.35);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.45);
    aspect-ratio: 16 / 9;
    min-height: clamp(520px, 65vh, 780px);
}

video#preview,
canvas#overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

canvas#overlay {
    cursor: crosshair;
}

.focus-gauge {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(90%, 420px);
    background: rgba(15, 23, 42, 0.65);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    backdrop-filter: blur(4px);
}

.gauge-bar {
    flex: 1;
    height: 0.65rem;
    background: rgba(30, 41, 59, 0.9);
    border-radius: 999px;
    overflow: hidden;
}

#gauge-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ef4444, #f97316, #facc15, #22c55e);
    transition: width 160ms ease;
}

#gauge-label {
    min-width: 70px;
    text-align: right;
    font-weight: 600;
}

.notice {
    position: absolute;
    bottom: calc(1.25rem + 3.75rem);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.75);
    border-radius: 999px;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    letter-spacing: 0.01em;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

#processing-canvas {
    display: none;
}

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

    .controls {
        order: 2;
    }

    .viewer {
        order: 1;
    }
}
