/* X01002 desktop shell: everything is scoped to html.desk, so a normal browser is untouched.
   Pairs with desktop.js. html.mini = the compact widget (same page, same <audio>). */

/* ---- full window --------------------------------------------------------- */
/* One solid 40px title strip across the top. The shell draws the native min/max/close buttons
   over its right end (titleBarOverlay); our logo + buttons sit in it, and EVERY full-screen layer
   (stories, player, menus) starts below it, so nothing is ever hidden under the native buttons. */
html.desk:not(.mini) { --tb: max(env(titlebar-area-height, 0px), 40px); }
html.desk:not(.mini)::before {
  content: ""; position: fixed; left: 0; right: 0; top: 0; height: var(--tb); z-index: 399;
  background: #09090d; box-shadow: 0 1px 0 rgba(255,255,255,.05); -webkit-app-region: drag;
}
html.desk:not(.mini) body { padding-top: calc(var(--tb) + 6px); }
html.desk:not(.mini) .topbar {
  position: fixed; left: 0; right: 0; top: 0; height: var(--tb); z-index: 400; margin: 0;
  padding: 0 calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 8px) 0 max(14px, calc(50vw - 356px));
  -webkit-app-region: drag; pointer-events: none;      /* the strip underneath is the drag handle */
}
html.desk:not(.mini) .topbar > * { pointer-events: auto; }
html.desk:not(.mini) body[data-view="profile"] .topbar { display: flex; }   /* keep the strip's logo + buttons on every tab */
html.desk .topbar button, html.desk .topbar .out-toggle, html.desk .topbar a { -webkit-app-region: no-drag; }
/* full-screen layers begin under the strip */
html.desk:not(.mini) #story { top: calc(var(--tb) + 6px); border-radius: 14px 14px 0 0; overflow: hidden; }
html.desk:not(.mini) .wave-banner { top: calc(var(--tb) + 8px); }
@media (max-width: 500px) { html.desk:not(.mini) .soc-sheet.pl-sheet { top: calc(var(--tb) + 6px); max-height: none; border-radius: 14px 14px 0 0; } }
html.desk body { overscroll-behavior: none; }
html.desk ::-webkit-scrollbar { width: 10px; height: 10px; }
html.desk ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
html.desk ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); background-clip: content-box; border: 2px solid transparent; }
html.desk ::-webkit-scrollbar-track { background: transparent; }

/* footer links to the installers (Windows + Android, one row): shown in ordinary browsers, never inside the apps or on iPhone/iPad */
.dl-row { display: none; justify-content: center; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
html.can-apps .dl-row { display: flex; }
.dl-link { display: flex; align-items: center; justify-content: center; gap: 7px; font: 600 11px var(--sans); letter-spacing: .04em;
  color: var(--muted); text-decoration: none; }
.dl-link:hover { color: var(--text); }
.dl-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Settings card */
.dk-card .dk-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid var(--border); cursor: pointer; }
.dk-card .card-head + .dk-row { border-top: 0; }
.dk-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dk-t b { font-size: 14px; font-weight: 700; }
.dk-t i { font-style: normal; font-size: 12px; color: var(--muted); }
.dk-sw { appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 40px; height: 24px; border-radius: 99px; background: var(--raise);
  border: 1px solid var(--border-2); position: relative; cursor: pointer; transition: background .2s; }
