:root {
    --bg: #071018;
    --bg-elevated: #0f1a24;
    --panel: #122030;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e8f4fc;
    --muted: #8ba3b8;
    --primary: #22d3ee;
    --primary-hover: #06b6d4;
    --accent: #38bdf8;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(34, 211, 238, 0.15), transparent 35%),
        radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.1), transparent 30%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
}

code {
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.15em 0.4em;
    border-radius: 6px;
}

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(100%, 440px);
    background: rgba(18, 32, 48, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-icon {
    display: inline-grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.35), rgba(56, 189, 248, 0.2));
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.brand h1,
.hero h1,
.panel-header h2 {
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
}

.topbar {
    border-bottom: 1px solid var(--border);
    background: rgba(15, 26, 36, 0.9);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subtitle {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 400;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: rgba(18, 32, 48, 0.85);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #042f3a;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.05);
}

.btn-secondary {
    background: rgba(34, 211, 238, 0.12);
    color: var(--primary);
    border-color: rgba(34, 211, 238, 0.35);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: var(--border);
}

.btn-block {
    width: 100%;
}

.login-form label {
    display: block;
    margin-bottom: 14px;
}

.login-form label span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}

.login-form input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text);
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.alert-success {
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #a7f3d0;
}

.alert-info {
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: #a5f3fc;
}

.hidden {
    display: none !important;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
}

.badge-ok {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.badge-warn {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.clip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 80px;
}

.clip-list.empty-state .clip-item {
    display: none;
}

.empty-hint {
    padding: 24px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

.clip-item {
    display: grid;
    grid-template-columns: auto 72px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.clip-item.dragging {
    opacity: 0.5;
}

.clip-handle {
    cursor: grab;
    color: var(--muted);
    font-size: 1.1rem;
    user-select: none;
}

.clip-thumb {
    width: 72px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    background: #000;
}

.clip-meta strong {
    display: block;
    font-size: 0.9rem;
}

.clip-meta span {
    font-size: 0.8rem;
    color: var(--muted);
}

.clip-remove {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.analysis-text {
    font-size: 1rem;
    line-height: 1.6;
}

.order-list {
    margin: 16px 0;
    padding-left: 1.25rem;
}

.order-list li {
    margin-bottom: 8px;
}

.transition-list {
    list-style: disc;
    padding-left: 1.25rem;
}

.result-video {
    width: 100%;
    max-height: 420px;
    border-radius: 12px;
    margin: 16px 0;
    background: #000;
}

.auth-footnote {
    margin-top: 20px;
    font-size: 0.8rem;
    text-align: center;
}

.debug-panel .panel-header {
    align-items: center;
}

.debug-pre {
    margin: 0;
    padding: 14px;
    max-height: 320px;
    overflow: auto;
    font-size: 0.75rem;
    line-height: 1.45;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cbd5e1;
}

@media (max-width: 640px) {
    .clip-item {
        grid-template-columns: auto 60px 1fr auto;
    }

    .clip-thumb {
        width: 60px;
        height: 40px;
    }
}
