:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --error: #ef4444;
    --success: #22c55e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
}

.card {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

select,
input[type="date"],
input[type="range"],
input[type="text"],
input[type="time"] {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: #0f172a;
    border: 1px solid #334155;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

select:focus,
input[type="date"]:focus,
input[type="text"]:focus,
input[type="time"]:focus {
    border-color: var(--accent);
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.primary-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 0.5rem;
    background: var(--accent);
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    transition: all 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(56, 189, 248, 0.1);
}

.status-msg {
    margin-top: 1.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
}

.status-msg.info {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
}

.status-msg.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.status-msg.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.hidden {
    display: none;
}

.video-actions {
    margin-top: 1.5rem;
    text-align: center;
}

footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Custom Range Slider */
input[type="range"] {
    padding: 0;
    height: 8px;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

/* ── History Section ─────────────────────────────────────── */
.history-section {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 0 2rem;
}

/* Sortable column headers */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.sortable:hover {
    color: var(--text-primary);
}

.sortable.sorted {
    color: var(--accent);
}

.sort-arrow {
    font-size: 0.6rem;
    opacity: 0.35;
    margin-left: 0.15rem;
}

.sort-arrow.active {
    opacity: 1;
    color: var(--accent);
}

/* Mobile sort pills (hidden on desktop) */
.sort-bar {
    display: none;
}

/* Column header row (desktop only) */
.history-header {
    display: grid;
    grid-template-columns: 2.4fr 2fr 72px 90px;
    gap: 0 1.25rem;
    padding: 0 0 0.6rem;
    border-bottom: 1px solid #334155;
    margin-bottom: 0.125rem;
}

.history-header span {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
}

/* Each timelapse row (desktop) */
.history-item {
    display: grid;
    grid-template-columns: 2.4fr 2fr 72px 90px;
    gap: 0 1.25rem;
    align-items: center;
    padding: 0.8rem 0.5rem;
    margin: 0 -0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.hi-bridge {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Shown only in mobile card as combined "size · date" line */
.hi-sub {
    display: none;
}

.hi-range {
    color: var(--text-secondary);
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hi-size {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.hi-action {
    display: flex;
    justify-content: flex-end;
}

.play-btn {
    padding: 0.38rem 0.9rem;
    font-size: 0.8rem;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    font-weight: 600;
}

.play-btn:hover {
    background: rgba(56, 189, 248, 0.25);
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    /* Tighten card padding site-wide on small screens */
    .card {
        padding: 1.25rem 1rem;
        border-radius: 0.75rem;
    }

    .history-header {
        display: none;
    }

    .sort-bar {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        flex-wrap: wrap;
        margin-bottom: 0.625rem;
    }

    .sort-label {
        font-size: 0.7rem;
        color: var(--text-secondary);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-right: 0.1rem;
    }

    .sort-pill {
        padding: 0.25rem 0.75rem;
        font-size: 0.75rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-secondary);
        border-radius: 999px;
        cursor: pointer;
        transition: all 0.15s;
        font-weight: 500;
    }

    .sort-pill.active {
        background: rgba(56, 189, 248, 0.15);
        border-color: var(--accent);
        color: var(--accent);
    }

    .history-items {
        margin-top: 0.5rem;
    }

    /* List-cell layout: bridge + play on row 1, range + meta below */
    .history-item {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0 0.5rem;
        padding: 0.875rem 0;
        margin: 0;
        background: none;
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.07);
        border-radius: 0;
    }

    .history-item:last-child {
        border-bottom: none;
    }

    .history-item:hover {
        background: none;
    }

    /* Fills remaining row width beside the play button */
    .hi-bridge {
        flex: 1;
        min-width: 0;
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Sits beside bridge on same row */
    .hi-action {
        flex-shrink: 0;
    }

    /* Wraps onto its own row */
    .hi-range {
        width: 100%;
        font-size: 0.8rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        margin-top: 0.2rem;
    }

    /* "45.2 MB · 3 Feb 2026" — own row below range */
    .hi-sub {
        display: block;
        width: 100%;
        font-size: 0.73rem;
        color: var(--text-secondary);
        opacity: 0.75;
        margin-top: 0.1rem;
    }

    .hi-size {
        display: none;
    }
}