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

/* ─── Tokens ─── */
:root {
  --bg:        #f5f4ff;
  --surface:   #ffffff;
  --surface2:  #f0effe;
  --border:    rgba(120,105,240,0.13);
  --border-md: rgba(120,105,240,0.22);

  --accent:    #6c5ce7;
  --accent-lt: rgba(108,92,231,0.08);
  --accent-glow: rgba(108,92,231,0.18);
  --accent2:   #e8405a;
  --accent3:   #00c9a7;

  --text:      #1a1833;
  --text-dim:  #7b78a0;
  --text-hint: #b5b2d4;

  --success:   #00c9a7;
  --danger:    #e8405a;
  --warn:      #f5a623;

  --radius:    14px;
  --radius-sm: 9px;
  --radius-xs: 6px;

  --mono:    'DM Mono', monospace;
  --display: 'Outfit', sans-serif;

  /* glass */
  --glass-bg:     rgba(255,255,255,0.62);
  --glass-border: rgba(255,255,255,0.85);
  --glass-blur:   blur(18px);
}

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

html, body {
  height: 100%;
  overflow: hidden; 
}

body {
  font-family: var(--display);
  background: var(--bg);
  color: var(--text);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 30%,  rgba(108,92,231,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 85% 70%,  rgba(0,201,167,0.08)  0%, transparent 65%),
    radial-gradient(ellipse 40% 40% at 60% 10%,  rgba(232,64,90,0.06)  0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ════════════════════════════════════════
   SETUP SCREEN
════════════════════════════════════════ */
.setup-layout {
  display: flex;
  height: 100%;
}

.setup-brand {
  width: 300px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #2d1f8f 0%, #1e1560 40%, #150f4a 100%);
  position: relative;
  overflow: hidden;
}

.setup-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(108,92,231,0.4) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(0,201,167,0.15) 0%, transparent 60%);
}

.brand-inner {
  position: relative;
  z-index: 1;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.brand-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-icon {
  width: 42px; height: 42px; background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2); border-radius: 11px;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px);
}
.brand-logo h1 { font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.brand-logo h1 span { color: rgba(180,168,255,0.9); }
.brand-tagline { font-size: 15px; font-weight: 500; color: rgba(255,255,255,0.55); line-height: 1.6; margin-bottom: 44px; }

.brand-steps { flex: 1; }
.brand-step { display: flex; align-items: center; gap: 14px; }
.brand-step-num {
  width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18); display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.7); flex-shrink: 0;
}
.brand-step-text { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.65); }
.brand-step-line { width: 1px; height: 28px; background: rgba(255,255,255,0.12); margin: 6px 0 6px 15.5px; }
.brand-badge {
  display: flex; align-items: center; gap: 7px; background: rgba(0,201,167,0.12);
  border: 1px solid rgba(0,201,167,0.25); border-radius: 99px; padding: 8px 14px;
  font-size: 11px; font-family: var(--mono); color: rgba(0,201,167,0.9); margin-top: 32px;
}

.setup-form { flex: 1; overflow-y: auto; display: flex; align-items: center; padding: 32px 48px; }
.setup-form::-webkit-scrollbar { width: 5px; }
.setup-form::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }

.form-inner { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.form-section { display: flex; flex-direction: column; gap: 8px; }

.form-label { font-size: 12px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-dim); font-family: var(--mono); }
.form-label-row { display: flex; justify-content: space-between; align-items: center; }
.line-count { font-family: var(--mono); font-size: 11px; color: var(--accent); background: var(--accent-lt); padding: 3px 9px; border-radius: 99px; }

.file-drop {
  border: 1.5px dashed var(--border-md); border-radius: var(--radius); padding: 26px; text-align: center;
  cursor: pointer; transition: all 0.2s; background: var(--glass-bg); backdrop-filter: var(--glass-blur); position: relative;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: var(--accent-lt); }
.file-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-drop-content { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.file-drop-icon { color: var(--accent); opacity: 0.6; }
.file-drop-label { font-size: 14px; font-weight: 600; color: var(--text); }
.file-drop-formats { font-size: 11px; font-family: var(--mono); color: var(--text-hint); }
.file-name { display: none; font-family: var(--mono); font-size: 12px; color: var(--accent3); margin-top: 4px; font-weight: 500; }

textarea {
  width: 100%; height: 110px; background: var(--glass-bg); backdrop-filter: var(--glass-blur);
  border: 1.5px solid var(--border-md); border-radius: var(--radius-sm); color: var(--text);
  font-family: var(--mono); font-size: 13px; padding: 14px 16px; resize: vertical; transition: border-color 0.2s; outline: none; line-height: 1.65;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--text-hint); }

