/* ShallowSID: small overrides on top of Ionic. Always dark; colors are tokens on :root. */

/* Keep dialog contents hidden until Ionic takes over their visibility. */
ion-modal:not(.hydrated) {
  display: none;
}

:root,
/* Ionic's dark palette also sets its tokens on `.ios body` / `.md body` */
.ios body,
.md body {
  /* Default accent RGB; Appearance overrides it. Shade and tint follow it. */
  --ion-color-primary-rgb: 169, 156, 255;
  --ion-color-primary: rgb(var(--ion-color-primary-rgb));
  --ion-color-primary-contrast: #16131f;   /* = --app-bg; Ionic needs it literal, with its rgb */
  --ion-color-primary-contrast-rgb: 22, 19, 31;
  --ion-color-primary-shade: color-mix(in srgb, var(--ion-color-primary) 88%, black);
  --ion-color-primary-tint: color-mix(in srgb, var(--ion-color-primary) 90%, white);

  /* The grays: every one in the app comes from these. */
  --app-bg: #16131f;                     /* page, bars, rows; dark text on accents */
  --app-surface: #221d31;                /* tiles, covers, the tab bar, tag capsules */
  --app-text: #ffffff;
  --app-muted: var(--ion-color-medium);  /* secondary text */
  --app-border: rgba(255, 255, 255, 0.1);
  --app-outline: rgba(255, 255, 255, 0.25);
  --app-shadow: rgba(0, 0, 0, 0.35);

  --ion-background-color: var(--app-bg);
  --ion-background-color-rgb: 22, 19, 31;
  --ion-toolbar-background: var(--app-bg);
  --ion-tab-bar-background: var(--app-surface);
  --ion-tab-bar-background-focused: var(--app-surface);
  --ion-item-background: var(--app-bg);
  --ion-card-background: var(--app-surface);
  --ion-text-color: var(--app-text);
  /* Ionic's gray ramps, mixed from the app's background and text rather than
     the dark palette's black and white, so its components share the tint. */
  --ion-background-color-step-50: color-mix(in srgb, var(--app-text) 5%, var(--app-bg));
  --ion-background-color-step-100: color-mix(in srgb, var(--app-text) 10%, var(--app-bg));
  --ion-background-color-step-150: color-mix(in srgb, var(--app-text) 15%, var(--app-bg));
  --ion-background-color-step-200: color-mix(in srgb, var(--app-text) 20%, var(--app-bg));
  --ion-background-color-step-250: color-mix(in srgb, var(--app-text) 25%, var(--app-bg));
  --ion-background-color-step-300: color-mix(in srgb, var(--app-text) 30%, var(--app-bg));
  --ion-background-color-step-350: color-mix(in srgb, var(--app-text) 35%, var(--app-bg));
  --ion-background-color-step-400: color-mix(in srgb, var(--app-text) 40%, var(--app-bg));
  --ion-background-color-step-450: color-mix(in srgb, var(--app-text) 45%, var(--app-bg));
  --ion-background-color-step-500: color-mix(in srgb, var(--app-text) 50%, var(--app-bg));
  --ion-background-color-step-550: color-mix(in srgb, var(--app-text) 55%, var(--app-bg));
  --ion-background-color-step-600: color-mix(in srgb, var(--app-text) 60%, var(--app-bg));
  --ion-background-color-step-650: color-mix(in srgb, var(--app-text) 65%, var(--app-bg));
  --ion-background-color-step-700: color-mix(in srgb, var(--app-text) 70%, var(--app-bg));
  --ion-background-color-step-750: color-mix(in srgb, var(--app-text) 75%, var(--app-bg));
  --ion-background-color-step-800: color-mix(in srgb, var(--app-text) 80%, var(--app-bg));
  --ion-background-color-step-850: color-mix(in srgb, var(--app-text) 85%, var(--app-bg));
  --ion-background-color-step-900: color-mix(in srgb, var(--app-text) 90%, var(--app-bg));
  --ion-background-color-step-950: color-mix(in srgb, var(--app-text) 95%, var(--app-bg));
  --ion-text-color-step-50: color-mix(in srgb, var(--app-bg) 5%, var(--app-text));
  --ion-text-color-step-100: color-mix(in srgb, var(--app-bg) 10%, var(--app-text));
  --ion-text-color-step-150: color-mix(in srgb, var(--app-bg) 15%, var(--app-text));
  --ion-text-color-step-200: color-mix(in srgb, var(--app-bg) 20%, var(--app-text));
  --ion-text-color-step-250: color-mix(in srgb, var(--app-bg) 25%, var(--app-text));
  --ion-text-color-step-300: color-mix(in srgb, var(--app-bg) 30%, var(--app-text));
  --ion-text-color-step-350: color-mix(in srgb, var(--app-bg) 35%, var(--app-text));
  --ion-text-color-step-400: color-mix(in srgb, var(--app-bg) 40%, var(--app-text));
  --ion-text-color-step-450: color-mix(in srgb, var(--app-bg) 45%, var(--app-text));
  --ion-text-color-step-500: color-mix(in srgb, var(--app-bg) 50%, var(--app-text));
  --ion-text-color-step-550: color-mix(in srgb, var(--app-bg) 55%, var(--app-text));
  --ion-text-color-step-600: color-mix(in srgb, var(--app-bg) 60%, var(--app-text));
  --ion-text-color-step-650: color-mix(in srgb, var(--app-bg) 65%, var(--app-text));
  --ion-text-color-step-700: color-mix(in srgb, var(--app-bg) 70%, var(--app-text));
  --ion-text-color-step-750: color-mix(in srgb, var(--app-bg) 75%, var(--app-text));
  --ion-text-color-step-800: color-mix(in srgb, var(--app-bg) 80%, var(--app-text));
  --ion-text-color-step-850: color-mix(in srgb, var(--app-bg) 85%, var(--app-text));
  --ion-text-color-step-900: color-mix(in srgb, var(--app-bg) 90%, var(--app-text));
  --ion-text-color-step-950: color-mix(in srgb, var(--app-bg) 95%, var(--app-text));

  --app-accent: var(--ion-color-primary);
  --app-accent-alt: #f2b872;             /* the row's tune, playing another subtune */
  --wave-played: var(--app-accent);
  --wave-rendered: var(--app-muted);
  --wave-pending: var(--app-border);
  --side-width: 400px;
}

