/* TrackerLab — streaming-service look (Netflix/Disney+ inspired). Poster-forward
   tiles with a bottom gradient scrim and overlaid title, bold grotesque type,
   flat elevation (single soft shadow, no neumorphism). Palette is user-specified
   (dusk/twilight family): a muted slate-violet, dusty rose, soft pink, a bright
   periwinkle accent and a pale lavender-white for text — built primarily for the
   dark theme, with a lighter variant of the same family for the light theme so
   both stay one coherent brand. Theme is token-level: light is the default
   (:root), dark redefines only the tokens via [data-theme="dark"].*/

@font-face {
  font-family: 'Archivo';
  src: url('/fonts/archivo-var.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --bg-elevated: #f4f3fa;
  --bg-well: #ebe9f7;
  --border: rgba(86, 86, 118, 0.16);
  --ink: #2c2a40;
  --muted: #565676;      /* given palette, unchanged — reads fine on both grounds */
  --accent: #6b69d6;     /* darker cut of the periwinkle for contrast on white */
  --accent-2: #a76571;   /* given palette: dusty rose */
  --on-accent: #ffffff;
  --good: #2f8a5f;
  --warn: #a5636c;
  --bad: #a23a4d;
  --scrim: linear-gradient(0deg, rgba(0,0,0,.86) 0%, rgba(0,0,0,.55) 42%, rgba(0,0,0,0) 100%);

  --shadow-1: 0 1px 2px rgba(44, 42, 64, 0.08), 0 1px 1px rgba(44, 42, 64, 0.04);
  --shadow-2: 0 12px 28px rgba(44, 42, 64, 0.16), 0 3px 8px rgba(44, 42, 64, 0.08);
  --accent-glow: 0 6px 16px rgba(107, 105, 214, 0.30);

  --r-lg: 12px;
  --r-md: 8px;
  --r-sm: 6px;
  --font-ui: 'Archivo', system-ui, sans-serif;
  --font-data: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-theme='dark'] {
  --bg: #110f18;
  --bg-elevated: #1c1926;
  --bg-well: #272232;
  --border: rgba(216, 220, 255, 0.12);
  --ink: #d8dcff;        /* given palette: pale lavender */
  --muted: #8d89ab;      /* lightened from the given #565676 for AA contrast on near-black */
  --accent: #aeadf0;     /* given palette: periwinkle */
  --accent-2: #a76571;   /* given palette: dusty rose */
  --on-accent: #1c1926;
  --good: #74b191;
  --warn: #c38d94;       /* given palette: soft pink */
  --bad: #c1596b;
  --scrim: linear-gradient(0deg, rgba(0,0,0,.92) 0%, rgba(0,0,0,.65) 45%, rgba(0,0,0,0) 100%);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 16px 36px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4);
  --accent-glow: 0 6px 18px rgba(174, 173, 240, 0.30);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; font-weight: 700; }
h1, h2, h3 { font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.5rem; margin-bottom: 16px; font-weight: 900; }
h3 { font-size: 1.05rem; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; font-family: var(--font-data); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- icons ---------- */
.icon { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font-weight: 900; font-size: 1.2rem; color: var(--ink); white-space: nowrap;
  display: flex; align-items: center; gap: 9px; letter-spacing: -0.02em;
  margin-right: auto;
}
.logo img { width: 28px; height: 28px; border-radius: 7px; }
.logo b { color: var(--accent-2); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.avatar-link {
  display: flex; border-radius: 50%; line-height: 0;
  /* order stays default (last in DOM = rightmost) on desktop; the mobile
     breakpoint below flips it to the front so profile sits top-left there. */
}
.avatar-link.active .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* ---------- bottom tab dock (always bottom, all screen sizes) ---------- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 30;
  display: flex; gap: 4px; max-width: min(640px, calc(100vw - 24px));
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow-2);
  padding: 6px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 8px 16px; border-radius: 999px; flex: 1;
  color: var(--muted); white-space: nowrap; border: none;
  background: transparent; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.64rem;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--ink); background: var(--bg-elevated); }
.tab.active { color: var(--on-accent); background: var(--accent); box-shadow: var(--accent-glow); }
.tab.active:hover { color: var(--on-accent); }

.icon-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-toggle:hover { background: var(--bg-elevated); }

