:root {
  --gutter: max(24px, calc((100% - 1440px) / 2));
  --bg: #f6f7f8; --panel: #fff; --text: #18191c; --muted: #61666d; --faint: #9499a0;
  --line: #e3e5e7; --accent: #f25d8e; --accent-soft: #fde8ef; --blue: #00aeec;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181a; --panel: #212226; --text: #e6e7e9; --muted: #a2a6ad; --faint: #7c8089;
    --line: #33353a; --accent: #ff6f9c; --accent-soft: #3a2330; --blue: #2db7ef;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }

.hd { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px;
  padding: 10px var(--gutter); background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 22px; color: var(--accent); letter-spacing: -.5px; }
.search { flex: 1; max-width: 560px; display: flex; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
.search input { flex: 1; border: 0; background: transparent; padding: 8px 12px; outline: none; min-width: 0; }
.search button { border: 0; background: transparent; padding: 0 12px; cursor: pointer; color: var(--muted); }
.search svg { width: 18px; height: 18px; }
.hd-right { display: flex; gap: 18px; margin-left: auto; color: var(--muted); white-space: nowrap; }
.hd-right a:hover { color: var(--accent); }
.hd-right i { font-style: normal; font-size: 11px; color: var(--accent); margin-left: 2px; }

.presets { padding: 0 var(--gutter); background: var(--panel); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs-wrap { position: relative; }
.tabs { display: flex; gap: 26px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
.tabs::-webkit-scrollbar, .subnav::-webkit-scrollbar { display: none; }
.tabs.fade { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent); }
.tab { position: relative; flex: none; padding: 12px 0 11px; font-size: 15px; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); font-weight: 600; }
.tab.on::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 18px; height: 3px; margin-left: -9px;
  border-radius: 2px; background: var(--accent); }
.tabs-more { position: absolute; right: -6px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; }
.tabs-more[hidden] { display: none; }
.subnav { display: flex; gap: 8px; padding: 2px 0 12px; overflow-x: auto; scrollbar-width: none; }
.gsec { margin-bottom: 18px; }
.ghead { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.ghead h2 { margin: 0; font-size: 22px; }
.ghead a { margin-left: auto; color: var(--accent); font-size: 13px; }
.gsec .shelf { margin-bottom: 18px; }
.gsec .shelf-head h2 { font-size: 16px; }
.edfield { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.tagsugg { display: flex; flex-direction: column; gap: 8px; }
.sg { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sg b { width: 100%; font-weight: 500; font-size: 12px; color: var(--faint); }
.sg .chip { font-size: 12px; padding: 2px 10px; }
.sg .linkbtn { font-size: 12px; padding: 2px 4px; }
.chip { flex: none; padding: 6px 14px; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.custom { border-style: dashed; color: var(--accent); }

main { padding: 0 var(--gutter) 40px; }
.feed-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 14px; }
.feed-head h2 { margin: 0; font-size: 18px; }
.feed-head p { margin: 0; color: var(--faint); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 20px 16px; }

.card { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cover { position: relative; aspect-ratio: 16/10; border-radius: var(--radius); overflow: hidden;
  background: var(--line); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.card:hover .cover img { transform: scale(1.04); }
.cover .meta { position: absolute; inset: auto 0 0 0; display: flex; gap: 10px; padding: 18px 8px 5px;
  font-size: 12px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.cover .meta .dur { margin-left: auto; }
.card h3 { margin: 0; font-size: 14px; font-weight: 500; line-height: 1.45; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card:hover h3 { color: var(--blue); }
.byline { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; min-width: 0; }
.byline .up { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; padding: 0 5px; border-radius: 3px; font-size: 11px; background: var(--accent-soft);
  color: var(--accent); }
.badge.dup { background: transparent; border: 1px solid var(--line); color: var(--faint); }

.more { display: block; margin: 28px auto 0; padding: 8px 28px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.empty { padding: 60px 0; text-align: center; color: var(--faint); }

/* home shelves */
.shelf { margin: 6px 0 26px; }
.shelf-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; min-width: 0; }
.shelf-head h2 { margin: 0; font-size: 18px; flex: none; }
.shelf-head span { color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-head a { margin-left: auto; flex: none; color: var(--muted); font-size: 13px; }
.shelf-head a:hover { color: var(--accent); }
.big { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.big .card h3 { font-size: 16px; }
.srow { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 5 * 16px) / 6); gap: 16px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; padding-bottom: 6px;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.srow > .card { scroll-snap-align: start; }
.subs { display: flex; gap: 8px; margin: -4px 0 16px; overflow-x: auto; scrollbar-width: none; }
.chip.sm { padding: 3px 12px; font-size: 13px; }

/* editor */
.editor { position: sticky; top: 72px; padding: 16px 18px 20px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; display: flex; flex-direction: column; gap: 14px; }
.editor[hidden] { display: none; }
.ed-head { display: flex; align-items: baseline; gap: 10px; font-size: 16px; }
.ed-head small { color: var(--faint); font-size: 12px; }
.cpage { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 24px; align-items: start; padding-top: 6px; }
.cpv .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.hd-right a.on { color: var(--accent); font-weight: 600; }

.reroll { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px;
  padding: 2px 12px; font-size: 13px; cursor: pointer; }
.reroll:hover { color: var(--accent); border-color: var(--accent); }
.reroll.sm { padding: 0 8px; margin-left: auto; font-size: 14px; }
.reroll.sm + a { margin-left: 10px; }
.shelf-head .reroll:not(.sm), .feed-head .reroll { margin-left: auto; }
.shelf-head .reroll:not(.sm) + a { margin-left: 10px; }
.reroll.gpage { display: block; margin: 0 0 12px auto; }
.reroll:disabled { opacity: .5; }

/* about */
.about { max-width: 860px; margin: 8px auto 0; line-height: 1.75; }
.about h1 { font-size: 26px; margin: 8px 0 10px; }
.about h2 { font-size: 18px; margin: 32px 0 12px; }
.about .lead { color: var(--muted); font-size: 15px; margin: 0 0 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--faint); font-size: 12px; }
.arch { width: 100%; height: auto; display: block; }
.a-box { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.a-t { fill: var(--text); font-size: 17px; font-weight: 600; }
.a-ln { stroke: var(--faint); stroke-width: 1.5; fill: none; }
.a-hd { fill: var(--faint); }
.steps { padding: 0; margin: 14px 0 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 10px; }
.steps li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.steps li div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.steps li b::before { counter-increment: s; content: counter(s) ". "; color: var(--accent); }
.steps code, .formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.steps code { color: var(--faint); }
.steps p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.formula { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  overflow-x: auto; line-height: 1.7; color: var(--text); }
.stack { margin: 0; padding-left: 20px; color: var(--muted); }
.about .fine { color: var(--faint); font-size: 12px; margin-top: 28px; }

/* leaderboard */
.rlist { display: flex; flex-direction: column; gap: 2px; }
.rrow { display: grid; grid-template-columns: 36px 160px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 8px 10px; border-radius: var(--radius); }
.rrow:hover { background: var(--panel); }
.rrow:hover h3 { color: var(--blue); }
.rrow .cover { aspect-ratio: 16/10; }
.rrow h3 { margin: 0 0 4px; font-size: 14px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.rn { font-size: 18px; color: var(--faint); text-align: center; font-variant-numeric: tabular-nums; }
.rn.top { color: var(--accent); font-size: 22px; }
.rmetric { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.editor label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.editor small { color: var(--faint); }
.editor textarea, .editor input[type=text], .editor input:not([type]), .editor input[type=number] {
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 6px 8px; outline: none; }
.editor fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.editor legend { width: 100%; color: var(--muted); font-size: 13px; margin-bottom: 4px; padding: 0; }
.editor .ck { flex-direction: row; align-items: center; gap: 4px; color: var(--text); }
.editor .sl { flex-direction: row; align-items: center; gap: 8px; width: 100%; color: var(--text); }
.editor .sl input { flex: 1; accent-color: var(--accent); }
.editor .sl output { width: 28px; text-align: right; color: var(--faint); }
.editor .row label { width: calc(50% - 7px); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); padding: 5px 6px; }
.tags span { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  cursor: pointer; font-size: 12px; }
.tags span::after { content: " ×"; }
.tags input { flex: 1; min-width: 80px; border: 0 !important; background: transparent !important; padding: 2px !important; }
.ed-actions { display: flex; gap: 10px; }
.ed-actions button { flex: 1; padding: 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; }
.ed-actions .primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* video page */
.vp { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.player { aspect-ratio: 16/9; width: 100%; border: 0; border-radius: 10px; background: #000; display: block; }
.vp h1 { font-size: 22px; font-weight: 600; margin: 16px 0 8px; line-height: 1.4; }
.vstats { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; }
.whys { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 14px 0 4px; font-size: 12px; }
.whys b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.why { padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.why.hot { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.vbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.vup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.vup img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.vup b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vup:hover b { color: var(--blue); }
.vactions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary.on { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.btn.on:not(.primary) { color: var(--accent); border-color: var(--accent); }
.vdesc { white-space: pre-wrap; color: var(--muted); font-size: 13px; line-height: 1.7; }
.vdesc.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.linkbtn { border: 0; background: none; padding: 4px 0; color: var(--blue); cursor: pointer; font-size: 13px; }
.vsec { margin-top: 28px; }
.vsec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.vsec-head h4 { margin: 0; font-size: 16px; }
.vsec-head span { color: var(--faint); font-size: 12px; }
.grid.same { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100vh - 88px); }
.side h4 { margin: 0; font-size: 16px; }
.side-list { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
.mini.card { display: grid; grid-template-columns: 150px 1fr; gap: 10px; flex-direction: unset; }
.mini .cover { aspect-ratio: 16/10; }
.mini h3 { font-size: 13px; }
.box { background: var(--panel); border-radius: var(--radius); padding: 12px; margin-top: 14px; }

.ft { padding: 20px var(--gutter) 30px; color: var(--faint); font-size: 12px; border-top: 1px solid var(--line); }
.ft span { margin-left: 8px; }

@media (max-width: 1100px) { .vp { grid-template-columns: minmax(0, 1fr) 300px; } .grid.same { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .srow { grid-auto-columns: calc((100% - 3 * 16px) / 4); } }
@media (max-width: 900px) { .cpage { grid-template-columns: 1fr; } .editor { position: static; } }
@media (max-width: 900px) { .vp { grid-template-columns: 1fr; } .side { position: static; max-height: none; } .side-list { overflow: visible; } }
@media (max-width: 640px) {
  .hd { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .search { order: 3; max-width: none; flex-basis: 100%; }
  .presets, main, .ft { padding-left: 16px; padding-right: 16px; }
  .tabs { gap: 20px; }
  .tabs-more { display: none !important; }
  .ghead h2 { font-size: 19px; }
  .vp h1 { font-size: 18px; }
  .vbar { flex-direction: column; align-items: stretch; }
  .vactions .btn { flex: 1; text-align: center; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .cover .meta { white-space: nowrap; gap: 6px; font-size: 11px; }
  .cover .meta span:nth-child(2), .byline > span:last-child { display: none; }
  .card h3 { font-size: 13px; }
  .feed-head { flex-wrap: wrap; gap: 2px 10px; }
  .big { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 80%; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; }
  .big > .card { scroll-snap-align: start; }
  .srow { grid-auto-columns: 42%; gap: 10px; }
  .shelf-head span { display: none; }
  .hd-right { gap: 10px; font-size: 13px; }
  .about h1 { font-size: 21px; }
  .rrow { grid-template-columns: 26px 110px minmax(0, 1fr); gap: 8px; padding: 6px 0; }
  .rmetric { grid-column: 3; font-size: 12px; }
  .rrow h3 { font-size: 13px; }
}

/* skeletons */
@keyframes shimmer { to { background-position: -200% 0; } }
.sk .cover, .sk-line, .sk-block {
  background: linear-gradient(90deg, var(--line) 25%, var(--bg) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-line { height: 14px; border-radius: 4px; margin-top: 4px; }
.sk-line.short { width: 55%; }
#sentinel { height: 1px; }
@media (prefers-reduced-motion: reduce) { .sk .cover, .sk-line, .sk-block { animation: none; } }
