:root {
  --bg: #0b0d12;
  --surface: #151922;
  --surface-2: #1c2130;
  --border: #262d3b;
  --text: #e9edf5;
  --muted: #8b93a7;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --danger: #ef4444;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 12px 10px;
  background: rgba(11, 13, 18, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--surface-2);
}

/* ---------- Layout ---------- */
.page {
  padding: 12px 12px calc(96px + var(--safe-bottom));
  max-width: 820px;
  margin: 0 auto;
}

/* ---------- Search ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 12px;
  margin-bottom: 12px;
}

.search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  height: 46px;
  font-size: 16px;
}

.search .s-icon {
  color: var(--muted);
  font-size: 16px;
}

/* ---------- Breadcrumb ---------- */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 2px 2px 10px;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.crumbs button {
  border: none;
  background: transparent;
  color: var(--primary);
  padding: 4px 2px;
  cursor: pointer;
  font-size: 13px;
}

.crumbs span.sep {
  opacity: 0.5;
}

/* ---------- List ---------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.row:active {
  background: var(--surface-2);
}

.row .thumb {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--surface-2);
}

.row .meta {
  flex: 1;
  min-width: 0;
}

.row .name {
  font-size: 15px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 17px;
  background: rgba(59, 130, 246, 0.16);
  color: #8ab4ff;
}

.row .del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.row .del:active {
  color: var(--danger);
}

/* ---------- Empty / loading ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 56px 16px;
  font-size: 14px;
}

.empty .big {
  font-size: 40px;
  margin-bottom: 10px;
}

.load-more {
  margin: 14px auto 0;
  display: block;
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 20px;
  border-radius: 27px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.4);
  border: none;
  cursor: pointer;
}

.fab:active {
  transform: scale(0.97);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  border: none;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
}

/* ---------- Upload ---------- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input[type="text"] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  outline: none;
}

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 14px;
  background: var(--surface);
}

.dropzone.drag {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.dropzone .big {
  font-size: 34px;
  margin-bottom: 6px;
}

.queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 14px;
}

.qitem {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.qitem .q-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.qitem .q-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qitem .q-state {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.2s ease;
}

.q-state.done {
  color: #34d399;
}

.q-state.err {
  color: var(--danger);
}

/* ---------- Watch ---------- */
.player-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}

.player-wrap video {
  display: block;
  width: 100%;
  max-height: 62vh;
  background: #000;
}

.watch-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.watch-info .title {
  font-size: 16px;
  font-weight: 600;
  word-break: break-all;
}

.watch-info .kv {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  word-break: break-all;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 100;
  max-width: 84vw;
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(30, 35, 48, 0.96);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
