/* VideoDL — Cartwall gray + gold theme */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #141618;
    --surface: #1c1f24;
    --surface-2: #262a31;
    --border: rgba(255, 255, 255, 0.1);
    --text: #eceff4;
    --text-dim: #9aa3b2;
    --accent: #c9a227;
    --accent-hover: #dbb42e;
    --accent-soft: rgba(201, 162, 39, 0.18);
    --danger: #c53030;
    --success: #3d8f5f;
    --font: 'DM Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --radius: 10px;
}

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

html, body {
    min-height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), #8a7018);
    display: grid;
    place-items: center;
    color: var(--bg);
    font-size: 0.75rem;
    font-weight: 800;
}

.brand-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-left: 0.25rem;
}

.topbar-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chip {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    border: 1px solid rgba(201, 162, 39, 0.35);
}

.main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.url-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.url-input {
    flex: 1;
    min-width: 220px;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
}

.url-input:focus {
    outline: none;
    border-color: rgba(201, 162, 39, 0.55);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent-hover);
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.18);
    background: #323842;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border);
}

.hint {
    margin-top: 0.65rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.45;
}

.hint strong { color: var(--accent-hover); font-weight: 600; }

.meta-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
    align-items: start;
}

.thumb {
    width: 140px;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.meta-body h2 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.35rem;
}

.meta-line {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 0.2rem;
}

.meta-line span { color: var(--text); font-family: var(--mono); font-size: 0.78rem; }

.format-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.85rem;
}

.format-row label {
    font-size: 0.82rem;
    color: var(--text-dim);
}

.format-select {
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    min-width: 200px;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.progress-wrap {
    margin-top: 0.85rem;
    display: none;
}

.progress-wrap.visible { display: block; }

.progress-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8a7018, var(--accent));
    transition: width 0.2s ease;
}

.progress-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 0.35rem;
    font-family: var(--mono);
}

.editor-panel { display: none; }
.editor-panel.visible { display: block; }

.video-wrap {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    aspect-ratio: 16/9;
    max-height: 52vh;
}

.video-wrap video {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

.trim-block { margin-top: 1rem; }

.trim-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.trim-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
}

.trim-stat em {
    font-style: normal;
    color: var(--text-dim);
    margin-right: 0.25rem;
}

.trim-stat strong {
    font-family: var(--mono);
    color: var(--accent-hover);
}

.timeline {
    position: relative;
    height: 44px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.timeline-track {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
}

.timeline-range {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--accent-soft);
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
}

.timeline-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #fff;
    pointer-events: none;
    z-index: 2;
}

.timeline-handle {
    position: absolute;
    top: 4px;
    bottom: 4px;
    width: 12px;
    margin-left: -6px;
    border-radius: 4px;
    background: var(--accent);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
    cursor: ew-resize;
    z-index: 3;
}

.timeline-handle.in { background: var(--success); }
.timeline-handle.out { background: var(--accent-hover); }

.time-inputs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.field label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.25rem;
}

.field input {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.82rem;
}

.toast {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    font-size: 0.85rem;
    z-index: 100;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.25s, opacity 0.25s;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast.error { border-color: rgba(197, 48, 48, 0.5); color: #ffb4b4; }

.hidden { display: none !important; }

@media (max-width: 640px) {
    .meta-grid { grid-template-columns: 1fr; }
    .thumb { width: 100%; max-width: 280px; }
}
