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

:root {
    --bg: #050810;
    --panel: #11182b;
    --accent: #2ee6c5;
    --accent-soft: rgba(46, 230, 197, 0.15);
    --text: #f5f7ff;
    --muted: #8ea4c8;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    --radius: 20px;
    --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top, rgba(46, 230, 197, 0.15), transparent 55%), var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 12px;
}

.app-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.app-header p {
    margin: 4px 0 0;
    color: var(--muted);
}

.session-info span {
    display: inline-block;
    margin-left: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.workflow {
    display: grid;
    gap: 24px;
    margin-top: 24px;
}

.step {
    background: rgba(17, 24, 43, 0.85);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 45px rgba(0, 0, 0, 0.25);
}

.step h2 {
    margin-top: 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card {
    background: rgba(5, 8, 16, 0.8);
    border-radius: calc(var(--radius) - 6px);
    padding: 16px;
    border: 1px solid var(--border);
    margin-top: 12px;
}

label {
    display: block;
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--muted);
}

input[type="text"],
input[type="file"] {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    padding: 10px;
    border-radius: 12px;
    color: var(--text);
    margin-top: 6px;
}

button {
    margin-top: 16px;
    width: 100%;
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    font-size: 1rem;
    color: #000;
    background: linear-gradient(120deg, #2ee6c5, #2e9de6);
    box-shadow: 0 15px 35px rgba(46, 230, 197, 0.35);
    cursor: pointer;
    transition: transform 0.2s var(--transition), box-shadow 0.2s var(--transition);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(46, 230, 197, 0.4);
}

.status-panel,
.json-view {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 14px;
    padding: 12px;
    margin-top: 12px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.9rem;
    color: var(--muted);
    border: 1px dashed var(--border);
}

.analysis-preview {
    width: 100%;
    height: 220px;
    margin-top: 16px;
    border-radius: 12px;
    background: #050b17;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    width: 100%;
    height: 200px;
}

.beat-table {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.beat-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.beat-table th,
.beat-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.beat-table tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.beat-table th {
    position: sticky;
    top: 0;
    background: rgba(5, 8, 16, 0.9);
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.photo-thumb {
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    position: relative;
}

.photo-thumb img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

.photo-thumb span {
    position: absolute;
    bottom: 6px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 0.75rem;
}

.timeline-preview {
    margin-top: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 10px;
    background: var(--accent-soft);
    overflow-x: auto;
}

.transport {
    margin: 16px 0;
    display: grid;
    grid-template-columns: 150px 1fr 80px;
    gap: 10px;
    align-items: center;
}

.transport button {
    margin: 0;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(46, 230, 197, 0.8);
    box-shadow: none;
}

.transport input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.transport span {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

#timelineContainer {
    min-width: 600px;
    display: flex;
    gap: 4px;
}

.clip-detail {
    margin-top: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px;
    min-height: 100px;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.35);
}

.clip-block {
    height: 120px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(46, 230, 197, 0.25), rgba(46, 157, 230, 0.25));
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text);
    font-size: 0.8rem;
    position: relative;
    overflow: hidden;
}

.clip-block span {
    font-weight: 600;
}

.clip-block em {
    font-style: normal;
    color: var(--muted);
    font-size: 0.75rem;
}

.clip-block::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.clip-block.active::after {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(46, 230, 197, 0.5);
}

.timeline-preview::-webkit-scrollbar {
    height: 8px;
}

.timeline-preview::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 999px;
}

.json-view {
    max-height: 260px;
    overflow-y: auto;
}

body.is-busy {
    cursor: progress;
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    button {
        width: 100%;
    }
}
