:root {
  --cream: #fffdf6;
  --sidebar: #fff4e3;
  --card: #ffffff;
  --border: #f0e3cf;
  --orange: #ff8c32;
  --orange-dark: #e47018;
  --soft-orange: #ffeed9;
  --green: #4caf50;
  --danger: #e5484d;
  --text: #3a2d21;
  --muted: #7d6b5d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--cream);
  color: var(--text);
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.error-text { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* Buttons & Inputs */
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--soft-orange); color: var(--orange-dark); }
.btn-secondary:hover { background: #ffe2be; }
.btn-ghost { background: #f6efe4; color: var(--text); }
.btn-ghost:hover { background: #ede1cf; }
.btn-danger { background: #fdeaea; color: var(--danger); }
.btn-danger:hover { background: #fad4d4; }
.btn-full { width: 100%; margin-top: 12px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }

.input, .textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--orange); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text); }
.field.full { grid-column: 1 / -1; }

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(255, 140, 50, 0.12);
}
.brand-badge {
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  border-radius: 20px;
  background: var(--soft-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.login-card h1 { margin: 0 0 8px; font-size: 24px; }
.login-card form { text-align: left; margin-top: 22px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 253, 246, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.logo-emoji { font-size: 32px; }
.logo-title { font-size: 18px; font-weight: 800; color: var(--orange-dark); }
.logo-sub { font-size: 12px; color: var(--muted); }
.nav-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-tab {
  border: 1.5px solid transparent;
  background: var(--sidebar);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.nav-tab.active {
  background: var(--orange);
  color: #fff;
}

/* Main */
.main-content {
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.pill.active {
  border-color: var(--orange);
  background: var(--soft-orange);
  color: var(--orange-dark);
}

/* Album Cards (mirrors Xiaomi TV 4-column look!) */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}
.album-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 14px rgba(58, 45, 33, 0.05);
}
.album-card.disabled { opacity: 0.55; }
.album-cover-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #ffe9c7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.album-cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.album-cover-placeholder { font-size: 40px; }
.badge-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(45, 36, 28, 0.72);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-top-left {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255, 140, 50, 0.92);
  color: #fff;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}
.album-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.album-title { font-size: 16px; font-weight: 800; }
.album-meta { font-size: 12px; color: var(--muted); }
.album-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

/* Categories list */
.category-list { display: flex; flex-direction: column; gap: 12px; }
.category-row {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.cat-info { display: flex; align-items: center; gap: 12px; }
.cat-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--soft-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.cat-name { font-size: 16px; font-weight: 800; }

/* Settings */
.settings-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 26px;
  max-width: 820px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 25, 16, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  background: var(--cream);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal-large { max-width: 780px; }
.modal-header {
  padding: 16px 22px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.icon-close {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.section-box {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
}
.section-title { font-size: 14px; font-weight: 800; margin-bottom: 10px; }

.cover-editor { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.cover-preview {
  width: 160px;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  background: var(--sidebar);
  border: 1px dashed var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-controls { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 10px; }
.upload-label { display: inline-flex; align-items: center; }

.mode-switch { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.mode-btn {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--cream);
  font-weight: 700;
  cursor: pointer;
}
.mode-btn.active {
  border-color: var(--orange);
  background: var(--soft-orange);
  color: var(--orange-dark);
}

.batch-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.episodes-editor { display: flex; flex-direction: column; gap: 10px; max-height: 280px; overflow-y: auto; }
.ep-row { display: grid; grid-template-columns: 76px 1fr 1.2fr 1.1fr auto; gap: 8px; align-items: center; }
.ep-thumb-mini {
  width: 76px;
  height: 46px;
  border-radius: 8px;
  background: var(--sidebar);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
.ep-thumb-mini img { width: 100%; height: 100%; object-fit: cover; }
.alist-preview {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--sidebar);
  font-size: 13px;
  line-height: 1.6;
}

.global-toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #2e241b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  z-index: 100;
}

@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .ep-row { grid-template-columns: 1fr; }
}
