* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #232733;
    --border: #2e3345;
    --text: #e4e4e7;
    --text-muted: #9499ad;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --favorite: #eab308;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.nav-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--accent);
    text-decoration: none;
}
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: var(--text); }

main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

h1 { font-size: 24px; margin-bottom: 4px; }
h2 { font-size: 20px; margin-bottom: 16px; color: var(--text-muted); }
.subtitle { color: var(--text-muted); margin-bottom: 24px; }
.page-header { margin-bottom: 24px; }
.editable-title { cursor: pointer; }
.editable-title:hover { color: var(--accent-hover); }
.rename-input {
    font-size: inherit; font-weight: inherit; font-family: inherit;
    background: var(--surface2); border: 1px solid var(--accent);
    border-radius: 4px; color: var(--text); padding: 2px 8px;
    width: 100%; outline: none;
}

/* Upload */
.upload-section { max-width: 480px; }
.upload-form { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 14px; font-weight: 500; }
.form-group .hint { font-weight: 400; color: var(--text-muted); font-size: 12px; display: block; }
.form-group input[type="file"],
.form-group input[type="number"] {
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}
.progress-msg {
    margin-top: 16px; padding: 12px;
    background: var(--surface2); border-radius: var(--radius);
    color: var(--accent); font-size: 14px;
    align-items: center; gap: 10px; flex-wrap: wrap;
    display: none;
}
.progress-msg:not([hidden]) { display: flex; }
.progress-bar-track {
    width: 100%; height: 6px;
    background: var(--border); border-radius: 3px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; background: var(--accent);
    border-radius: 3px; transition: width 0.2s ease;
}

/* Buttons */
.btn {
    padding: 10px 20px; border: none; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 6px 14px; font-size: 13px; background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-small:hover { background: var(--border); }
.btn-icon {
    background: none; border: none; cursor: pointer;
    font-size: 20px; color: var(--text-muted); transition: color 0.15s;
    padding: 0; line-height: 1;
}
.btn-icon:hover { color: var(--favorite); }
.btn-icon.active { color: var(--favorite); }
a.btn-icon { text-decoration: none; }
a.btn-icon:hover { color: var(--accent-hover); }

.page-header { display: flex; flex-direction: column; gap: 8px; }
.page-header .btn-small { align-self: flex-start; text-decoration: none; }

/* Video list */
.video-list { display: flex; flex-direction: column; gap: 8px; }
.video-card {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); text-decoration: none; color: var(--text);
    transition: border-color 0.15s;
}
.video-card:hover { border-color: var(--accent); }
.video-card-thumb {
    width: 96px; height: 54px; flex-shrink: 0;
    border-radius: 6px; overflow: hidden;
    border: 1px solid var(--border); background: #0b0d12;
}
.video-card-thumb img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}
.video-card-thumb.placeholder {
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 11px; letter-spacing: 0.02em;
}
.video-card-info { display: flex; flex-direction: column; gap: 2px; }
.video-card-info strong { font-size: 15px; }
.video-card-info span { font-size: 13px; color: var(--text-muted); }
.video-date { font-size: 12px !important; }

.videos-section { margin-top: 40px; }

/* Bulk tag bar */
.bulk-tag-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; margin-bottom: 20px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); flex-wrap: wrap;
}
.bulk-label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.bulk-tag-bar .tag-input { max-width: 220px; }

/* Save bar */
.save-bar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
}

/* Clips grid */
.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}
.clip-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}
.clip-card.deselected { opacity: 0.45; }

/* Clip select checkbox */
.clip-select {
    position: absolute; top: 8px; right: 8px; z-index: 3;
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.5); border-radius: 6px;
    cursor: pointer;
}
.clip-checkbox {
    width: 18px; height: 18px; cursor: pointer;
    accent-color: var(--accent);
}
.clip-video {
    --clip-bottom-bar-height: 32px;
    background-size: cover;
    background-position: center;
    background-color: #000;
    position: relative;
}
.clip-video video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    background: #000;
    position: relative;
    z-index: 0;
}
.video-poster-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--clip-bottom-bar-height);
    z-index: 1;
    opacity: 1;
    pointer-events: auto;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    transition: opacity 0.18s ease;
}
.video-poster-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.video-overlay-play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 52px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}
.video-overlay-play:active {
    transform: translate(-50%, -50%) scale(0.97);
}
.video-overlay-loading {
    position: absolute;
    left: 50%;
    top: calc(50% + 36px);
    transform: translateX(-50%);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
    display: none;
    white-space: nowrap;
}
.video-poster-overlay.loading .video-overlay-loading {
    display: block;
}
.video-poster-overlay.loading .video-overlay-play {
    opacity: 0.4;
}

