/* ============================================================
   龙虾视频库 · macOS 风格（浅/深自动+手动 · 多彩 · 紧凑）
   ============================================================ */

:root {
  color-scheme: light dark;
  --desktop: #e8e8ed;
  --content: #ffffff;
  --sidebar: rgba(246, 246, 248, 0.82);
  --text: #1d1d1f;
  --text-2: #6b6b70;
  --text-3: #9a9aa0;
  --hair: rgba(0, 0, 0, 0.11);
  --hair-2: rgba(0, 0, 0, 0.06);
  --fill: #eeeef0;
  --accent: #0a84ff;
  --accent-press: #0060df;
  --danger: #ff453a;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.06);
  --shadow-hi: 0 10px 28px rgba(0,0,0,.16);
  /* macOS 系统多彩 */
  --sys-blue: #0a84ff; --sys-purple: #bf5af2; --sys-orange: #ff9f0a;
  --sys-green: #30d158; --sys-pink: #ff445a; --sys-gray: #8e8e93; --sys-teal: #40c8e0;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --r: 11px; --r-sm: 8px;
}
.dark-vars, :root[data-theme="dark"] {
  color-scheme: dark;
  --desktop: #161618; --content: #1d1d1f; --sidebar: rgba(40, 40, 43, 0.74);
  --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #79797f;
  --hair: rgba(255,255,255,0.14); --hair-2: rgba(255,255,255,0.07); --fill: #2c2c2e;
  --accent: #0a84ff; --accent-press: #409cff;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hi: 0 12px 30px rgba(0,0,0,.55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --desktop: #161618; --content: #1d1d1f; --sidebar: rgba(40, 40, 43, 0.74);
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #79797f;
    --hair: rgba(255,255,255,0.14); --hair-2: rgba(255,255,255,0.07); --fill: #2c2c2e;
    --accent: #0a84ff; --accent-press: #409cff;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-hi: 0 12px 30px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans); color: var(--text); background: var(--desktop);
  font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(10,132,255,0.22); }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 212px; flex: none; position: sticky; top: 0; align-self: flex-start; height: 100vh;
  display: flex; flex-direction: column; gap: 1px; padding: 0 10px 12px;
  background: var(--sidebar); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-right: 1px solid var(--hair);
}
.traffic { display: flex; gap: 8px; padding: 14px 8px 12px; }
.traffic i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.traffic .r { background: #ff5f57; } .traffic .y { background: #febc2e; } .traffic .g { background: #28c840; }
.brand-row { display: flex; align-items: center; gap: 9px; padding: 3px 8px 12px; }
.brand-glyph { width: 25px; height: 25px; border-radius: 7px; flex: none; background: linear-gradient(160deg, #ff7a5a, #e0244f); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 600; }
.brand-tx { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.brand-tx small { display: block; font-size: 10px; font-weight: 400; color: var(--text-3); }
.side-title { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 12px 9px 4px; }
.side-link { display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 7px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.side-link .ic { width: 18px; display: inline-flex; color: var(--ic, var(--sys-gray)); }
.side-link:hover { background: rgba(130,130,140,.12); }
.side-link.active { background: var(--ic, var(--accent)); color: #fff; }
.side-link.active .ic { color: #fff; }
.ic-blue { --ic: var(--sys-blue); } .ic-purple { --ic: var(--sys-purple); }
.ic-orange { --ic: var(--sys-orange); } .ic-green { --ic: var(--sys-green); } .ic-gray { --ic: var(--sys-gray); }
.side-spacer { flex: 1; }
.side-foot { border-top: 1px solid var(--hair-2); padding-top: 6px; display: grid; gap: 1px; }
.theme-toggle { border: 0; background: none; cursor: pointer; text-align: left; }

/* ---------- toolbar + main ---------- */
.main { flex: 1; min-width: 0; background: var(--content); display: flex; flex-direction: column; }
.toolbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 9px clamp(14px, 2.4vw, 28px); border-bottom: 1px solid var(--hair-2);
  background: color-mix(in srgb, var(--content) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
}
.tb-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.tb-title small { color: var(--text-3); font-weight: 400; margin-left: 6px; }
.grow { flex: 1; }
.search { position: relative; width: min(240px, 42vw); }
.search .mag { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search input { width: 100%; height: 29px; padding: 0 12px 0 29px; border: 1px solid var(--hair); border-radius: 8px; background: var(--fill); font-size: 12.5px; outline: none; }
.search input:focus { background: var(--content); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,132,255,.16); }
.content { padding: clamp(14px, 2.2vw, 26px) clamp(14px, 2.6vw, 32px) 56px; width: 100%; max-width: 1280px; }

/* ---------- titles ---------- */
.largetitle { font-size: clamp(22px, 3vw, 26px); font-weight: 600; letter-spacing: -0.022em; margin: 2px 0 2px; }
.subtitle { color: var(--text-2); font-size: 13.5px; margin: 0 0 18px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: 13px; font-weight: 500; margin-bottom: 10px; }

/* ---------- poster grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 22px 16px; }
.card { position: relative; display: flex; flex-direction: column; }
.poster { position: relative; display: block; overflow: hidden; aspect-ratio: 16/9; border-radius: var(--r); background: var(--fill); border: 0.5px solid var(--hair-2); box-shadow: var(--shadow); transition: transform .24s cubic-bezier(.2,.7,.2,1), box-shadow .24s ease; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster img.is-broken { display: none; }
.card:hover .poster { transform: translateY(-3px) scale(1.012); box-shadow: var(--shadow-hi); }
.dur { position: absolute; right: 7px; bottom: 7px; padding: 1px 6px; border-radius: 5px; background: rgba(0,0,0,.62); color: #fff; font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.play-o { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .2s ease; }
.play-o span { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.94); color: #111; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.card:hover .play-o { opacity: 1; }
.ct { padding: 9px 2px 0; }
.name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.card:hover .name { color: var(--accent); }
.when { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.when .ic { color: var(--text-3); }
.card-del { position: absolute; top: 7px; left: 7px; margin: 0; opacity: 0; transition: opacity .18s ease; }
.card:hover .card-del, .card-del:focus-within { opacity: 1; }

/* ---------- reels (openclaw folders) ---------- */
.reel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px 16px; }
.reel { position: relative; display: flex; flex-direction: column; }
.reel-cover { position: relative; display: block; overflow: hidden; aspect-ratio: 16/9; border-radius: var(--r); border: 0.5px solid var(--hair-2); box-shadow: var(--shadow); transition: transform .24s cubic-bezier(.2,.7,.2,1), box-shadow .24s ease; }
.reel:hover .reel-cover { transform: translateY(-3px) scale(1.012); box-shadow: var(--shadow-hi); }
.collage { position: absolute; inset: 0; display: grid; gap: 2px; background: var(--fill); }
.collage img { width: 100%; height: 100%; object-fit: cover; }
.collage img.is-broken { visibility: hidden; }
.collage-1 { grid-template-columns: 1fr; }
.collage-2 { grid-template-columns: 1fr 1fr; }
.collage-3, .collage-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.collage-3 img:first-child { grid-column: span 2; }
.reel-badge { position: absolute; top: 7px; left: 7px; padding: 2px 8px; border-radius: 980px; background: rgba(255,255,255,.86); color: #1d1d1f; font-size: 10.5px; font-weight: 600; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.reel-ct { padding: 9px 2px 0; }
.reel-del { position: absolute; top: 7px; right: 7px; margin: 0; opacity: 0; transition: opacity .18s ease; z-index: 2; }
.reel:hover .reel-del, .reel-del:focus-within { opacity: 1; }
.reel-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.reel-sub { color: var(--text-2); font-size: 12px; margin-top: 1px; font-variant-numeric: tabular-nums; }

/* ---------- buttons / inputs ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px; border: 1px solid var(--hair); border-radius: 8px; background: var(--content); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s ease, border-color .15s ease; }
.button:hover { background: var(--fill); }
.button-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
.button-ghost { background: transparent; }
.button-danger { color: var(--danger); border-color: rgba(255,69,58,.4); }
.button-danger:hover { background: rgba(255,69,58,.1); }
.full-width { width: 100%; }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--hair); border-radius: 8px; background: rgba(140,140,150,.16); color: var(--text-2); cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.icon-danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

/* ---------- watch ---------- */
.watch { max-width: 980px; margin: 0 auto; display: grid; gap: 16px; }
.player { width: 100%; aspect-ratio: 16/9; max-height: 76vh; border-radius: 14px; overflow: hidden; background: #000; border: 0.5px solid var(--hair-2); box-shadow: var(--shadow); }
.wtitle { font-size: clamp(22px, 3vw, 28px); font-weight: 600; letter-spacing: -0.022em; margin: 4px 0 4px; }
.wdesc { color: var(--text-2); max-width: 66ch; margin: 0; font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--hair-2); border: 1px solid var(--hair-2); border-radius: 12px; overflow: hidden; }
.fact { background: var(--fill); padding: 13px 16px; }
.fact .k { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.fact .v { font-size: 15px; font-weight: 500; margin-top: 3px; font-variant-numeric: tabular-nums; }
.backstrip, .watch-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.share-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.share-input { flex: 1; min-width: 15rem; height: 32px; padding: 0 12px; border: 1px solid var(--hair); border-radius: 8px; background: var(--fill); font-size: 12.5px; }

/* ---------- shared panels / admin / login / upload ---------- */
.panel, .auth-panel, .table-shell, .upload-form { background: var(--content); border: 1px solid var(--hair); border-radius: 13px; box-shadow: var(--shadow); }
.auth-panel { width: min(100%, 25rem); margin: 8vh auto 0; padding: 1.5rem; }
.upload-form { padding: 1.2rem; }
.form-stack { display: grid; gap: 0.9rem; }
.form-stack label { display: grid; gap: 0.35rem; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.form-actions { display: flex; gap: 0.6rem; align-items: center; }
input:not(.search input):not(.share-input), select, textarea { width: 100%; min-height: 32px; padding: 0 11px; border: 1px solid var(--hair); border-radius: 8px; background: var(--fill); outline: none; }
textarea { padding: 9px 11px; min-height: 5.5rem; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { background: var(--content); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,132,255,.16); }
.alert { padding: 0.75rem 0.9rem; border: 1px solid rgba(255,69,58,.4); border-radius: 9px; color: var(--danger); background: rgba(255,69,58,.08); font-size: 13.5px; }
.table-shell { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 0.95rem; border-bottom: 1px solid var(--hair-2); text-align: left; vertical-align: middle; font-size: 13.5px; }
th { font-size: 11.5px; font-weight: 600; color: var(--text-3); }
td { color: var(--text-2); }
.actions-cell { display: flex; gap: 0.45rem; align-items: center; }
.admin-strip { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

/* ---------- empty ---------- */
.empty-state { border: 1px solid var(--hair-2); border-radius: 14px; background: var(--fill); padding: clamp(2rem, 6vw, 4rem); text-align: center; }
.empty-state h2 { font-size: 18px; font-weight: 600; margin: 0 0 0.5rem; }
.empty-state p { color: var(--text-2); margin: 0 0 0.9rem; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card, .reel { animation: rise .42s both cubic-bezier(.2,.7,.2,1); }
.card:nth-child(2), .reel:nth-child(2) { animation-delay: .03s; }
.card:nth-child(3), .reel:nth-child(3) { animation-delay: .06s; }
.card:nth-child(4), .reel:nth-child(4) { animation-delay: .09s; }
.card:nth-child(n+5), .reel:nth-child(n+5) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) { .card, .reel { animation: none; } .poster, .reel-cover { transition: none; } }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: sticky; top: 0; flex-direction: row; align-items: center; gap: 2px; overflow-x: auto; padding: 7px 10px; border-right: 0; border-bottom: 1px solid var(--hair); }
  .traffic, .brand-tx small, .side-title, .side-spacer { display: none; }
  .side-foot { border-top: 0; padding-top: 0; display: flex; grid-auto-flow: column; }
  .side-link { white-space: nowrap; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
  .reel-grid { grid-template-columns: 1fr 1fr; }
}
@media (hover: none) { .card-del, .reel-del { opacity: 1; } .play-o { opacity: 1; } }

/* ============ 研究库 / Paper Vault 专用组件 ============ */
.ic-pink { --ic: var(--sys-pink); }
.ic-teal { --ic: var(--sys-teal); }

.feed { display: grid; gap: 11px; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 14px; }

.note-card { display: block; background: var(--content); border: 0.5px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); padding: 13px 16px; transition: transform .2s cubic-bezier(.2,.7,.2,1), box-shadow .2s ease, border-color .2s ease; }
.note-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hi); }
.note-card .nt { font-size: 15px; font-weight: 600; letter-spacing: -.01em; line-height: 1.34; color: var(--text); }
.note-card:hover .nt { color: var(--accent); }
.note-card .np { color: var(--text-2); font-size: 13px; line-height: 1.55; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }
.ibadge { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; color: #fff; padding: 2px 9px; border-radius: 980px; }
.ib-jay { background: var(--sys-blue); } .ib-flyp { background: var(--sys-purple); } .ib-tom { background: var(--sys-orange); } .ib-spark { background: var(--sys-green); } .ib-stephen { background: var(--sys-pink); }
.taglist { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11.5px; color: var(--text-2); background: var(--fill); border-radius: 980px; padding: 2px 9px; }
a.tag:hover { color: var(--accent); }
.tag.on { background: var(--accent); color: #fff; }

.prose { max-width: 768px; font-size: 15.5px; line-height: 1.72; color: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 25px; font-weight: 600; letter-spacing: -.02em; margin: 1.3em 0 .5em; }
.prose h2 { font-size: 20px; font-weight: 600; margin: 1.5em 0 .5em; padding-bottom: .3em; border-bottom: 1px solid var(--hair-2); }
.prose h3 { font-size: 17px; font-weight: 600; margin: 1.3em 0 .4em; }
.prose h4 { font-size: 15px; font-weight: 600; margin: 1.1em 0 .3em; }
.prose p { margin: .7em 0; }
.prose a { color: var(--accent); text-decoration: none; word-break: break-word; }
.prose a:hover { text-decoration: underline; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .6em 0; }
.prose li { margin: .25em 0; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .87em; background: var(--fill); padding: .12em .4em; border-radius: 5px; }
.prose pre { background: var(--fill); border: 0.5px solid var(--hair-2); border-radius: 10px; padding: 13px 15px; overflow: auto; margin: .9em 0; }
.prose pre code { background: none; padding: 0; font-size: 13px; line-height: 1.6; }
.prose blockquote { margin: .8em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--text-2); }
.prose table { border-collapse: collapse; width: 100%; margin: .9em 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 0.5px solid var(--hair); padding: 7px 10px; text-align: left; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--hair-2); margin: 1.4em 0; }

.paper-card { background: var(--content); border: 0.5px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 15px; display: flex; flex-direction: column; gap: 9px; transition: transform .2s cubic-bezier(.2,.7,.2,1), box-shadow .2s ease; }
.paper-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hi); }
.paper-card .pt { font-size: 14.5px; font-weight: 600; line-height: 1.32; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.arx { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text-3); }
.paper-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.btn-sm { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 1px solid var(--hair); border-radius: 7px; background: var(--content); color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.btn-sm:hover { background: var(--fill); }
.btn-sm.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm.pri:hover { background: var(--accent-press); }

.timeline { display: grid; gap: 9px; }
.dg-row { display: flex; align-items: center; gap: 14px; background: var(--content); border: 0.5px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 15px; }
.dg-row:hover { border-color: var(--accent); }
.dg-when { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; min-width: 118px; font-weight: 500; }
.dg-heat { display: flex; flex-wrap: wrap; gap: 6px; }

.heatbox { background: var(--fill); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 7px; }
.heat-row { display: grid; grid-template-columns: 86px 1fr 28px; align-items: center; gap: 10px; font-size: 12.5px; }
.heat-track { height: 7px; border-radius: 980px; background: rgba(120,120,128,.18); overflow: hidden; }
.heat-bar { height: 100%; border-radius: 980px; background: var(--accent); }
.heat-row .hc { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 30px; align-items: start; }
.aside { position: sticky; top: 60px; display: grid; gap: 12px; }
.aside .box { background: var(--fill); border-radius: var(--r); padding: 13px 14px; display: grid; gap: 8px; font-size: 13px; }
.aside .k { color: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.aside .box a { color: var(--accent); word-break: break-word; }
@media (max-width: 880px) { .detail { grid-template-columns: 1fr; } .aside { position: static; } }
