/* ======================================================
   Compress — Warm Tactile Design
   Light, physical, not-a-template aesthetic
   ====================================================== */

:root {
    --bg: #FAF8F5;
    --surface: #FFFFFF;
    --surface-dim: #F0EDE8;
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.1);
    --text: #1A1A1A;
    --text-2: #6B6B6B;
    --text-3: #707070; /* was #A0A0A0 — 2.5:1 on --bg, failed WCAG AA for the hints/meta text it colors */
    --accent: #F97316;
    --accent-hover: #EA580C;
    --accent-soft: rgba(249, 115, 22, 0.08);
    --accent-glow: rgba(249, 115, 22, 0.15);
    --success: #10B981;
    --success-soft: rgba(16, 185, 129, 0.08);
    --danger: #E11D48;
    --r: 16px;
    --r-lg: 24px;
    --r-full: 9999px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.05);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --font: 'Space Grotesk', -apple-system, system-ui, sans-serif;
    --font-serif: 'DM Serif Display', Georgia, serif;
    --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, monospace;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

body { position: fixed; width: 100%; }

#app {
    position: relative;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

button, label, .quality-pills, .meta-strip, .screen-nav, .badge {
    user-select: none;
    -webkit-user-select: none;
}

/* Keyboard-only focus ring (mouse/touch never triggers :focus-visible) */
:is(button, a, input, label[tabindex]):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ======================================================
   Screen System
   ====================================================== */

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    transform: translateX(105%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.45s var(--ease), opacity 0.35s var(--ease), visibility 0s 0.45s;
    will-change: transform, opacity;
    z-index: 1;
}

.screen.active {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    z-index: 2;
    transition: transform 0.45s var(--ease), opacity 0.35s var(--ease), visibility 0s 0s;
}

.screen.exit-left {
    transform: translateX(-25%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.45s var(--ease), opacity 0.35s var(--ease), visibility 0s 0.45s;
}

.screen-inner {
    flex: 1;
    padding: 0 24px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.screen-inner::-webkit-scrollbar { width: 0; }

.scroll-y { padding-bottom: 100px; }

.center-v {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ---- Nav bar ---- */
.screen-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    padding-top: calc(8px + var(--safe-t));
    min-height: 52px;
    background: rgba(250, 248, 245, 0.8);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-back {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: none;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-full);
    min-width: 44px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--spring);
}
.nav-back:active { transform: scale(0.88); }
.nav-back svg { width: 20px; height: 20px; }

.nav-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nav-spacer { flex: 1; }

/* ---- Screen bottom ---- */
.screen-bottom {
    padding: 12px 24px;
    padding-bottom: calc(16px + var(--safe-b));
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ======================================================
   Screen 1 — Select
   ====================================================== */

#screen-select .screen-inner {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: calc(72px + var(--safe-t));
    padding-bottom: calc(56px + var(--safe-b)); /* clears the engine-status chip */
    gap: 40px;
}

@media (max-height: 740px) {
    #screen-select .screen-inner {
        gap: 20px;
        padding-top: calc(56px + var(--safe-t));
    }
    #screen-select .specs { display: none; }
    #screen-select .file-picker {
        aspect-ratio: auto;
        min-height: 140px;
        max-height: 24vh;
    }
}

.select-top {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.eyebrow {
    display: flex;
    align-self: flex-start;
    align-items: baseline;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    min-width: 220px;
}
.eyebrow-num { color: var(--accent); font-weight: 700; }
.eyebrow-label { color: var(--text-2); }

.select-top h1 {
    font-family: var(--font-serif);
    font-size: clamp(48px, 12vw, 72px);
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: -0.015em;
    color: var(--text);
    margin-top: -4px;
}

.tagline {
    font-size: 16px;
    color: var(--text-2);
    max-width: 360px;
    line-height: 1.55;
}
.tagline em {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    color: var(--text);
    font-size: 1.06em;
    letter-spacing: 0.005em;
}

/* ---- File Picker ---- */
.file-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 30vh;
    min-height: 180px;
    flex-shrink: 0;
    border-radius: var(--r-lg);
    cursor: pointer;
    background: var(--surface);
    border: 2px dashed var(--border-strong);
    box-shadow: var(--shadow);
    transition: transform 0.3s var(--spring), border-color 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.file-picker::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent-soft) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
}

