/* The top bar. One file, both pages, one set of measurements.
 *
 * It was two bars before, written separately and adjusted by eye, and measuring
 * them side by side showed exactly how far apart they had drifted: 54px tall
 * against 72px, a panel gradient against a flat fill, Segoe UI against
 * system-ui, a 12px gap against 16px, and one of them not fixed in place at
 * all. None of that is visible while reading the CSS; all of it is obvious the
 * moment the two are put next to each other.
 *
 * Each page supplies the --bar-* tokens from its own palette, so the bar wears
 * the room's colours while keeping one shape.
 */

/* ------------------------------------------------------------------------
 * The bar's colours, defined ONCE for both pages.
 * They used to be written twice - hub.html mapped them onto its panel
 * gradient, theme.css onto Kino's flat card - so the two bars measurably
 * disagreed on background, shadow and corners even though the shape matched.
 * Values are literal on purpose: the two pages have different palette
 * variables, so pointing at var(--panel) / var(--card) is what split them.
 * ---------------------------------------------------------------------- */
:root {
  --bar-inset: clamp(12px, 2vw, 26px);   /* side margin - one value, both pages */
  --tag-radius: 7px;
  --bar-radius: 14px;
  --bar-bg: linear-gradient(to bottom, rgba(255,255,255,.96), rgba(243,249,254,.93));
  --bar-line: rgba(23,72,116,.16);
  --bar-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(4,30,58,.16), 0 10px 26px rgba(4,30,58,.28);
  --bar-font: "Segoe UI", Tahoma, sans-serif;
  --bar-ink: #0f2437; --bar-muted: #35516b; --bar-accent: #0a4a80;
  --bar-input: #ffffff;
  --bar-chip: linear-gradient(to bottom, #eaf4fd, #c9e0f5);
}
:root[data-theme="dark"] {
  --tag-radius: 7px;
  --bar-radius: 14px;
  --bar-bg: linear-gradient(180deg, #161c25, #111621);
  --bar-line: rgba(255,255,255,.1);
  --bar-shadow: 0 16px 34px rgba(0,0,0,.5);
  --bar-font: "Segoe UI", Tahoma, sans-serif;
  --bar-ink: #eef3f9; --bar-muted: #a8b5c6; --bar-accent: #71bcff;
  --bar-input: #1c2431;
  --bar-chip: rgba(113,188,255,.16);
}
:root[data-theme="min"] {
  --tag-radius: 8px;
  --bar-radius: 16px;
  --bar-bg: #ffffff;
  --bar-line: #e3e8ee;
  --bar-shadow: 0 1px 2px rgba(20,30,50,.05), 0 8px 24px rgba(20,30,50,.07);
  --bar-font: "Segoe UI", Tahoma, sans-serif;
  --bar-ink: #12161c; --bar-muted: #4d5866; --bar-accent: #12161c;
  --bar-input: #ffffff;
  --bar-chip: #f2f5f8;
}
:root[data-theme="term"] {
  --tag-radius: 3px;
  --bar-radius: 5px;
  --bar-bg: #04140a;
  --bar-line: rgba(40,255,120,.26);
  --bar-shadow: 0 0 20px rgba(40,255,120,.08);
  --bar-font: "Consolas", "Lucida Console", monospace;
  --bar-ink: #8dffb5; --bar-muted: #4de08a; --bar-accent: #b6ffd2;
  --bar-input: #04140a;
  --bar-chip: rgba(40,255,120,.10);
}
:root[data-theme="ps2"] {
  --tag-radius: 3px;
  --bar-radius: 4px;
  --bar-bg: rgba(10,22,48,.82);
  --bar-line: rgba(130,180,255,.16);
  --bar-shadow: 0 2px 26px rgba(0,10,40,.6), inset 0 1px 0 rgba(150,200,255,.07);
  --bar-font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --bar-ink: #e6efff; --bar-muted: #a9c2e8; --bar-accent: #cfe2ff;
  --bar-input: #0b1830;
  --bar-chip: rgba(90,150,240,.16);
}

.appbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 54px;
  box-sizing: border-box;
  padding: 9px 16px;
  border-radius: var(--bar-radius, 14px);
  background: var(--bar-bg);
  border: 1px solid var(--bar-line);
  box-shadow: var(--bar-shadow, 0 6px 20px rgba(0, 0, 0, .28));
  font-family: var(--bar-font);
  color: var(--bar-ink);
  /* Stays put in both. Кино's page never scrolls, so this changes nothing
     there; the Hub's did, and its bar used to slide away. */
  position: sticky;
  top: 0;
  z-index: 40;   /* under the player (50) and the dialogs (60): the bar used to
                    sit on top of a playing film */
}

/* Whatever each page calls its flexible gap. */
.appbar .sp,
.appbar .spacer { flex: 1; min-width: 0; }

.appbar .barbrand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 16.5px; color: var(--bar-accent);
  white-space: nowrap;
}
.appbar .barbrand .ic-slot {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--bar-chip); flex: none;
}
.appbar .barbrand .ic { width: 16px; height: 16px; color: var(--bar-accent); }

