@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Pretendard:wght@300;400;600;700&display=swap');

:root {
    --bg: #f0f4f8;
    --surface: rgba(255, 255, 255, 0.92);
    --surface2: rgba(241, 245, 249, 0.85);
    --accent: #059669;
    --accent2: #6366f1;
    --primary: #2563eb;
    --danger: #dc2626;
    --text: #1e293b;
    --text-dim: #64748b;
    --border: rgba(0,0,0,0.08);
    --radius: 20px;
    --radius-sm: 12px;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Pretendard', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 32px 16px 60px;
    background-image:
        radial-gradient(ellipse 60% 40% at 20% 10%, rgba(5,150,105,0.07) 0%, transparent 60%),
        radial-gradient(ellipse 50% 50% at 80% 80%, rgba(99,102,241,0.07) 0%, transparent 60%);
}

.glass-container {
    width: 100%;
    max-width: 820px;
}

/* ── 헤더 ─────────────────────────────────────────────────── */
header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    font-family: 'DM Mono', monospace;
    font-size: 1.75rem;
    font-weight: 500;
    letter-spacing: -0.5px;
    background: linear-gradient(120deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-dim);
    font-size: 0.92rem;
    margin-top: 6px;
    letter-spacing: 0.5px;
}

/* ── 카드 ─────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* ── 업로드 존 ───────────────────────────────────────────── */
.upload-section {
    border: 1.5px dashed rgba(5,150,105,0.35);
    border-radius: var(--radius);
    padding: 36px;
    text-align: center;
    margin-bottom: 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-section:hover,
.upload-section.dragover {
    border-color: var(--accent);
    background: rgba(5,150,105,0.04);
}

.upload-label {
    cursor: pointer;
    display: block;
}

.upload-label span {
    color: var(--text-dim);
    font-size: 1rem;
    transition: color 0.2s;
}

.upload-section:hover .upload-label span {
    color: var(--accent);
}

/* ── 업로드 존 (드래그 영역 직접) ───────────────────────── */
.upload-area {
    border: 1.5px dashed rgba(5,150,105,0.35);
    border-radius: var(--radius-sm);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: rgba(5,150,105,0.04);
}
.upload-area .upload-label span {
    color: var(--text-dim);
    font-size: 1rem;
}

/* ── 비디오 ──────────────────────────────────────────────── */
video {
    width: 100%;
    border-radius: var(--radius-sm);
    background: #111;
    display: block;
}

/* ── 커스텀 범위 슬라이더 ────────────────────────────────── */
.range-wrap {
    position: relative;
    height: 36px;
    margin: 20px 0 24px;
    display: flex;
    align-items: center;
}

#range-bar {
    position: absolute;
    left: 0; right: 0;
    height: 6px;
    background: rgba(0,0,0,0.1);
    border-radius: 99px;
}

#range-highlight {
    position: absolute;
    height: 6px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 99px;
    pointer-events: none;
}

.range-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    cursor: grab;
    transform: translateX(-50%) translateY(0);
    top: 50%;
    margin-top: -10px;
    box-shadow: 0 0 0 4px rgba(5,150,105,0.15), 0 2px 6px rgba(0,0,0,0.12);
    transition: box-shadow 0.15s, border-color 0.15s;
    z-index: 2;
    touch-action: none;
    user-select: none;
}

#handle-end {
    border-color: var(--accent2);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15), 0 2px 6px rgba(0,0,0,0.12);
}

.range-handle:active { cursor: grabbing; transform: translateX(-50%) scale(1.15) translateY(0); margin-top: -10px; }

/* ── 썸네일 그리드 ──────────────────────────────────────── */
.thumbnail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

.thumb-box {
    position: relative;
    background: #1a1a1a;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 16/9;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.badge {
    position: absolute;
    top: 8px; left: 8px;
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    padding: 3px 8px;
    border-radius: 6px;
    z-index: 1;
}

.thumb-box:first-child .badge { background: rgba(5,150,105,0.9); color: #fff; }
.thumb-box:last-child  .badge { background: rgba(99,102,241,0.9); color: #fff; }

.time-label {
    position: absolute;
    bottom: 8px; right: 8px;
    font-size: 13px;
    font-family: 'DM Mono', monospace;
    background: rgba(0,0,0,0.65);
    padding: 2px 7px;
    border-radius: 5px;
    color: #fff;
}

/* ── 버튼 ────────────────────────────────────────────────── */
.primary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 14px rgba(5,150,105,0.25);
}

.primary-btn:hover    { opacity: 0.9; }
.primary-btn:active   { transform: scale(0.99); }
.primary-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 진행 바 ─────────────────────────────────────────────── */
#progress-wrap {
    margin-top: 16px;
}

.progress-track {
    height: 6px;
    background: rgba(0,0,0,0.08);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 99px;
    transition: width 0.3s;
}

#progress-text {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-family: 'DM Mono', monospace;
}

/* ── 다운로드 버튼 ───────────────────────────────────────── */
#download-link {
    display: none;
    margin-top: 14px;
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--accent);
    background: rgba(5,150,105,0.07);
    color: var(--accent);
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s;
}

#download-link:hover { background: rgba(5,150,105,0.14); }

/* ── 포맷 모달 ───────────────────────────────────────────── */
#format-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

#format-modal.open { display: flex; }

.modal-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 340px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-box h3 {
    font-family: 'DM Mono', monospace;
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text);
}