.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setting-card { background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1.5px solid var(--border-md); border-radius: var(--radius-sm); padding: 14px 16px; }
.setting-card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); font-family: var(--mono); margin-bottom: 8px; }
.setting-card-input { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.setting-card-input input {
  width: 70px; padding: 6px 10px; background: rgba(108,92,231,0.06); border: 1.5px solid var(--border-md);
  border-radius: var(--radius-xs); color: var(--accent); font-family: var(--mono); font-size: 18px; font-weight: 500; text-align: center; outline: none; transition: border-color 0.2s;
}
.setting-card-input input:focus { border-color: var(--accent); }
.setting-unit { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.setting-card-desc { font-size: 11px; color: var(--text-hint); line-height: 1.4; }

.btn-start {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 16px;
  background: linear-gradient(135deg, var(--accent) 0%, #9c84ff 100%); border: none; border-radius: var(--radius);
  color: #fff; font-family: var(--display); font-size: 15px; font-weight: 700; cursor: pointer; letter-spacing: 0.2px;
  box-shadow: 0 8px 28px rgba(108,92,231,0.32); transition: all 0.2s;
}
.btn-start:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(108,92,231,0.4); }
.btn-start:active { transform: scale(0.98); }

/* ════════════════════════════════════════
   SYNC SCREEN
════════════════════════════════════════ */
.sync-layout { display: flex; flex-direction: column; height: 100%; overflow: hidden; }

.sync-topbar {
  display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 54px; flex-shrink: 0;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); border-bottom: 1px solid var(--border); position: relative; z-index: 10;
}
.sync-logo { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; white-space: nowrap; }
.sync-logo span { color: var(--accent); }
.sync-logo-icon { width: 28px; height: 28px; background: linear-gradient(135deg, var(--accent), #9c84ff); border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.shortcut-bar { display: flex; align-items: center; gap: 0; background: var(--surface2); border: 1px solid var(--border-md); border-radius: 99px; padding: 5px 14px; flex: 1; justify-content: center; }
.shortcut-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.shortcut-divider { width: 1px; height: 14px; background: var(--border-md); margin: 0 16px; }

kbd {
  display: inline-flex; align-items: center; justify-content: center; background: var(--surface);
  border: 1px solid var(--border-md); border-bottom: 2.5px solid var(--border-md); border-radius: 5px; padding: 2px 9px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--text); min-width: 28px;
}
kbd.kbd-space { border-color: var(--accent); border-bottom-color: rgba(108,92,231,0.4); color: var(--accent); }
kbd.kbd-back  { border-color: var(--danger); border-bottom-color: rgba(232,64,90,0.4);  color: var(--danger); }

.topbar-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.time-display { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--accent); letter-spacing: 1.5px; background: var(--accent-lt); padding: 5px 12px; border-radius: 99px; }
.btn-save {
  display: flex; align-items: center; gap: 7px; padding: 8px 16px; background: linear-gradient(135deg, var(--accent3), #00a882);
  border: none; border-radius: 99px; color: #fff; font-family: var(--display); font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(0,201,167,0.3); transition: all 0.2s; white-space: nowrap;
}
.btn-save:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,201,167,0.4); }
.btn-save:active { transform: scale(0.98); }

.sync-body { display: grid; grid-template-columns: 1fr 380px; gap: 0; flex: 1; overflow: hidden; min-height: 0; }
.panel { background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-shrink: 0; }
.panel-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); font-family: var(--mono); }
.panel-meta { font-family: var(--mono); font-size: 11px; color: var(--text-hint); }

.sync-left { display: flex; flex-direction: column; gap: 10px; padding: 14px 10px 14px 14px; overflow: hidden; min-height: 0; }
.sync-left .panel:first-child { flex-shrink: 0; }
.panel-history { flex: 1; min-height: 0; }