.file-picker:active {
    transform: scale(0.97);
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}
.file-picker:active::before { opacity: 1; }

.file-picker.drag-over {
    border-color: var(--accent);
    border-style: solid;
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
}
.file-picker.drag-over::before { opacity: 1; }

.picker-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.picker-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: white;
    border-radius: var(--r);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    transition: transform 0.3s var(--spring);
}
.file-picker:active .picker-icon { transform: scale(1.08); }
.picker-icon svg { width: 28px; height: 28px; }

.picker-label {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.picker-sub {
    font-size: 13px;
    color: var(--text-3);
    display: none;
}

@media (min-width: 640px) {
    .picker-sub { display: block; }
}

/* ---- URL download section ---- */
.url-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.url-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.url-divider::before,
.url-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-strong);
}

.url-input-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.url-input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    min-width: 0;
}

.url-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-input::placeholder {
    color: var(--text-3);
    font-weight: 400;
}

.url-go-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: none;
    background: var(--accent);
    color: white;
    border-radius: var(--r);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
    transition: transform 0.2s var(--spring);
    flex-shrink: 0;
}

.url-go-btn:active { transform: scale(0.9); }
.url-go-btn:disabled { opacity: 0.4; pointer-events: none; }
.url-go-btn svg { width: 20px; height: 20px; }

.url-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    animation: slideUp 0.3s var(--spring);
}

.url-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.url-status.done .url-status-dot {
    background: var(--success);
    animation: none;
}

.url-status.error .url-status-dot {
    background: var(--danger);
    animation: none;
}

/* ---- URL action buttons ---- */
.url-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: slideUp 0.3s var(--spring);
}

/* All five action buttons share one uniform grid. The Audio button spans
   the bottom row so the layout is 2 / 2 / 1 with everything the same height. */
.url-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.url-actions-grid .url-action-wide {
    grid-column: 1 / -1;
}

.url-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 12px 14px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--spring), opacity 0.2s ease;
}

.url-action:active { transform: scale(0.94); }
.url-action svg { width: 18px; height: 18px; flex-shrink: 0; }

.url-action.save {
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
    background: var(--success-soft);
}

.url-action.compress {
    border-color: rgba(26, 26, 26, 0.15);
    color: var(--text);
    background: var(--surface);
}

.url-action.edit {
    border-color: rgba(249, 115, 22, 0.2);
    color: var(--accent);
    background: var(--accent-soft);
}

.url-action.audio {
    border-color: rgba(99, 102, 241, 0.25);
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}

.url-action.share {
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.url-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.url-share-hint {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--text-3);
    text-align: center;
    line-height: 1.4;
    word-break: break-all;
}

/* When URL flow is active, collapse the file picker + about link
   so the action buttons can breathe and fill the freed space. */
.screen.url-active .file-picker,
.screen.url-active .url-divider,
.screen.url-active .about-link,
.screen.url-active .select-top .tagline {
    display: none;
}
.screen.url-active .select-top h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

/* When URL flow is active, give the action grid more breathing room
   so the (uniform-sized) buttons read as the focus. */
.screen.url-active .url-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: flex-end;
    padding-bottom: 16px;
}
.screen.url-active .url-actions {
    gap: 10px;
}
.screen.url-active .url-actions-grid {
    gap: 10px;
}
.screen.url-active .url-action {
    min-height: 64px;
    padding: 16px 14px;
    font-size: 14px;
}
.screen.url-active .url-action svg {
    width: 20px;
    height: 20px;
}

/* ---- Engine status chip ----
   Informational overlay: never intercept taps, and .screen-inner reserves
   bottom padding so content can always scroll clear of it. */
.engine-status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    padding-bottom: calc(14px + var(--safe-b));
    transition: opacity 0.4s;
}

.engine-status.ready {
    opacity: 0;
    pointer-events: none;
    transition-delay: 1.5s;
}

.engine-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-dot 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

