:root {
    --ui-bg: #0B0E14;
    --ui-panel: #111827;
    --ui-panel-2: #151E2D;
    --ui-border: #263449;
    --ui-text: #F8FAFC;
    --ui-muted: #94A3B8;
    --ui-dim: #64748B;
    --ui-cyan: #22D3EE;
    --ui-orange: #F97316;
    --ui-green: #4ADE80;
}

html, body {
    min-height: 100%;
    background: var(--ui-bg);
}

body {
    margin: 0;
    color: var(--ui-text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
    position: relative;
    z-index: 1;
    width: 100%;
    min-height: 100dvh;
    background: var(--ui-bg);
}

.screen {
    display: none;
    flex-direction: column;
    width: 100%;
    min-height: 100dvh;
}

.screen.active { display: flex; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 56px;
    min-height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid rgba(148, 163, 184, .12);
    background: rgba(11, 14, 20, .96);
}

.topbar-spacer { width: 36px; height: 36px; flex: 0 0 36px; }

.topbar-title {
    min-width: 0;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 16px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-btn, .paste-btn, .btn-go, .seg-dl, .seg-replay, .seg-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ui-border);
    color: var(--ui-muted);
    background: var(--ui-panel);
    cursor: pointer;
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover, .paste-btn:hover, .seg-replay:hover, .seg-dl:hover { color: var(--ui-cyan); border-color: var(--ui-cyan); }

.screen-body {
    width: min(100%, 560px);
    margin: 0 auto;
    padding: 28px 16px 32px;
}

.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
}