.appbar .barclock {
  font-family: "Consolas", "Lucida Console", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 14.5px; font-weight: 600; color: var(--bar-muted);
  white-space: nowrap;
}

/* The picker, drawn by us rather than by the operating system - a native
   <select> looks different on every machine, which is half of why the two bars
   never matched. */
.appbar select.barsel {
  appearance: none; -webkit-appearance: none;
  font-family: inherit; font-size: 14px; font-weight: 700;
  color: var(--bar-accent); cursor: pointer;
  height: 30px; padding: 0 26px 0 11px;
  border-radius: 8px; border: 1px solid var(--bar-line);
  background-color: var(--bar-input);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.appbar select.barsel option { background-color: var(--bar-input); color: var(--bar-ink); }
.appbar select.barsel:focus-visible { outline: 2px solid var(--bar-accent); outline-offset: 1px; }

.appbar .barbtn {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0; flex: none;
  cursor: pointer;
  border-radius: 10px; border: 1px solid var(--bar-line);
  background: var(--bar-input);
  color: var(--bar-muted);
}
.appbar .barbtn:hover { color: var(--bar-ink); border-color: var(--bar-accent); }
.appbar .barbtn:focus-visible { outline: 2px solid var(--bar-accent); outline-offset: 1px; }
.appbar .barbtn .ic,
.appbar .barbtn svg { width: 18px; height: 18px; }

/* The avatar. Twice reported as looking broken, and the border was most of the
   reason: a small bordered box with a picture inside it reads as a failed
   image. No border, a touch larger, and the glyph centred by the grid rather
   than left on a text baseline it does not share. */
.appbar .baravatar {
  width: 28px; height: 28px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 16px; line-height: 1;
  background: var(--bar-chip);
  overflow: hidden;
}
/* The empty state: a neutral outline, sized like the emoji it replaces. */
.appbar .baravatar.noav { color: var(--bar-accent); }
.appbar .baravatar.noav .ic { width: 17px; height: 17px; }
.appbar .barname {
  font-size: 14px; font-weight: 600; color: var(--bar-ink);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 680px) { .appbar .barname { display: none; } }

/* ---------------- phones ----------------
 *
 * Every child of the bar is `white-space: nowrap` and most are `flex: none`, so
 * when the row stops fitting it does not wrap or shrink - it overflows, and the
 * controls on the right walk off the screen. Measured on a 430px viewport: the
 * bar wanted 518px in the Hub and 440px in Кино.
 *
 * What goes first is what the phone already shows elsewhere. The clock is two
 * centimetres below the status bar's own clock; on a TV, where there is no
 * other clock, this rule never applies. Then the gaps and the padding tighten,
 * and the brand is finally allowed to shrink - it was the one wide, unshrinkable
 * item ("Yankov Family Hub" alone is 185px). */
@media (max-width: 560px) {
  .appbar { gap: 8px; padding: 8px 10px; }
  .appbar .barclock { display: none; }
  .appbar .barbrand { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .appbar .barbrand .ic-slot { width: 24px; height: 24px; }
  .appbar select.barsel { font-size: 13px; height: 28px; padding: 0 22px 0 8px;
                          background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px; }
  .appbar .barbtn { width: 30px; height: 30px; }
  .appbar .barbtn .ic, .appbar .barbtn svg { width: 17px; height: 17px; }
}
