:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #e3e6eb;
  --text: #1d2229;
  --muted: #697280;
  --accent: #9f2d3b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e9eb;
  --radius: 12px;
  --font: Inter, "Noto Sans", "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #191d23;
    --line: #2a3038;
    --text: #e6e9ee;
    --muted: #8d96a3;
    --accent: #d0606c;
    --accent-ink: #111418;
    --accent-soft: #2b1c20;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px 48px; flex: 1; }
a { color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; max-width: 1160px; margin: 0 auto; width: 100%; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 650; text-decoration: none; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.intake { max-width: 720px; margin: 40px auto 28px; text-align: center; }
.intake h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 700; }
.intake > p { margin: 0 0 20px; }
.bar { display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); }
.bar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bar input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; padding: 8px 10px; outline: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 550; font-size: 14px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--bg); }
.btn[disabled], .btn.busy { opacity: 0.55; pointer-events: none; }

.error { margin: 12px 0 0; color: var(--accent); font-size: 14px; }

.recent { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.recent button { display: flex; align-items: center; gap: 8px; max-width: 240px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 12px 4px 4px; font: inherit; font-size: 13px; cursor: pointer; }
.recent img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.recent span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .result { grid-template-columns: 1fr; } }

.post { padding: 18px; position: sticky; top: 16px; }
@media (max-width: 860px) { .post { position: static; } }
.author { display: flex; gap: 10px; align-items: center; }
.author img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--line); }
.post h2 { font-size: 18px; line-height: 1.35; margin: 14px 0 8px; letter-spacing: -0.01em; }
.desc { white-space: pre-wrap; margin: 0 0 12px; font-size: 14px; max-height: 320px; overflow: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tags span { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; }
.stats div { padding: 8px 10px; }
.stats div + div { border-left: 1px solid var(--line); }
.stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats dd { margin: 2px 0 0; font-weight: 650; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 12px; flex-wrap: wrap; position: sticky; top: 8px; z-index: 2; }
.toolbar .spacer { flex: 1; }
.fmt { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 600px) {
  .toolbar .spacer { display: none; }
  .toolbar #zip { width: 100%; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
.toolbar select { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; font-size: 14px; }
.check input, .tile input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tile { position: relative; border-radius: 10px; overflow: hidden; background: var(--line); aspect-ratio: 3 / 4; border: 2px solid transparent; }
.tile.selected { border-color: var(--accent); }
.tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.tile .pick { position: absolute; top: 8px; left: 8px; background: rgb(255 255 255 / 0.92); border-radius: 6px; padding: 4px; display: flex; }
.tile .badges { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.badge { font-size: 11px; font-weight: 650; background: rgb(17 20 24 / 0.72); color: #fff; padding: 2px 6px; border-radius: 5px; letter-spacing: 0.03em; }
.tile .dl { position: absolute; bottom: 8px; right: 8px; opacity: 0; transition: opacity 0.15s; background: rgb(17 20 24 / 0.78); color: #fff; border: 0; padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.tile:hover .dl, .tile:focus-within .dl { opacity: 1; }
@media (hover: none) { .tile .dl { opacity: 1; } }

.video { overflow: hidden; }
.video video { width: 100%; max-height: 62vh; background: #000; display: block; }
.video-info { padding: 14px 16px; display: grid; gap: 10px; }
.video-info p { margin: 0; }

.viewer { width: min(1000px, 96vw); height: min(92vh, 1000px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
.viewer::backdrop { background: rgb(10 12 15 / 0.7); }
.viewer[open] { display: flex; flex-direction: column; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; background: var(--bg); }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 38px; height: 38px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; }
#prev { left: 12px; } #next { right: 12px; }

footer { text-align: center; padding: 20px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 9px; font-size: 14px; z-index: 50; }

.transcript { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: grid; gap: 10px; }
.transcript-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.transcript h3 { margin: 0; font-size: 15px; }
.transcript select { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.transcript p { margin: 0; }
.t-progress { display: grid; gap: 6px; }
.bar-track { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }
.bar-fill.indeterminate { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.t-actions { margin-top: 8px; }
.t-lines { list-style: none; margin: 8px 0 0; padding: 0; max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.t-lines li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 7px 10px; font-size: 14px; cursor: pointer; }
.t-lines li + li { border-top: 1px solid var(--line); }
.t-lines li:hover { background: var(--bg); }
.t-lines li.active { background: var(--accent-soft); }
.t-lines time { color: var(--muted); font-size: 12px; padding-top: 2px; }
.t-lines .lang { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; text-transform: uppercase; }