.logo-block { text-align: center; }
.logo-icon {
    width: 88px;
    height: 88px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    color: var(--ui-text);
    background: linear-gradient(145deg, #F8FAFC, #CBD5E1);
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .35);
}
.logo-icon svg { width: 58px; height: 58px; color: #0B0E14; }
.logo-block h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.logo-block p { margin: 6px 0 0; color: var(--ui-muted); font-size: 14px; }

.url-card, .video-info-card {
    width: 100%;
    border: 1px solid var(--ui-border);
    border-radius: 14px;
    background: rgba(17, 24, 39, .9);
    box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
}
.url-card { padding: 12px; }
.url-input-row { display: flex; align-items: center; gap: 8px; }
.url-input-row input {
    min-width: 0;
    flex: 1;
    height: 46px;
    padding: 0 13px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    outline: none;
    color: var(--ui-text);
    background: #0D1420;
    font: inherit;
    font-size: 14px;
}
.url-input-row input:focus { border-color: var(--ui-cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, .12); }
.url-input-row input::placeholder { color: var(--ui-dim); }
.paste-btn { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 10px; }
.paste-btn svg { width: 20px; height: 20px; }

.btn-primary-full {
    width: 100%;
    min-height: 46px;
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: 0;
    border-radius: 10px;
    color: #071018;
    background: linear-gradient(135deg, #22D3EE, #38BDF8);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.btn-primary-full:hover { filter: brightness(1.08); }
.btn-primary-full:disabled { opacity: .55; cursor: wait; }
.btn-primary-full svg { width: 18px; height: 18px; }
.spinner, .spinner-lg {
    border: 2px solid rgba(7, 16, 24, .25);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: ui-spin .7s linear infinite;
}
.spinner { width: 17px; height: 17px; }
.spinner-lg { width: 34px; height: 34px; color: var(--ui-cyan); border-color: rgba(34, 211, 238, .2); border-top-color: var(--ui-cyan); }
@keyframes ui-spin { to { transform: rotate(360deg); } }

.video-info-card { align-items: center; gap: 12px; padding: 10px; }
.video-info-card img { width: 72px; height: 48px; object-fit: cover; border-radius: 7px; }
.video-info-text { min-width: 0; flex: 1; }
.video-info-title { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.video-info-dur { margin-top: 3px; color: var(--ui-muted); font-size: 12px; }
.btn-go { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; color: var(--ui-cyan); }
.btn-go svg { width: 18px; height: 18px; }

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    background: rgba(0, 0, 0, .65);
}
.bottom-sheet { width: 100%; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: #111827; }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 18px; border-radius: 5px; background: #475569; }
.sheet-title { margin: 0; font-size: 20px; }
.sheet-sub { margin: 5px 0 16px; color: var(--ui-muted); font-size: 13px; }
.quality-list { display: grid; gap: 8px; margin-bottom: 16px; }
.quality-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-text); background: #0D1420; cursor: pointer; }
.quality-row.checked { border-color: var(--ui-cyan); background: rgba(34, 211, 238, .08); }
.quality-row input { accent-color: var(--ui-cyan); }
.q-badge { margin-left: auto; color: var(--ui-cyan); font-size: 11px; font-weight: 700; }
.q-badge.low { color: var(--ui-muted); }
.btn-ghost-full { width: 100%; min-height: 42px; margin-top: 8px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-muted); background: transparent; font: inherit; cursor: pointer; }

.player-loading { flex: 1; min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--ui-muted); }
.player-loading p { margin: 0; font-size: 13px; }
#custom-player-container { width: 100%; padding: 12px; }
.trim-panel { display: flex; flex-direction: column; width: 100%; padding: 0 12px 24px; }
.output-quality-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    color: var(--ui-muted);
    background: rgba(17, 24, 39, .9);
    font-size: 13px;
    font-weight: 600;
}
.output-quality-row select {
    min-width: 145px;
    padding: 8px 28px 8px 10px;
    border: 1px solid var(--ui-border);
    border-radius: 8px;
    outline: none;
    color: var(--ui-text);
    background: #0D1420;
    font: inherit;
    font-size: 12px;
}
.output-quality-row select:focus { border-color: var(--ui-cyan); }
.segments-scroll { display: flex; flex-direction: column; gap: 8px; max-height: 230px; overflow-y: auto; padding: 4px 0; }
.seg-empty { padding: 16px; color: var(--ui-dim); font-size: 13px; text-align: center; }
.seg-row { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 8px 10px; border: 1px solid var(--ui-border); border-radius: 10px; background: var(--ui-panel); }
.seg-num { flex: 0 0 24px; color: var(--ui-cyan); font-size: 12px; font-weight: 700; text-align: center; }
.seg-time { min-width: 0; flex: 1; color: var(--ui-text); font-size: 13px; }
.seg-dl, .seg-replay, .seg-del { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border-radius: 8px; }
.seg-dl svg, .seg-replay svg, .seg-del svg { width: 16px; height: 16px; }
.seg-del { color: #F87171; border-color: rgba(248, 113, 113, .25); }
.seg-del:hover { border-color: #F87171; background: rgba(248, 113, 113, .1); }
.trim-actions-row { display: flex; justify-content: center; gap: 12px; padding: 16px 0 8px; }
.trim-btn { min-width: 120px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 12px 18px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-text); background: var(--ui-panel); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.trim-btn svg { width: 18px; height: 18px; }
.trim-btn.mark-in:hover { border-color: var(--ui-green); color: var(--ui-green); }
.trim-btn.mark-out:hover { border-color: var(--ui-orange); color: var(--ui-orange); }

.list-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.empty-state { padding: 36px 12px; color: var(--ui-dim); text-align: center; font-size: 14px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 18px; z-index: 50; transform: translateY(20px); opacity: 0; padding: 12px 14px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-text); background: #172235; box-shadow: 0 12px 32px rgba(0,0,0,.35); font-size: 13px; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(248, 113, 113, .55); }
.toast.success { border-color: rgba(74, 222, 128, .55); }

.download-status {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid var(--ui-border);
    border-radius: 9px;
    color: var(--ui-muted);
    background: rgba(13, 20, 32, .85);
    font-size: 12px;
}
.download-status-badge {
    flex: 0 0 auto;
    padding: 3px 6px;
    border-radius: 5px;
    color: var(--ui-cyan);
    background: rgba(34, 211, 238, .1);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
}
.download-status-badge.busy { color: var(--ui-orange); background: rgba(249, 115, 22, .12); }
.download-status-badge.success { color: var(--ui-green); background: rgba(74, 222, 128, .12); }
.download-status-badge.error { color: #F87171; background: rgba(248, 113, 113, .12); }

@media (min-width: 700px) {
    .screen-body { padding-left: 24px; padding-right: 24px; }
    .bottom-sheet { width: min(560px, 100%); margin: 0 auto; border-radius: 18px 18px 0 0; }
}
@media (max-width: 380px) {
    .trim-actions-row { gap: 8px; }
    .trim-btn { min-width: 0; flex: 1; padding-left: 10px; padding-right: 10px; }
}

/* Current inline player controls must remain visible on small screens. */
.custom-player { width: 100%; }
.player-video-wrapper { width: 100%; }
.player-video { display: block; width: 100%; max-height: 58vh; background: #000; }
.player-controls { width: 100%; }
.player-control-bar { flex-wrap: wrap; }
.player-control-left, .player-control-right { flex-wrap: wrap; }

/* Cache-busting is handled by the app, not by browser-specific markup. */