.sync-badge {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-data); font-size: 0.78rem;
}
.sync-badge:hover { background: var(--bg-elevated); }
.sync-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.sync-badge.pending .dot { background: var(--warn); }
.sync-badge.off .dot { background: var(--bad); }
.sync-badge.busy .dot { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.content { max-width: 1180px; margin: 0 auto; padding: 28px 22px 90px; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--bg-elevated); color: var(--ink);
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 20px; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-well); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--accent-glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 6px 14px; font-size: 0.82rem; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--bg-elevated); }
.btn.danger { color: var(--bad); }
.btn.link { background: none; border: none; padding: 4px 0; color: var(--accent); font-weight: 700; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 6px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--ink); background: var(--bg-elevated); }

.form { display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.83rem; font-weight: 700; color: var(--muted); flex: 1; }
.form-row { display: flex; gap: 12px; }
input, select, textarea {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 13px; font-family: var(--font-data); font-size: 0.92rem; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.error, .success, .warning {
  padding: 10px 15px; border-radius: var(--r-md); font-size: 0.87rem;
  font-family: var(--font-data); border: 1px solid currentColor;
}
.error { color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--bg)); }
.success { color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--bg)); }
.warning { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--bg)); margin-bottom: 14px; }

/* select dropdown with a custom chevron */
.select-wrap { position: relative; display: flex; flex-direction: column; gap: 5px; }
.select-label { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.select-wrap select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  font-weight: 700; min-width: 150px;
}
.select-chevron {
  position: absolute; right: 11px; bottom: 10px; pointer-events: none; color: var(--muted);
}

/* ---------- auth ---------- */
.center-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 390px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
  padding: 34px; display: flex; flex-direction: column; gap: 15px;
  box-shadow: var(--shadow-2);
}
.auth-card h1 { font-size: 1.7rem; font-weight: 900; display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; }
.auth-card h1 img { width: 38px; height: 38px; border-radius: 10px; }
.auth-card h1 b { color: var(--accent-2); }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 0.83rem; font-weight: 700; color: var(--muted); }

/* ---------- cards & grid (streaming tiles: poster + scrim + overlaid title) ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 18px; }
.card {
  position: relative; border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-1);
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-4px) scale(1.015); box-shadow: var(--shadow-2); z-index: 1; }
.card:active { transform: translateY(-1px) scale(1); }
.card-media { position: relative; }
.card-media .poster { display: block; }
.card-media .poster.placeholder span { display: none; }
.card-scrim {
  position: absolute; inset: 0; background: var(--scrim); pointer-events: none;
}
.card-badges { position: absolute; top: 9px; left: 9px; display: flex; gap: 5px; flex-wrap: wrap; z-index: 1; }
.card-status { position: absolute; top: 9px; right: 9px; z-index: 1; }
.card-quick-add {
  position: absolute; top: 9px; right: 9px; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(20,20,24,0.55); backdrop-filter: blur(3px); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.card-quick-add:hover { background: rgba(20,20,24,0.8); transform: scale(1.08); }
.card-quick-add.added { background: var(--good); color: #fff; }
.card-overlay-text {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 11px 12px;
  display: flex; flex-direction: column; gap: 3px; z-index: 1;
}
.card-title { color: #fff; font-weight: 800; font-size: 0.92rem; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.card-meta { color: rgba(255,255,255,0.82); font-size: 0.76rem; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.card-media .progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px; border-radius: 0;
  background: rgba(255,255,255,0.28); box-shadow: none; margin: 0; z-index: 1;
}
.card-footer { padding: 8px 10px; }

.poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: var(--bg-well); }
.poster.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 14px; color: var(--muted); font-weight: 800; font-size: 0.9rem;
  background: linear-gradient(150deg, var(--bg-well), var(--bg-elevated));
}
.poster.sm, .poster.xs, .poster.lg { border-radius: var(--r-md); flex-shrink: 0; box-shadow: var(--shadow-1); }
.poster.sm { width: 92px; }
.poster.xs { width: 48px; border-radius: var(--r-sm); }
.poster.lg { width: 200px; border-radius: var(--r-lg); box-shadow: var(--shadow-2); }

.badge {
  font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em;
  padding: 3px 9px; border-radius: 999px; color: #fff; text-transform: uppercase;
  font-family: var(--font-data);
}
.cat-movie { background: #6a68c9; }
.cat-show { background: #a76571; }
.cat-anime { background: #c38d94; }
.badge.custom, .badge.src { background: rgba(20,20,24,0.55); color: #fff; backdrop-filter: blur(3px); }
.badge-icon.fav { color: var(--bad); display: inline-flex; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.st-watchlist { background: rgba(20,20,24,0.6); backdrop-filter: blur(3px); }
.st-watching { background: var(--accent); }
.st-watched { background: var(--good); }
.st-dropped { background: #7a4a5f; }

.progress { height: 6px; background: var(--bg-well); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }

/* ---------- filter bar (dropdowns) ---------- */
.filter-bar { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.filter-fav {
  width: 40px; height: 40px; border-radius: var(--r-md); flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.filter-fav:hover { background: var(--bg-elevated); }
.filter-fav.active { color: var(--bad); border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg)); }

