:root {
  --bg: #01123a;            /* Union Jack navy, deepened */
  --blue: #012169;          /* Pantone 280 C — Union Jack blue */
  --red: #c8102e;           /* Pantone 186 C — Union Jack red */
  --white: #ffffff;
  --card: #0a1f52cc;
  --card-2: #12297095;
  --text: #f4f6ff;
  --muted: #aab4d4;
  --green: #1db954;
  --amber: #ffcc44;
  --bad: #ff6b61;
  --radius: 16px;
  --stripes: repeating-linear-gradient(
    135deg,
    var(--red) 0 14px,
    var(--white) 14px 22px,
    var(--blue) 22px 36px,
    var(--white) 36px 44px
  );
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
/* The flag itself, flying behind everything. --page-bg (set from JS) swaps in
   a member's custom station background. */
body::before {
  content: "";
  position: fixed; inset: -20px; z-index: -2;
  background: var(--page-bg, url("/queenofengland.jpg")) center / cover no-repeat;
  filter: blur(2px) saturate(1.15) brightness(.9);
}
/* Navy wash so text stays readable over the flag */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, #01123ad9 0%, #01123ae8 40%, #010c2bf2 100%);
}

#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--blue) 68%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 3px solid transparent;
  border-image: var(--stripes) 1;
}
#brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 17px; }
#me-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
#me-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
#me-chip button { background: none; border: 1px solid #ffffff2a; color: var(--muted); border-radius: 99px; padding: 4px 10px; font-size: 12px; }
#me-chip a.chip-btn { border: 1px solid #ffffff2a; color: var(--muted); border-radius: 99px; padding: 4px 10px; font-size: 12px; text-decoration: none; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
@media (min-width: 700px) { main { max-width: 720px; } }

h1 { font-size: 22px; margin: 8px 0 16px; }
h1::after { content: " 🇬🇧"; }
.sub { color: var(--muted); font-size: 14px; margin: -10px 0 18px; line-height: 1.5; }

