:root {
  --bg: #141210;
  --surface: #1f1c19;
  --surface-2: #2a2622;
  --line: #3a352f;
  --text: #f3eee8;
  --muted: #a39a90;
  --accent: #e2553b;      /* tomato */
  --accent-ink: #fff;
  --gold: #f5b93b;        /* stars */
  --star-empty: #4a443d;
  --watch: #3fb27f;
  --skip: #c9604a;
  --movie: #6c8cff;
  --tv: #c07cff;
  --radius: 14px;
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }

#views { padding-top: env(safe-area-inset-top); padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); max-width: 640px; margin: 0 auto; }
.view { min-height: 60vh; }
.pad { padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff8a73; }
.error:empty { display: none; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 24px 0; }

/* Top bar */
.top { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 5; min-height: 56px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 600; cursor: pointer; min-height: 44px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { color: #ff8a73; }
.btn.wide { display: flex; width: calc(100% - 32px); margin: 16px auto; }
.btn.google { background: #fff; color: #1f1f1f; }
.icon-btn { background: none; border: 0; padding: 8px; cursor: pointer; color: var(--muted); display: inline-flex; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bookmark.on { color: var(--gold); }
.bookmark.on svg .fill { fill: currentColor; }
.link { background: none; border: 0; padding: 4px 6px; color: var(--muted); cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: #ff8a73; }

/* Tags & badges */
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; vertical-align: middle; }
.tag.movie { background: color-mix(in srgb, var(--movie) 22%, transparent); color: var(--movie); }
.tag.tv { background: color-mix(in srgb, var(--tv) 22%, transparent); color: var(--tv); }
.verdict { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.verdict.watch { background: color-mix(in srgb, var(--watch) 20%, transparent); color: var(--watch); }
.verdict.skip { background: color-mix(in srgb, var(--skip) 20%, transparent); color: var(--skip); }
.role { font-size: 12px; text-transform: capitalize; color: var(--muted); }
.role.owner { color: var(--gold); }
.role.admin { color: var(--accent); }

/* Stars */
.stars { display: inline-flex; color: var(--star-empty); font-size: 16px; line-height: 1; letter-spacing: 1px; }
.stars.tiny { font-size: 12px; }
.star { position: relative; display: inline-block; }
.star-fill { position: absolute; left: 0; top: 0; overflow: hidden; color: var(--gold); white-space: nowrap; }
.picker-wrap { display: flex; align-items: center; gap: 14px; }
.stars.picker { font-size: 42px; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; outline: none; letter-spacing: 4px; }
.stars.picker:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.picker-label { color: var(--muted); font-size: 14px; }

/* Posters */
.poster { width: 72px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); flex-shrink: 0; }
.poster.small { width: 52px; border-radius: 6px; }
.poster.big { width: 140px; border-radius: 10px; }
.poster.none { display: flex; align-items: center; justify-content: center; font-size: 22px; }

/* Feed cards */
.cards { display: flex; flex-direction: column; gap: 10px; padding: 0 12px; }
.card { display: flex; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 12px; cursor: pointer; }
.card:active { background: var(--surface-2); }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title strong { font-size: 17px; }
.card-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-link { font-weight: 600; color: var(--text); }
.comment { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.comment.small { color: var(--text); font-size: 14px; }
.card-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: auto; }
.card-meta .bookmark { padding: 2px; margin: -4px -4px -4px 0; }
.empty { text-align: center; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Title page */
.title-head { display: flex; gap: 16px; padding: 4px 16px 12px; }
.title-info { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.title-info h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.title-info p { margin: 0; }
.title-info .bookmark { padding: 4px; margin-left: -4px; }
.group-line { color: var(--gold); font-weight: 600; margin: 0; }
.title-head + .group-line { padding: 0 16px 12px; font-size: 17px; }
.group-line.small { font-size: 13px; font-weight: 500; }
.title-actions { display: flex; gap: 10px; padding: 0 16px 16px; flex-wrap: wrap; }
.title-actions:empty { display: none; }
.reviews { display: flex; flex-direction: column; gap: 1px; background: var(--line); border-block: 1px solid var(--line); }
.review { background: var(--bg); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.review.mine { background: color-mix(in srgb, var(--accent) 7%, var(--bg)); }
.row-actions { display: inline-flex; gap: 4px; }

/* Rows (library, watchlist, profiles) */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--surface-2); }
.row:active { background: var(--surface); }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-text strong { overflow: hidden; text-overflow: ellipsis; }
.row.member { padding-block: 8px; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.section { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 28px 16px 6px; }

/* Library controls */
.controls { display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Add / search */
.search, input[type="email"], select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; }
.search:focus, input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.search { font-size: 17px; margin-bottom: 8px; }
.results { display: flex; flex-direction: column; }
.result { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: none; border: 0; border-bottom: 1px solid var(--surface-2); text-align: left; cursor: pointer; }
.result:active { background: var(--surface); }
.result-text { display: flex; flex-direction: column; gap: 3px; }

/* Review form */
.form form { display: flex; flex-direction: column; gap: 10px; }
.form-title { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.form-title p { margin: 4px 0 0; }
.field-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 12px; display: flex; justify-content: space-between; }
.counter { text-transform: none; letter-spacing: 0; }
.counter.near { color: var(--gold); }
textarea { resize: vertical; min-height: 96px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }
.seg.watch.on { background: var(--watch); border-color: var(--watch); color: #06140d; }
.seg.skip.on { background: var(--skip); border-color: var(--skip); color: #1b0905; }
.form .btn.wide { width: 100%; margin: 12px 0 0; }

/* Profile */
.profile-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.profile-head h2 { margin: 0; font-size: 22px; }
.profile-head p { margin: 2px 0 0; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin: 12px; }
.panel h3 { margin: 0 0 8px; font-size: 16px; }
.radios { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.about { text-align: center; padding: 24px 16px 8px; color: var(--muted); font-size: 13px; }
.tmdb-logo { height: 14px; margin: 0 auto 8px; }

/* Access */
.add-member .inline { display: flex; gap: 8px; flex-wrap: wrap; }
.add-member input { flex: 1 1 200px; }
.add-member select { width: auto; }
.access-row select { width: auto; padding: 6px 10px; }
.email { font-weight: 500; overflow-wrap: anywhere; }

/* Tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tabs-h); color: var(--muted); font-size: 11px; text-align: center; }
.tabs a.active { color: var(--text); }
.tabs .ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs .add-tab .ico { background: var(--accent); color: #fff; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.tabs .lbl { line-height: 1.1; max-width: 72px; }

/* Gates: splash, login, install card */
.splash, .gate { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 32px 24px; text-align: center; }
.splash img, .gate-icon { width: 88px; height: 88px; border-radius: 22px; }
.gate h1 { margin: 0; font-size: 28px; }
.gate p { margin: 0; max-width: 340px; }
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.steps { text-align: left; max-width: 340px; padding-left: 22px; line-height: 1.6; }

/* Overlay sheet */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 22px 20px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 0 0 4px; }
.sheet .btn.wide { width: 100%; margin: 12px 0 0; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