/* ---------- chips (used where a flat multi-toggle row still fits, e.g. search type) ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.chip {
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 7px 15px; cursor: pointer;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.84rem;
}
.chip:hover { color: var(--ink); background: var(--bg-elevated); }
.chip.active { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: var(--accent-glow); }

/* ---------- search ---------- */
.search-bar { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.search-input { font-size: 1.05rem; padding: 15px 20px; border-radius: 999px; }
.search-footer { margin-top: 30px; display: flex; gap: 12px; align-items: center; }

/* ---------- lists ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h2, .page-head h3 { margin: 0; }
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 18px; }
.list-card { background: var(--bg-elevated); border-radius: var(--r-lg); overflow: hidden; cursor: pointer; box-shadow: var(--shadow-1); transition: transform 0.15s, box-shadow 0.15s; }
.list-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.list-posters { display: flex; height: 112px; background: var(--bg-well); }
.list-posters img, .mini-placeholder { flex: 1; object-fit: cover; min-width: 0; height: 100%; }
.mini-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.list-card-body { padding: 12px 16px 14px; }

/* ---------- watching ---------- */
.watch-rows { display: flex; flex-direction: column; gap: 16px; }
.watch-row {
  display: flex; gap: 16px; background: var(--bg-elevated);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow-1);
}
.watch-poster { cursor: pointer; }
.watch-info { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.watch-title { font-weight: 800; font-size: 1.08rem; cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.next-ep { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; flex-wrap: wrap; }
.next-ep-label { font-size: 0.9rem; font-family: var(--font-data); display: flex; align-items: center; gap: 6px; }

/* ---------- upcoming ---------- */
.upcoming-group { margin-bottom: 24px; }
.upcoming-date {
  display: flex; align-items: baseline; gap: 14px; justify-content: space-between;
  padding: 9px 4px; margin-bottom: 10px;
  border-bottom: 2px solid var(--border);
  font-weight: 800;
}
.countdown {
  color: var(--accent); font-family: var(--font-data);
  font-variant-numeric: tabular-nums; font-size: 0.88rem; font-weight: 700;
}
.countdown.out { color: var(--good); font-weight: 800; }
.upcoming-row {
  display: flex; gap: 13px; align-items: center; padding: 8px 8px;
  border-radius: var(--r-md); cursor: pointer; transition: background 0.15s;
}
.upcoming-row:hover { background: var(--bg-elevated); }
.upcoming-title { font-weight: 800; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- media detail ---------- */
.media-page { position: relative; }
.backdrop {
  position: absolute; inset: -28px -22px auto; height: 320px;
  background-size: cover; background-position: center 22%;
  border-radius: 0;
  mask-image: linear-gradient(var(--bg) 0%, transparent 75%);
  -webkit-mask-image: linear-gradient(var(--bg) 0%, transparent 75%);
  pointer-events: none;
}
[data-theme='dark'] .backdrop { opacity: 0.5; }
.media-head { display: flex; gap: 28px; position: relative; }
.media-head-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 11px; }
.media-meta { display: flex; gap: 13px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 0.87rem; font-family: var(--font-data); }
.overview { max-width: 68ch; }
.state-controls { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.note { max-width: 560px; min-height: 68px; resize: vertical; }
.add-to-list { display: flex; gap: 9px; flex-wrap: wrap; }
.others { display: flex; gap: 10px; flex-wrap: wrap; }
.other-rating {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; padding: 4px 13px 4px 5px;
  font-size: 0.85rem; font-family: var(--font-data);
}
.admin-row { margin-top: 8px; }
.cat-select { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.cat-select select { width: auto; padding: 5px 10px; }

.stars { display: flex; align-items: center; gap: 1px; }
.star {
  background: none; border: none; font-size: 1.4rem; cursor: pointer; padding: 0 1px;
  color: var(--muted); opacity: 0.4; transition: transform 0.1s;
}
.star:hover { transform: scale(1.2); }
.star.on { color: var(--warn); opacity: 1; }
.stars-value { margin-left: 10px; color: var(--muted); font-size: 0.85rem; font-family: var(--font-data); }

/* ---------- episodes ---------- */
.episodes { margin-top: 34px; }
.season { border-radius: var(--r-lg); margin-bottom: 12px; background: var(--bg-elevated); box-shadow: var(--shadow-1); overflow: hidden; }
.season-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: transparent; border: none; color: var(--ink);
  padding: 13px 18px; cursor: pointer; font-family: var(--font-ui); font-weight: 800; font-size: 0.95rem;
}
.episode-row { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-top: 1px solid var(--border); }
.episode-row.future { opacity: 0.5; }
.ep-check { display: flex; align-items: center; gap: 11px; flex: 1; cursor: pointer; min-width: 0; }
.ep-check input {
  appearance: none; width: 20px; height: 20px; border-radius: 6px;
  background: var(--bg-well); border: 1px solid var(--border); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.ep-check input:checked { background: var(--accent); border-color: transparent; }
.ep-check input:checked::after { content: '✓'; color: var(--on-accent); font-size: 0.75rem; font-weight: 900; }
.ep-num { color: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-data); font-size: 0.85rem; flex-shrink: 0; }
.ep-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.ep-actions { display: flex; gap: 2px; align-items: center; }
.ep-rate {
  width: auto; padding: 3px 6px; font-size: 0.78rem; border-radius: 8px;
  color: var(--muted); flex-shrink: 0;
}
.ep-rate.rated { color: var(--warn); font-weight: 700; }
.icon-btn.rewatch { font-size: 0.78rem; font-family: var(--font-data); white-space: nowrap; gap: 3px; }
.btn.heart.on { color: var(--bad); }
.filter-fav.active { color: var(--bad); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 5, 8, 0.6); z-index: 50;
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 18px;
  padding: 26px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-2);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* ---------- profile ---------- */
.avatar {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; flex-shrink: 0; user-select: none;
}
.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.profile-head .logout { margin-left: auto; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat-card { background: var(--bg-elevated); border-radius: var(--r-lg); padding: 16px 13px; text-align: center; box-shadow: var(--shadow-1); }
.stat-value { font-size: 1.5rem; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.76rem; font-family: var(--font-data); }
.profile-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.color-row { display: flex; gap: 10px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dot.active { border-color: var(--ink); }
.member-list { display: flex; flex-direction: column; gap: 10px; }
.member { display: flex; align-items: center; gap: 10px; }

.avatar-edit { position: relative; flex-shrink: 0; }
.avatar-edit-btn {
  position: absolute; bottom: -2px; right: -2px; width: 24px; height: 24px;
  border-radius: 50%; border: 2px solid var(--bg); background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.avatar-edit-btn:hover { filter: brightness(1.08); }
.avatar-edit-btn:disabled { opacity: 0.6; cursor: default; }

.import-tvtime { max-width: 560px; margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.import-progress { display: flex; flex-direction: column; gap: 8px; }

/* ---------- misc ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 60px 24px;
  background: var(--bg-elevated); border: 1px dashed var(--border); border-radius: var(--r-lg);
}
.spinner {
  width: 26px; height: 26px; margin: 30px auto;
  border: 3px solid var(--bg-well); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- phone layout: avatar moves top-left, dock spans full width ---------- */
@media (max-width: 720px) {
  .content { padding: 18px 14px 96px; }
  .topbar { padding: 10px 14px; }
  .avatar-link { order: -1; } /* mobile: profile jumps to the front (left) */
  .tabs { left: 12px; right: 12px; transform: none; max-width: none; }
  .media-head { flex-direction: column; }
  .poster.lg { width: 150px; }
  .profile-cols { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 12px; }
  .logo span { display: none; }
  .sync-badge span:not(.dot) { display: none; } /* dot-only on phones, saves space next to the avatar */
  .filter-bar { gap: 10px; }
  .select-wrap select { min-width: 0; }
}
