:root {
    --bg-page: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-card: #ffffff;
    --border-subtle: #e2e8f0;
    --border-hover: #cbd5e1;
    --border-focus: #0f172a;

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;

    --color-primary: #0f172a;
    --color-primary-hover: #1e293b;
    --color-danger: #ef4444;
    --color-success: #16a34a;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* Header */
.header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
    letter-spacing: -0.02em;
}

.brand-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.privacy-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

/* Grid Layout */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 900px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
}

/* Form Groups */
.form-group {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}

.form-group:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.field-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 10px;
}

.input-sublabel {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* URL Input */
.url-row {
    display: flex;
    gap: 8px;
}

input[type="text"] {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.92rem;
    color: var(--text-main);
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.mono-input {
    font-family: var(--font-mono) !important;
    font-size: 0.95rem !important;
    text-align: center;
}

.error-box {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
}

/* Video Preview Box */
.preview-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
}

.preview-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 16px;
    align-items: center;
}

@media (max-width: 640px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }
}

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

#yt-player-wrapper, #yt-player, .thumbnail-fallback, .thumbnail-fallback img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.meta-separator {
    margin: 0 4px;
}

.mono-text {
    font-family: var(--font-mono);
}

.sub-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.sync-row {
    display: flex;
    gap: 8px;
}

/* Time Grid */
.time-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clip-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--color-success);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 2px 8px;
    border-radius: 999px;
}

.time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 600px) {
    .time-grid {
        grid-template-columns: 1fr;
    }
}

.preset-row {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.btn-preset {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-preset:hover {
    color: var(--text-main);
    border-color: var(--border-hover);
    background: #f8fafc;
}

/* Choice Box Options (Quality & Orientation) */
.options-grid {
    display: grid;
    gap: 8px;
}

.quality-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.orientation-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.choice-box {
    cursor: pointer;
    position: relative;
}

.choice-box input {
    position: absolute;
    opacity: 0;
}

.choice-inner {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all 0.15s ease;
}

.choice-inner:hover {
    border-color: var(--border-hover);
    background: #f8fafc;
}

.choice-box input:checked + .choice-inner {
    border-color: var(--color-primary);
    background: #f8fafc;
    box-shadow: 0 0 0 1px var(--color-primary);
}

.choice-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.choice-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Framing Style */
.framing-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 12px;
}

.framing-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.framing-choice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-main);
    cursor: pointer;
}

.framing-choice input {
    margin-top: 3px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
}

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

.btn-secondary {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--border-hover);
}

.btn-tiny {
    padding: 4px 8px;
    font-size: 0.72rem;
    border-radius: 4px;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.btn-tiny:hover {
    border-color: var(--border-hover);
    background: #f8fafc;
}

.btn-block {
    width: 100%;
    padding: 13px;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Action & Progress */
.action-area {
    margin-top: 24px;
}

.progress-box {
    margin-top: 16px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px;
}

.progress-top {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 500;
}

.progress-pct {
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Completed Box */
.completed-box {
    margin-top: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-md);
    padding: 16px;
}

.completed-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.completed-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #15803d;
}

.completed-file {
    font-size: 0.8rem;
    color: var(--text-main);
    word-break: break-all;
    margin-top: 2px;
}

.completed-size {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.server-notice {
    font-size: 0.74rem;
    color: #15803d;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(22, 163, 74, 0.2);
}

/* History Card */
.history-card {
    background: #ffffff;
}

.history-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.history-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
}

.history-badge {
    font-size: 0.68rem;
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 520px;
    overflow-y: auto;
}

.history-item {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-main);
    word-break: break-all;
    line-height: 1.3;
}

.history-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    padding: 32px 12px;
    color: var(--text-subtle);
    font-size: 0.82rem;
}

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.2s ease;
}

.toast-error {
    background: #ef4444;
}

.toast-success {
    background: #16a34a;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.hide {
    display: none !important;
}
