/* ══════════════════════════════════════════════════
   VideoFetch — Dark Theme (HSL System)
   ══════════════════════════════════════════════════ */

:root {
  /* ── Core colors (HSL) ── */
  --bg: hsl(220, 24%, 13%);
  --surface: hsl(220, 22%, 16%);
  --surface2: hsl(218, 21%, 21%);
  --surface3: hsl(218, 18%, 25%);
  --border: hsl(218, 17%, 30%);
  --border-light: hsl(218, 17%, 38%);
  --text: hsl(210, 40%, 94%);
  --text2: hsl(214, 22%, 70%);
  --text3: hsl(214, 18%, 52%);

  /* ── Accent (green) ── */
  --accent-h: 142;
  --accent-s: 58%;
  --accent-l: 60%;
  --accent: hsl(var(--accent-h), var(--accent-s), var(--accent-l));
  --accent-hover: hsl(var(--accent-h), var(--accent-s), 68%);
  --accent-muted: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.12);
  --accent-glow: hsla(var(--accent-h), var(--accent-s), var(--accent-l), 0.22);

  /* ── Semantic ── */
  --green: hsl(142, 58%, 60%);
  --red: hsl(0, 63%, 56%);
  --yellow: hsl(42, 85%, 58%);
  --blue: hsl(210, 80%, 62%);

  /* ── Radius ── */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* ── Font ── */
  --font: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* ══════════════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════════════ */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
  line-height: 1.55;
  /* Background: dark navy + subtle 22px grid */
  background-color: hsl(220, 24%, 13%);
  background-image:
    linear-gradient(rgba(157, 173, 194, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 173, 194, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ══════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════ */

.container {
  width: 100%;
  max-width: 1100px;
  padding: 1.5rem 0 2rem;
}

/* ══════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════ */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}

.topbar .logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.topbar .logo span {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ── Points badge ── */
.points-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.7rem 0.25rem 0.55rem;
  font-size: 0.78rem;
  color: var(--yellow);
  display: none;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}
.points-badge .icon {
  width: 14px;
  height: 14px;
}
.points-badge.visible {
  display: inline-flex;
}

/* ── User button ── */
.user-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 1rem;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.user-btn:hover {
  background: var(--surface2);
  border-color: var(--border-light);
}
.user-btn.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.user-btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.user-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Avatar-only button (topbar) ── */
.avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 0;
}
.avatar-btn:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

/* ── User menu dropdown ── */
.user-menu {
  position: relative;
  display: none;
}
.user-menu.visible {
  display: block;
}
.user-menu .dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 170px;
  z-index: 100;
  display: none;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.user-menu .dropdown.open {
  display: block;
}
.user-menu .dropdown button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s;
}
.user-menu .dropdown button:hover {
  background: var(--surface3);
}
.user-menu .dropdown .danger {
  color: var(--red);
}
.user-menu .dropdown .divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0.75rem;
}

/* ── Wide dropdown (profile card) ── */
.dropdown-wide {
  min-width: 240px !important;
}

/* ── Avatar circle ── */
.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-letter {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.avatar-circle.large {
  width: 44px;
  height: 44px;
}
.avatar-letter.large {
  font-size: 1.2rem;
}
.avatar-circle.xlarge {
  width: 64px;
  height: 64px;
}
.avatar-letter.xlarge {
  font-size: 1.8rem;
}

/* ── Dropdown profile header ── */
.dropdown-profile-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.5rem;
}
.dp-info {
  flex: 1;
  min-width: 0;
}
.dp-username {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-rank {
  font-size: 0.75rem;
  color: var(--yellow);
  margin-top: 0.15rem;
}
.dp-stats {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 1rem 0.4rem;
}
.dp-stat {
  flex: 1;
  text-align: center;
  background: var(--surface3);
  border-radius: var(--radius-xs);
  padding: 0.3rem 0;
}
.dp-stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text3);
}
.dp-stat-value {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.dp-rank-value {
  color: var(--yellow);
}
.dp-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--text3);
  padding: 0.2rem 1rem 0.4rem;
}

