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

:root {
  --bg-base:    #0d0d1a;
  --bg-surface: #13132a;
  --bg-raised:  #1a1a35;
  --bg-hover:   #20203d;
  --border:     #252545;
  --border-hi:  #353565;
  --accent:     #7c3aed;
  --accent-2:   #3b82f6;
  --text-pri:   #e8e8f0;
  --text-sec:   #9090b0;
  --text-muted: #55557a;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-base);
  color: var(--text-pri);
  font-size: 18px;
}

/* ========== Status Bar ========== */

.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: #0d0d2a;
  border-top: 1px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(124,58,237,0.15);
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 160px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.status-job-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #c4b5fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.status-bar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.status-progress-bg {
  flex: 1;
  height: 4px;
  background: var(--bg-raised);
  border-radius: 2px;
  overflow: hidden;
}

.status-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
  transition: width 0.6s ease;
  width: 0%;
}

.status-msg {
  font-size: 0.78rem;
  color: var(--text-sec);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-bar-right {
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

.status-pct {
  font-size: 0.78rem;
  font-weight: 700;
  color: #a78bfa;
}

/* ========== App Layout ========== */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ========== Left Sidebar ========== */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-user-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.credit-badge {
  font-size: 0.68rem;
  color: #f59e0b;
  font-weight: 600;
  flex-shrink: 0;
}
.credit-hold-badge {
  color: #f59e0b;
  font-size: 0.75rem;
}
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  flex-shrink: 0;
}
.btn-logout {
  width: 100%;
  background: none;
  border: 1px solid var(--border-hi);
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.btn-logout:hover {
  color: #f87171;
  border-color: #f87171;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { font-size: 1.3rem; }
.logo-img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.logo-banner { width: 100%; height: auto; }

.logo-text {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-section-label {
  padding: 14px 16px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  flex-shrink: 0;
}

.new-project-row {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  flex-shrink: 0;
}

.new-project-row input {
  flex: 1;
  padding: 7px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-pri);
  font-size: 0.82rem;
  min-width: 0;
}

.new-project-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-icon-add {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.btn-icon-add:hover { opacity: 0.85; }

.sidebar-project-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.sidebar-project-list::-webkit-scrollbar { width: 4px; }
.sidebar-project-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-project-list::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.sidebar-project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.sidebar-project-item:hover { background: var(--bg-hover); }
.sidebar-project-item.active { background: rgba(124,58,237,0.18); }
.sidebar-project-item.active .sidebar-project-name { color: #c4b5fd; }

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

.sidebar-project-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-pri);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-project-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-sidebar-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-project-item:hover .btn-sidebar-delete { opacity: 1; }
.btn-sidebar-delete:hover { color: #f87171; background: rgba(248,113,113,0.1); }

.sidebar-empty {
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ========== Main Content ========== */

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  min-width: 0;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; opacity: 0.4; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-sec); }
.empty-sub { font-size: 0.85rem; }

/* Main Header */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.main-project-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-pri);
}

.btn-delete-project {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-hi);
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete-project:hover {
  border-color: #f87171;
  color: #f87171;
  background: rgba(248,113,113,0.07);
}

/* Section Boxes */
.section-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header-row .section-title { margin-bottom: 0; }

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

/* Completed Cards */
.completed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.completed-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.2s, background 0.2s;
  cursor: grab;
}

.completed-card:hover { background: var(--bg-hover); border-color: var(--border-hi); }
.completed-card.selected { border-color: var(--accent); background: rgba(124,58,237,0.1); }
.completed-card.dragging { opacity: 0.4; }
.completed-card.drag-over { border-color: var(--accent-2); border-style: dashed; }

.drag-handle {
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.job-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

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

.completed-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-pri);
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
.completed-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.badge-edited, .badge-editing {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
  opacity: 0.85;
}
.badge-edited {
  color: var(--accent);
  border: 1px solid var(--accent);
}
.badge-editing {
  color: #f59e0b;
  border: 1px solid #f59e0b;
}

.completed-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.job-id, .project-id {
  font-family: monospace;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.7;
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: opacity 0.15s, border-color 0.15s;
}
.job-id:hover, .project-id:hover {
  opacity: 1;
  border-bottom-color: var(--text-muted);
}

.completed-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.btn-dl {
  padding: 4px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  color: var(--text-sec);
  font-size: 0.75rem;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-dl:hover { background: var(--bg-hover); color: var(--text-pri); }

.btn-merge {
  padding: 6px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.btn-merge:hover { opacity: 0.9; }
.btn-merge:disabled { opacity: 0.4; cursor: wait; }

.btn-delete-selected {
  padding: 6px 18px;
  background: #ef4444;
  border: none;
  border-radius: 7px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-delete-selected:hover { opacity: 0.85; }

/* Active Cards */
.active-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 6px;
}

.active-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.job-status {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-done       { background: #064e3b; color: #6ee7b7; }
.status-processing,
.status-queued     { background: #1e3a5f; color: #93c5fd; }
.status-error      { background: #4c1d1d; color: #fca5a5; }
.status-composing  { background: #3b1e5f; color: #c4b5fd; }

.queue-badge {
  font-size: 0.65rem;
  color: #f59e0b;
  font-weight: 600;
}

.btn-delete-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.btn-delete-sm:hover { color: #f87171; }

.job-progress { margin-top: 4px; }

.progress-bar-bg {
  width: 100%;
  height: 5px;
  background: var(--bg-base);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0 4px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-msg { color: var(--text-sec); font-size: 0.82rem; }

.job-error { color: #fca5a5; font-size: 0.82rem; margin-top: 4px; }

/* Merge Cards */
.merge-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
}

.merge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.merge-title {
  font-size: 0.88rem;
  color: var(--text-pri);
  flex: 1;
}

.merge-title.clickable { cursor: pointer; user-select: none; }
.merge-title.clickable:hover { color: #a78bfa; }
.clickable { cursor: pointer; user-select: none; }
.completed-info.clickable:hover .completed-name,
.active-info .completed-name.clickable:hover { color: #a78bfa; text-decoration: underline; }
.merge-toggle { font-size: 0.6rem; color: #7c8cf8; }

.merge-songs {
  flex-direction: column;
  gap: 3px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.merge-song-item { font-size: 0.78rem; color: var(--text-sec); padding: 2px 4px; }

.merge-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 0.88rem;
}

/* ========== Right Form Panel ========== */

.form-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}

.form-panel::-webkit-scrollbar { width: 4px; }
.form-panel::-webkit-scrollbar-track { background: transparent; }
.form-panel::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.panel-header {
  padding: 18px 20px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-new-form {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}
.btn-new-form:hover { background: var(--accent); color: #fff; }

#mvForm { padding: 16px 20px 24px; }

/* Form elements */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-sec);
  margin-bottom: 5px;
  font-weight: 500;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72rem;
}
.file-hint {
  font-size: 0.72rem;
  color: #a78bfa;
  margin-top: 3px;
  min-height: 0;
}
.slider-val {
  font-weight: 600;
  color: var(--accent);
  margin-left: 6px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 6px;
}

input[type="file"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-pri);
  font-size: 0.82rem;
  cursor: pointer;
}

input[type="file"]:focus { outline: none; border-color: var(--accent); }

input[type="file"]::file-selector-button {
  background: var(--bg-hover);
  border: 1px solid var(--border-hi);
  color: var(--text-sec);
  padding: 4px 10px;
  border-radius: 5px;
  margin-right: 8px;
  cursor: pointer;
  font-size: 0.78rem;
}

input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-pri);
  font-size: 0.85rem;
}

input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* Toggle group */
.toggle-group {
  display: flex;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.toggle-group input { display: none; }

.toggle-group label {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  background: var(--bg-raised);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-sec);
  margin: 0;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
}

.toggle-group label:last-of-type { border-right: none; }

.toggle-group input:checked + label {
  background: rgba(124,58,237,0.25);
  color: #c4b5fd;
}

/* Color swatches */
.palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}
.ps {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.12s, transform 0.12s;
  flex-shrink: 0;
}
.ps:hover { transform: scale(1.15); }
.ps-active {
  border-color: #a78bfa;
  box-shadow: 0 0 6px rgba(167,139,250,0.6);
}
.color-picker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 1px;
  cursor: pointer;
  background: transparent;
  flex-shrink: 0;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-sec);
}

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

/* Form divider */
.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0 16px;
}

/* Submit button */
.btn-submit {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 9px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: opacity 0.2s;
}

.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* Error */
.error-msg { display: none; color: #f87171; font-size: 0.82rem; margin-top: 10px; }
.error-msg.active { display: block; }

/* ========== Modal ========== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-pri);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close-btn:hover {
  color: #f87171;
}

.modal-msg {
  color: var(--text-sec);
  font-size: 0.88rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-secondary {
  padding: 7px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-radius: 7px;
  color: var(--text-sec);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  padding: 7px 18px;
  background: #c0392b;
  border: none;
  border-radius: 7px;
  color: white;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

/* ========== Text Position Modal ========== */

/* "Set as project default" button inside the modal actions */
.btn-set-default {
  background: none;
  border: 1px solid rgba(255,220,50,0.35);
  border-radius: 6px;
  color: rgba(255,220,50,0.75);
  font-size: 0.78rem;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-set-default:hover {
  background: rgba(255,220,50,0.1);
  border-color: rgba(255,220,50,0.7);
  color: rgba(255,220,50,1);
}

.btn-back-default {
  background: none;
  border: 1px solid rgba(150,180,255,0.35);
  border-radius: 6px;
  color: rgba(150,180,255,0.75);
  font-size: 0.78rem;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-back-default:hover {
  background: rgba(150,180,255,0.1);
  border-color: rgba(150,180,255,0.7);
  color: rgba(150,180,255,1);
}

/* Button in the form that opens the modal */
.btn-text-pos {
  width: 100%;
  padding: 9px 14px;
  background: rgba(124,58,237,0.12);
  border: 1px dashed rgba(124,58,237,0.45);
  border-radius: 8px;
  color: #c4b5fd;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}
.btn-text-pos:hover {
  background: rgba(124,58,237,0.22);
  border-color: rgba(124,58,237,0.7);
}

/* Small summary line below the button */
.text-pos-summary {
  font-size: 0.75rem;
  color: var(--text-sec);
  margin-top: 5px;
  text-align: center;
}

/* Modal box override for text-pos (wider to fit canvas + controls) */
.text-pos-modal-box {
  max-width: 620px;
  width: 95vw;
  max-height: 95vh;
  overflow-y: auto;
  transition: max-width 0.2s ease;
}
.text-pos-modal-box.landscape {
  max-width: 720px;
}

/* Two-column flex layout: canvas left, controls right */
.text-pos-modal-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.text-pos-modal-body.landscape {
  flex-direction: column;
  align-items: stretch;
}
.text-pos-modal-body.landscape .text-pos-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.text-pos-modal-body.landscape .tpc-section {
  width: 100%;
}

.text-pos-canvas-col {
  flex-shrink: 0;
}

/* Right-side style controls panel */
.text-pos-controls {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 24px;
}

.tpc-section {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-sec);
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
  margin-top: 8px;
}
.tpc-section:first-child { margin-top: 0; }

.tpc-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tpc-label {
  font-size: 0.75rem;
  color: var(--text-pri);
}

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

.tpc-row input[type="color"] {
  width: 48px;
  height: 28px;
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  cursor: pointer;
  background: none;
  padding: 2px;
}

.text-canvas {
  position: relative;
  width: 360px;
  height: 640px;
  background: #111120;
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  overflow: hidden;
  margin: 0 auto;
  box-shadow: 0 0 0 3px var(--bg-card), 0 4px 16px rgba(0,0,0,0.5);
}
.text-canvas-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.9;
}

/* Draggable text handles */
.text-handle {
  position: absolute;
  transform: translate(0, 0);  /* top-left anchor matches ASS Alignment=7 for Song/Artist */
  z-index: 2;
  background: rgba(0,0,0,0.6);  /* overridden by JS with user color */
  color: #fff;                   /* overridden by JS */
  font-size: 0.65rem;            /* overridden by JS */
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: move;
  user-select: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.5);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  transition: opacity 0.15s;
}

.text-handle::before {
  content: attr(data-label) ' ✥';
}

.text-handle:active {
  opacity: 0.75;
}
#handle-subtitle {
  transform: translate(-50%, 0);  /* bottom-center anchor matches ASS Alignment=2 */
}


.canvas-hint { display: none; }

/* Alignment guide lines shown during drag */
.canvas-guideline {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.1s;
}
.canvas-guideline.visible { opacity: 1; }
/* horizontal guide: spans full width */
.canvas-guideline.h {
  left: 0; right: 0; height: 0;
  border-top: 1px dashed rgba(255, 200, 60, 0.7);
}
/* vertical guide: spans full height */
.canvas-guideline.v {
  top: 0; bottom: 0; width: 0;
  border-left: 1px dashed rgba(255, 200, 60, 0.7);
}
/* canvas center lines: slightly different color */
.canvas-guideline.center {
  border-color: rgba(120, 200, 255, 0.5);
  border-style: dashed;
}
/* edge lines: slightly more transparent than center lines */
.canvas-guideline.edge {
  border-color: rgba(255, 200, 60, 0.4);
}
/* active handle's own guide lines (follow while dragging) */
.canvas-guideline.active {
  border-color: rgba(100, 220, 255, 0.9);
  border-style: solid;
}
.canvas-guideline.active.edge {
  border-color: rgba(100, 220, 255, 0.55);
  border-style: dashed;
}

/* ========== Text Position Quick View ========== */

.text-pos-quickview {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #111120;
  border: 1px solid var(--border-hi);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-pos-quickview:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124,58,237,0.3);
}

.tpq-handle {
  position: absolute;
  transform: translate(0, 0);  /* top-left for Song/Artist */
  font-size: 6px; /* overridden by JS */
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 2px;
  border: 1px solid currentColor;
  background: rgba(0,0,0,0.6);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.4;
}
.tpq-handle::before {
  content: attr(data-label);
}
#qv-subtitle {
  transform: translate(-50%, 0);
}

.tpq-hint {
  position: absolute;
  bottom: 5px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 5px;
  color: rgba(255,255,255,0.45);
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* ========== Orientation Toggle ========== */

.orientation-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}
.orient-btn {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.orient-btn:hover { color: var(--text-primary); }
.orient-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Landscape canvas mode */
.text-canvas.landscape {
  width: 640px;
  height: 360px;
}
.text-pos-quickview.landscape {
  aspect-ratio: 16 / 9;
}

/* ========== Help Tooltip ========== */

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 4px;
}
.help-tip .help-tip-text {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  color: #ffd700;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  z-index: 100;
  white-space: normal;
  text-align: left;
}
.help-tip:hover .help-tip-text,
.help-tip:focus .help-tip-text {
  display: block;
}

/* ========== Timeline Editor ========== */
.tl-modal-box {
  width: 96vw;
  height: 92vh;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  box-sizing: border-box;
}
.tl-preview-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  background: #000;
  overflow: hidden;
}
.tl-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.tl-overlay-handle {
  position: absolute;
  color: #fff;
  font-weight: bold;
  text-shadow: 0 2px 6px #000, 0 0 3px #000;
  cursor: move;
  user-select: none;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  z-index: 5;
  touch-action: none;
  transition: border-color 0.15s;
  font-family: "Noto Sans CJK SC", "Noto Sans CJK KR", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
.tl-overlay-handle:hover {
  border-color: rgba(255,255,255,0.4);
}
.tl-overlay-sub {
  bottom: 10%;
  top: auto;
  text-align: center;
  transform: translateX(-50%);
}
#tlOvArtist {
  font-weight: normal;
}
/* Hide text overlays when video already has burned-in subtitles */
.tl-preview-wrap.no-clean .tl-overlay-handle { display: none; }
.tl-zoom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tl-zoom-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.tl-zoom-slider {
  flex: 1;
  max-width: 220px;
  accent-color: var(--accent);
  cursor: pointer;
}
#tlZoomVal {
  font-size: 12px;
  color: var(--accent);
  min-width: 32px;
  flex-shrink: 0;
}
.tl-scroll-wrapper {
  position: relative;
  flex-shrink: 0;
}
.tl-scroll-area {
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-width: none;
  min-height: 80px;
}
.tl-scroll-area::-webkit-scrollbar { display: none; }
.tl-scrollbar-track {
  position: relative;
  height: 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 7px;
  margin-top: 6px;
  flex-shrink: 0;
  cursor: pointer;
}
.tl-lyric-display {
  text-align: center;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  flex-shrink: 0;
}
.tl-lyric-primary {
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  line-height: 1.3;
  max-width: 100%;
  word-break: keep-all;
  overflow-wrap: break-word;
  font-family: "Noto Sans CJK SC", "Noto Sans CJK KR", "Noto Sans CJK JP", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Malgun Gothic", system-ui, sans-serif;
}
.tl-lyric-secondary {
  font-size: 18px;
  color: var(--text-muted);
  line-height: 1.3;
  max-width: 100%;
  word-break: keep-all;
  overflow-wrap: break-word;
  font-family: "Noto Sans CJK SC", "Noto Sans CJK KR", "Noto Sans CJK JP", "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Malgun Gothic", system-ui, sans-serif;
}
.tl-transport {
  display: flex;
  justify-content: center;
  margin-top: 10px;
  flex-shrink: 0;
}
.tl-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  line-height: 1;
  padding: 0;
}
.tl-play-btn:hover { background: var(--accent-2); transform: scale(1.08); }
.tl-scrollbar-thumb {
  position: absolute;
  top: 0; bottom: 0;
  min-width: 24px;
  background: var(--accent);
  border-radius: 7px;
  cursor: grab;
  transition: background 0.15s;
}
.tl-scrollbar-thumb:hover, .tl-scrollbar-thumb.dragging { background: var(--accent-2); cursor: grabbing; }
.tl-inner {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-ruler {
  position: relative;
  height: 22px;
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.tl-tick {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.tl-container {
  position: relative;
  height: 70px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: crosshair;
}
.tl-playhead {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  pointer-events: all;
  cursor: ew-resize;
  z-index: 20;
  left: 0;
  transform: translateX(0);
  box-shadow: 0 0 4px var(--accent);
  padding: 0 3px;
  margin-left: -3px;
  background-clip: content-box;
}
.tl-chip {
  position: absolute;
  top: 6px; bottom: 6px;
  min-width: 3px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 5px;
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  cursor: grab;
  user-select: none;
  overflow: hidden;
  box-sizing: border-box;
  transition: box-shadow 0.1s;
}
.tl-chip:hover {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}
.tl-chip.dragging {
  cursor: grabbing;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  opacity: 0.92;
  z-index: 20;
}
.tl-chip-time {
  font-size: 9px;
  color: rgba(255,255,255,0.75);
  line-height: 1;
  font-family: monospace;
}
.tl-chip-text {
  font-size: 11px;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-chip-lock {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  line-height: 1;
  color: rgba(255,255,255,0.25);
  pointer-events: none;
  z-index: 5;
  transition: color 0.15s;
}
.tl-chip.locked .tl-chip-lock {
  color: #22c55e;
  text-shadow: 0 0 6px rgba(34,197,94,0.6);
}
.tl-chip.locked {
  cursor: default;
  border: 1.5px solid rgba(74,222,128,0.5);
  opacity: 0.85;
}
.tl-chip-resize, .tl-chip-resize-left {
  position: absolute;
  top: 0; bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: rgba(255,255,255,0.15);
  opacity: 0;
  transition: opacity 0.15s;
}
.tl-chip-resize { right: 0; border-radius: 0 4px 4px 0; }
.tl-chip-resize-left { left: 0; border-radius: 4px 0 0 4px; }
.tl-chip:hover .tl-chip-resize, .tl-chip:hover .tl-chip-resize-left { opacity: 1; }
.tl-chip.locked .tl-chip-resize, .tl-chip.locked .tl-chip-resize-left { opacity: 0; }
.tl-chip.locked:hover .tl-chip-resize, .tl-chip.locked:hover .tl-chip-resize-left { opacity: 1; }
.tl-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.btn-edit-timing {
  background: rgba(139,92,246,0.15);
  border: 1px solid rgba(139,92,246,0.4);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-edit-timing:hover {
  background: rgba(139,92,246,0.28);
}

/* ========== Drop Zones ========== */
.drop-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-hi);
  border-radius: 8px;
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.drop-zone:hover, .drop-zone.dz-over {
  border-color: var(--accent);
  background: rgba(139,92,246,0.08);
}
.drop-zone.dz-over {
  border-style: solid;
}
.dz-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.dz-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