.engine-status.ready .engine-dot {
    background: var(--success);
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.engine-label {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-3);
    font-weight: 400;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    text-transform: uppercase;
}

.engine-progress {
    flex: 1;
    height: 3px;
    background: var(--surface-dim);
    border-radius: 2px;
    overflow: hidden;
}

.engine-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s var(--ease);
}

.engine-status.ready .engine-progress {
    display: none;
}

/* ---- Resume card ----
   In-flow flex child pinned below the scroller (.screen-inner shrinks to
   make room) — an absolute overlay here covers the About link. */
.resume-card {
    margin: 8px 24px calc(12px + var(--safe-b));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--border-strong);
    animation: slideUp 0.35s var(--spring);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.resume-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.resume-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resume-meta {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.resume-btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--r-full);
    background: var(--text);
    color: var(--surface);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s var(--spring);
}

.resume-btn:active { transform: scale(0.94); }

/* Install prompt (mobile PWA) — sibling to resume-card, stacks below it */
.install-card {
    margin: 8px 24px calc(12px + var(--safe-b));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 14px 14px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-lg);
    border: 1.5px solid var(--border-strong);
    animation: slideUp 0.35s var(--spring);
}
.install-card.hidden { display: none; }

.install-dismiss {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}
.install-dismiss:hover { background: var(--surface-dim); color: var(--text); }
.install-dismiss:active { transform: scale(0.9); }
.install-dismiss svg { width: 12px; height: 12px; }

.install-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
}
.install-icon svg { width: 22px; height: 22px; }

.install-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-right: 22px;
}
.install-title { font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.005em; }
.install-sub { font-size: 12px; color: var(--text-2); font-weight: 500; line-height: 1.45; }

.install-btn {
    padding: 9px 18px;
    border: none;
    border-radius: var(--r-full);
    background: var(--text);
    color: var(--surface);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.18s var(--spring), background 0.15s;
    white-space: nowrap;
}
.install-btn:active { transform: scale(0.94); }

/* iOS variant: no button (no programmatic install), instruction text grows */
.install-card.ios .install-btn { display: none; }
.install-card.ios .install-sub { font-size: 12.5px; }
.install-card.ios .install-icon { background: var(--text); }

/* "Open in browser" variant for in-app webviews */
.install-card.webview .install-btn { display: none; }
.install-card.webview .install-icon { background: var(--text-2); }

/* When resume-card is visible too, tighten the stack gap */
.resume-card:not(.hidden) ~ .install-card { margin-top: 0; }

/* ======================================================
   Screen 2 — Options
   ====================================================== */

.preview-card {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-xl);
    margin-bottom: 20px;
}

.preview-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---- Meta strip ---- */
.meta-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 0;
    margin-bottom: 28px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.meta-val {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.meta-key {
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-3);
    opacity: 0.5;
}

/* ---- Quality pills ---- */
.quality-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quality-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill {
    flex: 1;
    min-width: 0;
    padding: 12px 8px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.25s var(--spring);
    box-shadow: var(--shadow-sm);
    text-align: center;
    white-space: nowrap;
}

.pill:active:not(:disabled) { transform: scale(0.94); }

.pill:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pill.active {
    background: var(--text);
    color: var(--surface);
    border-color: var(--text);
    box-shadow: var(--shadow);
}

.pill.accent.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.quality-hint {
    font-size: 14px;
    color: var(--text-3);
    line-height: 1.5;
    padding: 0 4px;
}

/* ======================================================
   Buttons
   ====================================================== */

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--r);
    background: var(--text);
    color: var(--surface);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s var(--spring), box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.06), transparent);
    pointer-events: none;
}

.btn-primary:active {
    transform: scale(0.97) translateY(1px);
    box-shadow: var(--shadow);
}

.btn-primary:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn-primary svg, .btn-ico { width: 18px; height: 18px; }

.btn-ghost {
    width: 100%;
    padding: 14px 24px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--spring);
}

.btn-ghost:active { transform: scale(0.97); }

.btn-ghost.danger {
    color: var(--danger);
    border-color: rgba(225, 29, 72, 0.2);
    background: rgba(225, 29, 72, 0.04);
}

