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

:root {
    --bg: #0e0e10;
    --surface: #1a1a1f;
    --surface-hover: #222228;
    --border: #2a2a32;
    --text: #e4e4e7;
    --text-dim: #71717a;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Login ─────────────────────────────────────── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-box p {
    color: var(--text-dim);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    margin-bottom: 16px;
    outline: none;
}

.login-box input:focus {
    border-color: var(--accent);
}

/* ── App layout ────────────────────────────────── */
.app {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.app.active { display: block; }

.app-header {
    margin-bottom: 48px;
}

.app-header h1 {
    font-size: 28px;
    font-weight: 600;
}

.app-header .version {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-dim);
    vertical-align: middle;
}

.app-header p {
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 4px;
}

/* ── Sections ──────────────────────────────────── */
section {
    margin-bottom: 40px;
}

section h2 {
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 16px;
}

.section-hint {
    color: var(--text-dim);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ── Drop zone ─────────────────────────────────── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.drop-zone p {
    color: var(--text-dim);
    font-size: 15px;
}

.drop-zone .hint {
    font-size: 13px;
    margin-top: 8px;
}

/* ── Clip list ─────────────────────────────────── */
.clip-list {
    list-style: none;
}

.clip-item {
    display: flex;
    gap: 16px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    cursor: grab;
    transition: background 0.15s;
}

.clip-item:active { cursor: grabbing; }
.clip-item.dragging { opacity: 0.5; }
.clip-item.drag-over { border-color: var(--accent); }

.clip-thumb {
    width: 80px;
    height: 45px;
    border-radius: 6px;
    background: var(--bg);
    object-fit: cover;
    flex-shrink: 0;
}

.clip-info {
    flex: 1;
    min-width: 0;
}

.clip-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clip-meta {
    font-size: 12px;
    color: var(--text-dim);
}

.clip-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.clip-remove:hover { color: var(--danger); }

/* ── Script editor ─────────────────────────────── */
.script-editor {
    width: 100%;
    min-height: 160px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.script-editor:focus { border-color: var(--accent); }
.script-editor::placeholder { color: var(--text-dim); }

/* ── Settings ──────────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.card-row .toggle-row {
    margin: 0;
}

.card-row .sound-select {
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.card-row .sound-select:focus { border-color: var(--accent); }

.setting-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.setting-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    cursor: pointer;
}

.setting-group select:focus { border-color: var(--accent); }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.setting-group .toggle-row {
    margin-top: 0;
    margin-bottom: 0;
    color: var(--text);
}

.toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-dim);
    border: 1px solid var(--border);
    width: 100%;
    margin-top: 8px;
}

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

.btn-hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 8px;
}

/* ── Edit plan / Segment list ──────────────────── */
.segment-list {
    margin-bottom: 20px;
}

.segment-item {
    display: flex;
    gap: 12px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}

.segment-item:hover {
    border-color: var(--accent);
}

.segment-number {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.segment-details {
    flex: 1;
    min-width: 0;
}

.segment-clip {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.segment-time {
    font-size: 12px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.segment-duration {
    color: var(--accent);
}

.segment-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.segment-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.segment-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.segment-remove:hover { color: var(--danger); }

.segment-warning {
    font-size: 12px;
    color: #eab308;
    margin-top: 4px;
    padding: 4px 8px;
    background: rgba(234, 179, 8, 0.1);
    border-radius: 4px;
}

.segment-item--warned {
    border-color: rgba(234, 179, 8, 0.3);
}

.no-segments {
    text-align: center;
    color: var(--text-dim);
    padding: 32px;
    font-size: 14px;
}

.edit-plan-actions {
    margin-top: 16px;
}

/* ── Progress ──────────────────────────────────── */
.progress-section {
    display: none;
}

.progress-section.active { display: block; }

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.progress-message {
    font-size: 14px;
    color: var(--text-dim);
}

/* ── Downloads ─────────────────────────────────── */
.download-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.download-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.download-card:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
}

.download-card .label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.download-card .sublabel {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 640px) {
    .clip-item { flex-direction: column; align-items: flex-start; }
    .clip-thumb { width: 100%; height: 120px; }
    .settings-grid { grid-template-columns: 1fr; }
    .download-grid { grid-template-columns: 1fr; }
    .segment-item { flex-direction: column; align-items: flex-start; }
}