.modal-box p {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.format-btn {
    padding: 14px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}

.format-btn:hover {
    border-color: var(--accent);
    background: rgba(5,150,105,0.06);
}

.format-btn .fmt-name { font-family: 'DM Mono', monospace; font-size: 1rem; font-weight: 500; display: block; }
.format-btn .fmt-desc { font-size: 0.85rem; color: var(--text-dim); display: block; margin-top: 3px; }

#modal-close {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.2s;
}

#modal-close:hover { background: rgba(0,0,0,0.05); }

/* ── 반응형 ──────────────────────────────────────────────── */
@media (max-width: 500px) {
    header h1 { font-size: 1.3rem; }
    .thumbnail-grid { grid-template-columns: 1fr; }
    .format-grid { grid-template-columns: 1fr 1fr; }
}

/* ── 클립 기능 ────────────────────────────────────────────────── */
.secondary-btn {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.secondary-btn:hover { background: rgba(0,0,0,0.04); border-color: var(--accent); }

.clip-section h3 {
    font-family: 'DM Mono', monospace;
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--accent);
}

.clip-item {
    display: flex;
    align-items: center;
    background: var(--surface2);
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.clip-thumb {
    width: 60px;
    height: 34px;
    border-radius: 4px;
    background: #1a1a1a;
    margin-right: 12px;
    object-fit: cover;
}

.clip-info { flex: 1; }

.clip-time {
    font-size: 0.95rem;
    font-family: 'DM Mono', monospace;
    color: var(--text);
}

.clip-actions-btn {
    display: flex;
    gap: 6px;
}

.clip-btn {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--surface2);
    color: var(--text);
    transition: background 0.2s;
}

.clip-btn:hover { background: rgba(5,150,105,0.1); border-color: var(--accent); }
.clip-btn.delete { color: var(--danger); }
.clip-btn.delete:hover { background: rgba(220,38,38,0.08); border-color: var(--danger); }

/* ── 필름스트립 ────────────────────────────────────────────────── */
.filmstrip-card { padding: 16px; }
.filmstrip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}
.filmstrip-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.15) transparent;
}
.filmstrip-scroll::-webkit-scrollbar { height: 4px; }
.filmstrip-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
.filmstrip-frame {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.15s;
}
.filmstrip-frame:hover { transform: scale(1.05); }
.filmstrip-frame canvas {
    width: 120px;
    height: 68px;
    border-radius: 6px;
    border: 2px solid transparent;
    background: #e2e8f0;
    object-fit: cover;
    transition: border-color 0.2s;
}
.filmstrip-frame:hover canvas { border-color: var(--accent); }
.filmstrip-frame.active canvas { border-color: var(--primary); box-shadow: 0 0 8px rgba(37,99,235,0.3); }
.filmstrip-frame .fs-time {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-family: 'DM Mono', monospace;
}
.filmstrip-frame .fs-loading {
    width: 120px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    border-radius: 6px;
    color: #aaa;
    font-size: 0.85rem;
    border: 2px solid var(--border);
}
.filmstrip-hint {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-dim);
    margin-top: 8px;
}

/* ── 주의사항 패널 ────────────────────────────────────────────────── */
.warning-panel {
    background: rgba(220, 38, 38, 0.07);
    border-left: 4px solid var(--danger);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: var(--text);
}
.warning-panel.compact {
    padding: 8px 14px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    line-height: 1.6;
}
.warning-panel strong { color: var(--danger); }
.warning-panel ul { margin:0; padding-left: 20px; }
.warning-panel li { margin-bottom: 4px; line-height: 1.4; }

/* 업로드 테두리 강조 */
.upload-highlight-card {
    border: 2px solid var(--danger) !important;
    box-shadow: 0 0 16px rgba(220,38,38,0.12);
}

/* ── 탭 메뉴 ────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    color: var(--text-dim);
}
.tab:hover { background: rgba(0,0,0,0.04); }
.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(37,99,235,0.25);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── 병합 그룹 리스트 (다중 파일) ────────────────────────── */
.group-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}
.group-card::before {
    content: ''; position: absolute; top:0; left:0; width:4px; height:100%; background: var(--primary);
}
.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}
.group-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.group-files { font-size: 0.95rem; color: var(--text-dim); margin-top: 4px; }
.merge-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.2);
}
.merge-btn:hover { background: #1d4ed8; transform: scale(1.02); }

/* ── 법적 고지 배너 ──────────────────────────────────────── */
.legal-banner {
    background: rgba(180, 130, 0, 0.09);
    border: 1px solid rgba(180, 130, 0, 0.3);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    color: #7c5500;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.6;
}
.legal-banner .lb-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.legal-banner strong { color: #5c3d00; }
.legal-banner a { color: #7c5500; text-decoration: underline; }
.legal-banner em { color: #8a6010 !important; font-size: 0.82rem !important; font-style: normal; }
.legal-banner .lb-toggle {
    background: none; border: none; color: #9a7020;
    cursor: pointer; font-size: 0.85rem; margin-left: auto; padding: 0 0 0 8px;
    white-space: nowrap; flex-shrink: 0; align-self: flex-start;
}
.legal-banner .lb-body { flex: 1; }
.legal-banner .lb-detail {
    display: none;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(180,130,0,0.2);
    color: #7c5500;
    font-size: 0.82rem;
}
.legal-banner.expanded .lb-detail { display: block; }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
    margin-top: 40px;
    padding: 20px 0 8px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.8;
}
.site-footer a { color: var(--text-dim); text-decoration: underline; opacity: 0.7; }
.site-footer a:hover { opacity: 1; }
.site-footer .footer-divider { margin: 0 6px; opacity: 0.3; }