/* ── Profile edit card ── */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.profile-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* Top row: avatar presets + password side by side */
.profile-top-row {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.profile-avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  min-width: 130px;
}
.avatar-presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}
.preset-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.preset-dot:hover {
  transform: scale(1.18);
}
.preset-dot.active {
  border-color: var(--text);
  transform: scale(1.12);
}
.preset-dot.def-dot {
  border: 2px dashed var(--text3);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text2);
}

/* Password column */
.profile-password-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  justify-content: center;
}
.profile-password-col input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}
.profile-password-col input:focus {
  border-color: var(--accent);
  outline: none;
}

/* Stats row: 4 equal boxes */
.profile-stats-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.pstat-box {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  text-align: center;
}
.pstat-icon { font-size: 1.1rem; margin-bottom: 0.2rem; }
.pstat-label { font-size: 0.68rem; color: var(--text3); text-transform: uppercase; margin-bottom: 0.15rem; }
.pstat-val { font-size: 0.82rem; font-weight: 600; color: var(--text); }

/* Clickable avatar */
.avatar-circle.clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.avatar-circle.clickable:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.avatar-hint {
  font-size: 0.7rem;
  color: var(--text3);
  text-align: center;
  margin-top: 0.3rem;
}

/* Avatar picker grid */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.avatar-option {
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.12s, transform 0.12s;
  background: var(--surface2);
}
.avatar-option:hover {
  border-color: var(--accent);
  transform: scale(1.06);
}
.avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-option.default-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text2);
}

/* ── Admin-only elements (hidden until JS confirms admin) ── */
.admin-only {
  display: none;
}

/* ── Captcha ── */
.captcha-field {
  margin-bottom: 0.75rem;
}
.captcha-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}
.captcha-img {
  border-radius: var(--radius-xs);
  cursor: pointer;
  height: 44px;
  border: 1px solid var(--border);
}
.captcha-reload-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text2);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.3rem 0.6rem;
  line-height: 1;
  transition: color 0.15s;
}
.captcha-reload-btn:hover {
  color: var(--accent);
}

/* ── Topbar stats ── */
.topbar-stats {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.5rem;
}
.ts-item {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.32rem 0.5rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.ts-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
#tsPoints { color: var(--yellow); font-weight: 600; }
#tsLevel { color: var(--accent); font-weight: 600; }
#tsDownloads { color: var(--blue); font-weight: 600; }

/* ── Redeem card ── */
.redeem-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.redeem-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.redeem-card .desc {
  font-size: 0.78rem;
  color: var(--text2);
  margin-bottom: 0.75rem;
}
.redeem-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.redeem-input-row input {
  padding: 0.5rem 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}
.redeem-input-row input:focus {
  border-color: var(--accent);
  outline: none;
}

/* ══════════════════════════════════════════════════
   HERO
   ══════════════════════════════════════════════════ */

.hero {
  text-align: center;
  margin: 1rem 0 1.5rem;
}
.hero h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  background: linear-gradient(135deg, var(--accent), hsl(170, 71%, 45%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text2);
  font-size: 0.88rem;
}

/* ══════════════════════════════════════════════════
   URL INPUT
   ══════════════════════════════════════════════════ */

.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.input-card input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
.input-card input::placeholder {
  color: var(--text3);
}
.input-card button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.input-card button:hover {
  background: var(--accent-hover);
}
.input-card button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ══════════════════════════════════════════════════
   ERROR
   ══════════════════════════════════════════════════ */

.error-msg {
  background: hsla(0, 72%, 56%, 0.1);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  display: none;
  border: 1px solid hsla(0, 72%, 56%, 0.15);
}
.error-msg.visible {
  display: block;
}

/* ══════════════════════════════════════════════════
   VIDEO INFO
   ══════════════════════════════════════════════════ */

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.25rem;
  padding: 1.2rem;
  display: none;
  gap: 1rem;
}
.info-card.visible {
  display: flex;
}

.info-thumb {
  flex-shrink: 0;
  width: 200px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
  aspect-ratio: 16/9;
}
.info-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info-body {
  flex: 1;
  min-width: 0;
}
.info-body h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.45rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.info-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 0.3rem;
}
.info-meta .tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.info-meta .tag svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   FORMATS
   ══════════════════════════════════════════════════ */

.formats-section {
  margin-top: 1.25rem;
  display: none;
}
.formats-section.visible {
  display: block;
}
.formats-section h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.6rem;
}

