:root {
  --bg: #0f0f0f;
  --bg-elev: #181818;
  --bg-hover: #272727;
  --line: #303030;
  --text: #f1f1f1;
  --muted: #aaaaaa;
  --accent: #ff4757;
  --accent-hover: #ff6b78;
  --ok: #2ed573;
  --danger: #ff4757;
  --radius: 12px;
  --header-h: 56px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "DM Sans", var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; }

/* ===== Top bar ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: rgba(15,15,15,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  position: relative;
  box-shadow: 0 6px 18px rgba(255,71,87,0.35);
}
.logo-mark::after {
  content: "";
  position: absolute;
  inset: 9px 8px 9px 11px;
  background: #fff;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
}
.header-search {
  flex: 1;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  height: 40px;
}
.header-search input {
  flex: 1;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 40px 0 0 40px;
  background: #121212;
  color: var(--text);
  padding: 0 16px;
  outline: none;
}
.header-search input:focus { border-color: #3ea6ff; }
.header-search button {
  border: 1px solid var(--line);
  border-radius: 0 40px 40px 0;
  background: #222;
  color: var(--text);
  padding: 0 18px;
  cursor: pointer;
}
.header-search button:hover { background: #333; }
.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.header-actions a,
.header-actions .chip-user,
.header-actions .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
}
.header-actions .ghost-btn {
  border: 1px solid #333;
  border-radius: 999px;
}
.header-actions .ghost-btn:hover {
  color: var(--text);
  border-color: #555;
  background: var(--bg-hover);
}
.header-actions a:hover,
.header-actions a.on {
  color: var(--text);
  background: var(--bg-hover);
}
.header-actions .btn-upload {
  background: rgba(255,71,87,0.12);
  color: #ff8a95;
  border: 1px solid rgba(255,71,87,0.35);
}
.header-actions .btn-upload:hover {
  background: rgba(255,71,87,0.22);
  color: #fff;
}
.chip-user {
  color: var(--text) !important;
  background: #222;
}

/* ===== Page shell ===== */
.page {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 48px;
}
.page-narrow { width: min(520px, calc(100% - 28px)); }
.page-watch { width: min(1400px, calc(100% - 24px)); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.chips .chip-label {
  color: var(--muted);
  font-size: 0.82rem;
  align-self: center;
  margin-right: 4px;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.88rem; }

/* category chips */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.chip {
  display: inline-flex;
  padding: 7px 14px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}
.chip:hover, .chip.on {
  background: #fff;
  color: #0f0f0f;
  border-color: #fff;
}

/* ===== Video grid ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px 14px;
}
.v-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.v-card:hover .thumb { border-radius: 4px; }
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  transition: border-radius 0.15s ease;
}
.thumb img,
.thumb .ph {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb .ph {
  background:
    linear-gradient(135deg, #1c1c1c, #101010 60%),
    repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(255,255,255,0.02) 8px, rgba(255,255,255,0.02) 16px);
}
.thumb .dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.thumb .badge {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(46,213,115,0.95);
  color: #062;
}
.thumb .progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255,255,255,0.2);
}
.thumb .progress > i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.v-meta h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.v-meta p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 260px);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 28px;
  scroll-snap-type: x mandatory;
}
.rail .v-card { scroll-snap-align: start; }

.group-block { margin-bottom: 28px; }

.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 196px);
  gap: 18px 14px;
  justify-content: start;
}
.pl-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 196px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.pl-stack {
  position: relative;
  padding-top: 8px;
}
.pl-stack > i {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 8px;
  border-radius: 10px 10px 0 0;
  background: #3a3a3a;
}
.pl-stack > i:first-child {
  top: 0;
  left: 14%;
  right: 14%;
  background: #2a2a2a;
}
.pl-stack > i:nth-child(2) {
  top: 4px;
  left: 8%;
  right: 8%;
  background: #404040;
}
.pl-stack .thumb {
  position: relative;
  z-index: 1;
  border-radius: 10px;
}
.pl-card:hover .pl-stack .thumb { border-radius: 4px; }
.pl-count {
  position: absolute;
  right: 0;
  bottom: 0;
  left: auto;
  background: rgba(0,0,0,0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px 0 10px 0;
}
.pl-card .v-meta h3 {
  font-size: 0.88rem;
  -webkit-line-clamp: 2;
}
.pl-card .v-meta p { color: var(--muted); font-size: 0.78rem; }
.pl-card:hover .v-meta p { color: #fff; }

.pl-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}
.pl-crumb a { color: var(--muted); }
.pl-crumb a:hover { color: #fff; }
.pl-crumb strong { color: var(--text); font-weight: 600; }

.empty-box {
  text-align: center;
  padding: 56px 20px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: var(--bg-elev);
}
.empty-box a {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ===== Watch page ===== */
.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.player-main video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  outline: none;
}
.watch-title {
  margin: 14px 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
}
.watch-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.watch-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.watch-side {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-elev);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  overflow: hidden;
}
.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.side-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 12px 10px;
  cursor: pointer;
}
.side-tab.on {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.side-panel {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.side-panel.on { display: flex; }
.side-panel .side-list {
  padding: 10px;
  overflow: auto;
}

.note-composer {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.note-composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.note-live-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
}
#noteStampBtn.on {
  color: #fff;
  border-color: rgba(255,71,87,0.55);
  background: rgba(255,71,87,0.2);
}
#noteInput {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: #0d0d0d;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  line-height: 1.45;
}
#noteInput:focus {
  outline: none;
  border-color: rgba(255,71,87,0.45);
}
.note-composer-actions { margin-top: 8px; }
.note-hint { margin: 8px 0 0; font-size: 0.75rem; }
.btn.tiny {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 999px;
  border: 1px solid #333;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}
.btn.tiny:hover { color: #fff; border-color: #555; }

.note-list {
  padding: 10px 12px 16px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.note-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}
.note-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.note-ts {
  appearance: none;
  border: 0;
  background: rgba(255,71,87,0.14);
  color: #ff8a95;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.note-ts:hover { background: rgba(255,71,87,0.28); color: #fff; }
.note-del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 4px;
}
.note-del:hover { color: #ff8a95; }
.note-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  line-height: 1.5;
}
.note-empty { padding: 8px 4px; }

.notes-search {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.notes-search input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg-elev);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}
.notes-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.notes-feed-item {
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid rgba(255,255,255,0.05);
}
.notes-feed-video {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  color: inherit;
  text-decoration: none;
}
.notes-feed-video h3 {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
}
.notes-feed-video p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.notes-feed-body {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.notes-feed-body p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side-item {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 10px;
  padding: 6px;
  border-radius: 10px;
}
.side-item:hover { background: var(--bg-hover); }
.side-item .thumb { border-radius: 8px; }
.side-item h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.side-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ===== History ===== */
.history-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.history-item {
  display: grid;
  grid-template-columns: 200px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid transparent;
}
.history-item:hover { border-color: var(--line); background: var(--bg-hover); }
.history-item .thumb { border-radius: 8px; }
.history-item h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.history-item p { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }
.history-item .cta {
  color: var(--muted);
  font-size: 0.85rem;
  padding-right: 8px;
}

/* ===== Forms / panels ===== */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}
.field span {
  font-size: 0.85rem;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  background: #121212;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
.field input:focus,
.field select:focus { border-color: #3ea6ff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: #333; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }

.flash {
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 14px;
  font-size: 0.92rem;
}
.flash.error { background: rgba(255,71,87,0.12); color: #ff8a95; }
.flash.ok { background: rgba(46,213,115,0.12); color: var(--ok); }

.upload-drop {
  margin: 4px 0 16px;
  padding: 36px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  color: var(--muted);
  background: #121212;
}
.upload-drop.on {
  border-color: var(--accent);
  background: rgba(255,71,87,0.06);
  color: var(--text);
}

.login-hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 0%, rgba(255,71,87,0.18), transparent 55%),
    radial-gradient(700px 360px at 90% 10%, rgba(62,166,255,0.1), transparent 50%),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.login-card .logo { margin-bottom: 8px; }
.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}
.login-card .lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

@media (max-width: 980px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-side {
    position: static;
    max-height: none;
  }
  .notes-feed-video { grid-template-columns: 112px 1fr; }
  .header-search { max-width: none; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px 10px; }
  .pl-grid { grid-template-columns: repeat(auto-fill, 164px); gap: 14px 10px; }
  .pl-card { width: 164px; }
}
@media (max-width: 720px) {
  .site-header { gap: 8px; padding: 0 10px; }
  .header-actions a span.hide-sm { display: none; }
  .history-item { grid-template-columns: 120px 1fr; }
  .history-item .cta { display: none; }
  .side-item { grid-template-columns: 140px 1fr; }
  .logo span.name { display: none; }
}