.btn-text {
    width: 100%;
    padding: 10px 24px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
}
.btn-text:active { color: var(--text-2); }

.share-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-3);
    text-align: center;
    line-height: 1.4;
}

/* ======================================================
   Screen 3 — Progress
   ====================================================== */

.progress-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.progress-ring-wrap {
    position: relative;
    width: 180px;
    height: 180px;
    display: grid;
    place-items: center;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--surface-dim);
    stroke-width: 5;
}

.ring-fill {
    fill: none;
    stroke: url(#ringGrad);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 427.26;
    stroke-dashoffset: 427.26;
    transition: stroke-dashoffset 0.5s var(--ease);
}

.ring-label {
    position: absolute;
    display: flex;
    align-items: baseline;
}

.ring-pct {
    font-size: 52px;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.ring-sym {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-3);
    margin-left: 2px;
}

.progress-msg {
    font-size: 15px;
    color: var(--text-3);
    font-weight: 500;
}

/* ======================================================
   Screen 4 — Done
   ====================================================== */

.done-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.done-icon {
    width: 72px;
    height: 72px;
    animation: pop 0.5s var(--spring);
}
.done-icon svg { width: 100%; height: 100%; }

.size-compare {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 260px;
}

.size-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 14px 20px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

.size-row.result {
    background: var(--success-soft);
    box-shadow: none;
    border: 1.5px solid rgba(16, 185, 129, 0.2);
}

.size-label {
    font-size: 14px;
    color: var(--text-3);
    font-weight: 500;
}

.size-val {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.size-row.result .size-val { color: var(--success); }

/* Output grew — don't dress the After row in success green */
.size-row.result.grew {
    background: rgba(180, 83, 9, 0.10);
    border-color: rgba(180, 83, 9, 0.25);
}
.size-row.result.grew .size-val { color: #B45309; }

.size-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-3);
    opacity: 0.4;
}
.size-arrow svg { width: 100%; height: 100%; }

.savings-badge {
    display: inline-flex;
    padding: 8px 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-soft);
    border-radius: var(--r-full);
}
.savings-badge.grew {
    color: #B45309;
    background: rgba(180, 83, 9, 0.10);
}

/* ---- Done header (replaces center-v) ---- */
.done-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: calc(40px + var(--safe-t));
    padding-bottom: 8px;
}

/* ======================================================
   Stats Panel
   ====================================================== */

.stats-panel {
    margin-top: 24px;
    padding-bottom: 20px;
}

.stats-heading {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 16px;
}

.stats-group {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    padding: 4px 0;
    margin-bottom: 12px;
    overflow: hidden;
}

.stats-group-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    padding: 10px 16px 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 16px;
    gap: 12px;
}

.stat-row + .stat-row {
    border-top: 1px solid var(--border);
}

.stat-key {
    font-size: 13px;
    color: var(--text-2);
    font-weight: 500;
}

.stat-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.stat-val.highlight {
    color: var(--success);
    font-weight: 700;
}

.stats-explainer {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-3);
    padding: 8px 16px 12px;
}

/* ======================================================
   Estimation
   ====================================================== */

.estimate-section {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.estimate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
}

.estimate-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.estimate-label {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.estimate-value {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.estimate-tag {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: var(--surface-dim);
    color: var(--text-3);
}

.estimate-tag.good {
    background: var(--success-soft);
    color: var(--success);
}

.btn-test {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r);
    background: none;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s var(--spring);
}

.btn-test:active {
    transform: scale(0.97);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-test:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn-test svg {
    width: 16px;
    height: 16px;
}

/* ---- Test steps checklist ---- */
.test-steps {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    opacity: 0.35;
    transition: opacity 0.3s;
}

.step.active, .step.done {
    opacity: 1;
}

.step-icon {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    margin-top: 1px;
    position: relative;
    transition: border-color 0.3s, background 0.3s;
}

.step.active .step-icon {
    border-color: var(--accent);
    border-top-color: transparent;
    animation: spin 0.7s linear infinite;
}

.step.done .step-icon {
    border-color: var(--success);
    background: var(--success);
}

.step.done .step-icon::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 5px;
    width: 5px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.step-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.step-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.step-detail {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.step-detail:empty {
    display: none;
}

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

/* ======================================================
   Screen 5 — About
   ====================================================== */

.about-content {
    padding-top: 16px;
    padding-bottom: 40px;
}

.about-content h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 20px;
}

.about-content h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 10px;
}

.about-content p {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-2);
    margin-bottom: 16px;
}