.station-list { display: flex; flex-direction: column; gap: 10px; }
.station {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: var(--radius); padding: 12px;
  color: var(--text); text-decoration: none;
  border: 1px solid #ffffff22;
  border-left: 5px solid var(--red);
  transition: transform .06s ease;
}
.station:nth-child(even) { border-left-color: var(--white); }
.station:active { transform: scale(.985); }
.station img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--card-2); }
.station .info { flex: 1; min-width: 0; }
.station .name { font-weight: 650; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.station .track { color: var(--muted); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station.quiet .track { font-style: italic; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.badge { font-size: 11px; color: var(--muted); background: var(--card-2); border-radius: 99px; padding: 3px 8px; flex: none; }
.badge.tuned { color: var(--white); background: var(--red); font-weight: 700; }

.bg-preview { width: 100%; height: 110px; object-fit: cover; border-radius: 10px; margin: 6px 0 2px; border: 1px solid #ffffff22; }

.progress { height: 4px; background: #ffffff2c; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--red), var(--white), var(--blue)); border-radius: 4px; width: 0%; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; font-variant-numeric: tabular-nums; }

button.primary, a.primary {
  display: inline-block; background: var(--red); color: var(--white); border: none;
  font-size: 16px; font-weight: 700; padding: 14px 34px; border-radius: 99px; margin-top: 18px;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--blue);
}
button.primary:active { filter: brightness(.92); }
button.primary.leave { background: var(--card-2); color: var(--text); border: 1px solid #ffffff2a; box-shadow: none; }
button.ghost, a.ghost {
  background: none; border: 1px solid #ffffff3a; color: var(--text);
  padding: 10px 20px; border-radius: 99px; font-size: 14px; margin-top: 12px; text-decoration: none; cursor: pointer;
}

.spinner { width: 12px; height: 12px; border: 2px solid #ffffff33; border-top-color: var(--text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  border: 1px solid #ffffff22; margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--stripes);
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card p { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 8px 0; }
input, select, textarea {
  width: 100%; background: #081a45; color: var(--text); border: 1px solid #ffffff2f;
  border-radius: 10px; padding: 11px 12px; font-size: 15px; margin: 6px 0;
}
textarea { font-family: inherit; resize: vertical; }
label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { margin: 6px 0; }
button.small { background: var(--card-2); color: var(--text); border: 1px solid #ffffff2a; border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; flex: none; }
button.small.danger { color: var(--bad); border-color: #e5534b55; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px 6px 0; }
td { padding: 8px 8px 8px 0; border-top: 1px solid #ffffff1a; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--blue); color: var(--text); border: 2px solid var(--white);
  box-shadow: 0 0 0 3px var(--red);
  padding: 10px 18px; border-radius: 99px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.center { text-align: center; }
.big-emoji { font-size: 44px; margin: 30px 0 10px; text-align: center; }
.big-emoji::after { content: " 🇬🇧"; }

/* ---------- BYO join wizard (invite page) ---------- */
.wiz-step { display: flex; gap: 11px; margin: 16px 0; }
.wiz-num {
  flex: none; width: 22px; height: 22px; border-radius: 50%; margin-top: 1px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 800;
  display: grid; place-items: center;
}
.wiz-step > div { flex: 1; min-width: 0; }
.wiz-step .primary { display: inline-block; font-size: 15px; }
.wiz-step p { margin: 6px 0; }
.wiz-lead { margin-top: 0 !important; }
.wiz-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
button.chip {
  background: var(--card-2); color: var(--text); border: 1px solid #ffffff2a;
  border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
button.chip:active { filter: brightness(1.25); }
.wiz-help { margin-top: 14px; }
.wiz-help summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.wiz-help p { font-size: 12px; }

/* ---------- MySpace mode: station profile pages ----------
   body.retro = white page, no blur/navy wash; a member's background photo
   shows raw behind bordered white boxes, like a customized 2006 profile. */
body.retro { background: #fff; }
body.retro::before { background: var(--page-bg, #fff) center / cover no-repeat; filter: none; }
body.retro::after { display: none; }
body.retro main { max-width: 900px; }
body.retro .sub { color: #444; }

.ms, .ms-note { font-family: Verdana, Geneva, Tahoma, sans-serif; color: #000; }
.ms { display: flex; flex-direction: column; gap: 12px; font-size: 12px; line-height: 1.5; }
.ms .ms-col { display: contents; }
/* Mobile: one column, the useful boxes float up */
.ms-prof { order: 1; } .ms-player { order: 2; } .ms-banner { order: 3; } .ms-contact { order: 4; }
.ms-blurbs { order: 5; } .ms-friends { order: 6; } .ms-blog { order: 7; } .ms-details { order: 8; } .ms-url { order: 9; }
@media (min-width: 660px) {
  .ms { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 14px; align-items: start; }
  .ms .ms-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .ms .ms-col > * { order: 0; } /* desktop: classic MySpace order (DOM order) */
}

.ms-box { background: #fff; border: 1px solid #6699cc; }
.ms-box .ms-h { background: #6699cc; color: #fff; font-weight: bold; font-size: 12px; padding: 3px 8px; }
.ms-box .ms-b { padding: 8px 9px; }
.ms-box.org { border-color: #ff9933; }
.ms-box.org .ms-h { background: #ffcc99; color: #b34700; }

.ms a { color: #0033cc; font-weight: bold; text-decoration: none; cursor: pointer; }
.ms a:hover { text-decoration: underline; }

.ms-banner {
  background: #fff; border: 2px solid #000; padding: 22px 10px; text-align: center;
  font-family: Arial, Helvetica, sans-serif; font-size: 15px;
}

.ms-id { display: flex; gap: 10px; }
.ms-ava { width: 110px; height: 110px; object-fit: cover; border: 1px solid #888; background: #eee; flex: none; }
.ms-ava.ph, .ms-fpic.ph { display: grid; place-items: center; font-size: 42px; }
.ms-idinfo { font-size: 11px; line-height: 1.55; }
.ms-online { color: #090; font-weight: bold; }
.ms-viewmy { margin-top: 8px; font-size: 11px; }

.ms-contact .ms-b { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 8px; }
.ms-c { font-size: 11px; }

.ms-t { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 11px; }
.ms-t td { padding: 4px 6px; background: #d5e8fb; color: #333; border-top: 0; }
.ms-t td.k { background: #b1d0f0; color: #336699; font-weight: bold; width: 42%; }
.ms-url .ms-b { font-size: 11px; word-break: break-all; }

.ms-play { display: flex; gap: 10px; }
.ms-art { width: 96px; height: 96px; object-fit: cover; border: 1px solid #888; background: #eee; flex: none; }
.ms-playinfo { flex: 1; min-width: 0; }
.ms-track { font-weight: bold; font-size: 13px; }
.ms-artist { font-size: 11px; color: #444; margin: 1px 0 8px; }
.ms .progress { height: 12px; background: #fff; border: 1px solid #7f9db9; border-radius: 0; }
.ms .progress > div { background: repeating-linear-gradient(90deg, #316ac5 0 8px, #7ba7e0 8px 10px); border-radius: 0; }
.ms .times { color: #555; font-size: 10px; margin-top: 3px; }
.ms-pausedtag { font-size: 10px; font-weight: bold; color: #777; margin-top: 4px; }
.ms-quiet { font-size: 12px; }
.ms-status { margin-top: 8px; font-size: 11px; font-weight: bold; display: flex; align-items: center; gap: 6px; }
.ms-status.good { color: #080; } .ms-status.warn { color: #b60; } .ms-status.bad { color: #c00; }
.ms .spinner { border-color: #bbb; border-top-color: #333; flex: none; }
.ms-hint { font-size: 11px; color: #555; margin: 0 0 8px; }

.ms-btn {
  display: inline-block; margin: 8px 6px 0 0; padding: 5px 14px; cursor: pointer;
  background: #d4d0c8; color: #000; border: 2px outset #efedea; border-radius: 0;
  font: bold 12px Verdana, sans-serif; text-decoration: none;
}
.ms-btn:active { border-style: inset; }
.ms-btn.danger { color: #a00; }
.ms a.ms-btn { color: #000; }
.ms a.ms-btn:hover { text-decoration: none; }

.ms-blog .ms-b { font-size: 11px; }
.ms-blurbs h4 { color: #e56717; font-size: 12px; margin: 6px 0 2px; }
.ms-blurbs p { margin: 0 0 6px; }

.ms-fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 10px 8px; margin-top: 10px; }
.ms-friend { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; text-align: center; min-width: 0; }
.ms-friend .ms-fname { color: #b00; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-fpic { width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid #888; background: #eee; }
.ms-fpic.ph { font-size: 26px; }
.ms-count { color: #b00; }
.ms-viewall { text-align: center; margin-top: 10px; font-size: 11px; }

.ms-note {
  background: #ffffcc; border: 1px solid #cccc88; color: #665500;
  font-size: 11px; font-weight: bold; padding: 6px 9px; margin-bottom: 12px;
}
.ms.ms-edit { display: flex; flex-direction: column; margin-top: 14px; }
.ms textarea {
  width: 100%; background: #fff; color: #000; border: 1px solid #7f9db9; border-radius: 0;
  font: 12px Verdana, sans-serif; padding: 7px; margin: 0 0 4px;
}
.ms .bg-preview { border-radius: 0; border: 1px solid #888; margin: 0 0 4px; height: 120px; }
.ms-genders { display: flex; gap: 14px; margin: 0 0 8px; font-size: 12px; color: #000; }
.ms-genders label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ---------- MySpace mode: landing page (the radio's own Friend Space) ----------
   Single column even on desktop: undo the profile grid, its align-items: start
   (would shrink flex children to content width) and its mobile box ordering. */
.ms.ms-home { display: flex; flex-direction: column; align-items: stretch; }
.ms.ms-home > * { order: 0; }
.ms-banner .ms-status { justify-content: center; }
.ms-banner .ms-btn { margin: 10px 0 0; }
.ms-dirgrid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 10px; }
.ms-tile .ms-fname { font-size: 11px; }
.ms-tile .ms-fpic { font-size: 40px; } /* the 📻 placeholder scales with the bigger tile */
.ms-cap { font-size: 10px; color: #333; max-width: 100%; }
.ms-cap2 { color: #777; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-you { color: #777; font-weight: normal; }
