:root {
    --sidebar-width: 420px;
    --sidebar-resizer-width: 8px;
    --footer-height: 34px;
    --app-bg: rgb(9, 14, 18);
    --sidebar-bg: rgb(13, 19, 24);
    --panel-bg: rgb(16, 23, 29);
    --divider: rgba(255, 255, 255, 0.1);
    --muted: rgba(230, 237, 243, 0.7);
    --text: rgb(240, 240, 240);
    --active: rgba(64, 138, 255, 0.2);
    --danger-bg: rgba(167, 29, 42, 0.25);
    --danger-fg: rgb(255, 202, 209);
    --info-bg: rgba(25, 87, 151, 0.2);
    --info-fg: rgb(203, 229, 255);
    --time-width: 88px;
    --event-time-width: 72px;
    --cue-width: 64px;
    --note-icon-width: 24px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    height: 100%;
    background: var(--app-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow: hidden;
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) var(--sidebar-resizer-width) 1fr;
    min-height: calc(100vh - var(--footer-height));
    height: calc(100vh - var(--footer-height));
    overflow: hidden;
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.sidebar-resizer {
    width: var(--sidebar-resizer-width);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0.04),
        rgba(255, 255, 255, 0.11),
        rgba(255, 255, 255, 0.04)
    );
    cursor: col-resize;
    touch-action: none;
}

.sidebar-resizer:hover {
    background: linear-gradient(
        to right,
        rgba(120, 186, 255, 0.12),
        rgba(120, 186, 255, 0.35),
        rgba(120, 186, 255, 0.12)
    );
}

body.sidebar-resizing {
    user-select: none;
    cursor: col-resize;
}

.sidebar-title {
    padding: 10px 12px 9px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.sidebar-recording-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

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

.sidebar-recording-subtitle {
    min-width: 0;
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.bookmark-header {
    border-bottom: 1px solid var(--divider);
    padding: 10px 16px 8px;
    min-height: 39px;
}

.bookmark-header-row {
    display: grid;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.bookmark-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 4px 0 10px;
}

.sidebar-message {
    margin: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

.sidebar-message.error {
    border-color: rgba(255, 128, 141, 0.4);
    background: rgba(167, 29, 42, 0.2);
    color: var(--danger-fg);
}

.bookmark-row {
    width: calc(100% - 8px);
    margin: 0 4px;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 7px 12px;
    border-radius: 7px;
    text-align: left;
    cursor: pointer;
}

.bookmark-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.bookmark-row.active {
    background: var(--active);
}

.bookmark-row-grid {
    display: grid;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.time-cell,
.event-time-cell,
.cue-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--muted);
}

.event-time-cell {
    font-size: 12px;
}

.cue-cell {
    color: var(--text);
}

.label-cell {
    min-width: 0;
    overflow: hidden;
}

.note-icon-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-icon-cell img {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    filter: invert(1);
}

.plain-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.plain-label.fallback {
    color: var(--muted);
}

.label-chip {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
}

.chip-red {
    background: rgb(162, 25, 31);
    color: rgb(240, 240, 240);
}
.chip-magenta {
    background: rgb(208, 38, 112);
    color: rgb(240, 240, 240);
}
.chip-purple {
    background: rgb(73, 29, 139);
    color: rgb(240, 240, 240);
}
.chip-blue {
    background: rgb(0, 29, 108);
    color: rgb(240, 240, 240);
}
.chip-cyan {
    background: rgb(0, 83, 154);
    color: rgb(240, 240, 240);
}
.chip-teal {
    background: rgb(0, 65, 68);
    color: rgb(240, 240, 240);
}
.chip-green {
    background: rgb(14, 96, 39);
    color: rgb(240, 240, 240);
}
.chip-amber {
    background: rgb(255, 176, 0);
    color: rgb(30, 30, 30);
}
.chip-orange {
    background: rgb(254, 97, 0);
    color: rgb(30, 30, 30);
}
.chip-violet {
    background: rgb(120, 94, 240);
    color: rgb(240, 240, 240);
}

.scene-row {
    margin: 6px 6px 2px;
    padding: 10px 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.95;
}

.scene-divider {
    height: 8px;
    background: rgb(0, 50, 26);
    flex: 1;
}

.scene-title {
    min-width: 0;
    max-width: 65%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.main-pane {
    position: relative;
    background: var(--app-bg);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
    gap: 10px;
}

.drop-area,
.player-shell {
    border: 1px solid var(--divider);
    border-radius: 10px;
    background: var(--panel-bg);
}

.drop-area {
    flex: 1;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 24px;
}

.drop-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--divider);
    display: grid;
    place-items: center;
    color: var(--muted);
}

.drop-area h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.drop-area p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.player-shell {
    display: flex;
    flex-direction: column;
    padding: 12px;
    min-height: 260px;
    gap: 10px;
}

video {
    width: 100%;
    max-height: calc(100vh - 300px);
    border-radius: 8px;
    background: black;
}

.cue-marker-notes-container {
    background: var(--panel-bg);
    border: 1px solid var(--divider);
    border-radius: 10px;
    padding: 10px;
}

.cue-marker-notes {
    display: block;
    width: 100%;
    min-height: 80px;
    max-height: 200px;
    resize: vertical;
    border-radius: 6px;
    border: 1px solid var(--divider);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    line-height: 1.45;
    padding: 10px 12px;
    outline: none;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.cue-marker-notes:focus {
    border-color: rgba(121, 201, 255, 0.65);
    background: rgba(255, 255, 255, 0.06);
}

.cue-marker-notes:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    resize: none;
}

.cue-marker-notes::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.timeline-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.timeline-viewport {
    position: relative;
    height: 110px;
    user-select: none;
    touch-action: none;
    cursor: pointer;
}

.timeline-track-bg {
    position: absolute;
    left: 0;
    right: 0;
    top: 12px;
    height: 64px;
    background: black;
    border-radius: 6px;
}

.timeline-thumbnails {
    position: absolute;
    left: 0;
    right: 0;
    top: 12px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    opacity: 0.8;
    display: flex;
}

.timeline-thumbnail-frame {
    position: relative;
    flex: 1 1 auto;
    height: 100%;
    min-width: 0;
    background: rgba(148, 163, 184, 0.18);
}

.timeline-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.timeline-thumbnail-divider {
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
}

.timeline-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.timeline-scene-indicator {
    position: absolute;
    top: 12px;
    width: 12px;
    height: 64px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 0;
    transform: translateX(-50%);
}

.timeline-scene-indicator > span:nth-child(1),
.timeline-scene-indicator > span:nth-child(3) {
    width: 1.5px;
    background: black;
}

.timeline-scene-indicator > span:nth-child(2) {
    width: 3px;
    background: rgb(0, 80, 30);
}

.timeline-playhead-line {
    position: absolute;
    top: 12px;
    width: 2px;
    height: 64px;
    background: white;
    transform: translateX(-50%);
    pointer-events: none;
}

.timeline-playhead-arrow {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 10px solid white;
    transform: translateX(-50%);
    pointer-events: auto;
    cursor: ew-resize;
    z-index: 3;
}

.timeline-playhead-arrow::after {
    content: "";
    position: absolute;
    left: -10px;
    top: -4px;
    width: 20px;
    height: 18px;
}

.timeline-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    top: 78px;
    transform: translateX(-50%);
}

