:root {
  --bg: #f6f7f9; --card: #fff; --text: #1a1d21; --muted: #6b7280; --line: #e3e6ea;
  --accent: #1d4ed8; --accent-text: #fff; --danger: #b91c1c; --ok: #15803d;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111417; --card: #1b1f24; --text: #e8eaed; --muted: #9aa3ad; --line: #2b3138; --accent: #3b82f6; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1, h2 { margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.3rem; } h2 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.error { color: var(--danger); }
.spacer { flex: 1; }
input, button { font: inherit; }
input[type=url], input[type=search], input[type=password], input[readonly] {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); }
button { padding: .55rem 1rem; border: 0; border-radius: 8px; background: var(--accent);
  color: var(--accent-text); cursor: pointer; white-space: nowrap; }
button.link { background: none; color: var(--accent); padding: .3rem .5rem; }
button.danger { color: var(--danger); }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem;
  background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
.container { max-width: 900px; margin: 0 auto; padding: 1.25rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; }
.add form { display: flex; gap: .5rem; }
.add p { margin: .5rem 0 0; min-height: 1.2em; }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.5rem 0 .75rem; }
.search input { width: 220px; }

.videos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.video { display: grid; grid-template-columns: 128px 1fr auto; gap: 1rem; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.video .thumb { width: 128px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--line); }
.video .thumb[hidden] { display: block !important; visibility: hidden; }
.video .title { font-weight: 600; word-break: break-word; }
.video .body > * + * { margin-top: .35rem; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); transition: width .4s; }
.share { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.share input { flex: 1 1 220px; font-size: .85rem; }
.share a.open { padding: .55rem .5rem; }
.actions { display: flex; flex-direction: column; align-items: flex-end; }
@media (max-width: 600px) {
  .video { grid-template-columns: 1fr; }
  .video .thumb { width: 100%; }
  .actions { flex-direction: row; }
}

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .75rem; }
.login label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }

body.watch { background: #000; color: #eee; }
.player { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.player video { width: 100%; max-height: 85vh; background: #000; border-radius: 8px; }
.player h1 { margin-top: .9rem; }
body.watch .muted { color: #9aa3ad; }

/* --- phase 2: users --- */
.topbar .brand { color: inherit; text-decoration: none; }
.tabs { display: flex; gap: .25rem; margin-left: .5rem; }
.tabs a { padding: .3rem .6rem; border-radius: 6px; color: var(--muted); text-decoration: none; }
.tabs a.on { background: var(--bg); color: var(--text); font-weight: 600; }
.who { display: inline-flex; align-items: center; gap: .5rem; }
.who img { width: 26px; height: 26px; border-radius: 50%; }
.banner { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem 1rem; margin: 0 0 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .6rem; padding: .6rem 1rem;
  border-radius: 8px; text-decoration: none; font-weight: 500; }
.btn.google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; }
.login .fallback { margin-top: .5rem; }
.login .fallback summary { cursor: pointer; }
.login .fallback form { display: flex; flex-direction: column; gap: .75rem; margin-top: .75rem; }
.login form { display: flex; flex-direction: column; gap: .75rem; }
.table-wrap { overflow-x: auto; }
table.users { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table.users th, table.users td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.users tr:last-child td { border-bottom: 0; }
table.users .num { text-align: right; }
table.users .who img { width: 32px; height: 32px; }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .8rem; }
form.inline { display: inline-flex; align-items: center; gap: .4rem; }
code { font-size: .85em; background: var(--bg); padding: .1em .3em; border-radius: 4px; }
@media (max-width: 700px) { .topbar { flex-wrap: wrap; } }

/* storage tracker */
.storage { display: flex; align-items: center; gap: .5rem; }
.storage-bar { width: 110px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.storage-bar > div { height: 100%; background: var(--ok); transition: width .4s; }
.storage-bar.warn > div { background: #d97706; }
.storage-bar.crit > div { background: var(--danger); }
@media (max-width: 700px) { .storage-bar { width: 70px; } }

/* prune */
.prune { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.prune p { margin: 0; }
button[disabled] { opacity: .5; cursor: default; }
.player .placeholder { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; opacity: .5; }

.steps { margin: 0 0 .9rem; padding-left: 1.2rem; }
.steps li { margin: .15rem 0; }
.topbar > *, .topbar .tabs a, .topbar .storage span { white-space: nowrap; }
@media (max-width: 1100px) { .topbar { gap: .7rem; } .topbar .storage span, .topbar .count { display: none; } }
@media (max-width: 900px) { .topbar .who { display: none; } }
