:root {
  color-scheme: dark;
  /* Jewtube palette, matched to Books (bookportal public/css/style.css). */
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1f1f1f;
  --line: #282828;
  --text: #fff;
  --muted: rgba(255, 255, 255, .6);
  --dim: rgba(160, 160, 160, .55);
  --accent: #6279CD;
  --accent-rgb: 98, 121, 205;
  --gold: #F0B90B;
  --live: #35d07f;
  --warn: #ffb020;
  --down: #ff5c5c;
  --radius: 14px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  --sans: 'Noto Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Noto Sans, the face Jellyfin and the other Jewtube apps use (400/700 only). */
@font-face {
  font-family: 'Noto Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/noto-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Noto Sans'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/noto-sans-latin-700-normal.woff2') format('woff2');
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #8FA3E8; }
[hidden] { display: none !important; }
::selection { background: rgba(var(--accent-rgb), .45); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- top bar (same shape as Books') ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: .7rem 20px;
  display: flex; align-items: center; gap: 1.5rem;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-size: 1.5rem; font-weight: 700; color: var(--text); letter-spacing: .02em;
}
.brand:hover { color: var(--gold); }
.brand-logo { height: 1.9rem; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: .8rem; margin-left: auto; }

/* ---------- Jewtube Ecosystem app switcher ----------
   The switcher itself is the shared <jewtube-ecosystem> element (styles live in
   its shadow DOM). This is only the fallback link shown if the script can't load. */
.products-dropdown-btn {
  background: rgba(0, 0, 0, .5); border: 1px solid var(--line); color: rgba(255, 255, 255, .75);
  width: 34px; height: 34px; border-radius: 8px; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s ease;
}
.products-dropdown-btn:hover { color: #fff; background: rgba(80, 80, 80, .8); }

.meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.meta b { color: var(--text); font-weight: 600; }

.tabs { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 10px; }
.tabs button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px;
  padding: 6px 14px; border-radius: 7px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }

/* ---------- hero ---------- */
.hero {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; margin-bottom: 20px; display: flex; gap: 28px; align-items: center;
  flex-wrap: wrap;
}
.hero.quiet { background: linear-gradient(180deg, #161616, #101010); }
.hero.busy { border-color: #235c3f; background: linear-gradient(180deg, #10241b, #101010); }
.hero .count { font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.hero.quiet .count { color: var(--dim); }
.hero.busy .count { color: var(--live); }
.hero .headline { font-size: 21px; font-weight: 600; }
.hero.quiet .headline { color: var(--muted); font-weight: 500; }
.hero .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.hero .who { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hero-stats { display: flex; gap: 26px; margin-left: auto; text-align: right; }
.hero-stats div span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; }
.hero-stats div b { font-size: 22px; font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: 13px;
}
.chip.person { background: #16321f; border-color: #235c3f; color: #b9f2d0; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); }

/* ---------- service cards ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 12px; display: flex; flex-direction: column; min-height: 150px;
}
.card.active { border-color: #2c6a49; }
.card.down { border-color: #5c2626; }
.card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.card-head .name { font-weight: 600; font-size: 15px; }
.card-head .kind { color: var(--dim); font-size: 12px; }
.status { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.status.up { background: #2e6b4c; }
.status.live { background: var(--live); box-shadow: 0 0 0 3px rgba(53, 208, 127, 0.18); }
.status.down { background: var(--down); }
.card .big { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.card .big.zero { color: var(--dim); font-weight: 500; }
.card .label { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.users { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 10px; }
.user-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.user-row .u { font-weight: 600; }
.user-row .d { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: #9fe7c1; background: #16321f; border-radius: 4px; padding: 1px 5px; }
.card .err { color: #ff8f8f; font-size: 12px; font-family: var(--mono); word-break: break-word; }
.card .spark { margin-top: auto; padding-top: 8px; }
.card .foot { display: flex; justify-content: space-between; color: var(--dim); font-size: 11.5px;
  font-variant-numeric: tabular-nums; padding-top: 6px; }

.servers { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.servers .s { font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--muted); }
.servers .s.up { color: var(--text); }
.servers .s.busy { color: #b9f2d0; border-color: #235c3f; background: #16321f; }
.servers .s.down { color: var(--dim); }  /* stopped on purpose is not an error */

/* ---------- panels & charts ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 2px; font-size: 15px; }
.panel .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.chart { width: 100%; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.55; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.range { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 9px; }
.range button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12.5px;
  padding: 5px 11px; border-radius: 6px; cursor: pointer; }
.range button[aria-selected="true"] { background: var(--panel); color: var(--text); }
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--line); }
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
.tag { font-size: 11.5px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; margin-right: 5px; display: inline-block; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 20; background: #0a0a0aee; color: var(--text);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 12.5px;
  box-shadow: 0 8px 26px #0009; max-width: 280px; display: none;
}
.tooltip b { font-variant-numeric: tabular-nums; }
.tooltip .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.tooltip .row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.empty { color: var(--dim); font-size: 13.5px; padding: 18px 0; text-align: center; }
.hidden { display: none !important; }
.err-banner { background: #2a1414; border: 1px solid #5c2626; color: #ffb3b3; padding: 10px 14px;
  border-radius: 10px; margin-bottom: 16px; font-size: 13px; }

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: .7rem; }
  .topbar .tabs { order: 3; width: 100%; justify-content: space-between; }
}

@media (max-width: 620px) {
  .hero { padding: 20px; }
  .hero .count { font-size: 48px; }
  .hero-stats { margin-left: 0; text-align: left; }
}

/* ================= stats.jewtube.live additions ================= */
html, body { overflow-x: hidden; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; font: inherit;
  font-weight: 600; padding: 10px 18px; cursor: pointer;
}
.btn:hover { background: #7489d6; color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: #2a2a2a; }
.dim { color: var(--dim); }

.signin { max-width: 460px; margin: 8vh auto; text-align: center; padding: 34px 26px; }
.signin h1 { margin: 12px 0 6px; font-size: 24px; }
.signin p { color: var(--muted); }
.signin .hint { font-size: 12.5px; margin-top: 18px; }

/* account menu */
.account { position: relative; }
.account summary {
  list-style: none; cursor: pointer; font-size: 13px; color: var(--muted);
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account summary::-webkit-details-marker { display: none; }
.account[open] summary { color: var(--text); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 180px;
  box-shadow: 0 10px 30px #000a; z-index: 150; font-size: 13.5px;
}
.account-role { color: var(--dim); font-size: 12px; margin-bottom: 6px; }

/* owner bar */
.ownerbar { background: #16192a; border-bottom: 1px solid #2b3358; font-size: 13px; }
.ownerbar.previewing { background: #2a2210; border-bottom-color: #5c4a1a; }
.ownerbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 8px 20px; display: flex; gap: 14px;
  align-items: center; flex-wrap: wrap; color: var(--muted);
}
.ownerbar label { display: inline-flex; gap: 8px; align-items: center; margin-left: auto; }
.ownerbar select, .merge-form input {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; font: inherit; font-size: 13px; max-width: 100%;
}
.owner-tag { color: #c9d2f5; border-color: #2b3358; background: #16192a; }
.card .orig { color: var(--dim); font-size: 11.5px; margin: -2px 0 4px; }
.user-row.you .u { color: var(--gold); }
.card.small { min-height: 0; }

/* uptime */
.uptime-summary { margin-bottom: 14px; }
.usum { display: flex; gap: 12px; align-items: baseline; padding: 12px 14px; border-radius: 10px; flex-wrap: wrap; }
.usum.ok { background: #10241b; border: 1px solid #235c3f; }
.usum.ok b { color: var(--live); }
.usum.bad { background: #2a1414; border: 1px solid #5c2626; }
.usum.bad b { color: #ff8f8f; }
.usum span { color: var(--muted); font-size: 12.5px; }
.urow { padding: 14px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; }
.uname { font-weight: 600; }
.uname a { color: var(--text); }
.uname a:hover { color: var(--gold); }
.ustate { margin-left: auto; font-size: 12.5px; font-weight: 600; }
.ustate.up { color: var(--live); }
.ustate.down { color: var(--down); }
.ustate.unknown { color: var(--dim); }
.ustats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.ustats span { display: flex; flex-direction: column; }
.ustats small { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ustats b { font-size: 15px; }
.ubars { display: flex; gap: 2px; height: 30px; align-items: stretch; }
.ubar { flex: 1 1 0; min-width: 2px; border-radius: 2px; opacity: .9; }
.ubar:hover { opacity: 1; outline: 1px solid #fff6; }
.urt { margin-top: 8px; }
.urt small { color: var(--dim); font-size: 11px; }

/* people */
.you-card { background: #1d1a0d; border: 1px solid #5c4a1a; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.you-card b { color: var(--gold); }
.you-card span { color: var(--muted); }
table.people .rank { width: 36px; color: var(--muted); }
table.people .pick { width: 26px; }
tr.you-row td { background: #1d1a0d; }
.you-name { color: var(--gold); }
.member { color: var(--muted); }
.ids { color: var(--dim); font-size: 12px; }
#merge-panel h3 { font-size: 13px; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.merge-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.merge-form input { flex: 1 1 220px; }
.arrow { color: var(--dim); }
.merge-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.merge-row .btn { margin-left: auto; }
.identities { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.identity { display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 3px 0; flex-wrap: wrap; }
.iname { font-weight: 600; }

#history-stats { margin: 18px 0 0; gap: 32px; text-align: left; }

@media (max-width: 720px) {
  .account summary { max-width: 110px; }
  .ownerbar label { margin-left: 0; }
}
@media (max-width: 620px) {
  .wrap { padding: 16px 16px 50px; }
  .topbar-inner { padding: .6rem 16px; }
  .grid { grid-template-columns: 1fr; }
  .svc-col, .seen-col { display: none; }
  .ustats { gap: 14px; }
  .hero-stats { gap: 18px; }
  .ubars { gap: 1px; }
  #history-stats { gap: 18px; }
  .meta { display: none; }
}
table.people td.rank, table.people th.rank { text-align: left; padding-right: 12px; width: 44px; }

/* ---------- all-time ranking + imported internal uptime ---------- */
.ubar.internal { opacity: .45; background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(0,0,0,.28) 3px 5px); }
.ubar.mixed { opacity: .7; }
.uptime-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 14px;
  color: var(--muted); font-size: 12.5px; }
.uptime-legend .lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.uptime-legend .sw { width: 12px; height: 14px; border-radius: 2px; background: var(--live); display: inline-block; }
.uptime-legend .sw.internal { opacity: .45; background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(0,0,0,.28) 3px 5px); }
.uptime-legend .lg-text { flex-basis: 100%; }
td .est { color: var(--dim); font-size: 11px; white-space: nowrap; }
.people-notes { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.people-notes h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.people-notes ul.notes { list-style: none; margin: 0 0 10px; padding: 0; font-size: 12.5px; color: var(--muted); }
.people-notes ul.notes li { margin: 4px 0; }
.people-notes ul.notes b { color: var(--text); font-weight: 600; }
.mtag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); }
.mtag.measured { border-color: rgba(53, 208, 127, .5); }
.mtag.logged { border-color: rgba(98, 121, 205, .6); }
.mtag.estimated { border-color: rgba(255, 176, 32, .6); color: var(--warn); }

/* Library totals under the hero */
.library { margin: 14px 0 18px; }
.library .lib-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  margin: 0 0 8px 2px; }
.library .lib-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.library .lib-tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.library .lib-tile b { font-size: 26px; font-variant-numeric: tabular-nums; color: var(--gold); }
.library .lib-tile span { font-size: 13px; color: var(--muted); }
@media (max-width: 620px) {
  .library .lib-tiles { gap: 8px; }
  .library .lib-tile { padding: 10px 12px; }
  .library .lib-tile b { font-size: 20px; }
}
.library .lib-tiles + .lib-title { margin-top: 16px; }
.library .lib-owner { margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10px;
  background: rgba(var(--accent-rgb), 0.18); color: var(--accent); letter-spacing: 0.04em; }
.library .lib-tiles.music .lib-tile b { color: var(--accent); }