/* Double-tap seek zones */
.tap-zone {
    position: absolute; top: 0; width: 40%; height: calc(100% - var(--clip-bottom-bar-height));
    z-index: 2; display: flex; align-items: center;
    pointer-events: none; opacity: 0; transition: opacity 0.2s;
}
.tap-zone.tap-left { left: 0; justify-content: center; border-radius: 0 50% 50% 0; }
.tap-zone.tap-right { right: 0; justify-content: center; border-radius: 50% 0 0 50%; }
.tap-zone.show {
    pointer-events: none; opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}
.tap-label {
    font-size: 14px; font-weight: 700; color: white;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.speed-bar {
    display: flex; justify-content: center; gap: 2px;
    height: var(--clip-bottom-bar-height);
    padding: 4px 6px; background: var(--surface2);
    position: relative; z-index: 3;
}
.speed-btn {
    background: none; border: 1px solid transparent; border-radius: 4px;
    color: var(--text-muted); font-size: 12px; padding: 2px 8px;
    cursor: pointer; transition: all 0.15s; font-weight: 500;
}
.speed-btn:hover { color: var(--text); border-color: var(--border); }
.speed-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(99, 102, 241, 0.1); }
.clip-info { padding: 12px; }
.clip-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.rep-label {
    font-weight: 600; font-size: 14px;
    background: var(--accent); color: white;
    padding: 2px 8px; border-radius: 4px;
}
.clip-time { font-size: 12px; color: var(--text-muted); flex: 1; }

/* Trim controls */
.trim-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.trim-btn { padding: 3px 8px; font-size: 11px; }
.trim-display {
    flex: 1; text-align: center;
    font-size: 12px; color: var(--text-muted);
}
.trim-display.flash { animation: flash-green 0.8s ease-out; }
.trim-viz {
    margin: 24px 0 10px;
    padding: 0 18px;
}
.trim-track {
    position: relative; height: 8px; border-radius: 999px;
    background: rgba(148, 153, 173, 0.2);
    border: 1px solid rgba(148, 153, 173, 0.28);
    cursor: pointer;
    touch-action: none;
    overflow: visible;
}
.trim-range {
    position: absolute; top: 0; height: 100%;
    border-radius: 999px;
    background: rgba(234, 179, 8, 0.35);
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.45);
}
.trim-marker {
    position: absolute; top: 50%;
    width: 12px; height: 12px; border-radius: 50%;
    transform: translate(-50%, -50%);
    background: #facc15;
    border: 2px solid #fef08a;
    box-shadow: 0 0 0 2px rgba(15, 17, 23, 0.95);
    cursor: ew-resize;
    touch-action: none;
}
.trim-marker-out { background: #eab308; }
.trim-marker.dragging { transform: translate(-50%, -50%) scale(1.08); }
.trim-marker-label {
    position: absolute; left: 50%; bottom: 15px;
    transform: translateX(-50%);
    font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
    color: #facc15;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
    text-transform: uppercase;
    white-space: nowrap;
}
.trim-marker-in .trim-marker-label {
    left: 0;
    transform: translateX(0);
}
.trim-marker-out .trim-marker-label {
    left: auto;
    right: 0;
    transform: translateX(0);
}
.trim-marker::before {
    content: "";
    position: absolute;
    inset: -8px;
}

/* Tags */
.tag-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.tag-row label { font-size: 12px; color: var(--text-muted); min-width: 44px; }
.tag-input {
    flex: 1; padding: 4px 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text); font-size: 13px;
}
.tag-input:focus { outline: none; border-color: var(--accent); }
.tag-input.saved { border-color: #22c55e; }

/* Notes */
.notes-row { margin-top: 8px; }
.notes-input {
    width: 100%; padding: 6px 8px; min-height: 48px; resize: vertical;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; color: var(--text); font-size: 13px;
    font-family: inherit; line-height: 1.4;
}
.notes-input:focus { outline: none; border-color: var(--accent); }
.notes-input.flash { animation: flash-green 0.8s ease-out; }

/* Filter bar */
.filter-bar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 24px; flex-wrap: wrap;
}
.filter-bar select {
    padding: 6px 10px; background: var(--surface2);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-size: 13px;
}
.checkbox-label { font-size: 13px; display: flex; align-items: center; gap: 4px; color: var(--text-muted); }

.empty-state { color: var(--text-muted); text-align: center; padding: 48px; }

/* Status badges */
.status-badge {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 10px; margin-left: 8px;
    vertical-align: middle;
}
.status-processing { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.status-failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/* Processing status */
.processing-status {
    display: flex; align-items: center; gap: 20px;
    padding: 32px; margin-top: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.processing-text p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.spinner {
    width: 40px; height: 40px; flex-shrink: 0;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error status */
.error-status {
    padding: 24px; margin-top: 8px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
}
.error-status strong { color: #ef4444; }
.error-status p { color: var(--text-muted); font-size: 13px; margin-top: 6px; font-family: monospace; }

/* Flash on save */
@keyframes flash-green {
    0% { border-color: #22c55e; }
    100% { border-color: var(--border); }
}
.tag-input.flash { animation: flash-green 0.8s ease-out; }