.about-checklist {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.about-checklist li {
    position: relative;
    padding-left: 26px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-2);
}
.about-checklist li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.about-checklist li::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    width: 5px;
    height: 9px;
    border: solid var(--accent);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.about-checklist li strong {
    color: var(--text);
    font-weight: 600;
}

.about-divider {
    width: 40px;
    height: 3px;
    background: var(--surface-dim);
    border-radius: 2px;
    margin: 28px 0;
}

.about-link-ext {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    padding: 10px 0;
    transition: opacity 0.2s;
}

.about-link-ext:active { opacity: 0.7; }

.about-link-ext svg {
    width: 16px;
    height: 16px;
}

.about-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.about-footer p {
    font-size: 14px;
    color: var(--text-3);
    font-style: italic;
}

/* ---- Specs block (home) ---- */
.specs {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.spec-row {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 16px;
    align-items: baseline;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.55;
}
.spec-key {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    font-size: 11px;
}
.spec-val {
    color: var(--text-2);
}
.screen.url-active .specs {
    display: none;
}

/* ---- About link on home screen ---- */
.about-link {
    display: block;
    text-align: center;
    padding: 12px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.about-link:active { color: var(--text-2); }

/* ======================================================
   Animations
   ====================================================== */

@keyframes pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* ======================================================
   Desktop
   ====================================================== */

@media (min-width: 640px) {
    #app {
        max-width: 440px;
        margin: 0 auto;
        box-shadow: -1px 0 0 var(--border), 1px 0 0 var(--border);
    }

    .file-picker:hover {
        border-color: var(--accent);
        box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
    }
    .file-picker:hover::before { opacity: 1; }
    .file-picker:hover .picker-icon { transform: scale(1.08); }

    .btn-primary:hover {
        box-shadow: var(--shadow-xl);
    }

    .pill:hover {
        border-color: var(--text-3);
    }
}

/* ======================================================
   Screen 6 — Edit / Trim
   ====================================================== */

.edit-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---- Video preview ---- */
.edit-preview-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    flex-shrink: 0;
}

.edit-preview-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.edit-time-display {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 3px 8px;
    border-radius: 6px;
}

.edit-time-sep {
    opacity: 0.5;
    margin: 0 2px;
}

/* ---- Playback controls ---- */
.edit-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    flex-shrink: 0;
}

.edit-ctrl-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: none;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-full);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s var(--spring);
}

.edit-ctrl-btn:active { transform: scale(0.88); }
.edit-ctrl-btn svg { width: 22px; height: 22px; }

/* ---- Timeline ---- */
.timeline-container {
    padding: 0 24px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ---- Zoom controls ---- */
.timeline-zoom-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-btn {
    position: relative;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-full);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s var(--spring);
}
/* Invisible hit-area extension to a ~44px touch target */
.zoom-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
}
.zoom-btn:active { transform: scale(0.88); }
.zoom-btn svg { width: 14px; height: 14px; }

.zoom-track {
    flex: 1;
    height: 4px;
    background: var(--surface-dim);
    border-radius: 2px;
    overflow: hidden;
}

.zoom-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.15s var(--ease);
}

.zoom-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Timeline ruler ---- */
.timeline-ruler {
    position: relative;
    height: 16px;
    overflow: hidden;
}

.ruler-mark {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
}

.ruler-tick {
    width: 1px;
    height: 5px;
    background: var(--text-3);
    opacity: 0.4;
}

.ruler-tick.major {
    height: 8px;
    opacity: 0.7;
}

.ruler-time {
    font-size: 9px;
    color: var(--text-3);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    margin-top: 1px;
}

