* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    padding: 16px;
    -webkit-user-select: none;
    user-select: none;
}

#app {
    max-width: 600px;
    margin: 0 auto;
}

.section {
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* URL Section */
h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--tg-theme-text-color, #000);
}

.hint {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #999);
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

input[type="text"] {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--tg-theme-hint-color, #ccc);
    border-radius: 8px;
    font-size: 16px;
    background: var(--tg-theme-bg-color, #fff);
    color: var(--tg-theme-text-color, #000);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.7;
}

.btn-primary {
    background: var(--tg-theme-button-color, #0088cc);
    color: var(--tg-theme-button-text-color, #fff);
}

.btn-secondary {
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
    color: var(--tg-theme-text-color, #000);
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid var(--tg-theme-hint-color, #ccc);
    border-top-color: var(--tg-theme-button-color, #0088cc);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Video Section */
.video-info {
    margin-bottom: 16px;
}

.video-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.video-info p {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #999);
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

#video-player {
    width: 100%;
    display: block;
}

/* Timeline */
.timeline-container {
    position: relative;
    width: 100%;
    height: 80px;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

#timeline-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#timeline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.selection-area {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 136, 204, 0.3);
    border-left: 2px solid var(--tg-theme-button-color, #0088cc);
    border-right: 2px solid var(--tg-theme-button-color, #0088cc);
    pointer-events: none;
}

.handle {
    position: absolute;
    top: 0;
    width: 20px;
    height: 100%;
    background: var(--tg-theme-button-color, #0088cc);
    cursor: ew-resize;
    pointer-events: all;
    z-index: 10;
}

.handle-start {
    left: 0;
    border-radius: 8px 0 0 8px;
}

.handle-end {
    right: 0;
    border-radius: 0 8px 8px 0;
}

.handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 30px;
    background: white;
    border-radius: 2px;
}

.playhead {
    position: absolute;
    top: 0;
    width: 2px;
    height: 100%;
    background: red;
    pointer-events: none;
    z-index: 5;
}

/* Time Display */
.time-display {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.time-input-group {
    flex: 1;
}

.time-input-group label {
    display: block;
    font-size: 12px;
    color: var(--tg-theme-hint-color, #999);
    margin-bottom: 4px;
}

.time-input-group input {
    width: 100%;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 600;
}

/* Controls */
.controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.controls .btn {
    flex: 1;
}

/* Quality Selector */
.quality-selector {
    margin-top: 16px;
}

.quality-selector h4 {
    font-size: 16px;
    margin-bottom: 12px;
}

#quality-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
}

#quality-buttons .btn {
    width: 100%;
}

/* Result Section */
.result-message {
    text-align: center;
    padding: 32px 16px;
}

.result-message h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.result-message p {
    font-size: 16px;
    color: var(--tg-theme-hint-color, #999);
}
