/* Flick — the phone interface.
 *
 * Below 1024px the site is the Android app: these rules draw the screens that
 * includes/mobile.php renders, with every size, radius and colour taken from
 * lib/widgets/ui_kit.dart, lib/theme/app_theme.dart and the screens that use
 * them. Numbers are the app's logical pixels, which are CSS pixels.
 *
 * Loaded after style.css and desktop.css. Only the first block below applies
 * at desktop widths, and all it does is hide the phone markup — so nothing in
 * this file can move the desktop layout.
 */

@media (min-width: 1024px) {
  .m-only,
  .m-tabbar { display: none !important; }
}

/* Material Symbols: the web face of the app's Material icons. */
.msr {
  font-family: "Material Symbols Rounded";
  font-weight: normal; font-style: normal; line-height: 1;
  letter-spacing: normal; text-transform: none; white-space: nowrap;
  display: inline-block; direction: ltr; flex: none;
  font-feature-settings: "liga"; -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
}
.msr.fill { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

@media (max-width: 1023.98px) {

  /* ------------------------------------------------------------ palette */

  /* AppPalette.dark — the default, as in the app. */
  :root {
    --m-bg: #08080C;
    --m-surface: #121218;
    --m-card: #16161F;
    --m-button: #1C1C24;
    --m-shimmer: #16161F;
    --m-accent: #B39DFF;
    --m-accent-deep: #3B1E7A;
    --m-hairline: rgba(255, 255, 255, .141);
    --m-text: #FFFFFF;
    --m-text-2: rgba(255, 255, 255, .62);
    --m-text-3: rgba(255, 255, 255, .38);
    --m-title: linear-gradient(90deg, #D9BFFF, #A78BFA, #E3A9FF);
    --m-accent-grad: linear-gradient(90deg, #B39DFF, #8B7BE8);
    --m-cta: linear-gradient(90deg, #7C5CF5, #C06BD8, #F0A05A);
    --m-gold: #F3C34E;
    --m-info: #5B8DEF;
    --m-chip: #15151C;
    --m-chip-border: rgba(255, 255, 255, .12);
    --m-shadow: rgba(0, 0, 0, .5);
    --m-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* AppPalette.light, following the same three-state theme as style.css. */
  :root[data-theme="light"] {
    --m-bg: #F6F6FA;
    --m-surface: #FFFFFF;
    --m-card: #FFFFFF;
    --m-button: #ECECF3;
    --m-shimmer: #E7E7EE;
    --m-accent: #6D4AE0;
    --m-accent-deep: #FFFFFF;
    --m-hairline: rgba(0, 0, 0, .10);
    --m-text: #101014;
    --m-text-2: rgba(0, 0, 0, .62);
    --m-text-3: rgba(0, 0, 0, .40);
    --m-title: linear-gradient(90deg, #8B5CF6, #6D4AE0, #B05CE6);
    --m-accent-grad: linear-gradient(90deg, #8B5CF6, #6D4AE0);
    --m-gold: #D9A21B;
    --m-info: #3B6FD4;
    --m-chip: #FFFFFF;
    --m-chip-border: rgba(0, 0, 0, .08);
    --m-shadow: rgba(0, 0, 0, .10);
  }
}

@media (max-width: 1023.98px) and (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --m-bg: #F6F6FA;
    --m-surface: #FFFFFF;
    --m-card: #FFFFFF;
    --m-button: #ECECF3;
    --m-shimmer: #E7E7EE;
    --m-accent: #6D4AE0;
    --m-accent-deep: #FFFFFF;
    --m-hairline: rgba(0, 0, 0, .10);
    --m-text: #101014;
    --m-text-2: rgba(0, 0, 0, .62);
    --m-text-3: rgba(0, 0, 0, .40);
    --m-title: linear-gradient(90deg, #8B5CF6, #6D4AE0, #B05CE6);
    --m-accent-grad: linear-gradient(90deg, #8B5CF6, #6D4AE0);
    --m-gold: #D9A21B;
    --m-info: #3B6FD4;
    --m-chip: #FFFFFF;
    --m-chip-border: rgba(0, 0, 0, .08);
    --m-shadow: rgba(0, 0, 0, .10);
  }
}

@media (max-width: 1023.98px) {

  /* ---------------------------------------------------------------- frame */

  .d-only { display: none !important; }
  .m-only [hidden] { display: none !important; }

  body {
    background: var(--m-bg);
    color: var(--m-text);
    /* Clears the floating tab bar: 68 tall, 8 off the bottom, plus breathing
       room — the app's own 108 under its last shelf. */
    padding-bottom: calc(100px + var(--m-safe-bottom));
  }
  body:has(main[data-tab="detail"]) { padding-bottom: calc(36px + var(--m-safe-bottom)); }

  .offline-bar { top: 0; }
  .toast { bottom: calc(92px + var(--m-safe-bottom)); }

  .m-screen {
    max-width: 900px; margin: 0 auto;
    font-family: Outfit, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.3;
  }
  .m-only a { color: inherit; text-decoration: none; }
  .m-only button { font: inherit; color: inherit; }
  /* …except a shared `.btn`, which brings its own colour and needs to keep it.
     Every phone component here sets its own, so the reset above was harmless
     until the account block (includes/account.php) put the first `.btn`
     *button* inside `.m-only` — `.m-only button` outranks `.btn-accent`, so
     "Continue with Google" came out as body text on a purple pill, and in
     light mode "Sync now" and "Sign out" came out white on white. */
  .m-only button.btn-accent { color: var(--accent-deep); }
  .m-only button.btn-ghost { color: var(--text); }
  .m-pad { padding-left: 20px; padding-right: 20px; }
  .m-flex { flex: 1; }

  /* ---------------------------------------------------------------- header */

  .m-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 20px 12px;
    max-width: 900px; margin: 0 auto;
    font-family: Outfit, system-ui, sans-serif;
  }
  .m-wordmark {
    font-size: 30px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2;
    background: var(--m-title); -webkit-background-clip: text; background-clip: text;
    color: transparent !important;
  }

  /* ---------------------------------------------------------------- search */

  .m-search-wrap { padding-bottom: 18px; }
  .m-search-gap { padding-bottom: 22px; }
  .m-search {
    display: flex; align-items: center; gap: 12px;
    height: 54px; padding: 0 16px; border-radius: 16px;
    background: var(--m-card); border: 1px solid var(--m-hairline);
  }
  .m-search:focus-within { border-color: color-mix(in srgb, var(--m-accent) 60%, transparent); }
  .m-search input {
    flex: 1; min-width: 0; height: 100%;
    border: 0; outline: 0; background: none; padding: 0;
    font: inherit; font-size: 15.5px; color: var(--m-text);
    caret-color: var(--m-accent);
  }
  .m-search input::placeholder { color: var(--m-text-3); }
  .m-search input::-webkit-search-cancel-button { display: none; }
  .m-search-clear {
    display: grid; place-items: center; padding: 3px; border-radius: 50%;
    background: var(--m-button); color: var(--m-text-2);
  }
  .m-search-tune { display: grid; place-items: center; }

  /* ------------------------------------------------------------ headings */

  .m-heading { padding-bottom: 16px; }
  .m-heading h1, .m-title-row h1 {
    margin: 0; font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--m-text);
  }
  .m-heading-row {
    display: flex; align-items: flex-end; gap: 12px; margin-top: 6px;
    font-size: 14px; color: var(--m-text-2);
  }
  .m-heading-row p {
    flex: 1; min-width: 0; margin: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .m-heading-row b { color: var(--m-accent); font-weight: 600; }

  .m-title-row { display: flex; align-items: center; gap: 14px; padding-top: 4px; padding-bottom: 18px; }
  .m-title-row > div { flex: 1; min-width: 0; }
  .m-title-row p { margin: 4px 0 0; font-size: 14px; color: var(--m-text-2); }

  .m-block-head { padding-bottom: 18px; }
  .m-block-head h2 { margin: 0; font-size: 19px; font-weight: 500; letter-spacing: .2px; color: var(--m-text); }
  .m-block-head p { margin: 4px 0 0; font-size: 14px; color: var(--m-text-2); }

  .m-sec-head {
    display: flex; align-items: center; gap: 7px;
    padding: 0 20px 14px;
  }
  .m-sec-head h2 {
    flex: 1; margin: 0; font-size: 19px; font-weight: 500; letter-spacing: .2px;
    color: var(--m-text); line-height: 1.3;
  }
  .m-see-all {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: 0; padding: 0; cursor: pointer;
    font-size: 14px; font-weight: 500; color: var(--m-text-2) !important;
  }

  /* ----------------------------------------------------------------- pills */

  .m-pills {
    display: flex; gap: 10px; height: 42px;
    padding: 0 20px; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; margin-bottom: 18px;
  }
  .m-pills::-webkit-scrollbar { display: none; }
  .m-pill {
    flex: none; display: inline-flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 16px; border-radius: 999px;
    background: var(--m-chip); border: 1px solid var(--m-chip-border);
    font-size: 13.5px; font-weight: 500; color: var(--m-text-2) !important;
    white-space: nowrap; line-height: 1;
  }
  .m-pill.on {
    background: color-mix(in srgb, var(--m-accent) 12%, transparent);
    border: 1.2px solid var(--m-accent);
    color: var(--m-text) !important; font-weight: 600;
  }
  .m-home-pills { margin-bottom: 26px; }

  /* ----------------------------------------------------------------- tiles */

  .m-grid { display: grid; gap: 12px; }
  .m-grid-explore { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m-grid-explore > .m-tile { aspect-ratio: 0.68; }
  .m-grid-fav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .m-grid-fav > .m-tile { aspect-ratio: 0.6; }

  .m-tile {
    position: relative; display: block; overflow: hidden;
    border-radius: 16px; min-width: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .m-tile img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    display: block;
  }
  .m-tile:active img { transform: scale(.985); }
  .m-tile[hidden] { display: none !important; }

  .m-heart {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    display: grid; place-items: center;
    padding: 7px; margin: 0; border: 0; background: none; cursor: pointer;
    color: #fff !important;
    text-shadow: 0 0 8px rgba(0, 0, 0, .55);
  }
  .m-heart .msr { font-size: 20px; }
  .m-heart.on .msr { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

  .m-quality {
    position: absolute; left: 8px; bottom: 8px; z-index: 2;
    padding: 3px 7px; border-radius: 7px;
    background: rgba(0, 0, 0, .55); color: #fff;
    font-size: 10px; font-weight: 700; letter-spacing: .3px; line-height: 1.2;
  }

  /* --------------------------------------------------------------- shelves */

  .m-shelf { margin-bottom: 26px; }
  .m-shelf-row {
    display: flex; gap: 10px; padding: 0 20px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .m-shelf-row::-webkit-scrollbar { display: none; }
  .m-shelf-row > .m-tile { flex: none; width: 112px; height: 200px; scroll-snap-align: start; }

  /* ---------------------------------------------------------------- hero */

  .m-hero {
    position: relative; overflow: hidden;
    aspect-ratio: 1.62; border-radius: 26px;
    background: var(--m-shimmer);
    margin-bottom: 20px;
  }
  .m-hero-track {
    display: flex; height: 100%;
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
    overscroll-behavior-x: contain;
  }
  .m-hero-track::-webkit-scrollbar { display: none; }
  .m-hero-slide {
    position: relative; flex: none; width: 100%; height: 100%;
    scroll-snap-align: start; overflow: hidden;
  }
  .m-hero-slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .m-hero-scrim {
    position: absolute; inset: 0;
    background: linear-gradient(to top right, rgba(0,0,0,.9) 0%, rgba(0,0,0,.4) 55%, rgba(0,0,0,.05) 100%);
  }
  .m-hero-body {
    position: absolute; inset: 0; padding: 18px;
    display: flex; flex-direction: column; align-items: flex-start;
  }
  .m-hero-spacer { flex: 1; }
  .m-hero-title {
    font-size: 27px; font-weight: 700; line-height: 1.12; color: #fff;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .m-hero-sub {
    margin-top: 6px; max-width: 100%;
    font-size: 13.5px; line-height: 1.3; color: rgba(255, 255, 255, .78);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .m-hero-btn {
    margin-top: 14px;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 11px 16px; border-radius: 999px;
    background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .3);
    font-size: 14px; font-weight: 600; color: #fff; line-height: 1;
  }
  .m-hero-dots {
    position: absolute; right: 18px; bottom: 16px; z-index: 3;
    display: flex; align-items: center; pointer-events: none;
  }
  .m-hero-dots i {
    width: 6px; height: 6px; margin-left: 5px; border-radius: 50%;
    background: rgba(255, 255, 255, .42);
    transition: width .25s, height .25s, background .25s;
  }
  .m-hero-dots i.on { width: 8px; height: 8px; background: #fff; }

  .m-eyebrow {
    display: inline-block; align-self: flex-start;
    padding: 6px 10px; border-radius: 8px;
    background: color-mix(in srgb, var(--m-accent) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--m-accent) 35%, transparent);
    font-size: 10px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase;
    color: var(--m-accent); line-height: 1.2;
  }

  /* ------------------------------------------------------------ buttons */

  .m-surface-btn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    width: 100%; height: 52px; padding: 0 14px; border-radius: 14px;
    background: var(--m-button); border: 1px solid var(--m-hairline);
    font-size: 15px; font-weight: 500; color: var(--m-text) !important;
    cursor: pointer; white-space: nowrap; overflow: hidden;
  }
  .m-surface-btn span:not(.msr) { overflow: hidden; text-overflow: ellipsis; }
  .m-surface-btn.loading { pointer-events: none; }
  .m-surface-btn.loading::after {
    content: ""; width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--m-accent); border-right-color: transparent;
    animation: m-spin .7s linear infinite;
  }
  .m-surface-btn.loading > * { display: none; }
  @keyframes m-spin { to { transform: rotate(360deg); } }

  .m-grad-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 52px; padding: 0 22px; border-radius: 14px;
    background: var(--m-cta); color: #fff !important;
    font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden;
  }
  .m-grad-btn span:not(.msr) { overflow: hidden; text-overflow: ellipsis; }
  .m-grad-sm { height: 44px; padding: 0 16px; font-size: 14.5px; gap: 6px; flex: none; }
  .m-grad-auto { height: 46px; margin-top: 20px; }

  .m-more { margin-top: 16px; }
  .m-random { margin-bottom: 26px; }
  .m-end { text-align: center; margin: 24px 0 0; font-size: 12px; font-weight: 500; color: var(--m-text-2); }

  .m-circle {
    flex: none; display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%; padding: 0;
    background: var(--m-card); border: 1px solid var(--m-hairline);
    color: var(--m-text) !important; cursor: pointer;
  }
  .m-circle.on-photo {
    background: rgba(0, 0, 0, .45); border-color: rgba(255, 255, 255, .14); color: #fff !important;
  }


  /* ------------------------------------------------------------- panels */

  .m-stack { display: flex; flex-direction: column; gap: 16px; }
  .m-panel {
    padding: 4px 16px; border-radius: 20px;
    background: var(--m-card); border: 1px solid var(--m-hairline);
  }
  .m-group { margin: 6px 0 -6px; font-size: 13.5px; font-weight: 500; color: var(--m-text-3); }

  .m-glyph {
    flex: none; display: grid; place-items: center; border-radius: 13px;
    background: color-mix(in srgb, var(--tint) 13%, transparent);
    border: 1px solid color-mix(in srgb, var(--tint) 18%, transparent);
  }

  .m-row {
    position: relative; display: flex; align-items: center; gap: 14px;
    padding: 12px 0;
  }
  .m-row + .m-row::before {
    content: ""; position: absolute; top: 0; left: 58px; right: 0;
    height: 1px; background: var(--m-hairline);
  }
  .m-row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
  .m-row-text strong { font-size: 17px; font-weight: 600; color: var(--m-text); }
  .m-row-text span { font-size: 13px; line-height: 1.35; color: var(--m-text-2); }
  .m-row-value { font-size: 14.5px; font-weight: 500; color: var(--m-accent); }
  .m-mini-btn {
    border: 0; border-radius: 12px; padding: 10px 16px; cursor: pointer;
    background: var(--m-cta); color: #fff !important; font-weight: 600;
  }

  /* -------------------------------------------------------- empty state */

  .m-empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 48px 32px;
  }
  .m-empty strong { margin-top: 18px; font-size: 17px; font-weight: 600; color: var(--m-text); }
  .m-empty p { margin: 6px 0 0; font-size: 13px; line-height: 1.35; color: var(--m-text-2); }

  /* ------------------------------------------------------------ profile */

  .m-id-card {
    border-radius: 20px; overflow: hidden;
    background: var(--m-card); border: 1px solid var(--m-hairline);
  }
  .m-id-banner { position: relative; height: 150px; }
  .m-id-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .m-id-scrim {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,.72), rgba(0,0,0,.28));
  }
  .m-id-row {
    position: relative; height: 100%;
    display: flex; align-items: center; gap: 16px; padding: 16px;
  }
  .m-avatar {
    position: relative; flex: none;
    width: 84px; height: 84px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--m-accent-grad); border: 2.5px solid rgba(255, 255, 255, .55);
    font-size: 32px; font-weight: 700; color: #fff !important;
  }
  /* It is a <button> when this site can sign you in and an <a> to the app
     when it cannot — see profile.php. A button brings its own font and no
     pointer, and `overflow: hidden` is what keeps a Google avatar inside the
     circle once account.js swaps the initial for an <img>. */
  button.m-avatar {
    font-family: inherit; cursor: pointer; padding: 0; overflow: visible;
  }
  .m-avatar > span:first-child {
    display: grid; place-items: center; width: 100%; height: 100%;
    border-radius: 50%; overflow: hidden;
  }
  .m-avatar > span:first-child img {
    width: 100%; height: 100%; object-fit: cover; display: block;
  }
  .m-avatar-badge {
    position: absolute; right: -2px; bottom: -2px;
    display: grid; place-items: center; padding: 5px; border-radius: 50%;
    background: var(--m-card); border: 1px solid var(--m-hairline);
    color: var(--m-text); font-size: 0;
  }
  .m-id-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .m-id-text strong { font-size: 23px; font-weight: 700; color: #fff; line-height: 1.2; }
  .m-id-plan {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
    font-size: 13.5px; font-weight: 600; color: rgba(255, 255, 255, .7);
  }
  .m-id-tag {
    margin-top: 6px; font-size: 13px; line-height: 1.3; color: rgba(255, 255, 255, .82);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .m-stats { display: flex; align-items: center; padding: 14px 8px 16px; }
  .m-stats > a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .m-stats > a > span:last-child { font-size: 12px; font-weight: 500; color: var(--m-text-2); }
  .m-stats > i { width: 1px; height: 34px; background: var(--m-hairline); }
  .m-stat-n { display: inline-flex; align-items: center; gap: 7px; }
  .m-stat-n b { font-size: 19px; font-weight: 700; color: var(--m-text); }

  /* -------------------------------------------------------- collections */

  .m-coll-list { display: flex; flex-direction: column; gap: 14px; }
  .m-coll-card {
    position: relative; display: flex; align-items: center;
    min-height: 118px; border-radius: 20px; overflow: hidden;
    border: 1px solid var(--m-hairline);
    background: linear-gradient(90deg,
      color-mix(in srgb, var(--tint) 16%, var(--m-card)) 0%,
      var(--m-card) 55%, var(--m-card) 100%);
  }
  .m-coll-cover { position: absolute; left: 0; top: 0; bottom: 0; width: 128px; }
  .m-coll-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .m-coll-text {
    flex: 1; min-width: 0; margin-left: 128px; padding: 14px 8px 14px 16px;
    display: flex; flex-direction: column;
  }
  .m-coll-text strong {
    font-size: 19px; font-weight: 600; color: var(--m-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .m-coll-blurb {
    margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--m-text-2);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .m-coll-count { margin-top: 8px; font-size: 13.5px; font-weight: 600; color: var(--tint); }
  .m-coll-chev {
    flex: none; margin-right: 14px;
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
    background: var(--m-button); border: 1px solid var(--m-hairline); color: var(--m-text-2);
  }
  .m-own { margin-top: 14px; }

  /* ------------------------------------------------------------- detail */

  .m-detail-hero {
    position: relative; overflow: hidden;
    aspect-ratio: 0.83; border-radius: 26px;
  }
  .m-detail-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .m-detail-scrim {
    position: absolute; left: 0; right: 0; top: 0; height: 110px;
    background: linear-gradient(to bottom, rgba(0,0,0,.4), rgba(0,0,0,0));
  }
  .m-detail-bar {
    position: absolute; top: 12px; left: 12px; right: 12px; z-index: 3;
    display: flex; align-items: center; gap: 10px;
  }
  .m-detail-bar > .m-flex { margin-right: -10px; }
  .m-detail-heart.on { color: #FF6B8A !important; }
  .m-detail-heart.on .msr { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

  .m-menu {
    position: absolute; right: 0; top: 52px; z-index: 5; min-width: 220px;
    padding: 8px 0; border-radius: 16px;
    background: var(--m-surface); border: 1px solid var(--m-hairline);
    box-shadow: 0 12px 30px var(--m-shadow);
  }
  .m-menu > a, .m-menu > button {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 16px; border: 0; background: none; cursor: pointer; text-align: left;
    font-size: 15px; color: var(--m-text) !important;
  }
  .m-menu .msr { color: var(--m-text-2); }

  .m-info-card {
    margin-top: 16px; padding: 18px; border-radius: 26px;
    background: var(--m-card); border: 1px solid var(--m-hairline);
  }
  .m-info-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .m-info-card h1 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.15; color: var(--m-text); }
  .m-info-by { margin: 6px 0 0; font-size: 14.5px; color: var(--m-text-2); }
  .m-info-summary { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: var(--m-text-2); }

  .m-meta-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 18px; }
  .m-meta { display: flex; align-items: flex-start; gap: 9px; min-width: 0; }
  .m-meta > span:last-child { display: grid; gap: 1px; min-width: 0; padding-top: 1px; }
  .m-meta b, .m-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-meta b { font-size: 12.5px; font-weight: 600; color: var(--m-text); }
  .m-meta small { font-size: 11.5px; color: var(--m-text-2); }

  .m-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
  .m-tag {
    padding: 8px 14px; border-radius: 999px;
    background: var(--m-button); border: 1px solid var(--m-hairline);
    font-size: 13.5px; font-weight: 500; color: var(--m-text-2) !important; line-height: 1.2;
  }
  .m-tag.on {
    background: color-mix(in srgb, var(--m-accent) 12%, transparent);
    border-color: color-mix(in srgb, var(--m-accent) 45%, transparent);
    color: var(--m-accent) !important;
  }

  .m-info-card hr { border: 0; height: 1px; background: var(--m-hairline); margin: 18px 0; }

  .m-actions { display: flex; gap: 10px; }
  .m-actions > * { min-width: 0; }
  .m-act-share { flex: 4; font-size: 13.5px; padding: 0 10px; gap: 6px; }
  .m-act-dl { flex: 5; font-size: 13.5px; padding: 0 10px; gap: 6px; }
  .m-act-main { flex: 5; font-size: 14.5px; padding: 0 12px; }

  .m-detail-related { margin-top: 28px; }
  .m-detail-related .m-shelf { margin-bottom: 0; }

  /* ------------------------------------------------------------ sheets */

  .m-sheet-scrim {
    position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55);
    opacity: 0; transition: opacity .22s;
  }
  .m-sheet-scrim.open { opacity: 1; }
  .m-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 91;
    max-width: 640px; margin: 0 auto;
    padding: 12px 20px calc(28px + var(--m-safe-bottom));
    border-radius: 20px 20px 0 0; background: var(--m-surface);
    transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.7,.3,1);
  }
  .m-sheet.open { transform: none; }
  .m-sheet-handle { width: 40px; height: 4px; margin: 0 auto 16px; border-radius: 2px; background: var(--m-hairline); }
  .m-sheet h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; color: var(--m-text); }
  .m-sheet-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 4px;
    font-size: 16px; color: var(--m-text) !important;
  }
  .m-sheet-row .msr { color: var(--m-text-2); }
  .m-sheet-row.on, .m-sheet-row.on .msr { color: var(--m-accent) !important; font-weight: 600; }

  /* ------------------------------------------------------------ tab bar */

  .m-tabbar {
    position: fixed; z-index: 60;
    left: 12px; right: 12px; bottom: calc(8px + var(--m-safe-bottom));
    max-width: 640px; margin: 0 auto;
    display: flex; height: 68px; border-radius: 24px;
    background: color-mix(in srgb, var(--m-surface) 94%, transparent);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 1px solid var(--m-hairline);
    box-shadow: 0 8px 20px var(--m-shadow);
    font-family: Outfit, system-ui, sans-serif;
  }
  body:has(main[data-tab="detail"]) .m-tabbar,
  body:has(.preview-root) .m-tabbar,
  body:has(main.bare) .m-tabbar { display: none; }
  body:has(.preview-root) .m-header { display: none; }

  .m-tab {
    position: relative; flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--m-text-3) !important; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .m-tab-rule {
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--m-accent); opacity: 0; transition: opacity .2s;
  }
  .m-tab .msr {
    font-size: 23px; border-radius: 50%;
    transition: color .2s, box-shadow .2s;
  }
  .m-tab-label { margin-top: 5px; font-size: 10.5px; font-weight: 500; line-height: 1.1; }
  .m-tab.on { color: var(--m-accent) !important; }
  .m-tab.on .m-tab-rule { opacity: 1; }
  .m-tab.on .msr {
    font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
    box-shadow: 0 0 16px 1px color-mix(in srgb, var(--m-accent) 35%, transparent);
    background: color-mix(in srgb, var(--m-accent) 6%, transparent);
  }
  .m-tab.on .m-tab-label { font-weight: 600; }

  /* ------------------------------------------------------ wider phones */

  /* columnsFor() in lib/widgets/responsive.dart: base below 600, +1 to 780,
     +2 up to the desktop breakpoint. */
  @media (min-width: 600px) {
    .m-grid-explore { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .m-grid-fav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  }
  @media (min-width: 780px) {
    .m-grid-explore { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .m-grid-fav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  }

}

@media (max-width: 1023.98px) {
  /* The sync line under a library heading — account.js reveals it only while
     signed in, because the subtitle above it already says where an unsynced
     library lives. */
  .m-sync-line {
    margin: 4px 0 0; font-size: 12.5px; font-weight: 500;
    color: var(--m-accent, #B39DFF);
  }
  .m-sync-line[hidden] { display: none; }
}
