/* Yumora wide layout: tablet and desktop (2026-11-19).
 *
 * The phone layout in styles.css + chat.css is the product (it also ships in
 * the Play Store app) and must stay pixel-identical below 768 px. Everything
 * here is therefore inside a min-width media query, and index.html links this
 * file with media="(min-width: 768px)" as well, so a phone never applies it.
 *
 *   >= 768   full-width app, the bottom tabbar becomes a left icon rail,
 *            home rails become grids, detail goes two-column, chat is a
 *            centred reading column, every sheet becomes a centred dialog
 *   >= 1024  the rail grows into a sidebar with the brand, tag chips wrap
 *   >= 1280  chat gets the character card beside the column
 *   >= 1440  wider content cap
 */

@media (min-width: 768px) {
  :root {
    --nav-w: 88px;
    --gutter: 28px;
    --content-max: 1360px;
    /* no bottom tabbar to clear on wide screens */
    --tab-clear: 48px;
  }

  /* ---------- frame: full window, no phone outline ---------- */
  .app { max-width: none; border-radius: 0; box-shadow: none; }

  /* ---------- tabbar -> left navigation rail ---------- */
  /* The rail is permanent on wide screens: showScreen() still toggles .hide
     for the phone, which is neutralised here. */
  .tabbar,
  .tabbar.hide {
    left: 0; right: auto; top: 0; bottom: 0;
    width: var(--nav-w); height: auto;
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    padding: max(22px, env(safe-area-inset-top)) 10px 22px;
    border: 0; border-right: 1px solid var(--line); border-radius: 0;
    background: rgba(14, 12, 32, .86);
    box-shadow: none;
    transform: none; opacity: 1; pointer-events: auto;
  }
  .tabbar button { flex: none; min-height: 70px; border-radius: 18px; gap: 5px; font-size: 12px; transition: color .2s, background .2s; }
  .tabbar button.on { background: var(--glass); }
  .tabbar button.on::before { top: 11px; }

  /* every screen sits to the right of the rail */
  .screen { left: var(--nav-w); }

  /* ---------- shared content column ---------- */
  .pad,
  .topbar { padding-left: max(var(--gutter), calc((100% - var(--content-max)) / 2)); padding-right: max(var(--gutter), calc((100% - var(--content-max)) / 2)); }
  .safe-top { padding-top: max(32px, env(safe-area-inset-top)); }

  /* ---------- home ---------- */
  .topbar { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: 12px; }
  .section-h { margin: 30px 0 14px; }
  .section-h h2 { font-size: 21px; }

  /* coverflow: the same carousel, it just no longer bleeds past the column */
  .flow { margin: 4px 0 0; }
  .flow-empty { margin: 0; }

  /* rails -> grids (no horizontal scrolling with a mouse) */
  .arche { flex-wrap: wrap; overflow: visible; margin: 0; padding: 4px 0 6px; gap: 16px 12px; }
  .arche button { width: 80px; }
  .rank { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 24px 16px; overflow: visible; margin: 0; padding: 4px 0 8px; }
  .rank-item { width: auto; min-width: 0; padding-left: 22px; }
  .rank-item .num { font-size: 76px; bottom: 38px; }
  .rank-item b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 24px 18px; }

  /* ---------- detail: cover | text ---------- */
  #scr-detail {
    display: grid;
    /* cover column: 40 % of the row, but never taller than the window */
    grid-template-columns: min(40%, calc((100dvh - 150px) * .5714)) minmax(0, 1fr);
    align-items: start;
    column-gap: clamp(28px, 4vw, 56px);
    /* a screen's own padding resolves % against the whole app, rail included */
    padding: 84px max(var(--gutter), calc((100% - var(--nav-w) - 1160px) / 2)) 0;
  }
  #scr-detail .float-bar { padding: 20px max(var(--gutter), calc((100% - 1160px) / 2)) 0; }
  #scr-detail .hero {
    grid-column: 1; grid-row: 1;
    /* sticky offsets count from the padding edge: 0 = just under the back button */
    position: sticky; top: 0;
    height: auto; aspect-ratio: 540 / 945;
    border-radius: 28px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .55), 0 0 0 1px var(--line);
  }
  /* the phone's scroll parallax would slide the art inside the card */
  #scr-detail .hero img { transform: none !important; }
  #scr-detail .hero::after { background: linear-gradient(180deg, rgba(12, 10, 28, 0) 62%, rgba(12, 10, 28, .55) 100%); }
  .detail-body { grid-column: 2; grid-row: 1; margin-top: 0; padding: 0 0 130px; max-width: 660px; }
  .detail-body h1 { font-size: 36px; }
  /* the start button rides along the bottom of the text column */
  #scr-detail .cta-bar {
    grid-column: 2; grid-row: 1; align-self: end;
    position: sticky; bottom: 0; z-index: 8;
    max-width: 660px;
    padding: 28px 0 max(26px, env(safe-area-inset-bottom));
  }

  /* ---------- chat: a centred reading column ---------- */
  #scr-chat {
    --col: min(760px, calc(100% - 2 * var(--gutter)));
    --col-x: calc((100% - var(--col)) / 2);
    --col-r: var(--col-x);
  }
  .chat-head { left: var(--col-x); right: auto; width: var(--col); padding-left: 0; padding-right: 0; }
  .composer { left: var(--col-x); right: auto; width: var(--col); padding-left: 0; padding-right: 0; }
  /* the log stays full width (the wheel scrolls it anywhere) with the text in the column */
  .log { padding-left: calc(var(--col-x) + 4px); padding-right: calc(var(--col-r) + 4px); }

  /* ---------- sheets -> centred dialogs ---------- */
  .sheet {
    left: 50%; right: auto; top: 50%; bottom: auto;
    width: min(540px, calc(100% - 48px));
    max-height: min(880px, calc(100% - 48px));
    padding: 28px 28px 26px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, .15);
    box-shadow: 0 40px 100px rgba(0, 0, 0, .6), 0 0 80px rgba(165, 148, 255, .1);
    /* closed = gone at once (no transition): crossing the 768 px line, e.g. a
       phone rotating, must not fly the phone's parked sheets across the screen */
    opacity: 0; visibility: hidden;
    transform: translate(-50%, -50%);
    transition: none;
  }
  .sheet.on { opacity: 1; visibility: visible; transform: translate(-50%, -50%); animation: dlg-in .32s cubic-bezier(.2, .8, .2, 1); }
  @keyframes dlg-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.97); } }
  .sheet .grab { display: none; }
  #pwSheet { width: min(640px, calc(100% - 48px)); }
  #actSheet, #crConfirm, #confirmSheet, #filterSheet { width: min(440px, calc(100% - 48px)); }

  /* ---------- stories / me / creator / billing return ---------- */
  #scr-stories > .pad { padding-left: max(var(--gutter), calc((100% - 1040px) / 2)); padding-right: max(var(--gutter), calc((100% - 1040px) / 2)); }
  #scr-me > .pad { padding-left: max(var(--gutter), calc((100% - 760px) / 2)); padding-right: max(var(--gutter), calc((100% - 760px) / 2)); }
  .cr-strip { flex-wrap: wrap; overflow: visible; margin: 0; padding: 2px 0 6px; }
  .cr-top, .cr-body, .cr-dock { padding-left: max(var(--gutter), calc((100% - 760px) / 2)); padding-right: max(var(--gutter), calc((100% - 760px) / 2)); }
  .bill-top, .bill-body { padding-left: max(var(--gutter), calc((100% - 560px) / 2)); padding-right: max(var(--gutter), calc((100% - 560px) / 2)); }

  /* ---------- age screen: a centred card over the collage ---------- */
  #scr-age { justify-content: center; align-items: center; }
  .age-bg { grid-template-columns: repeat(4, 1fr); }
  .age-bg img { height: 34vh; }
  .age-shade { background: radial-gradient(ellipse at center, rgba(12, 10, 28, .55), rgba(12, 10, 28, .92) 75%); }
  .age-box {
    width: min(460px, calc(100% - 48px));
    padding: 32px 32px 22px;
    border-radius: 28px;
    background: rgba(18, 15, 38, .8);
    border: 1px solid var(--line);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 40px 100px rgba(0, 0, 0, .55);
  }

  .toast { bottom: 40px; }

  /* ---------- mouse affordances ---------- */
  @media (hover: hover) {
    .tabbar button:hover { color: var(--ink); background: var(--glass); }
    .chip:not(.on):hover, .cr-chip:not(.on):hover { color: var(--ink); border-color: rgba(255, 255, 255, .24); }
    .rank-item .art { transition: transform .25s ease, box-shadow .25s ease; }
    .rank-item:hover .art { transform: translateY(-4px); box-shadow: 0 22px 40px rgba(0, 0, 0, .55); }
    .story-row:hover, .list button:hover, .list a.legal-row:hover { background: var(--glass-2); }
    .icon-btn:hover, .btn-line:hover, .btn-ghost:hover { background: var(--glass-2); }
  }
}