.format-grid {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.format-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: default;
  transition: border-color 0.15s;
}
.format-item:hover {
  border-color: var(--border-light);
}

.format-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex-wrap: wrap;
}

.format-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge-va {
  background: var(--accent-muted);
  color: var(--accent);
}
.badge-v {
  background: hsla(142, 71%, 50%, 0.12);
  color: var(--green);
}
.badge-a {
  background: hsla(42, 96%, 54%, 0.12);
  color: var(--yellow);
}

.format-detail {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  min-width: 0;
  flex-wrap: wrap;
}
.format-detail .ql {
  font-weight: 500;
}
.format-detail .meta {
  color: var(--text2);
  font-size: 0.78rem;
}

.format-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.points-cost {
  font-size: 0.75rem;
  color: var(--yellow);
  font-weight: 600;
  white-space: nowrap;
}

.dl-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-xs);
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.dl-btn:hover {
  background: var(--accent-hover);
}
.dl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.dl-btn.insuff {
  background: var(--surface3);
  color: var(--text2);
  cursor: not-allowed;
  opacity: 1;
}
.dl-btn.insuff:hover {
  background: var(--surface3);
}

/* ══════════════════════════════════════════════════
   AUTH PAGE (standalone)
   ══════════════════════════════════════════════════ */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.8rem;
  width: 100%;
  max-width: 400px;
}

.auth-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.auth-card .sub {
  color: var(--text2);
  font-size: 0.82rem;
  margin-bottom: 1.3rem;
}

.auth-card .field {
  margin-bottom: 0.85rem;
}
.auth-card .field label {
  display: block;
  font-size: 0.78rem;
  color: var(--text2);
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.auth-card .field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.auth-card .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.auth-card .submit-btn {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 0.2rem;
  transition: background 0.15s;
}
.auth-card .submit-btn:hover {
  background: var(--accent-hover);
}
.auth-card .submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.auth-card .switch-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text2);
}
.auth-card .switch-link a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.auth-card .switch-link a:hover {
  text-decoration: underline;
}

.auth-card .auth-err {
  color: var(--red);
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
  display: none;
  background: hsla(0, 72%, 56%, 0.08);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
}
.auth-card .auth-err.visible {
  display: block;
}

.auth-card .auth-ok {
  color: var(--green);
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
  display: none;
  background: hsla(142, 71%, 50%, 0.08);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-xs);
}
.auth-card .auth-ok.visible {
  display: block;
}

.auth-card .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text2);
  margin-bottom: 1rem;
}
.auth-card .back-link:hover {
  color: var(--text);
  text-decoration: none;
}

/* ══════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ══════════════════════════════════════════════════ */

.app-layout {
  display: none;
  margin-top: 0.5rem;
  gap: 1rem;
}
.app-layout.visible {
  display: flex;
}

.sidebar {
  width: 160px;
  flex-shrink: 0;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 0;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.sidebar-item:hover {
  color: var(--text);
  background: var(--surface2);
}
.sidebar-item.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 500;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.75rem;
}

.main-content {
  flex: 1;
  min-width: 0;
}

/* ── Dashboard tab panels ── */
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ══════════════════════════════════════════════════
   DASHBOARD — History
   ══════════════════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.dash-table th,