body {
  background: var(--ion-background-color);
}

/* Disable double-tap zoom throughout the app while allowing pinch zoom. */
* {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

/* ---- layout: phone first, side panel from 992px ----------------------- */

.layout {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr;
  /* Pin the row to the viewport: otherwise a tall side panel grows the row and
     pushes the tab bar below the (clipped) bottom edge. */
  grid-template-rows: minmax(0, 1fr);
}

#main-page {
  position: relative;
}

.side-panel {
  display: none;
}

body.has-side-panel .layout {
  grid-template-columns: 1fr var(--side-width);
}

body.has-side-panel .side-panel {
  display: block;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--app-border);
  background: var(--app-surface);
  padding-top: env(safe-area-inset-top);
}

body.has-side-panel .mini {
  display: none;
}

.toolbar-actions {
  display: flex;
  align-items: center;
}

/* ---- lists -------------------------------------------------------------- */

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--app-surface) center / cover no-repeat;
  image-rendering: pixelated;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  user-select: none;
}

.thumb-sm {
  width: 36px;
  height: 36px;
}

.thumb-missing {
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 20px;
}

/* Cover mosaic (see playlistArtStyle), or a note icon while empty. */
.playlist-art {
  background: var(--app-surface) center / cover no-repeat;
  image-rendering: pixelated;
  color: var(--app-muted);
  font-size: 20px;
}

.tune-row ion-label h2 {
  font-weight: 600;
}

.tune-row.is-current ion-label h2 {
  color: var(--app-accent);
}

.tune-row.is-current.is-other-subtune ion-label h2,
.tune-row.is-current.is-other-subtune .song-chip {
  color: var(--app-accent-alt);
}

.tune-row.is-missing {
  opacity: 0.55;
}