@media (min-width: 1024px) {
  :root { --nav-w: 232px; --gutter: 40px; }

  /* rail -> sidebar: brand on top, icon + label rows */
  .tabbar, .tabbar.hide { padding: max(26px, env(safe-area-inset-top)) 16px 24px; gap: 4px; }
  .tabbar .nav-brand { display: flex; align-items: center; min-height: 44px; padding: 0 12px; margin: 0 0 22px; border-radius: 12px; }
  .tabbar .nav-brand img { height: 38px; width: auto; }
  .tabbar button { flex-direction: row; justify-content: flex-start; gap: 14px; min-height: 52px; padding: 0 16px; border-radius: 14px; font-size: 15px; }
  .tabbar button.on { font-weight: 700; }
  .tabbar button.on::before { top: 50%; left: 10px; width: 34px; height: 30px; margin-top: -15px; }
  /* the sidebar carries the brand, so the home bar keeps only its pills */
  #scr-home .topbar { justify-content: flex-end; }
  #scr-home .topbar .logo { display: none; }

  /* tag chips wrap instead of scrolling sideways */
  .chips, .chips-wrap .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 2px 0 4px; }
  .chips-next { display: none; }

  .flow { height: 470px; }
  .flow-card { width: 280px; height: 450px; margin-left: -140px; }
  .flow-card h3 { font-size: 24px; }
  .flow-empty { height: 450px; }

  .rank-item .num { font-size: 92px; bottom: 34px; }
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

  /* two columns of rows */
  #storyList, #savedList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  #storyList > :not(.story-row), #savedList > :not(.story-row) { grid-column: 1 / -1; }

  /* scrollbars are useful with a mouse */
  .screen, .cr-body, .sheet { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent; }
  #scr-chat { scrollbar-width: none; }
  /* the particle canvas sizes itself from the screen's rect, which now includes
     the scrollbar: max-width wins over its inline width */
  #particles { max-width: 100%; }
}