.dash-table td {
  padding: 0.6rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dash-table th {
  color: var(--text2);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-table td {
  color: var(--text);
}
.dash-table .url-cell a {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.78rem;
}
.dash-table .url-cell a:hover {
  text-decoration: underline;
}

/* ── Admin panel action buttons ── */
.admin-action-btn.small {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.2rem;
}
.admin-action-btn.small.danger {
  color: var(--red);
  border-color: var(--red);
}
.admin-action-btn.small.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}
.pts-value {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.admin-pts-cell {
  white-space: nowrap;
}
.log-action {
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
.text-muted { color: var(--text3); font-size: 0.75rem; }
.text-green { color: var(--green); font-size: 0.78rem; font-weight: 600; }

.dash-table .title-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-table .title-cell:hover {
  overflow: visible;
  white-space: normal;
  position: relative;
  background: var(--surface);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  z-index: 2;
}

.action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  margin-right: 0.25rem;
  transition: border-color 0.12s;
}
.action-btn:hover {
  border-color: var(--text2);
}
.action-btn.danger {
  color: var(--red);
  border-color: hsla(0, 72%, 56%, 0.25);
}
.action-btn.danger:hover {
  border-color: var(--red);
  background: hsla(0, 72%, 56%, 0.08);
}

.clear-btn {
  background: none;
  border: 1px solid hsla(0, 72%, 56%, 0.3);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 0.75rem;
  transition: background 0.12s;
}
.clear-btn:hover {
  background: hsla(0, 72%, 56%, 0.08);
}

/* ══════════════════════════════════════════════════
   DASHBOARD — Points
   ══════════════════════════════════════════════════ */

.points-balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.points-balance-card .icon {
  width: 32px;
  height: 32px;
  background: hsla(42, 96%, 54%, 0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.points-balance-card .label {
  font-size: 0.78rem;
  color: var(--text2);
}
.points-balance-card .amount {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--yellow);
}

.points-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.points-row:last-child {
  border-bottom: none;
}
.points-row .amount {
  font-weight: 600;
}
.points-row .amount.pos {
  color: var(--green);
}
.points-row .amount.neg {
  color: var(--red);
}
.points-row .reason {
  color: var(--text2);
  font-size: 0.78rem;
}
.points-row .date {
  font-size: 0.75rem;
  color: var(--text3);
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   DASHBOARD — Referral
   ══════════════════════════════════════════════════ */

.ref-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.ref-card > strong {
  font-size: 1rem;
}
.ref-card .desc {
  font-size: 0.78rem;
  color: var(--text2);
  margin: 0.3rem 0 0.75rem;
}

.ref-link-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
}
.ref-link-row code {
  flex: 1;
  font-size: 0.82rem;
  color: var(--accent);
  font-family: var(--font-mono);
  word-break: break-all;
}
.ref-link-row button {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.12s;
}
.ref-link-row button:hover {
  background: var(--accent-hover);
}
.ref-link-row button.copied {
  background: var(--green);
}

.ref-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
}
.ref-stats .stat {
  text-align: center;
}
.ref-stats .stat .num {
  font-size: 1.2rem;
  font-weight: 700;
  display: block;
}
.ref-stats .stat .label {
  color: var(--text2);
  font-size: 0.75rem;
  margin-top: 0.05rem;
}

/* ══════════════════════════════════════════════════
   DASHBOARD — Cookie
   ══════════════════════════════════════════════════ */

.cookie-panel p {
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 0.75rem;
}

.cookie-guide {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}
.cookie-guide h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.cookie-guide .step-list {
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.7;
  padding-left: 1.1rem;
  margin: 0.3rem 0;
}
.cookie-guide .step-list a {
  color: var(--accent);
}

.cookie-status-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  margin: 0.75rem 0;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
}
.status-dot.loaded {
  background: var(--green);
  box-shadow: 0 0 6px hsla(142, 71%, 50%, 0.4);
}

.cookie-input-area {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}
.cookie-input-area textarea {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s;
}
.cookie-input-area textarea:focus {
  border-color: var(--accent);
}
.cookie-input-area .actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cookie-file-area {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px dashed var(--border);
}

.cookie-msg {
  font-size: 0.78rem;
  margin-top: 0.5rem;
  display: none;
}
.cookie-msg.visible {
  display: block;
}
.cookie-msg.ok {
  color: var(--green);
}
.cookie-msg.err {
  color: var(--red);
}

/* ══════════════════════════════════════════════════
   DASHBOARD — Settings / Admin
   ══════════════════════════════════════════════════ */

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-top: 1rem;
}
.admin-card h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.admin-field-row input {
  flex: 1;
  min-width: 80px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s;
}
.admin-field-row input:focus {
  border-color: var(--accent);
}

.admin-btn {
  background: var(--yellow);
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.12s;
}
.admin-btn:hover {
  opacity: 0.85;
}

.admin-msg {
  font-size: 0.78rem;
  margin-top: 0.3rem;
  display: none;
}
.admin-msg.visible {
  display: block;
}
.admin-msg.ok {
  color: var(--green);
}
.admin-msg.err {
  color: var(--red);
}

