:root {
  --bg: #fff8ef; --surface: #ffffff; --surface-2: #f6eee3; --ink: #2b2140; --muted: #7a6f86; --line: #eadfd0;
  --brand: #ff6b6b; --brand-lip: #e04f4f; --on-brand: #ffffff;
  --draft: #8a8fa3; --ready: #2fb380; --posted: #4a7cf0; --skipped: #b9a99a; --danger: #d64545; --warn: #c98a00;
  --radius: 14px; --shadow: 0 2px 0 var(--line), 0 6px 18px rgba(43, 33, 64, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161327; --surface: #221d3a; --surface-2: #2b2548; --ink: #f3eefc; --muted: #a59cbc; --line: #3a3360;
    --shadow: 0 2px 0 #0f0c1d, 0 6px 18px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--posted); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
header.top { position: relative; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.bar { display: flex; align-items: center; gap: 8px; padding: 12px 0 8px; }
.bar h1 { font-size: 20px; font-weight: 900; margin: 0; flex: 1; letter-spacing: -.01em; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scroll-x { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

.btn { border: 0; border-radius: 12px; padding: 9px 14px; background: var(--surface-2); font-weight: 700;
  box-shadow: 0 3px 0 var(--line); transition: transform .06s, box-shadow .06s; white-space: nowrap; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 3px 0 var(--brand-lip); }
.btn.primary:active { box-shadow: 0 1px 0 var(--brand-lip); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-size: 13px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; font-weight: 600; }
input.search { flex: 1; min-width: 160px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; margin-top: 14px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; border: 0; padding: 0; text-align: left; }
.thumb { aspect-ratio: 9 / 16; background: var(--surface-2); position: relative; overflow: hidden; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .textonly { padding: 14px; font-size: 13px; color: var(--muted); white-space: pre-wrap; overflow: hidden; height: 100%; }
.thumb .count { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 8px; padding: 2px 7px; font-size: 12px; font-weight: 700; }
.card .meta { padding: 10px 12px 6px; display: grid; gap: 6px; border: 0; background: none; text-align: left; cursor: pointer; }
.card-acts { display: flex; gap: 6px; padding: 0 12px 12px; }
.card-acts .btn.primary { flex: 1; }
.thumb video { background: #000; }

/* Posted: greyed out + a rubber stamp. pointer-events:none keeps the video playable underneath. */
.card.is-posted .thumb video, .card.is-posted .thumb img, .card.is-posted .thumb .textonly { filter: grayscale(1) brightness(.85); }
.card.is-posted .meta { opacity: .6; }
.stamp { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: rgba(60, 60, 70, .35); }
.stamp span { transform: rotate(-14deg); border: 4px solid var(--danger); color: var(--danger); border-radius: 10px;
  padding: 4px 12px; font-weight: 900; font-size: 22px; letter-spacing: .08em; background: rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); mix-blend-mode: normal; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 22px 0 8px; font-weight: 700; }
.card .cap { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.tags { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pill { border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; color: #fff; text-transform: uppercase; letter-spacing: .03em; }
.pill.draft { background: var(--draft); } .pill.ready { background: var(--ready); } .pill.posted { background: var(--posted); } .pill.skipped { background: var(--skipped); }
.loc { font-weight: 800; color: var(--ink); text-transform: uppercase; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

dialog#editor { border: 0; padding: 0; width: min(760px, 100vw); max-height: 100dvh; height: 100dvh; margin: 0 0 0 auto;
  background: var(--bg); color: var(--ink); box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
dialog#editor::backdrop { background: rgba(20, 15, 35, .45); }
@media (max-width: 760px) { dialog#editor { width: 100vw; max-width: 100vw; } }
.ed { display: flex; flex-direction: column; height: 100%; }
.ed-head { display: flex; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); }
.ed-head .title { flex: 1; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 18px; align-content: start; }
.ed-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.ed-foot .spacer { flex: 1; }
label.f { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
label.f input, label.f textarea, label.f select { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; font-weight: 500; color: var(--ink); width: 100%; }
textarea.caption { min-height: 160px; resize: vertical; font-size: 16px; line-height: 1.5; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.counter { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; }
.counter .over { color: var(--danger); }
.issue { font-size: 12px; font-weight: 600; }
.issue.error { color: var(--danger); } .issue.warn { color: var(--warn); }
.strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.tile { flex: 0 0 132px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.tile .thumb { aspect-ratio: 9 / 16; }
.tile .acts { display: flex; justify-content: space-between; padding: 4px; }
.tile .acts button { border: 0; background: none; padding: 4px 6px; border-radius: 8px; font-size: 14px; }
.tile .acts button:hover { background: var(--surface-2); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.drop.over { border-color: var(--brand); color: var(--brand); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.posted-info { font-size: 13px; color: var(--muted); }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); padding: 24px; border-radius: 18px; box-shadow: var(--shadow); width: min(360px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0; font-weight: 900; }
.login .err { color: var(--danger); font-size: 13px; min-height: 1em; }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- shell: sidebar + section ---------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px;
  padding: calc(18px + env(safe-area-inset-top)) 12px 18px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { font-size: 18px; font-weight: 900; padding: 0 8px; letter-spacing: -.01em; }
.nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left;
  padding: 10px 12px; border-radius: 12px; font-weight: 700; color: var(--muted); }
.nav-item:hover { background: var(--surface-2); }
.nav-item[aria-current="true"] { background: var(--ink); color: var(--bg); }
.nav-item .ico { font-size: 18px; }
.side-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.content { padding: 18px 20px calc(32px + env(safe-area-inset-bottom)); min-width: 0; }
.section-title { margin: 0 0 12px; font-size: 22px; font-weight: 900; letter-spacing: -.01em; }
.filters { border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* Library: gameplay clips are the keyboard's game panel (landscape), captures vary — show them whole. */
.content .grid.lib { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.thumb.contain { aspect-ratio: 16 / 10; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.thumb.contain img { object-fit: contain; }
.thumb.wide { aspect-ratio: 16 / 10; }
a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; justify-content: center; }
a.btn.primary { color: var(--on-brand); }

@media (max-width: 760px) {
  /* minmax(0, …): the nowrap nav tabs must scroll, not widen the page. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side, .content { min-width: 0; }
  .side { position: sticky; z-index: 6; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex: 1; padding: 0; font-size: 16px; }
  .side-foot { margin: 0; }
  .nav { order: 3; width: 100%; display: flex; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .content { padding: 12px 16px calc(32px + env(safe-area-inset-bottom)); }
  .section-title { display: none; }
  .content .grid.lib { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
