/* ==========================================================================
   PHONE LAYER (iPhone 17 Pro: 402 x 874 CSS px). Loaded ONLY on screens <= 700px wide
   (<link media="(max-width: 700px)">), so laptops, desktops and iPads never see these rules.
   Same journal, same whimsy: a bottom tab bar like an iOS app, nothing sideways, big tap targets.
   ========================================================================== */

:root { --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px); }

html, body { overflow-x: clip; -webkit-text-size-adjust: 100%; }  /* clip, not hidden: hidden would turn body into a scroll box and break sticky bars */
body { -webkit-tap-highlight-color: rgba(232, 93, 146, .15); }

/* ---- the journal page fills the phone; rings stay as a slim spiral on the left ---- */
.journal {
  margin: 0; max-width: none; min-height: 100dvh; border-radius: 0; border-left: 0; border-right: 0;
  padding: calc(10px + var(--safe-t)) 12px calc(var(--nav-h) + var(--safe-b) + 24px) 30px;
  overflow-x: clip;
}
.journal::before { left: 5px; width: 16px; background-size: 16px 34px;
  background-image: radial-gradient(circle at 8px 8px, var(--pink-300) 4.5px, var(--pink-700) 5.5px, transparent 6.5px); }
.sparkles, .floaties { display: none; }

/* ---- masthead: just the ribbon and bow; navigation lives in the bottom bar ---- */
.masthead { flex-wrap: nowrap; gap: 6px; margin-bottom: 2px; }
.ribbon { font-size: 1rem; padding: 6px 16px 8px; white-space: nowrap; }
.masthead .bow { width: 38px; height: 24px; }
.masthead .tabs, .tagline, .whoami { display: none; }

