:root {
  --bg: #0d0d10; --card: #18181d; --line: #2a2a32; --text: #f2f2f5; --dim: #9a9aa6;
  --accent: #ff6a3d; --accent-text: #fff; --ok: #3ecf8e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--text); background: var(--bg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px);
  -webkit-text-size-adjust: 100%;
}
header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
button { font: inherit; color: inherit; border: 0; border-radius: 12px; background: #26262e; padding: 0 14px; min-height: 44px; cursor: pointer; }
button:active { opacity: 0.7; }
button:disabled { opacity: 0.6; }
#refresh { min-height: 36px; font-size: 14px; color: var(--dim); background: transparent; border: 1px solid var(--line); }
main { padding: 0 16px; max-width: 560px; margin: 0 auto; }
.note { margin: 4px 16px 12px; padding: 10px 12px; border-radius: 12px; background: #1d2330; color: #cdd6ea; font-size: 14px; }
.status { color: var(--dim); text-align: center; padding: 48px 0; }
h3 { margin: 22px 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }

.card { display: grid; grid-template-columns: 108px 1fr; gap: 12px; padding: 12px; margin-bottom: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.card.done { opacity: 0.62; }
.poster { position: relative; padding: 0; min-height: 0; width: 108px; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; background: #000; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .play { position: absolute; inset: 0; margin: auto; width: 40px; height: 40px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); }
.poster .play::after { content: ""; position: absolute; left: 16px; top: 12px; border-style: solid; border-width: 8px 0 8px 13px; border-color: transparent transparent transparent #fff; }
.poster .dur { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.7); font-size: 12px; font-variant-numeric: tabular-nums; }
.info { min-width: 0; }
.info h2 { margin: 2px 0 2px; font-size: 18px; line-height: 1.2; }
.meta { margin: 0 0 8px; color: var(--dim); font-size: 13px; }
.caption { margin: 0; font-size: 14px; color: #d6d6de; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.caption.open { display: block; }
.actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .share { grid-column: 1 / -1; background: var(--accent); color: var(--accent-text); font-weight: 600; min-height: 50px; position: relative; overflow: hidden; }
.actions .share.ready { background: var(--ok); color: #04130c; }
.actions .share .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, 0.25); pointer-events: none; }
.actions .share span { position: relative; }
.actions .posted.on { color: var(--ok); }
.actions a.dl { grid-column: 1 / -1; text-align: center; color: var(--dim); font-size: 13px; padding: 4px 0 0; }

.pair { max-width: 340px; margin: 48px auto 0; text-align: center; }
.pair p { color: var(--dim); }
.pair input { width: 100%; font: 600 20px ui-monospace, Menlo, monospace; letter-spacing: 0.08em; text-align: center; text-transform: uppercase; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px; margin: 8px 0 12px; }
.pair button { width: 100%; background: var(--accent); color: var(--accent-text); font-weight: 600; min-height: 50px; }
.pair .err { color: #ff8a8a; min-height: 1.4em; }

.player { position: fixed; inset: 0; z-index: 10; background: #000; display: flex; align-items: center; justify-content: center; }
.player video { width: 100%; height: 100%; object-fit: contain; }
.player .close { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; z-index: 11; background: rgba(40, 40, 46, 0.85); min-height: 40px; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%); z-index: 20; max-width: 88%; padding: 10px 16px; border-radius: 999px; background: #f2f2f5; color: #111; font-size: 14px; font-weight: 600; text-align: center; }