.tune-row ion-note {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.tune-row [data-menu] {
  --padding-start: 6px;
  --padding-end: 6px;
  margin-inline-start: 0;
}

.tune-row .fav-mark {
  font-size: 14px;
  color: var(--app-accent);
  margin-inline-end: 4px;
}

.tune-row:not(.is-favorite) .fav-mark {
  display: none;
}

.np-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.np-title-row > div {
  flex: 1;
  min-width: 0;
}

.np-fav {
  --color: var(--app-accent);
  font-size: 20px;
  margin: -4px -8px 0 0;
}

.favorites-thumb {
  background: linear-gradient(135deg, #a99cff, #5b4aa3);
  color: var(--app-bg);
  font-size: 20px;
  --art-icon: #ffd166;
}

/* A row's second line: composer and year exactly as in a row without tags
   (wrapping when long), then its tags in the room left on that line. Tags that
   don't fit wrap onto a line of no height, which the clipping hides, so a row
   with tags is never taller or shorter than without. */
.tune-row .row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 6px;
  overflow: hidden;
}

.row-subtitle {
  flex: 0 1 auto;
  min-width: 0;
}

.row-tags {
  flex: 1 1 0;
  min-width: 32px;        /* less room than this: no tags */
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  height: 16px;
  margin-bottom: -16px;   /* takes no height, whichever line it lands on */
  overflow: hidden;
}

/* Quiet capsules: secondary text on the surface colour. */
.row-tag {
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  padding: 0 6px;
  border-radius: 8px;
  color: var(--app-muted);
  background: var(--app-surface);
  white-space: nowrap;
}

.song-chip {
  font-size: 11px;
  font-weight: 500;
  color: var(--app-muted);
  margin-inline-start: 4px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 20px 16px 8px;
}

/* "Jump back in": a sideways-scrolling row of large cards, labels below */
.shelf {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  padding: 0 16px 4px;
  scrollbar-width: none;
}

.shelf::-webkit-scrollbar {
  display: none;
}

.shelf-card {
  flex: 0 0 132px;
  scroll-snap-align: start;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.shelf-art {
  width: 132px;
  height: 132px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 64px;
  margin-bottom: 8px;
}

/* Mix covers: the mix's name in large type and a faint icon on a gradient */
.shelf-art.mix-art {
  position: relative;
  overflow: hidden;
  display: block;
  color: var(--app-bg);
}

.mix-art .art-label {
  position: absolute;
  inset: 12px 12px auto;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.mix-art ion-icon {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 40px;
}

/* Each cover's icon in a colour of its own that stands off the gradient
   (--art-icon, set with the gradients below), rather than a faint shade of it. */
.shelf-art > ion-icon,
.favorites-thumb > ion-icon {
  color: var(--art-icon, currentColor);
  opacity: 0.9;
}

.mix-art .art-avatar {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--app-surface);
  color: var(--app-muted);
  box-shadow: 0 2px 8px var(--app-shadow);
}

.mix-art .art-avatar ion-icon {
  position: static;
  font-size: 28px;
  opacity: 1;
}

.mix-art-0 { background: linear-gradient(135deg, #a99cff, #5b4aa3); --art-icon: #c4466f; }
.mix-art-1 { background: linear-gradient(135deg, #8cc2ec, #3d5c9c); --art-icon: #6cbf5a; }
.mix-art-2 { background: linear-gradient(135deg, #e6c070, #8c6332); --art-icon: #6cbf5a; }
.mix-art-3 { background: linear-gradient(135deg, #b9df85, #426e3e); --art-icon: #c4466f; }
.mix-art-4 { background: linear-gradient(135deg, #e88aaa, #8c3c66); --art-icon: #3d8bd0; }
.mix-art-5 { background: linear-gradient(135deg, #5ccfbf, #2f7d8c); --art-icon: #8f5a0a; }

.has-avatar {
  position: relative;
  overflow: hidden;
}

.has-avatar img {
  width: 100%;
  height: 100%;
}

.recent-art {
  background: linear-gradient(90deg, #e8887a, #c2507a);
  color: var(--app-bg);
  --art-icon: #4f74a8;
}

.most-played-art {
  background: linear-gradient(90deg, #5ccfbf, #3f8fa1);
  color: var(--app-bg);
  --art-icon: #8f5a0a;
}

.shelf-title,
.shelf-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-title {
  font-size: 14px;
  font-weight: 600;
}

.shelf-sub {
  font-size: 12px;
  color: var(--app-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  padding: 0 12px;
}

.result-count,
.breadcrumb {
  margin: 12px 16px 4px;
  color: var(--app-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--app-muted);
  max-width: 420px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 48px;
}

.playlist-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 12px 0;
}

/* ---- composer page (also the tune page a tune link opens) -------------- */

.composer-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 16px 4px;
}

.composer-avatar {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 64px;
}

.tune-cover {
  width: 168px;
  height: 168px;
  border-radius: 12px;
}

.composer-meta a {
  color: var(--app-accent);
  text-decoration: none;
}

.composer-name {
  margin: 16px 0 4px;
  font-size: 28px;
  font-weight: 700;
}

.composer-meta {
  margin: 0;
  color: var(--app-muted);
}

/* Outside a head, which has its own padding, keep the text off the edges. */
:not(.composer-head) > .composer-meta {
  margin: 8px 16px 0;
}

.composer-actions {
  justify-content: center;
}

.credits {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  font-size: 12px;
  color: var(--app-muted);
  text-align: center;
}

.credits:has(#hvsc-source[hidden]):has(#install-app-wrap[hidden]) {
  display: none;
}

.credits a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.credits a:hover,
.credits a:active {
  color: var(--app-accent);
}

.credits a:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

/* ---- mini-player ---------------------------------------------------------- */

.mini {
  background: var(--app-surface);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}

.mini-progress {
  height: 2px;
  background: var(--app-border);
}

#mini-bar {
  height: 100%;
  width: 0;
  background: var(--app-accent);
}

.mini-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 6px 12px;
}

.mini-text {
  flex: 1;
  min-width: 0;
}

.mini-title,
.mini-author {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-title {
  font-weight: 600;
  font-size: 15px;
}

.mini-author {
  font-size: 13px;
  color: var(--app-muted);
}

/* ---- Now Playing ----------------------------------------------------------- */

.np {
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
}

#np-host > .np,
.side-panel > .np {
  display: block;
}

/* Parked outside both hosts until placed */
ion-app > .np {
  display: none;
}

.np-art-wrap {
  display: flex;
  justify-content: center;
  padding: 8px 0 24px;
}

.np-art {
  width: min(78vw, 340px);
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6c5eb5, #2e2560) center / cover no-repeat;
  image-rendering: pixelated;
  color: var(--app-text);
  font-size: clamp(32px, 12vw, 64px);
  box-shadow: 0 16px 40px var(--app-shadow);
  touch-action: pan-y;
  user-select: none;
  cursor: pointer;
  transition: transform 200ms ease, opacity 200ms ease;
}

.side-panel .np-art {
  width: 100%;
  max-width: 320px;
}

.np.is-paused .np-art {
  transform: scale(0.94);
}

.np-meta h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.np-author {
  margin: 0;
  font-size: 16px;
  color: var(--app-accent);
}

.np-author.is-link {
  cursor: pointer;
}

.np-author.is-link:hover {
  text-decoration: underline;
}

.np-released {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--app-muted);
}

.np-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 20px;
}

.np-badges ion-badge {
  flex-shrink: 0;
}

.np-scrub {
  margin-top: 20px;
}

.np-wave {
  display: block;
  width: 100%;
  height: 56px;
  touch-action: none;
  cursor: pointer;
  border-radius: 4px;
}

.np-wave:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.np-times {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.np-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin: 12px 0;
}

.np-controls ion-button {
  --color: var(--ion-text-color);
  font-size: 22px;
}

/* Shuffle and repeat: dimmed when off, accent colour when on. */
.np-mode {
  position: relative;
  width: 44px;
  font-size: 18px !important;
}

.np-mode[aria-pressed="false"],
.np-repeat[data-mode="off"] {
  opacity: 0.5;
}

.np-mode[aria-pressed="true"],
.np-repeat:not([data-mode="off"]) {
  --color: var(--ion-color-primary) !important;
}

/* Ionicons has no repeat-one glyph: badge the icon with a 1. */
.np-repeat[data-mode="one"]::after {
  content: "1";
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--ion-color-primary);
  pointer-events: none;
}

/* Height follows width, so a narrow row shrinks the button but keeps it round. */
.np-play {
  width: 72px;
  min-width: 48px;
  min-height: 0;
  height: auto;
  aspect-ratio: 1;
  --border-radius: 50%;
  --padding-start: 0;
  --padding-end: 0;
  --color: var(--ion-color-primary-contrast) !important;
  font-size: 30px;
}

.np-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.np-extra ion-select {
  max-width: 200px;
}

.np-queue {
  margin-top: 8px;
  background: transparent;
}

.np-queue ion-item {
  --background: transparent;
}

.np-queue ion-list-header {
  font-size: 17px;
  padding-inline-start: 0;
}

.np-modal {
  --height: 100%;
  --background: var(--ion-background-color);
}

/* ---- Settings --------------------------------------------------------------- */

.settings-container {
  width: 100%;
  max-width: 640px;
  margin-inline: auto;
}

.help-content {
  margin: 0;
  padding: 32px 16px 64px;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.help-content h2 {
  margin: 28px 0 6px;
  font-size: 18px;
}

.help-content p, .help-content ul, .help-content ol {
  margin-block: 16px;
}

.help-content .muted {
  color: var(--app-muted);
}

.help-content a {
  color: var(--app-accent);
}

.help-content code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--app-text);
  background: color-mix(in srgb, var(--app-surface), var(--app-text) 8%);
  padding: 2px 5px;
  border-radius: 4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.help-content table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 16px;
}

.help-content th, .help-content td {
  padding: 8px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--app-border);
}

.help-content tbody th {
  white-space: nowrap;
  font-weight: inherit;
}

@media (min-width: 768px) {
  .sound-content ion-list.settings-menu[inset] ion-item {
    --min-height: 64px;
    --background: transparent;
  }
}

.sound-content {
  --background: var(--ion-background-color);
}

.sound-content ion-list[inset] ion-item {
  --background: var(--app-surface);
}

.sound-content ion-segment {
  width: auto;
  min-width: 190px;
  max-width: 240px;
}

.sound-content ion-segment[data-setting="engine"] {
  width: 100%;
  max-width: none;
}

.sound-content ion-range {
  --bar-background-active: var(--app-accent);
  --knob-background: var(--app-text);
}

.sound-content ion-range.appearance-hue {
  --bar-background: linear-gradient(to right, #ff9c9c, #ffff9c, #9cff9c, #9cffff, #9c9cff, #ff9cff, #ff9c9c);
  --bar-background-active: transparent;
  --knob-background: var(--app-accent);
}

.range-value {
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
  margin-inline-start: 6px;
}

.edited-mark {
  font-size: 11px;
  font-weight: 600;
  color: var(--app-accent);
  margin-inline-start: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sound-note {
  margin: 0 20px 8px;
  font-size: 12px;
  color: var(--app-muted);
}

/* iOS Settings-style section labels, above each card */
.sound-section {
  margin: 20px 20px -8px;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--app-muted);
}

.sync-key {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 17px;
  letter-spacing: 0.04em;
  user-select: all;
}

/* Keeps its width while paused so the row doesn't reflow */
.sync-status .is-hidden {
  visibility: hidden;
}

.sync-status ion-button ion-spinner {
  width: 20px;
  height: 20px;
}

.sync-qr {
  width: 200px;
  margin: 12px auto;
  padding: 8px;
  border-radius: 8px;
  background: #fff;   /* scanners want dark modules on light */
  line-height: 0;
}

.sync-qr:empty {
  display: none;
}

.qr-scan {
  margin: 16px;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: #000;
}

.qr-scan video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sound-note a {
  color: var(--app-accent);
}

/* Count and sort button above a tune list (search, folders, composer pages) */
.list-bar {
  display: flex;
  align-items: center;
  margin: 8px 8px 0 16px;
}

.list-bar .result-count {
  flex: 1;
  margin: 0;
}

/* The order's name and its direction arrow, sized alike to read as one control */
.sort-button,
.sort-direction {
  --padding-start: 8px;
  --padding-end: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}

.sort-direction {
  --padding-start: 4px;
  --padding-end: 8px;
  margin-inline-start: -8px;
}

.sort-direction ion-icon {
  font-size: 14px;
}

ion-action-sheet .sort-current {
  color: var(--app-accent);
  font-weight: 600;
}

ion-action-sheet .sheet-toggle .action-sheet-button-inner {
  position: relative;
  justify-content: center;
  padding-inline: 52px;
  text-align: center;
}

ion-action-sheet .sheet-toggle .action-sheet-button-inner::after {
  content: "";
  position: absolute;
  inset-inline-end: 0;
  width: 36px;
  height: 22px;
  border-radius: 11px;
  background: radial-gradient(circle at 11px 11px, var(--ion-color-primary-contrast) 8px, transparent 9px) var(--ion-color-medium);
}

ion-action-sheet .sheet-toggle[aria-checked="true"] .action-sheet-button-inner::after {
  background: radial-gradient(circle at 25px 11px, var(--ion-color-primary-contrast) 8px, transparent 9px) var(--app-accent);
}

/* Keep labels centered independently of the saved subtune's trailing tick. */
ion-action-sheet.subtune-sheet .action-sheet-button-inner {
  position: relative;
  justify-content: center;
  padding-inline: 36px;
  text-align: center;
}

ion-action-sheet.subtune-sheet .action-sheet-icon {
  position: absolute;
  inset-inline-end: 0;
  margin: 0;
  font-size: 22px;
  color: var(--app-accent);
}

/* "Anyone with the link" row on a shared playlist */
.visibility-row {
  --background: transparent;
  margin: 4px 4px 0;
}

.visibility-row h3 {
  font-size: 15px;
  font-weight: 600;
}

/* With the title bar hidden, the search bar is the top toolbar: give it the
   safe-area inset (notch) Ionic only adds to the first toolbar, plus air. */
#title-toolbar[hidden] + #search-toolbar {
  padding-top: calc(var(--ion-safe-area-top, 0px) + 8px);
}

/* Recent searches (Spotify-style), shown while the empty search bar is focused */
.recent-query {
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 20px;
  border-radius: 50%;
}

.install-card ion-item {
  --background: var(--app-surface);
}

.recent-searches ion-item {
  --min-height: 60px;
}

.recent-clear {
  display: flex;
  justify-content: center;
  padding: 16px 16px 24px;
}

/* Numbered steps in plain-text dialogs (see infoDialog) */
ion-alert.info-alert .alert-message {
  white-space: pre-line;
  text-align: start;
}

/* ---- tags ---------------------------------------------------------------- */

/* The Curation/Admin tab, only for curators: Ionic's display would override [hidden]. */
ion-tab-button[hidden] {
  display: none;
}

.np-tags {
  display: flex;
  flex-wrap: wrap;
  margin: 6px -4px 0;
}

.np-tags:empty {
  display: none;
}

.tag-song,
.tag-count {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.7;
}

.tag-edit {
  --background: transparent;
  --color: var(--app-muted);
}

.tag-edit ion-icon {
  margin: 0 4px 0 -2px;
  font-size: 15px;
}

.tag-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(var(--ion-color-primary-rgb), 0.16);
  color: var(--ion-color-primary);
  font-size: 48px;
  margin-bottom: 8px;
}

.invite-card {
  border-bottom: 1px solid var(--app-border);
  padding-bottom: 16px;
}

.tag-sheet-head {
  padding: 12px 16px 4px;
}

.tag-sheet-head h2 {
  margin: 0;
  font-size: 18px;
}

.tag-sheet-head p {
  margin: 2px 0 0;
  color: var(--app-muted);
  font-size: 13px;
}

.tag-scope {
  margin: 8px 16px 0;
  width: auto;
}

.tag-chips {
  padding: 0 12px;
}

/* The negative margin is for cards. Chips need space below the label. */
.sound-section:has(+ .chips) {
  margin-bottom: 4px;
}

.tag-toggle {
  --background: transparent;
  border: 1px solid var(--app-outline);
}

.tag-toggle.is-on {
  --background: var(--ion-color-primary);
  --color: var(--ion-color-primary-contrast);
  border-color: var(--ion-color-primary);
}

.tag-toggle.is-pending {
  border-style: dashed;
  border-color: var(--ion-color-warning);
}

/* A curated list item that is taken out, or will be. */
.tag-toggle.is-hidden ion-label {
  text-decoration: line-through;
  opacity: .7;
}

.tag-toggle.is-inherited {
  opacity: 0.55;
}

.tag-toggle ion-icon {
  margin: 0 2px 0 -4px;
  font-size: 16px;
  color: inherit;
}

.bpm-chip {
  cursor: default;
  font-variant-numeric: tabular-nums;
}

.tag-bpm {
  margin: 8px 16px 0;
  --padding-start: 0;
  --background: transparent;
}

/* ---- One-time notices (notices.js) ---------------------------------------- */

/* As tall as the text where the modal is a centered card (Ionic's tablet and
   desktop size); a full-height card sheet on phones */
@media (min-width: 768px) and (min-height: 600px) {
  ion-modal.notice-modal {
    --height: auto;
  }

  ion-modal.notice-modal .ion-page {
    position: relative;
    display: block;
    contain: content;
  }
}

.notice {
  flex: 1;   /* fills the sheet, so the buttons sit at its bottom */
  padding: 32px 24px 8px;
  line-height: 1.5;
  overflow-y: auto;
}

/* The app icon over a welcome title; the icon has its own rounded corners */
.notice-logo {
  display: block;
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
}

.notice-title {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

/* Stacked at the bottom: the choice to make, then the way out */
.notice-actions {
  padding: 8px 24px calc(16px + env(safe-area-inset-bottom));
}

.notice-actions ion-button {
  margin: 0;
  --border-radius: 14px;
  min-height: 50px;
  font-weight: 600;
}

.notice-actions ion-button[fill="clear"] {
  min-height: 44px;
  font-weight: 400;
}

.notice ol {
  padding-inline-start: 1.4em;
}

/* A short tour: each line starts with the icon of its tab */
.notice ul.notice-tour {
  padding: 0;
  list-style: none;
}

.notice li + li {
  margin-top: 8px;
}

.notice a {
  color: var(--app-accent);
}

/* Inline in the text, as the app shows them: the accent marks what to tap */
.notice ion-icon:not([slot]) {
  color: var(--app-accent);
  font-size: 1.15em;
  vertical-align: -0.2em;
}

.notice-widget ion-list[inset] {
  margin-inline: 0;
}

.notice-widget ion-item {
  --background: var(--app-surface);
}

/* Ultimate reachability, beside its address in Sound */
.u64-status {
  color: var(--app-muted);
  font-size: 15px;
}

.u64-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}

.u64-status[data-status="up"] {
  color: var(--ion-color-success);
}

.u64-status[data-status="down"] {
  color: var(--ion-color-danger);
}

.tag-definition-form { display: grid; gap: 12px; text-align: left; }
.tag-definition-form label { display: grid; gap: 5px; }
.tag-definition-form input, .tag-definition-form select, .tag-definition-form textarea {
  width: 100%; padding: 10px; color: inherit; background: var(--ion-item-background, transparent);
  border: 1px solid var(--ion-color-medium); border-radius: 6px; font: inherit;
}
.tag-definition-form textarea { min-height: 80px; resize: vertical; }
.tag-definition-form button {
  justify-self: start; padding: 10px 18px; border: 0; border-radius: 6px;
  color: var(--ion-color-primary-contrast); background: var(--ion-color-primary); font: inherit; cursor: pointer;
}
.tag-definition-form button:disabled { opacity: .5; cursor: default; }
.tag-definition-form [role="alert"]:empty { display: none; }
/* Inline suggestions under a form field, as an inset list. */
.list-suggestions { margin: -6px 0 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--app-surface); }
.list-suggestions ion-item { --background: var(--app-surface); --min-height: 48px; }
.list-suggestions ion-label p { color: var(--ion-color-medium); }

/* Playlist import: a focused, grouped sheet with one decision at a time. */
.playlist-import-sheet {
  color-scheme: dark;
  background: var(--app-bg);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: 22px;
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  height: min(560px, 88dvh);
  max-height: 88dvh;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 24px 80px var(--app-shadow);
  font-family: var(--ion-font-family, sans-serif);
  font-size: 16px;
  line-height: 1.45;
}
.playlist-import-sheet[open] { display: grid; grid-template-rows: 64px minmax(0, 1fr) 76px; }
.playlist-import-sheet::backdrop { background: var(--app-shadow); backdrop-filter: blur(6px); }
.playlist-import-sheet header { position: relative; display: grid; place-items: center; min-height: 60px; padding: 12px 90px; border-bottom: 1px solid var(--app-border); }
.playlist-import-sheet header:not(:has(button)) { padding-inline: 20px; }
.playlist-import-sheet header > button { position: absolute; left: 8px; top: 8px; }
.playlist-import-sheet h2 { font-size: 17px; text-align: center; margin: 0; }
.playlist-import-sheet h3 { font-size: 22px; line-height: 1.2; margin: 8px 0 4px; overflow-wrap: anywhere; }
.playlist-import-sheet section { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; }
.playlist-import-sheet button { font: inherit; color: var(--app-accent); background: transparent; border: 0; border-radius: 10px; padding: 10px 12px; cursor: pointer; min-height: 44px; }
.playlist-import-sheet button:disabled { opacity: .4; cursor: default; }
.playlist-import-sheet button:focus-visible, .playlist-import-sheet input:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 2px; }
.playlist-import-sheet .merge-start-actions { margin: 24px 0 0; }
.playlist-import-sheet .merge-start-actions ion-item { --background: var(--app-surface); }
.playlist-import-sheet .merge-start-actions ion-label { white-space: normal; }
.merge-playlist-name { margin: 4px 0; text-align: center; overflow-wrap: anywhere; font-weight: 500; }
.merge-playlist-name + .merge-subtitle { text-align: center; margin-top: 6px; }
.playlist-import-sheet .merge-remaining { display: block; font-size: 14px; margin: 8px auto 0; padding-inline: 0; }
.playlist-import-sheet .merge-primary { background: var(--ion-color-primary); color: var(--ion-color-primary-contrast); }
.playlist-import-sheet footer { border-top: 1px solid var(--app-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; }
.playlist-import-sheet footer .merge-primary { min-width: 144px; }

.merge-subtitle, .merge-path, .merge-choices small { color: var(--app-muted); }
.merge-path { font-size: 12px; overflow-wrap: anywhere; margin-top: 0; }
.playlist-import-sheet fieldset { border: 0; padding: 0; margin: 20px 0 0; border-radius: 12px; overflow: hidden; background: var(--app-surface); }
.playlist-import-sheet fieldset label { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 12px 16px; cursor: pointer; }
.playlist-import-sheet fieldset label + label { border-top: 1px solid var(--app-border); }
.playlist-import-sheet fieldset label:has(input:checked) { background: rgba(var(--ion-color-primary-rgb), 0.08); }
.merge-choices small { display: block; font-size: 13px; margin-top: 2px; }
.playlist-import-sheet input { accent-color: var(--ion-color-primary); width: 18px; height: 18px; }
.merge-warning { color: var(--ion-color-warning); }
@media (max-width: 600px) {
  .playlist-import-sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}

/* Use the same segmented control as Sound settings. */
.playlist-import-sheet ion-segment { width: 100%; }
.playlist-import-sheet ion-segment-button { min-width: 0; min-height: 44px; --padding-start: 6px; --padding-end: 6px; }
.playlist-import-sheet ion-segment ion-label { white-space: normal; font-size: 14px; line-height: 1.3; }
.playlist-import-sheet ion-segment small { display: block; font-size: 12px; opacity: .75; }
.merge-difference { padding: 16px 0; }
.merge-difference + .merge-difference { border-top: 1px solid var(--app-border); }
.playlist-import-sheet .merge-difference h3 { font-size: 17px; margin-top: 0; }
.playlist-import-sheet .merge-difference .merge-path { margin-bottom: 12px; }
.playlist-import-sheet .merge-difference .merge-remaining { margin: 4px 0 0 auto; font-size: 12px; min-height: 36px; }

.playlist-import-sheet section > h3 { font-size: 17px; }
.merge-tune { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.merge-tune > div:last-child { min-width: 0; flex: 1; }
.merge-tune .thumb { flex-shrink: 0; }
.merge-tune .merge-path { margin: 4px 0 0; }