.dk-sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #cfcfda; transition: transform .2s, background .2s; }
.dk-sw:checked { background: var(--accent); border-color: transparent; }
.dk-sw:checked::after { transform: translateX(16px); background: #fff; }
.dk-go { margin-top: 12px; width: 100%; }

/* ---- mini widget --------------------------------------------------------- */
.mw { display: none; }
html.mini, html.mini body { margin: 0; height: 100%; overflow: hidden; background: #0a0a0f; }
html.mini.mini-round, html.mini.mini-round body { background: transparent; }
html.mini #app, html.mini #login { display: none !important; }
/* belt and braces: nothing from the full UI may ever draw over the widget */
html.mini .soc-sheet, html.mini .soc-dim, html.mini #story, html.mini .ach-overlay, html.mini .soc-menu, html.mini .soc-dialog,
html.mini .wave-banner, html.mini .soc-undo, html.mini .toast, html.mini .badge-toast { display: none !important; }
html.mini .mw {
  position: fixed; inset: 0; display: grid; overflow: hidden; user-select: none; -webkit-user-select: none;
  grid-template-columns: 84px minmax(0, 1fr) auto; grid-template-rows: 1fr auto; gap: 8px 12px; padding: 12px 12px 10px;
  -webkit-app-region: drag; color: var(--text); font-family: var(--sans);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--mw-c1, #231c4a) 0%, transparent 62%),
    linear-gradient(160deg, var(--mw-c2, #14121f), #0a0a0f);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
  transition: background .6s;
}
html.mini.mini-round .mw { border-radius: 14px; }
html.mini .mw button, html.mini .mw input { -webkit-app-region: no-drag; }

.mw-cover { grid-row: 1; width: 84px; height: 84px; align-self: center; border-radius: 10px; overflow: hidden; position: relative;
  background: rgba(255,255,255,.05); box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.08); }
.mw-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mw-glyph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; color: var(--faint); }
.mw.playing .mw-glyph { color: var(--accent); }

.mw-main { grid-row: 1; min-width: 0; align-self: center; display: flex; flex-direction: column; gap: 3px; }
.mw-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mw-live { flex: 0 0 auto; font-size: 9px; font-weight: 800; letter-spacing: .12em; padding: 2px 6px; border-radius: 99px;
  background: rgba(255,255,255,.08); color: var(--muted); }
.mw-live[data-m="live"] { background: rgba(56,211,155,.16); color: var(--ok); }
.mw-live[data-m="paused"] { background: rgba(229,184,0,.14); color: var(--warn); }
.mw-st { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mw-title { font-family: var(--disp); font-weight: 800; font-size: 16px; line-height: 1.2; letter-spacing: -.01em; color: #fff; }
.mw-artist { font-size: 12.5px; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.2em; }

/* The shell's (invisible) window-controls overlay still swallows clicks in the top-right corner of the
   widget, so keep our buttons clear of it: the gap is whatever env() says the overlay occupies. */
.mw-win { grid-column: 3; grid-row: 1; align-self: start; display: flex; gap: 2px;
  margin: -4px calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw)) 0 0; }
.mw-win button, .mw-bar button { all: unset; box-sizing: border-box; display: grid; place-items: center; cursor: pointer; color: rgba(255,255,255,.62);
  border-radius: 8px; transition: color .15s, background .15s; -webkit-app-region: no-drag; }
.mw-win button { width: 26px; height: 26px; }
.mw-win button:hover, .mw-bar button:hover { color: #fff; background: rgba(255,255,255,.1); }
.mw-win button.on { color: var(--accent); }
.mw-win button:focus-visible, .mw-bar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.mw-bar { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; gap: 6px; }
.mw-bar button { width: 32px; height: 32px; }
.mw-bar .mw-play { width: 40px; height: 40px; border-radius: 50%; background: #fff; color: #0a0a0f; }
.mw-bar .mw-play:hover { background: #fff; color: #0a0a0f; filter: brightness(.92); }
.mw-bar input[type="range"] { flex: 1 1 auto; min-width: 60px; max-width: 150px; margin-left: auto; height: 4px; accent-color: var(--accent); cursor: pointer; }

.mw-eq { display: flex; align-items: flex-end; gap: 2px; height: 22px; width: 36px; margin-right: 6px; }
.mw-eq i { flex: 1; height: 18%; border-radius: 1px; background: var(--faint); transform-origin: bottom; }
.mw.playing .mw-eq i { background: var(--accent); animation: mw-eq 1s ease-in-out infinite; }
.mw.playing .mw-eq i:nth-child(2) { animation-delay: -.25s; animation-duration: .8s; }
.mw.playing .mw-eq i:nth-child(3) { animation-delay: -.5s;  animation-duration: 1.1s; }
.mw.playing .mw-eq i:nth-child(4) { animation-delay: -.1s;  animation-duration: .7s; }
.mw.playing .mw-eq i:nth-child(5) { animation-delay: -.7s;  animation-duration: 1.2s; }
.mw.playing .mw-eq i:nth-child(6) { animation-delay: -.35s; animation-duration: .9s; }
.mw.playing .mw-eq i:nth-child(7) { animation-delay: -.6s;  animation-duration: 1.05s; }
@keyframes mw-eq { 0%, 100% { height: 22%; } 50% { height: 100%; } }
@media (prefers-reduced-motion: reduce) { .mw.playing .mw-eq i { animation: none; height: 60%; } }

.mw-msg { position: absolute; left: 12px; right: 12px; bottom: 54px; padding: 6px 10px; border-radius: 8px; font-size: 12px; text-align: center;
  background: rgba(10,10,15,.92); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); opacity: 0; transform: translateY(4px);
  transition: opacity .2s, transform .2s; pointer-events: none; }
.mw-msg.show { opacity: 1; transform: none; }

/* ---- wide window: sidebar + two columns ------------------------------------ */
/* Below 900px the phone column is kept as is. From 900px up the bottom tab bar becomes a left
   sidebar, the now-playing bar floats at the bottom centre of the content area, and the big views
   use the width: Radio is hero | favorites + tuner, Settings is a two-column masonry. */
@media (min-width: 900px) {
  html.desk:not(.mini) { --side: 88px; }
  html.desk:not(.mini) .app { max-width: none; margin: 0 0 0 var(--side); padding: 0 36px 130px; }
  html.desk:not(.mini) .content { max-width: 1120px; margin: 0 auto; }
  html.desk:not(.mini) .topbar { padding-left: 20px; }

  html.desk:not(.mini) .dock { left: 0; right: 0; max-width: none; margin: 0; pointer-events: none; }
  html.desk:not(.mini) .dock .nowbar {
    pointer-events: auto; margin: 0 0 16px calc(var(--side) + (100vw - var(--side) - min(780px, 100vw - var(--side) - 40px)) / 2);
    width: min(780px, calc(100vw - var(--side) - 40px));
  }
  html.desk:not(.mini) .bottomnav {
    position: fixed; left: 0; top: var(--tb); bottom: 0; width: var(--side); flex-direction: column; justify-content: flex-start;
    gap: 4px; padding: 14px 8px; overflow: visible; border-top: 0; border-right: 1px solid var(--border); background: #0b0b10;
    backdrop-filter: none; pointer-events: auto;
  }
  html.desk:not(.mini) .tab { flex: 0 0 auto; min-width: 0; padding: 11px 4px; border-radius: 12px; }
  html.desk:not(.mini) .tab.active { background: rgba(124,92,255,.12); }

  /* SETTINGS: masonry, no card is split across columns */
  html.desk:not(.mini) #view-settings:not(.hidden) { column-count: 2; column-gap: 20px; }
  html.desk:not(.mini) #view-settings > .card { break-inside: avoid; margin-bottom: 16px; }
  /* a plain listener has just a couple of cards: one comfortable column instead */
  html.desk:not(.mini) body:not([data-role="admin"]) #view-settings:not(.hidden) { column-count: 1; max-width: 560px; margin: 0 auto; }

  /* RADIO stays a single column (like the player), just centred */
  html.desk:not(.mini) #view-radio { max-width: 720px; margin-left: auto; margin-right: auto; }

  /* single-column views get a readable width instead of stretching */
  html.desk:not(.mini) #view-people, html.desk:not(.mini) #view-profile,
  html.desk:not(.mini) #view-gallery, html.desk:not(.mini) #view-dashboard { max-width: 860px; margin-left: auto; margin-right: auto; }
}

/* version line in the footer (inside the app) */
.dk-ver { margin-top: 10px; font: 600 11px var(--sans); letter-spacing: .04em; color: var(--faint); display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.dk-ver button { all: unset; cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.dk-ver button:hover { color: var(--text); }
.dk-ver button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.dk-ver .ok { color: var(--ok); }
.dk-ver .go { color: #fff; text-decoration: none; background: var(--accent); padding: 2px 9px; border-radius: 99px; }