.timeline-tooltip {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1.2;
    white-space: nowrap;
    max-width: min(70%, 460px);
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    z-index: 2;
}

.timeline-time-row {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    padding: 0 2px;
}

.primary-button,
.secondary-button {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 7px 12px;
}

.primary-button:hover,
.secondary-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.main-status {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--divider);
    font-size: 13px;
    line-height: 1.35;
}

.main-status.error {
    background: var(--danger-bg);
    border-color: rgba(255, 128, 141, 0.4);
    color: var(--danger-fg);
}

.main-status.info {
    background: var(--info-bg);
    border-color: rgba(113, 182, 252, 0.35);
    color: var(--info-fg);
}

.drop-overlay {
    position: absolute;
    inset: 18px;
    border-radius: 10px;
    border: 3px dashed rgba(113, 182, 252, 0.85);
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}

.main-pane.drop-targeted .drop-overlay {
    opacity: 1;
}

.hidden {
    display: none !important;
}

.content-id-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--footer-height);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-top: 1px solid var(--divider);
    background: rgb(11, 17, 22);
    color: var(--muted);
    font-size: 12px;
    z-index: 50;
}

.content-id-readout {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.footer-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgb(255, 176, 0);
    color: rgb(30, 30, 30);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.sync-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sync-toggle-caption {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    color: var(--muted);
    white-space: nowrap;
}

.sync-toggle-button {
    width: 30px;
    height: 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.12);
    padding: 0;
    cursor: pointer;
    position: relative;
    transition:
        background-color 130ms ease,
        border-color 130ms ease;
}

.sync-toggle-knob {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgb(238, 244, 249);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    transition: transform 130ms ease;
}

.sync-toggle-button:hover {
    background: rgba(255, 255, 255, 0.17);
}

.sync-toggle-button:focus-visible {
    outline: 2px solid rgba(121, 201, 255, 0.85);
    outline-offset: 2px;
}

.sync-toggle-button.enabled {
    border-color: rgba(121, 201, 255, 0.75);
    background: rgba(52, 152, 219, 0.5);
}

.sync-toggle-button.enabled .sync-toggle-knob {
    transform: translateX(14px);
}

.content-id-label {
    font-weight: 600;
    letter-spacing: 0.03em;
}

.content-id-value {
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footer-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-action-button {
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 5px 8px;
    cursor: pointer;
}

.footer-action-button:hover {
    background: rgba(255, 255, 255, 0.14);
}

.footer-action-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 920px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 42vh) 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--divider);
    }

    .sidebar-resizer {
        display: none;
    }

    .main-pane {
        min-height: 58vh;
    }

    video {
        max-height: calc(58vh - 180px);
    }
}