/* ══════════════════════════════════════════════════
   PROGRESS MODAL
   ══════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.modal-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), hsl(170, 71%, 45%));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text2);
  margin-bottom: 0.5rem;
}

.modal-status {
  font-size: 0.88rem;
  color: var(--text2);
  margin: 0.5rem 0;
}
.modal-status.ok {
  color: var(--green);
}
.modal-status.fail {
  color: var(--red);
}

.remaining-points {
  font-size: 0.78rem;
  color: var(--text3);
  margin-top: 0.5rem;
}

/* ══════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════ */

footer {
  margin-top: auto;
  padding: 2rem 0 1.5rem;
  font-size: 0.72rem;
  color: var(--text3);
  text-align: center;
  width: 100%;
}

/* ══════════════════════════════════════════════════
   MONITOR / ADMIN PANEL
   ══════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-align: center;
}
.stat-card .num {
  font-size: 1.4rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}
.stat-card .num.green { color: var(--green); }
.stat-card .num.yellow { color: var(--yellow); }
.stat-card .num.blue { color: var(--blue); }
.stat-card .num.red { color: var(--red); }
.stat-card .label {
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 0.15rem;
}

/* ── Chart bars ── */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.chart-section h4 {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  height: 120px;
  padding-bottom: 1.5rem;
  position: relative;
}
.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  max-width: 32px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
  position: relative;
}
.chart-bar.pv {
  background: var(--accent);
  opacity: 0.8;
}
.chart-bar.dl {
  background: var(--yellow);
  opacity: 0.7;
}
.chart-bar-label {
  font-size: 0.6rem;
  color: var(--text3);
  white-space: nowrap;
  position: absolute;
  bottom: -1.2rem;
}
.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text2);
  margin-top: 0.5rem;
}
.chart-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.chart-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ── Admin section ── */
.main-content .admin-only,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}
.admin-only h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.admin-tab {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text2);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.admin-tab:hover {
  color: var(--text);
  border-color: var(--text3);
}
.admin-tab.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.admin-panel {
  display: none;
}
.admin-panel.active {
  display: block;
}

.monitor-table-wrap {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.monitor-table-wrap table {
  font-size: 0.78rem;
}
.monitor-table-wrap th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.monitor-table-wrap td {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text2);
}
.page-nav button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.page-nav button:hover {
  border-color: var(--text3);
}
.page-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ban-badge {
  display: inline-block;
  background: hsla(0, 72%, 56%, 0.15);
  color: var(--red);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.admin-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  margin-right: 0.2rem;
}
.admin-action-btn.danger {
  color: var(--red);
  border-color: hsla(0, 72%, 56%, 0.25);
}
.admin-action-btn.danger:hover {
  background: hsla(0, 72%, 56%, 0.1);
}
.admin-action-btn.warn {
  color: var(--yellow);
  border-color: hsla(42, 96%, 54%, 0.25);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-bars {
    height: 80px;
  }
  body {
    padding: 0 0.75rem;
  }
  .container {
    padding: 1rem 0 1.5rem;
  }

  .app-layout.visible {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    display: flex;
    overflow-x: auto;
    position: static;
    padding: 0.25rem;
    gap: 0;
  }
  .sidebar-item {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
    border-bottom: 2px solid transparent;
    font-size: 0.78rem;
  }
  .sidebar-item.active {
    border-right: none;
    border-bottom-color: var(--accent);
  }
  .sidebar-divider {
    width: 1px;
    height: auto;
    min-height: 2rem;
    margin: 0.3rem 0.25rem;
  }

  .info-card.visible {
    flex-direction: column;
  }
  .info-thumb {
    width: 100%;
    max-width: 280px;
  }

  .format-item {
    flex-wrap: wrap;
  }
  .format-right {
    margin-left: auto;
  }

  .topbar .logo {
    font-size: 1.1rem;
  }

  .dash-table .title-cell {
    max-width: 100px;
  }

  .auth-card {
    padding: 1.5rem;
  }

  .hero h2 {
    font-size: 1.15rem;
  }

  .input-card {
    flex-direction: column;
    padding: 0.75rem;
  }
  .input-card button {
    width: 100%;
  }

  .ref-stats {
    gap: 1rem;
  }
}

/* ── Modal header ── */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.modal-close:hover {
  color: var(--red);
}