@media (min-width: 1280px) {
  /* chat: column + character card, centred together */
  #scr-chat {
    --side: 300px;
    --side-gap: 36px;
    --col: min(720px, calc(100% - 2 * var(--gutter) - var(--side) - var(--side-gap)));
    --col-x: calc((100% - var(--col) - var(--side-gap) - var(--side)) / 2);
    --col-r: calc(var(--col-x) + var(--side-gap) + var(--side));
  }
  .chat-side {
    display: block; position: absolute; z-index: 4;
    top: 50%; left: calc(var(--col-x) + var(--col) + var(--side-gap));
    width: var(--side);
    transform: translateY(-50%);
    padding: 14px 14px 16px;
    border-radius: 26px;
    background: rgba(23, 20, 46, .62);
    border: 1px solid var(--line);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  }
  .chat-side .cs-art { position: relative; aspect-ratio: 3 / 4; border-radius: 18px; overflow: hidden; background: var(--deep); }
  .chat-side .cs-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 15%; }
  .chat-side .cs-art.ph::after { content: attr(data-initial); position: absolute; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #3a2a7e, #6d2c66 58%, #1f5a66); color: rgba(255, 255, 255, .85); font: italic 600 96px/1 var(--f-brand); }
  .chat-side .cs-name { display: block; margin-top: 14px; font: 700 20px/1.3 var(--f-display); overflow-wrap: anywhere; }
  .chat-side .cs-hook { margin: 6px 0 14px; font-size: 13px; line-height: 1.65; color: #ddd7f3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; overflow-wrap: anywhere; }
  .chat-side .cs-hook:empty { display: none; }
  .chat-side .cs-mem { width: 100%; }
  /* the sharp art lives on the card, the backdrop goes soft */
  .chat-bg img { filter: blur(26px) saturate(1.15) brightness(.8); transform: scale(1.12); animation: none; }
  .chat-bg::after { background: linear-gradient(180deg, rgba(12, 10, 28, .55), rgba(12, 10, 28, .75) 60%, rgba(12, 10, 28, .92)); }

  .age-bg { grid-template-columns: repeat(6, 1fr); }
  .age-bg img { height: 52vh; }
}

@media (min-width: 1440px) {
  :root { --content-max: 1480px; --gutter: 48px; }
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }
}