.waveform-meta { font-family: var(--mono); font-size: 11px; color: var(--text-hint); }
.waveform-wrapper { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
#waveform { padding: 8px 0; }

.btn-play {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; padding: 11px;
  background: var(--surface); border: 1.5px solid var(--accent); border-radius: var(--radius-sm); color: var(--accent);
  font-family: var(--display); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-play:hover { background: var(--accent-lt); }
.btn-play:active { transform: scale(0.98); }

.history-box { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; }
.history-box::-webkit-scrollbar { width: 4px; }
.history-box::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
.history-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-xs); border: 1px solid var(--border);
  background: var(--surface); font-family: var(--mono); font-size: 12px; cursor: pointer; transition: all 0.15s; animation: slideIn 0.18s ease; flex-shrink: 0;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
.history-item:hover { border-color: var(--accent3); background: rgba(0,201,167,0.07); transform: translateX(2px); }
.history-item--latest { border-color: var(--accent); background: rgba(108,92,231,0.06); }
.time-badge { color: var(--accent); font-weight: 500; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.history-text { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-end { color: var(--text-hint); font-size: 10px; white-space: nowrap; flex-shrink: 0; }
.time-end--active { color: var(--accent2); font-weight: 500; animation: blink 1s ease infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.btn-undo {
  display: flex; align-items: center; gap: 5px; background: transparent; border: 1px solid var(--danger);
  border-radius: var(--radius-xs); color: var(--danger); padding: 4px 10px; font-size: 11px; font-family: var(--mono); cursor: pointer; transition: all 0.15s;
}
.btn-undo:hover { background: rgba(232,64,90,0.08); }

.sync-right { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 14px 10px; border-left: 1px solid var(--border); overflow: hidden; min-height: 0; }
.sync-right .panel-history { flex: 1; min-height: 0; }

.progress-panel { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.progress-bar-track { flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #9c84ff); border-radius: 99px; transition: width 0.3s ease; width: 0%; }
.progress-label { font-family: var(--mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }

.status-panel { background: var(--glass-bg); backdrop-filter: var(--glass-blur); border: 1.5px solid var(--border-md); border-radius: var(--radius); padding: 20px 22px; flex-shrink: 0; transition: border-color 0.2s; position: relative; overflow: hidden; }
.status-panel::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent), #9c84ff); border-radius: 99px 99px 0 0; opacity: 0; transition: opacity 0.3s; }
.status-panel.active { border-color: var(--accent); }
.status-panel.active::before { opacity: 1; }
.status-hint { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-hint); margin-bottom: 10px; }
.status-current { font-size: 24px; font-weight: 800; color: var(--text); line-height: 1.25; min-height: 30px; letter-spacing: -0.3px; }
.status-divider { height: 1px; background: var(--border); margin: 14px 0; }
.status-next-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-hint); margin-bottom: 6px; }
.status-next { font-size: 14px; color: var(--text-dim); min-height: 20px; font-family: var(--mono); }

.panel-lyrics { flex: 1; min-height: 0; }
.lyrics-scroll { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; }
.lyrics-scroll::-webkit-scrollbar { width: 4px; }
.lyrics-scroll::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
.lyric-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--radius-xs); font-size: 13px; transition: all 0.15s; flex-shrink: 0; }
.lyric-row--done { color: var(--text-hint); text-decoration: line-through; }
.lyric-row--current { background: var(--accent-lt); border: 1px solid var(--accent); color: var(--accent); font-weight: 600; }
.lyric-row--upcoming { color: var(--text-dim); }
.lyric-num { font-family: var(--mono); font-size: 10px; color: var(--text-hint); width: 22px; flex-shrink: 0; text-align: right; }

#loadingOverlay { display: none; position: fixed; inset: 0; background: rgba(245,244,255,0.88); backdrop-filter: blur(12px); z-index: 999; align-items: center; justify-content: center; }
#loadingOverlay.active { display: flex; }
.loading-content { text-align: center; }
.loading-spinner { width: 42px; height: 42px; border: 3px solid var(--border-md); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.75s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.loading-sub { font-family: var(--mono); font-size: 11px; color: var(--text-hint); }

.wavesurfer-region { border-left: 2px solid var(--accent) !important; border-right: 2px solid var(--accent) !important; }
.wavesurfer-region[data-content]::before {
  content: attr(data-content); position: absolute; top: 3px; left: 5px; font-family: var(--mono); font-size: 10px;
  color: #fff; background: rgba(108,92,231,0.7); padding: 1px 6px; border-radius: 4px; white-space: nowrap; pointer-events: none; backdrop-filter: blur(4px);
}

@media (max-width: 900px) { .setup-brand { width: 220px; } .setup-form { padding: 24px 28px; } }
@media (max-width: 700px) {
  .setup-layout { flex-direction: column; } .setup-brand { width: 100%; height: auto; padding: 0; }
  .brand-inner { padding: 24px; flex-direction: row; flex-wrap: wrap; } .brand-steps, .brand-tagline { display: none; }
  .sync-body { grid-template-columns: 1fr; } .sync-right { border-left: none; border-top: 1px solid var(--border); } .panel-lyrics { display: none; }
}

/* ─── 새로 추가된 기능들의 CSS ─── */
/* SRT Import Button */
.btn-srt-import {
  display: flex; align-items: center; gap: 5px; background: var(--accent-lt); border: 1px solid var(--accent);
  color: var(--accent); border-radius: 99px; padding: 4px 10px; font-family: var(--mono); font-size: 11px; cursor: pointer; transition: all 0.2s;
}
.btn-srt-import:hover { background: var(--accent); color: #fff; }

/* Speed Select (Top bar) */
.speed-select {
  background: var(--surface2); border: 1px solid var(--border-md); color: var(--text); font-family: var(--mono);
  font-size: 12px; padding: 5px 10px; border-radius: 99px; outline: none; cursor: pointer;
}

/* Waveform Controls (Zoom) */
.waveform-controls { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.zoom-wrap {
  display: flex; align-items: center; gap: 8px; flex: 1; background: var(--surface2);
  border: 1px solid var(--border); padding: 8px 14px; border-radius: var(--radius-sm);
}
.zoom-icon { font-size: 12px; opacity: 0.7; }
.zoom-wrap input[type="range"] {
  width: 100%; accent-color: var(--accent); cursor: pointer; height: 4px; background: var(--border-md); border-radius: 99px;
  -webkit-appearance: none; appearance: none;
}
.zoom-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}