.timeline-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /* Let the browser own single-finger horizontal panning; JS handles taps,
       mouse scrubbing and two-finger pinch-zoom. */
    touch-action: pan-x;
    border-radius: var(--r);
    box-shadow: var(--shadow);
    border: 1.5px solid var(--border-strong);
    background: var(--surface);
}

.timeline-scroll::-webkit-scrollbar { display: none; }

.timeline-track {
    position: relative;
    height: 56px;
    min-width: 100%;
}

#timelineThumbs {
    display: block;
    height: 56px;
    width: 100%;
    border-radius: var(--r);
}

/* ---- Segments overlay ---- */
.timeline-segments {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.timeline-segment {
    position: absolute;
    top: 0;
    bottom: 0;
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.2s;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.timeline-segment:last-child {
    border-right: none;
}

.timeline-segment.selected {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    z-index: 2;
}

.timeline-segment.deleted {
    background: rgba(225, 29, 72, 0.45);
}

.timeline-segment.deleted::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 4px,
        rgba(225, 29, 72, 0.2) 4px,
        rgba(225, 29, 72, 0.2) 8px
    );
}

/* ---- Split markers ---- */
.timeline-split {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    transform: translateX(-1.5px);
    z-index: 3;
    pointer-events: none;
    box-shadow: 0 0 4px rgba(249, 115, 22, 0.5);
}

.timeline-split::before,
.timeline-split::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
}

.timeline-split::before { top: -4px; }
.timeline-split::after { bottom: -4px; }

/* ---- Playhead ---- */
.timeline-playhead {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 2px;
    background: white;
    z-index: 5;
    /* The thin line stays click-through; the ::after knob is the grab target
       so it doesn't block taps/clicks on the timeline body or segments. */
    pointer-events: none;
    touch-action: none;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    transition: left 0.05s linear;
}

.timeline-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid white;
}

/* Enlarged, invisible grab target around the playhead knob (44x40 — full
   touch-target size) so the playhead can be dragged for fine scrubbing on
   touch without scrolling. */
.timeline-playhead::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    width: 44px;
    height: 40px;
    transform: translateX(-50%);
    pointer-events: auto;
    cursor: ew-resize;
}

/* ---- Segment list ---- */
.segment-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: none;
}

.segment-list::-webkit-scrollbar { display: none; }

.segment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s var(--spring), opacity 0.2s;
    border: 1.5px solid transparent;
}

.segment-item:active { transform: scale(0.98); }

.segment-item.selected {
    border-color: var(--accent);
}

.segment-item.deleted {
    opacity: 0.45;
    text-decoration: line-through;
}

.segment-item-num {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: var(--r-full);
    background: var(--surface-dim);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    flex-shrink: 0;
}

.segment-item.deleted .segment-item-num {
    background: rgba(225, 29, 72, 0.1);
    color: var(--danger);
}

.segment-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.segment-item-time {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.segment-item-dur {
    font-size: 11px;
    color: var(--text-3);
    font-weight: 500;
}

.segment-item-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: var(--r-full);
    flex-shrink: 0;
}

.segment-item-status.keep {
    background: var(--success-soft);
    color: var(--success);
}

.segment-item-status.cut {
    background: rgba(225, 29, 72, 0.08);
    color: var(--danger);
}

/* ---- Edit bottom bar ---- */
.edit-bottom {
    gap: 12px !important;
}

.edit-actions {
    display: flex;
    gap: 8px;
}

.edit-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 8px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s var(--spring);
    box-shadow: var(--shadow-sm);
}

.edit-action-btn:active:not(:disabled) { transform: scale(0.94); }

.edit-action-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.edit-action-btn svg {
    width: 20px;
    height: 20px;
}

.edit-action-btn.danger {
    color: var(--danger);
    border-color: rgba(225, 29, 72, 0.15);
}

/* ======================================================
   Utilities
   ====================================================== */
.hidden { display: none !important; }

/* Toast — transient error/status messages (created by app.js showToast) */
.app-toast {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom, 24px));
    transform: translateX(-50%) translateY(12px);
    max-width: min(90vw, 420px);
    padding: 12px 18px;
    background: var(--text);
    color: var(--bg);
    font-size: 14px;
    line-height: 1.4;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 1000;
}
.app-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
