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

:root {
  --primary: #fe2c55;
  --primary-dark: #e5163d;
  --primary-light: #ff6b8a;
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #1e1e35;
  --bg-input: #16162b;
  --bg-log: #0c0c18;
  --text: #e8e8f0;
  --text-secondary: #8888a8;
  --text-muted: #55556a;
  --border: #2a2a45;
  --border-focus: #fe2c55;
  --success: #25d366;
  --error: #ff4757;
  --warning: #ffa502;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== Background decoration ===== */
.bg-decoration {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
}
.circle-1 { width: 400px; height: 400px; background: var(--primary); top: -100px; right: -100px; animation: float 20s ease-in-out infinite; }
.circle-2 { width: 300px; height: 300px; background: #25f4ee; bottom: -50px; left: -50px; animation: float 15s ease-in-out infinite reverse; }
.circle-3 { width: 200px; height: 200px; background: #8b5cf6; top: 50%; left: 50%; animation: float 18s ease-in-out infinite 3s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(30px, -30px); }
  50% { transform: translate(-20px, 20px); }
  75% { transform: translate(20px, 10px); }
}

/* ===== Page wrapper ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Top header ===== */
.top-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.top-header .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 14px;
  color: #fff;
  flex-shrink: 0;
}

.top-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.top-header .subtitle {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

/* ===== Two-column grid ===== */
.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1rem;
  min-height: 0;
}

/* ===== Panel shared ===== */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header-left {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
}

/* ===== Left panel – download config ===== */
.panel-left {
  overflow-y: auto;
}

.panel-body {
  padding: 1.25rem;
  flex-shrink: 0;
}

/* Input */
.input-group {
  margin-bottom: 1rem;
}

.input-group label,
.mode-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 2.5rem 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper input::placeholder { color: var(--text-muted); }

.input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.15);
}

.icon-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* Mode selector */
.mode-group { margin-bottom: 1.25rem; }

.mode-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.625rem 0.25rem;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.75rem;
  font-weight: 500;
}
.mode-btn:hover { border-color: var(--text-muted); color: var(--text); background: var(--bg-card-hover); }
.mode-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(254,44,85,0.08); }

/* Download button */
.download-btn {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}
.download-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 4px 20px rgba(254,44,85,0.35);
  transform: translateY(-1px);
}
.download-btn:active:not(:disabled) { transform: translateY(0); }
.download-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.download-btn .btn-loading { display: none; align-items: center; gap: 0.5rem; }
.download-btn.loading .btn-text { display: none; }
.download-btn.loading .btn-loading { display: flex; }

.spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Status */
.status-area { margin-top: 0.875rem; transition: all 0.3s ease; }
.status-area.hidden { display: none; }

.status-message {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.status-message.info { background: rgba(37,244,238,0.08); border: 1px solid rgba(37,244,238,0.2); color: #25f4ee; }
.status-message.success { background: rgba(37,211,102,0.08); border: 1px solid rgba(37,211,102,0.2); color: var(--success); }
.status-message.error { background: rgba(255,71,87,0.08); border: 1px solid rgba(255,71,87,0.2); color: var(--error); }

/* ===== History (inside left panel) ===== */
.history-section { border-top: 1px solid var(--border); }
.history-section.hidden { display: none; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-list {
  padding: 0.5rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.history-item:hover { border-color: var(--text-muted); }

.history-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.history-icon.video { background: rgba(254,44,85,0.12); color: var(--primary); }
.history-icon.audio { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.history-icon.cover { background: rgba(37,244,238,0.12); color: #25f4ee; }

.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: 0.75rem; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-meta { font-size: 0.625rem; color: var(--text-muted); }

.history-download {
  flex-shrink: 0; color: var(--text-muted); text-decoration: none;
  padding: 4px; border-radius: 6px; display: flex; align-items: center;
  transition: all var(--transition);
}
.history-download:hover { color: var(--primary); background: rgba(254,44,85,0.08); }

/* ===== Right panel – log ===== */
.panel-right {
  display: flex;
  flex-direction: column;
}

.log-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", "SF Mono",
    "Consolas", "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  background: var(--bg-log);
  min-height: 200px;
}

.log-content::-webkit-scrollbar { width: 6px; }
.log-content::-webkit-scrollbar-track { background: transparent; }
.log-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.log-content::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.log-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 2rem;
  text-align: center;
}

.log-line {
  padding: 0.125rem 0.875rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  transition: background 0.15s ease;
}
.log-line:hover { background: rgba(255,255,255,0.02); }
.log-line.level-INFO    { color: #8be9fd; border-left-color: #8be9fd; }
.log-line.level-WARNING { color: var(--warning); border-left-color: var(--warning); }
.log-line.level-ERROR   { color: var(--error); border-left-color: var(--error); }
.log-line.level-DEBUG   { color: var(--text-muted); border-left-color: var(--text-muted); }
.log-line.level-SUCCESS { color: var(--success); border-left-color: var(--success); }

.log-line-new { animation: logFadeIn 0.3s ease; }
@keyframes logFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Shared small elements ===== */
.text-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.75rem; padding: 4px 8px;
  border-radius: 4px; transition: all var(--transition);
}
.text-btn:hover { color: var(--error); background: rgba(255,71,87,0.08); }
.text-btn-sm { font-size: 0.6875rem; padding: 2px 6px; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 0.75rem;
  color: var(--text-muted);
  font-size: 0.6875rem;
  margin-top: auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .panel-right {
    min-height: 300px;
  }

  .top-header h1 { font-size: 1.125rem; }
}