/* ── Help page ── */
.help-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.help-section h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--accent);
}
.help-section p {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.7;
}
.help-list {
  list-style: none;
  padding: 0;
}
.help-list li {
  font-size: 0.82rem;
  color: var(--text2);
  padding: 0.35rem 0;
  padding-left: 1.2rem;
  position: relative;
  line-height: 1.6;
}
.help-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: bold;
}
.help-list li strong {
  color: var(--text);
}

/* ── User management filters ── */
#usersSearchInput:focus,
#usersLevelFilter:focus,
#usersStatusFilter:focus,
#logsUserFilter:focus,
#logsActionFilter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

/* ── Log action badge colors ── */
.log-action {
  display: inline-block;
}
.log-action[data-action="ban_user"],
span.log-action:contains("ban_user") { color: var(--red); }
.log-action[data-action="set_points"],
span.log-action:contains("set_points") { color: var(--yellow); }
.log-action[data-action="delete_user"],
span.log-action:contains("delete_user") { color: var(--red); }

/* ── Hot list ── */
.hot-grid {
  display: grid;
  gap: 0.5rem;
}
.hot-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s;
}
.hot-item:hover { background: var(--surface2); }
.hot-item .hot-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot-item .hot-meta { color: var(--text3); font-size: 0.72rem; white-space: nowrap; margin-left: 0.5rem; }
.hot-item .hot-dl { color: var(--accent); font-weight: 600; margin-left: 0.5rem; font-size: 0.75rem; }

/* ── Floating download queue ── */
.dl-queue-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  z-index: 300;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.12s;
}
.dl-queue-btn:hover { transform: scale(1.1); }
.dl-queue-btn #dlQueueCount {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  text-align: center;
  line-height: 18px;
  font-weight: 700;
}
.dl-queue-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 340px;
  max-height: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none;
  overflow: hidden;
}
.dl-queue-panel.open { display: flex; flex-direction: column; }
.dl-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.85rem;
}
.dl-queue-header button {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 1rem;
}
.dl-queue-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.3rem 0;
}
.dl-queue-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  gap: 0.5rem;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
}
.dl-queue-item:last-child { border-bottom: none; }
.dl-queue-item .q-status { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dl-queue-item .q-status.done { background: var(--green); }
.dl-queue-item .q-status.active { background: var(--accent); }
.dl-queue-item .q-status.wait { background: var(--yellow); }
.dl-queue-item .q-status.err { background: var(--red); }
.dl-queue-item .q-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-queue-item .q-info { color: var(--text3); font-size: 0.7rem; white-space: nowrap; }
.dl-queue-item .q-cancel { cursor: pointer; color: var(--red); font-size: 0.8rem; background: none; border: none; padding: 0; }

/* ── Hot list border ── */
#hotSection .table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ── Dashboard ── */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.dash-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.dash-icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
.dash-val { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.dash-lbl { font-size: 0.75rem; color: var(--text2); margin-top: 0.15rem; }
.dash-sub { font-size: 0.68rem; color: var(--text3); margin-top: 0.1rem; }
.dash-two-col { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
.dash-two-col > .dash-box { flex: 1; min-width: 0; }
.dash-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; }
.dash-box-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; }
@media (max-width:768px){ .dash-grid { grid-template-columns: repeat(2,1fr); } .dash-two-col { flex-direction: column; } }

/* ── Toast animation ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Cache video grid ── */
.cache-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.cache-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.cache-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.cache-card-thumb {
  aspect-ratio: 16/9;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text3);
}
.cache-card-body { padding: 0.5rem 0.6rem; }
.cache-card-title {
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 0.2rem;
}
.cache-card-meta {
  font-size: 0.68rem;
  color: var(--text3);
  display: flex;
  justify-content: space-between;
}
.cache-card-dl {
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
@media (max-width:768px){ .cache-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width:480px){ .cache-grid { grid-template-columns: 1fr; } }

/* ── Cache full list grouped ── */
.cache-group { margin-bottom: 1rem; }
.cache-group h4 { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; color: var(--accent); }
.cache-group-list { display: flex; flex-direction: column; gap: 0.3rem; }
.cache-group-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.4rem 0.5rem; border-radius: var(--radius-xs);
  font-size: 0.78rem; cursor: pointer; transition: background 0.1s;
}
.cache-group-item:hover { background: var(--surface2); }
.cache-group-item .cgi-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cache-group-item .cgi-dl { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 0.5rem; }