/* ---- bottom tab bar ---- */
.bottom-nav {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; z-index: 8000; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 6px calc(6px + var(--safe-b));
  background: rgba(255, 250, 252, .86); -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
  border-top: 2px solid var(--pink-200); box-shadow: 0 -6px 24px rgba(74, 43, 58, .08);
}
.bottom-nav > a, .bottom-nav summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px;
  border-radius: 16px; color: var(--ink-soft); text-decoration: none; font-size: .68rem; font-weight: 800; list-style: none;
  transition: background .2s, color .2s, transform .15s;
}
.bottom-nav summary::-webkit-details-marker { display: none; }
.bottom-nav svg { width: 26px; height: 26px; transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
.bottom-nav [aria-current='page'], .bottom-nav details[open] > summary, .bottom-nav details.has-current > summary {
  color: var(--pink-700); background: var(--pink-50); }
.bottom-nav [aria-current='page'] svg { transform: translateY(-2px) scale(1.12); }
.bottom-nav > a:active, .bottom-nav summary:active { transform: scale(.94); }
.bottom-nav details { position: relative; }
.more-sheet {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 8001;
  background: #fff; border: 2px solid var(--pink-200); border-radius: 22px; padding: 8px; box-shadow: 0 18px 40px rgba(74, 43, 58, .2);
  display: grid; gap: 4px; animation: sheet-up .28s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes sheet-up { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.more-sheet a, .more-sheet button {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 12px; border-radius: 14px; border: 0; background: none;
  font: inherit; font-weight: 800; font-size: .95rem; color: var(--ink); text-decoration: none; text-align: left; width: 100%;
}
.more-sheet a[aria-current='page'] { background: var(--pink-50); color: var(--pink-700); }
.more-sheet svg { width: 28px; height: 28px; flex: none; }
.more-sheet .who { font-size: .75rem; color: var(--ink-soft); padding: 4px 12px 0; overflow-wrap: anywhere; }
.more-sheet form { margin: 0; }

/* ---- pages scroll normally on a phone (no fixed-height app frame) ---- */
body.app-shell .page, body.app-shell .page.fit { overflow: visible; height: auto; min-height: 0; }
.dash-grid, .dash-grid.fill, .strawberry-grid { display: flex; flex-direction: column; gap: 14px; min-height: 0 !important; }
.scroll-panel { max-height: 60dvh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.chat-thread.scroll-panel { max-height: none; overflow: visible; }

/* ---- cards ---- */
.card { padding: 14px 14px 12px; border-radius: 20px; margin: 12px 0; max-width: 100%; }
.card.compact { padding: 10px 12px; }
.card h2 { font-size: 1.15rem; padding-right: 36px; }
.corner-doodle { width: 34px; height: 34px; top: -10px; right: 8px; }
.card .view-switch, .card-head .view-switch { position: static; display: inline-flex; width: fit-content !important; max-width: 100%; margin: 2px 0 10px; }
.view-switch button { min-height: 36px; padding: 4px 14px; }
.card-head { margin-right: 0; }

/* ---- filters: chips wrap, never scroll sideways; comfy tap size ---- */
.filters { gap: 8px 10px; }
.chip-group { flex-wrap: wrap; overflow: visible; width: auto; gap: 6px; }
.chip-group .label { font-size: 1.05rem; margin: 0 2px 0 0; }
.chip { font-size: .85rem; min-height: 38px; padding: 6px 14px; display: inline-flex; align-items: center; }
.last-import { flex-basis: 100%; text-align: left; font-size: .78rem; }
.cute-select, select, input, textarea { font-size: 16px !important; }  /* iOS zooms in on anything smaller */
.cute-dd-btn { min-height: 40px; font-size: .95rem; }

/* ---- stickers: two per row ---- */
.stickers, .ig-stickers, .ig-stickers.with-combined { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 10px 0 4px; }
.ig-stickers .ig-card { grid-column: 1 / -1; }
.sticker { padding: 10px 12px; border-radius: 18px; min-width: 0; transform: none; }
.sticker .value { font-size: 1.3rem; overflow-wrap: anywhere; }
.sticker .note { font-size: .72rem; }
.sticker .doodle { width: 28px; height: 28px; top: -12px; right: 6px; }
.period-note { position: static; grid-column: 1 / -1; text-align: right; }

/* ---- charts and legends ---- */
.chart, .chart.grow { min-height: 220px; height: 240px; flex: none; overflow: hidden; }
.twin-charts { display: flex; flex-direction: column; min-height: 0 !important; }
.twin-charts .chart { height: 200px; min-height: 200px !important; }
.legend { gap: 6px 12px; font-size: .8rem; }

/* ---- lists ---- */
.top-list li { grid-template-columns: 30px minmax(0, 1fr) auto; padding: 10px 4px; }
.lift-headline { font-size: .9rem; }

/* ---- tables become stacked cards (labels come from the header; see whimsy.js) ---- */
table.cute, table.cute tbody, table.cute tr, table.cute td { display: block; width: 100%; }
table.cute thead { display: none; }
table.cute tr { background: #fff; border: 2px solid var(--pink-100); border-radius: 16px; margin: 0 0 8px; padding: 6px 10px; }
table.cute td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
table.cute td::before { content: attr(data-label); font-weight: 800; color: var(--ink-soft); font-size: .78rem; text-align: left; }
table.cute td:first-child { font-weight: 800; font-size: .95rem; }
table.cute td[data-label=''] ::before, table.cute td:not([data-label])::before { content: none; }
table.cute tr.selected { border-color: var(--pink-500); box-shadow: 0 0 0 3px var(--pink-100); }

/* ---- pagers swipe like photo stacks (no scrollbars) ---- */
.pager-track { scrollbar-width: none; }
.pager-track::-webkit-scrollbar { display: none; }
.insight-page { grid-template-columns: minmax(0, 1fr) !important; gap: 12px; }

/* ---- drawers become full-screen sheets ---- */
.drawer { width: 100vw; border-radius: 0; padding-top: var(--safe-t); }
.drawer-close { width: 44px; height: 44px; top: calc(10px + var(--safe-t)); }

/* ---- Strawberry chat: composer stays reachable above the tab bar ---- */
.chat-thread { min-height: 46dvh; }
.bubble { max-width: 88%; }
.composer { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 6px); background: var(--paper); padding: 8px 0 4px; z-index: 5; }
.composer .btn { min-height: 44px; }

/* ---- forms ---- */
.btn { min-height: 44px; }
.consent-card { margin: 12px 0; }
.consent-actions .btn { flex: 1; }

/* ---- footer ---- */
.footer-note { margin-bottom: 8px; }

/* ---- Earnings "Sweetest first": one tidy row per book (title + pen name, total on the right, money underneath) ---- */
table.cute.pick-table tr { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px; padding: 9px 12px; align-items: start; }
table.cute.pick-table td { padding: 0; }
table.cute.pick-table td::before { content: none; }
table.cute.pick-table td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; justify-content: center; font-size: 1.1rem; color: var(--pink-500); }
table.cute.pick-table td:nth-child(2) { grid-column: 2; grid-row: 1; display: block; text-align: left; font-weight: 400; font-size: .9rem; line-height: 1.35; }
table.cute.pick-table td:nth-child(2) br { display: none; }
table.cute.pick-table td:nth-child(2) .title { display: block; font-weight: 800; }
table.cute.pick-table td:nth-child(5) { grid-column: 3; grid-row: 1; font-size: 1rem; }
table.cute.pick-table td:nth-child(3), table.cute.pick-table td:nth-child(4) { grid-row: 2; font-size: .76rem; color: var(--ink-soft); justify-content: flex-start; }
table.cute.pick-table td:nth-child(3) { grid-column: 2; }
table.cute.pick-table td:nth-child(4) { grid-column: 3; justify-content: flex-end; }
table.cute.pick-table td:nth-child(3)::before { content: 'sales '; font-size: .72rem; margin-right: 3px; }
table.cute.pick-table td:nth-child(4)::before { content: 'KU '; font-size: .72rem; margin-right: 3px; }

/* ---- Bookshelf: a whole series at a glance; books wrap into rows of three (no sideways scrolling) ---- */
body .shelf-page { --bh: 136px; padding: 26px 10px 6px; }
body .shelf-page .shelf-books { flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 16px 10px;
  padding: 22px 2px 0; overflow: visible; }
body .shelf-page .shelf-books > :first-child, body .shelf-page .shelf-books > :last-child { margin-left: 0; margin-right: 0; }
body .shelf-page .shelf-friend { display: none; }
body .shelf-page .book-spine:hover, body .shelf-page .book-spine:focus { transform: translateY(-6px) rotate(-2deg); }

/* a details sheet (book, post) covers the screen: tuck the tab bar away while it's open */
.bottom-nav { transition: transform .3s ease; }
body:has(.drawer.open) .bottom-nav, body:has(.br-drawer.open) .bottom-nav { transform: translateY(110%); }
.br-drawer-body { padding-bottom: calc(30px + var(--safe-b)) !important; }
.drawer-body { padding-bottom: calc(30px + var(--safe-b)); }

/* greeting next to the ribbon on phones */
.hey-phone { display: block; margin-left: auto; font-family: var(--font-hand); font-size: 1.2rem; line-height: 1; color: var(--pink-700);
  text-align: right; min-width: 0; }
.masthead .ribbon { font-size: .95rem; padding: 6px 14px 8px; }


/* ==========================================================================
   ANNAHVERSE frame on phones: a compact top bar, rooms as a tidy grid of doors,
   the village as a list of houses (the map is too small to tap at this size).
   ========================================================================== */
.journal.frame { padding: calc(10px + var(--safe-t)) 12px calc(var(--nav-h) + var(--safe-b) + 24px); margin: 0; max-width: none; }
.topbar { gap: 8px; min-height: 48px; margin-bottom: 8px; }
.topbar .house-strip, .topbar .round-btn, .me-text { display: none; }
.me-chip { padding: 3px; margin-left: auto; border-width: 2px; }
.brand-mark { width: 42px; height: 36px; }
.back-chip { padding: 8px 12px 8px 8px; }
.back-chip span { display: none; }
.place-name { font-size: 1.2rem; }
.place-sub { font-size: .75rem; }

.house-body { flex-direction: column; gap: 10px; }
.rooms-rail { width: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px; border-radius: 18px; }
.rooms-rail .rail-label, .rooms-rail .door.soon { display: none; }
.rooms-rail .door { flex-direction: column; justify-content: center; gap: 2px; min-height: 64px; padding: 6px 4px; text-align: center; }
.rooms-rail .door-text small { display: none; }
.rooms-rail .door-text b { font-size: .82rem; line-height: 1.15; }
.rooms-rail .door .sticker { width: 28px; height: 28px; }
.rooms-rail .door .sticker svg { width: 22px; height: 22px; }

.tile-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile-row-label { grid-column: 1 / -1; }
.stat-tile { padding: 9px 12px; }
.stat-tile b { font-size: 1.3rem; }

.village-grid { grid-template-columns: minmax(0, 1fr); }
.village-page .map-wrap { display: none; }
.house-list { display: grid; gap: 8px; }
.house-card {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 12px 8px 8px; border-radius: 20px;
  background: var(--paper); border: 2px solid var(--line); color: var(--ink); text-decoration: none;
}
.house-card.soon { border-style: dashed; opacity: .85; }
.house-card .pic { width: 52px; height: 52px; border-radius: 16px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--pink-50); }
.house-card .pic svg { width: 42px; height: 38px; }
.house-card .pic-academy { background: var(--midnight); }
.house-card .pic-nook, .house-card .pic-burrow { background: var(--sage-100); }
.house-card .pic-quests { background: #F6E4CE; }
.hc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hc-text b { font: 700 1rem/1.2 var(--font-head); }
.hc-text span { font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.house-card .chev { width: 18px; height: 18px; fill: none; stroke: var(--ink-faint); stroke-width: 2.5; stroke-linecap: round; flex: none; }
.today-panel { margin: 0; }

.parlor-grid { grid-template-columns: minmax(0, 1fr); }
.parlor-grid > .card { margin: 0; }
.mini-shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.theme-academy .house-body > .page { padding: 10px; border-radius: 18px; }
.me-grid, .household-grid { display: flex; flex-direction: column; }
.top-books { grid-template-columns: minmax(0, 1fr); }
.morning-note.phone-first { display: block; margin: 0; }
.today-panel .morning-note { display: none; }
.quest-strip { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; }
.qs-chip { min-height: 40px; }

/* phones: a small refresh button next to your picture (home-screen apps have no reload button) */
.topbar .refresh-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-left: auto; }
.topbar .refresh-btn + .me-chip { margin-left: 6px; }
/* the moon/sun stays on phones too */
.topbar .theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; margin-left: auto; }
.topbar .theme-toggle + .refresh-btn { margin-left: 6px; }
/* grid columns may always shrink to the phone's width (their insides wrap instead of pushing out) */
.upload-grid > *, .br-grid > *, .snail-grid > *, .dash-grid > * { min-width: 0; }
.br-table-list { table-layout: fixed; width: 100%; }
.br-table-list td, .br-table-list th { overflow-wrap: anywhere; }
.br-pill { white-space: normal; }
/* the data banner: one short line on phones (the details are one tap away) */
.data-alert { padding: 5px 12px; font-size: .8rem; margin-top: 6px; }
.data-alert .da-full { display: none; }

/* Did it work?: each post / email is a card (title full width, results below), never a squeezed table */
.br-table-list, .br-table-list tbody, .br-table-list tr, .br-table-list td { display: block; width: 100%; }
.br-table-list thead { display: none; }
.br-table-list tr { padding: 12px 12px 10px; margin-bottom: 10px; border-radius: 18px; border: 2px solid var(--pink-100); background: rgba(255, 255, 255, .55); }
.br-table-list td { padding: 0; border: 0; }
.br-table-list td:first-child { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; margin-bottom: 6px; }
.br-table-list td:not(:first-child) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; font-size: .82rem; }
.br-table-list td:not(:first-child)::before { content: attr(data-label); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); min-width: 96px; }
.br-table-list td:not(:first-child):has(> .muted:only-child) { display: none; }
.br-table-list .br-pill { white-space: normal; }
html[data-theme="dark"] .br-table-list tr { background: rgba(255, 255, 255, .04); }

/* Idea board: flip sideways through the ideas, one per page */
.br-ideas[data-idea-track] { display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: visible; scroll-snap-type: x mandatory; gap: 0;
  padding: 18px 0 6px; margin: 0 -4px; scrollbar-width: none; max-height: none; }
.br-ideas[data-idea-track]::-webkit-scrollbar { display: none; }
.br-ideas[data-idea-track] .br-idea { flex: 0 0 calc(100% - 16px); margin: 0 8px; scroll-snap-align: center; box-sizing: border-box; }
.br-idea-dots { display: flex; justify-content: center; gap: 7px; margin: 8px 0 4px; }
.br-idea-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--pink-200); cursor: pointer; transition: transform .2s, background .2s; }
.br-idea-dots i.on { background: var(--pink-500); transform: scale(1.3); }
.topbar .tea-btn { display: inline-flex !important; width: 38px; height: 38px; margin-left: auto; }
.topbar .tea-form + .theme-toggle { margin-left: 6px; }
