/* 种子边下边播 — dark media player UI */
:root {
  --bg: #0b0d10;
  --bg-elevated: #12151a;
  --bg-panel: #161a21;
  --bg-hover: #1c212b;
  --bg-active: #222833;
  --border: #2a3140;
  --border-subtle: #1e2430;
  --text: #e8eaed;
  --text-secondary: #9aa3b2;
  --text-muted: #6b7385;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --font: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
  --topbar-h: 56px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--accent); }

a { color: var(--accent); }

/* ——— Login ——— */
#login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(59, 130, 246, 0.18), transparent),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand .logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.login-brand h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 6px;
}

.login-form label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-form .field { margin-bottom: 16px; }
.login-form input { width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 1.2em;
}

/* ——— App shell ——— */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#app.hidden, #login-screen.hidden { display: none !important; }

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.topbar-brand .logo-sm {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  color: var(--text-secondary);
  font-size: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }

.speed-limit-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-limit-wrap input {
  width: 72px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--mono);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  color: var(--text-secondary);
  font-size: 13px;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 0;
  overflow: hidden;
}

/* ——— Left panel ——— */
.panel-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  min-height: 0;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.add-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.add-tab {
  flex: 1;
  padding: 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}
.add-tab.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 500;
}

.add-panel.hidden { display: none; }

.file-drop {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-drop input { display: none; }
.file-drop .file-name {
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  word-break: break-all;
}

.magnet-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  font-family: var(--mono);
  font-size: 12px;
}

.add-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.task-list-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}

.task-list-wrap h2 {
  padding: 0 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

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

.task-item {
  padding: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 4px;
}
.task-item:hover { background: var(--bg-hover); }
.task-item.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.35);
}

.task-item-name {
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.task-item-meta .ok { color: var(--success); }
.task-item-meta .warn { color: var(--warning); }
.task-item-meta .bad { color: var(--danger); }

.empty-hint {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ——— Right panel ——— */
.panel-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.player-area {
  flex-shrink: 0;
  background: #000;
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-area video,
.player-area audio {
  width: 100%;
  height: 100%;
  outline: none;
  background: #000;
}

.player-area audio {
  height: 54px;
  width: calc(100% - 48px);
  max-width: 640px;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 10px;
  pointer-events: none;
}
.player-placeholder.hidden { display: none; }
.player-placeholder .icon { font-size: 40px; opacity: 0.4; }

.playback-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.playback-bar .mono {
  font-family: var(--mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.files-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
  gap: 12px;
}

.files-header h2 {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-header .torrent-size {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--mono);
  flex-shrink: 0;
}

.file-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.file-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}

.file-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.file-table tr.playable {
  cursor: pointer;
}
.file-table tr.playable:hover { background: var(--bg-hover); }
.file-table tr.playing {
  background: var(--accent-soft);
}
.file-table tr.playing td:first-child { color: var(--accent); font-weight: 500; }

.file-table tr.non-playable {
  color: var(--text-muted);
  cursor: default;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-playable {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}
.badge-no {
  background: rgba(107, 115, 133, 0.2);
  color: var(--text-muted);
}

.file-size {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ——— Toasts ——— */
#toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.2s ease;
}
.toast.error { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.toast.warn { border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }
.toast.info { border-color: rgba(59, 130, 246, 0.4); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ——— Responsive ——— */
@media (max-width: 860px) {
  .main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
  }
  .player-area { max-height: 36vh; }
  .topbar-stats { display: none; }
}
