/* Dreamy pastel theme: a soft sky behind the page, frosted cards, delicate illustrations and
   gentle micro-interactions. Everything animated is switched off for prefers-reduced-motion. */

:root {
  --sky-1: #dfeefd;
  --sky-2: #eef6ff;
  --sky-3: #f7faff;
  --sky-4: #f8f3ff;
  --card: rgba(255, 255, 255, .78);
  --card-edge: rgba(255, 255, 255, .95);
  --glow: 0 14px 34px -16px rgba(74, 138, 204, .38), 0 2px 6px -2px rgba(74, 138, 204, .12);
  --glow-lift: 0 20px 40px -16px rgba(74, 138, 204, .48), 0 3px 8px -2px rgba(74, 138, 204, .16);
}

body {
  background-color: var(--sky-3);
  background-image: url("baby-pattern.svg"),
    radial-gradient(1200px 500px at 15% -10%, #d3e7fc 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #e9e2fb 0%, transparent 55%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 30%, var(--sky-3) 65%, var(--sky-4) 100%);
  background-size: 720px 600px, 100% 100%, 100% 100%, 100% 100%;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  background-attachment: fixed, fixed, fixed, fixed;  /* the doodles stay put while the page scrolls */
}

/* ---- Sky: floating clouds and twinkling stars, behind everything ---- */
.dreamy-sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
body > header { position: sticky; top: 0; z-index: 30; }
body > main { position: relative; z-index: 1; }
/* Each cloud keeps its own GPU layer and the shadow sits on the picture, not the moving box: Safari
   could drop a moving, filtered cloud once it left the screen and never draw it again. */
.dreamy-cloud {
  position: absolute; left: 0; opacity: .85;
  animation: dreamy-drift linear infinite;
  will-change: transform; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.js-sky .dreamy-cloud { animation: none; }  /* dreamy.js moves them */
.dreamy-cloud svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 14px rgba(120, 170, 220, .18)); }
.dreamy-bob { animation: dreamy-bob 7s ease-in-out infinite; }
.dreamy-star { position: absolute; animation: dreamy-twinkle 3.2s ease-in-out infinite; }
.dreamy-star svg { display: block; width: 100%; height: auto; }
.dreamy-moon { position: absolute; top: 9%; right: 7%; width: 34px; opacity: .8; animation: dreamy-bob 9s ease-in-out infinite; }
.dreamy-moon svg { display: block; width: 100%; }

/* Starts and ends just off screen, so a cloud never pops in or out at the edge. */
@keyframes dreamy-drift { from { transform: translate3d(calc(-100% - 2vw), 0, 0); } to { transform: translate3d(102vw, 0, 0); } }
@keyframes dreamy-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes dreamy-twinkle {
  0%, 100% { opacity: .35; transform: scale(.75) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.1) rotate(20deg); }
}
@media (max-width: 640px) { .dreamy-sky .hide-sm { display: none; } }

/* ---- Header: frosted glass ---- */
/* Its own soft band (baby blue to lavender), mostly opaque so it stands apart from the page. */
.dreamy-header {
  background: linear-gradient(90deg, rgba(196, 223, 249, .94) 0%, rgba(222, 236, 253, .94) 48%, rgba(229, 220, 250, .94) 100%);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(127, 180, 230, .55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 10px 26px -14px rgba(47, 101, 156, .45);
}
/* The nav links get their own frosted-white strip under the coloured top bar. */
.dreamy-navbar {
  background: rgba(255, 255, 255, .72);
  border-top: 1px solid rgba(255, 255, 255, .9);
  box-shadow: inset 0 1px 0 rgba(127, 180, 230, .25);
}
.dreamy-navbar .dreamy-nav a:hover { background: rgba(220, 236, 251, .8); }
.dreamy-navbar .dreamy-nav a[aria-current="page"] { background: #dcecfb; box-shadow: none; color: #27527f; }

/* The header folds away on phones while scrolling down (see base.html); sticky bars follow it. */
body > header { transition: transform .3s ease; }
body > header.is-tucked { transform: translateY(-100%); }
#category-list > section > div:first-child, .items-table thead th { transition: top .3s ease; }

/* Sliding highlight: one pill that glides to the current tab (positioned by base.html). Until it's
   placed, the current link keeps its own background. */
.nav-indicator { position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 9999px; background: #dcecfb;
  opacity: 0; pointer-events: none; transition: transform .35s cubic-bezier(.3, .8, .3, 1), width .35s cubic-bezier(.3, .8, .3, 1), opacity .2s; }
[data-nav-indicator].indicator-ready .nav-indicator { opacity: 1; }
[data-nav-indicator].indicator-ready a[aria-current="page"] { background: transparent !important; }
[data-nav-indicator] a { position: relative; z-index: 1; }

/* Count bubble for new price drops. */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem;
  margin-left: .35rem; border-radius: 9999px; background: #f08aa8; color: #fff; font-size: .68rem; font-weight: 800; line-height: 1;
  box-shadow: 0 2px 6px -2px rgba(217, 124, 153, .8); vertical-align: .1em; animation: dreamy-pop .4s ease; }
.dreamy-tab .nav-badge { position: absolute; top: -.35rem; right: -.65rem; margin: 0; }

/* Phones: bottom tab bar. */
.dreamy-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-top: 1px solid rgba(127, 180, 230, .45);
  box-shadow: 0 -8px 24px -16px rgba(47, 101, 156, .45);
}
.dreamy-tab { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem 0 .3rem; border-radius: 1rem;
  font-size: .72rem; transition: color .2s, transform .15s; }
.dreamy-tab:active { transform: scale(.94); }
.dreamy-tab[aria-current="page"] { background: #dcecfb; }
@media (max-width: 639px) { body.has-tabbar main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); } }
.dreamy-logo { display: inline-flex; align-items: center; gap: .6rem; }
/* A white cloud with a blue outline reads clearly on the blue header band. */
.dreamy-logo-mark { position: relative; width: 46px; height: 30px; flex: none; filter: drop-shadow(0 3px 6px rgba(47, 101, 156, .25)); }
@media (max-width: 639px) { .dreamy-logo-mark { width: 40px; height: 26px; } .dreamy-logo-mark .star { width: 13px; } }
.dreamy-logo-mark .cloud { position: absolute; inset: 0; width: 100%; height: 100%; }
.dreamy-logo-mark .star { position: absolute; width: 15px; right: -4px; top: -6px; animation: dreamy-twinkle 3s ease-in-out infinite; }
.dreamy-logo-text {
  /* Room below the baseline, or the gradient fill clips the tail of the "y". */
  line-height: 1.3; padding-bottom: .12em; display: inline-block;
  background: linear-gradient(90deg, #2f659c, #5b9bd8 55%, #8a76d6);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dreamy-nav a { border-radius: 9999px; padding: .3rem .8rem; white-space: nowrap; transition: background-color .2s, box-shadow .2s, color .2s; }
@media (max-width: 639px) { .dreamy-nav a { padding: .3rem .5rem; } }
.dreamy-nav a:hover { background: rgba(255, 255, 255, .75); }
.dreamy-nav a[aria-current="page"] { background: #fff; box-shadow: 0 4px 14px -8px rgba(74, 138, 204, .55); }

/* ---- Cards: frosted white with a soft blue glow ---- */
main .bg-white.rounded-lg {
  background: var(--card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: var(--card-edge) !important;
  border-radius: 1.25rem;
  box-shadow: var(--glow);
}
/* Frosted cards are stacking contexts: lift the one with an open pop-up (Rename) above its neighbours. */
#category-list > section { position: relative; }
#category-list > section:has(details[open]) { z-index: 5; }
.dreamy-lift { transition: transform .25s ease, box-shadow .25s ease; }
.dreamy-lift > div:first-of-type { padding-right: 2.25rem; }  /* room for the corner illustration */
.dreamy-lift:hover { transform: translateY(-3px); box-shadow: var(--glow-lift); }
.dreamy-card-deco { position: absolute; right: .75rem; top: .75rem; width: 34px; opacity: 1; transition: transform .4s ease; pointer-events: none; }
.dreamy-lift:hover .dreamy-card-deco { transform: rotate(-8deg) scale(1.08); }
.dreamy-bow { width: 24px; height: 24px; flex: none; transition: transform .3s ease; }
section:hover > div:first-child .dreamy-bow { transform: rotate(-10deg) scale(1.1); }
.dreamy-empty-teddy { width: 72px; margin: 0 auto .5rem; animation: dreamy-bob 5s ease-in-out infinite; }

/* Item rows: a soft tint and a little lift of the name on hover. */
.items-table tr[data-sortable] { transition: background-color .2s ease; }
.items-table tr[data-sortable]:hover { background-color: rgba(220, 236, 251, .45); }
.items-table thead { background: rgba(240, 247, 255, .7) !important; }
/* On desktop each category's column names stick just below the site header while you scroll
   through it. (Sticky needs no scrolling box around the table; at this width the table fits.) */
@media (min-width: 1024px) {
  .items-table-wrap { overflow: visible !important; }  /* beats Tailwind's overflow-x-auto */
  .items-table thead th {
    position: sticky; top: var(--header-height, 0px); z-index: 2;
    background: #f1f7fe; box-shadow: inset 0 -1px 0 rgba(195, 222, 247, .8);
  }
  .is-sorting thead th { position: static; }
}
/* On phones and tablets (item cards, no column names) the category's name bar sticks instead. */
@media (max-width: 1023px) {
  #category-list > section > div:first-child {
    position: sticky; top: var(--header-height, 0px); z-index: 3;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-radius: 1.25rem 1.25rem 0 0;
  }
}
/* Nothing sticks while dragging, so drop positions are measured against the plain layout. */
body:has(.is-sorting) #category-list > section > div:first-child { position: static; }
.items-table tbody tr { border-color: rgba(195, 222, 247, .45) !important; }

/* Keep items distinct. Desktop: clear dividers and a faint tint on every other row.
   Phones and tablets: each item is its own small card on a pale-blue backdrop. */
@media (min-width: 1024px) {
  .items-table tbody tr[data-sortable] { border-top: 1px solid rgba(164, 204, 241, .55) !important; }
  .items-table tbody tr[data-sortable]:nth-child(even) { background-color: rgba(238, 246, 255, .7); }
  .items-table tbody tr[data-sortable]:hover { background-color: rgba(220, 236, 251, .7); }
}
@media (max-width: 1023px) {
  #category-list .items-table tbody { padding: .25rem .6rem .75rem; background: rgba(238, 246, 255, .7); border-radius: 0 0 1.25rem 1.25rem; }
  .items-table tr[data-sortable] {
    margin-top: .6rem; background: #fff; border: 1px solid rgba(164, 204, 241, .7) !important; border-radius: 1rem;
    box-shadow: 0 6px 16px -12px rgba(47, 101, 156, .5);
  }
  .items-table tr[data-sortable]:hover { background: #fff; }
  tbody.is-sorting tr[data-sortable] { margin-top: .35rem; }
}

/* ---- Item rows ---- */
/* Float up softly as they scroll into view (dreamy.js adds .is-visible; without JS they just show). */
.js-reveal .items-table tr[data-sortable]:not(.is-visible) { opacity: 0; transform: translateY(10px); }
.js-reveal .items-table tr[data-sortable] { transition: opacity .5s ease, transform .5s ease, background-color .2s ease; }
/* While dragging, every row is shown at once and still, so drop positions are measured correctly. */
.js-reveal .is-sorting tr[data-sortable] { opacity: 1 !important; transform: none; transition: none; }
/* A tiny star twinkles beside the name on hover, and the drag handle wiggles. */
/* A little blue heart pops in beside the name on hover, then beats gently. */
.item-sparkle { display: inline-block; width: 14px; margin-left: .35rem; vertical-align: -.05em; opacity: 0; transform: scale(.3);
  transition: opacity .25s ease, transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.items-table tr[data-sortable]:hover .item-sparkle { opacity: 1; transform: scale(1); animation: dreamy-heartbeat 1.3s ease-in-out .4s infinite; }
@keyframes dreamy-heartbeat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 30% { transform: scale(.95); } 45% { transform: scale(1.15); } }
.items-table tr[data-sortable]:hover [data-drag-handle] { animation: dreamy-wiggle .5s ease; }
@keyframes dreamy-wiggle { 25% { transform: rotate(-8deg); } 50% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
.is-sorting .item-sparkle { display: none; }
/* Little bursts of stars: when an item is marked Delivered, or ticked as Necessary. */
.dreamy-burst { position: fixed; z-index: 60; width: 16px; height: 16px; pointer-events: none; margin: -8px 0 0 -8px;
  animation: dreamy-burst .9s cubic-bezier(.2, .7, .3, 1) forwards; }
.dreamy-burst svg { display: block; width: 100%; height: 100%; }
@keyframes dreamy-burst {
  0% { opacity: 1; transform: translate(0, 0) scale(.4) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(160deg); }
}

/* ---- Dialogs (e.g. the list behind "Spent so far") ---- */
.dreamy-dialog { width: min(32rem, calc(100vw - 2rem)); padding: 0; border: 1px solid rgba(164, 204, 241, .8); border-radius: 1.25rem;
  background: #fff; color: #2d3e51; box-shadow: 0 30px 60px -20px rgba(31, 65, 99, .45); }
.dreamy-dialog[open] { animation: pop-in .3s ease-out; }
.dreamy-dialog::backdrop { background: rgba(31, 65, 99, .25); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
[data-open-dialog]:focus-visible { outline: 2px solid #8fbbe8; outline-offset: 2px; }

/* ---- Search results ---- */
/* Results land just below the sticky header; matched words are marked and the matches glow briefly. */
#category-list, #category-list tr[data-sortable], #category-list > section { scroll-margin-top: calc(var(--header-height, 0px) + 4.5rem); }
/* "1 of 3 ↑ ↓ ✕" floats above the bottom of the screen (above the tab bar on phones). */
.search-nav { position: fixed; z-index: 45; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: .35rem; padding: .35rem .45rem .35rem .9rem; border-radius: 9999px;
  background: rgba(255, 255, 255, .95); border: 1px solid rgba(143, 187, 232, .8); box-shadow: 0 10px 28px -14px rgba(47, 101, 156, .6);
  font-size: .85rem; color: #27527f; white-space: nowrap; max-width: calc(100vw - 1.5rem); }
.search-nav > span { overflow: hidden; text-overflow: ellipsis; }
.search-nav button, .search-nav a { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem;
  border-radius: 9999px; color: #3b77b5; font-weight: 700; }
.search-nav button:hover, .search-nav a:hover { background: #dcecfb; }
@media (max-width: 639px) { body.has-tabbar .search-nav { bottom: calc(4.75rem + env(safe-area-inset-bottom)); } }
.search-mark { background: #fde9a6; color: inherit; border-radius: .25rem; padding: 0 .1em; }
.items-table tr[data-sortable].search-hit { animation: dreamy-search-glow 2.2s ease-out; }
@keyframes dreamy-search-glow { 0%, 40% { box-shadow: 0 0 0 3px rgba(143, 187, 232, .9); background-color: #eef6ff; } 100% { box-shadow: 0 0 0 0 rgba(143, 187, 232, 0); } }

/* ---- Drag and drop (reorder.js / SortableJS) ---- */
/* The handle: a light six-dot grip, no box. The visible dots are small but the grab area is
   comfortable. On devices with a mouse it stays faint until you hover the row. */
.drag-grip { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.75rem;
  margin-left: -.35rem; border-radius: .5rem; color: #9fb6cd; cursor: grab;
  /* On touch screens a press on the grip starts a drag, never scrolling, text selection or a callout. */
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  transition: color .15s ease, background-color .15s ease, opacity .15s ease; }
.drag-grip:hover { color: #3b77b5; background: rgba(220, 236, 251, .75); }
.drag-grip:focus-visible { outline: 2px solid #8fbbe8; outline-offset: 1px; opacity: 1; color: #3b77b5; }
@media (hover: hover) {
  .items-table tr[data-sortable] .drag-grip, #category-list > section > div:first-child .drag-grip { opacity: .45; }
  .items-table tr[data-sortable]:hover .drag-grip, #category-list > section > div:first-child:hover .drag-grip,
  .drag-chosen .drag-grip, .drag-grip:focus-visible { opacity: 1; }
}
/* The entry being dragged floats under the pointer as a lifted card... */
.drag-lifted {
  opacity: 1 !important; background: #fff !important; border-radius: 1rem !important;
  box-shadow: 0 22px 44px -18px rgba(47, 101, 156, .55), 0 0 0 2px rgba(164, 204, 241, .9) !important;
  transform: scale(1.02); cursor: grabbing;
}
tr.drag-lifted { display: flex !important; align-items: center; box-sizing: border-box; padding: 0; overflow: hidden; }
tr.drag-lifted > td { padding: .25rem .5rem !important; }
tr.drag-lifted > td:not(:first-child), tr.drag-lifted [id^="priceinfo-"], tr.drag-lifted .item-notes, tr.drag-lifted .item-sparkle,
section.drag-lifted > :not(:first-child) { display: none !important; }
section.drag-lifted > :first-child { border-bottom: 0; }
/* ...while a dashed, softly glowing gap shows where it will land. */
.drag-placeholder { background: rgba(220, 236, 251, .65) !important; outline: 2px dashed #8fbbe8; outline-offset: -4px; border-radius: .9rem; }
.drag-placeholder > * { visibility: hidden; }
.drag-chosen [data-drag-handle] { background: #dcecfb; color: #3b77b5; }
/* The category an item will drop into glows. */
#category-list > section { transition: box-shadow .2s ease, transform .2s ease; }
#category-list > section.drop-target { box-shadow: 0 0 0 3px rgba(143, 187, 232, .85), var(--glow-lift); }
#category-list > section.drop-target h2 { color: #2f659c; }
body:has(.drag-lifted), body:has(.drag-lifted) * { cursor: grabbing !important; user-select: none; }

/* ---- Micro-interactions ---- */
main button, main a.rounded-md, main a.rounded-full, main summary,
header button, .dreamy-nav a { transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease; }
main button:active, main a.rounded-md:active, header button:active { transform: scale(.96); }
main button.rounded-md:hover:not(:disabled), main a.rounded-md:hover { box-shadow: 0 6px 16px -10px rgba(74, 138, 204, .7); }
input[type="checkbox"]:checked { animation: dreamy-pop .35s ease; }
@keyframes dreamy-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid #a4ccf1; outline-offset: 2px; }
main input, main select, main textarea { transition: border-color .2s, box-shadow .2s; }
main input:focus, main select:focus, main textarea:focus { box-shadow: 0 0 0 4px rgba(164, 204, 241, .35); }

/* Flash messages float in. */
.dreamy-flash { animation: dreamy-float-in .5s ease-out; border-radius: 1rem; }
@keyframes dreamy-float-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Progress bars shimmer gently. */
.dreamy-shimmer { position: relative; overflow: hidden; }
.dreamy-shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .65) 50%, transparent 80%);
  transform: translateX(-100%); animation: dreamy-shimmer 3.5s ease-in-out infinite;
}
@keyframes dreamy-shimmer { 60%, 100% { transform: translateX(100%); } }

/* Headings in the rounded display face. */
/* Headings in the rounded display face. */
main h1, main h2 { font-family: Quicksand, Nunito, sans-serif; letter-spacing: -.01em; }

@media (prefers-reduced-motion: reduce) {
  .dreamy-cloud, .dreamy-bob, .dreamy-star, .dreamy-moon, .dreamy-logo-mark .star, .dreamy-empty-teddy,
  .dreamy-flash, .dreamy-shimmer::after, input[type="checkbox"]:checked,
  .items-table tr[data-sortable]:hover .item-sparkle, .items-table tr[data-sortable]:hover [data-drag-handle] { animation: none !important; }
  .dreamy-burst { display: none; }
  .items-table tr[data-sortable].search-hit { animation: none; }
  .nav-indicator, body > header, #category-list > section > div:first-child, .items-table thead th { transition: none; }
  .drag-lifted { transform: none; }
  .dreamy-lift, .dreamy-lift:hover, .dreamy-lift:hover .dreamy-card-deco { transform: none !important; transition: none; }
  main button:active, main a.rounded-md:active, header button:active { transform: none; }
}

/* ---- Photos page ---- */
[data-drop-zone] { transition: box-shadow .2s ease, background-color .2s ease; }
[data-drop-zone].is-drop-target { box-shadow: 0 0 0 3px rgba(143, 187, 232, .9), var(--glow-lift); background-color: #f2f8ff; }
.upload-row { padding: .5rem .75rem; border-radius: .75rem; background: #f4f9ff; border: 1px solid #dcecfb; transition: opacity .4s ease; }
.upload-bar { margin-top: .35rem; height: .35rem; border-radius: 9999px; background: #dcecfb; overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #8fbbe8, #b9a6ef); transition: width .2s ease; }
.upload-row.is-done { opacity: .6; }
.upload-row.is-done .upload-bar span { background: #7fcfa6; }
.upload-row.is-failed { background: #fff3ee; border-color: #f7c9b5; cursor: pointer; }
.upload-row.is-failed [data-state] { color: #c25a35; font-weight: 600; }

.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .375rem; }
@media (min-width: 640px) { .media-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; } }
@media (min-width: 1024px) { .media-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.media-tile { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: .9rem; background: linear-gradient(135deg, #e6f1fc, #ece6fb);
  border: 1px solid rgba(164, 204, 241, .7); transition: transform .2s ease, box-shadow .2s ease; }
.media-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(47, 101, 156, .55); }
.media-tile:focus-visible { outline: 3px solid #8fbbe8; outline-offset: 2px; }
.media-tile img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.media-tile-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.75rem; opacity: .7; }
.media-tile-badge { position: absolute; z-index: 2; right: .35rem; bottom: .35rem; display: inline-flex; align-items: center; gap: .2rem;
  padding: .1rem .4rem; border-radius: 9999px; background: rgba(31, 49, 72, .62); color: #fff; font-size: .68rem; font-weight: 700; }
.media-tile-comments { position: absolute; z-index: 2; left: .35rem; bottom: .35rem; display: inline-flex; align-items: center; gap: .2rem;
  padding: .1rem .4rem; border-radius: 9999px; background: rgba(31, 49, 72, .62); color: #fff; font-size: .68rem; font-weight: 700; }
.media-tile-comments[hidden] { display: none; }

.media-viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #111b29; color: #fff; overflow: hidden; }
.media-viewer[open] { display: flex; flex-direction: column; animation: pop-in .25s ease-out; }
.media-viewer::backdrop { background: rgba(17, 27, 41, .7); }
.media-viewer-bar { display: flex; align-items: center; justify-content: space-between; padding: calc(.5rem + env(safe-area-inset-top)) .75rem .5rem; }
.media-viewer-count { font-size: .8rem; font-weight: 700; color: rgba(255, 255, 255, .75); }
.media-viewer-btn { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 9999px; color: #fff; }
.media-viewer-btn:hover { background: rgba(255, 255, 255, .12); }
.media-viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 .5rem; touch-action: pan-y pinch-zoom; }
.media-viewer-stage img, .media-viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: .5rem;
  background-size: contain; background-position: center; background-repeat: no-repeat; }
.media-viewer-note { max-width: 20rem; text-align: center; color: rgba(255, 255, 255, .8); }
.media-viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
  border-radius: 9999px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 2rem; line-height: 1; padding-bottom: .2rem; }
.media-viewer-nav:hover { background: rgba(255, 255, 255, .25); }
.media-viewer-nav[hidden] { display: none; }
@media (hover: none) { .media-viewer-nav { display: none; } }
.media-viewer-info { display: flex; flex-direction: column; gap: .5rem; padding: .6rem .9rem calc(.75rem + env(safe-area-inset-bottom)); }
.media-comments { display: flex; flex-direction: column; gap: .4rem; max-height: 26dvh; overflow-y: auto; overscroll-behavior: contain; }
.media-comments:empty { display: none; }
.media-comment { padding: .4rem .7rem; border-radius: .9rem; background: rgba(255, 255, 255, .1); font-size: .85rem; line-height: 1.35; }
.media-comment p { white-space: pre-line; overflow-wrap: anywhere; }
.media-comment-head { display: flex; align-items: baseline; gap: .5rem; font-size: .72rem; color: rgba(255, 255, 255, .6); }
.media-comment-head b { color: #fff; font-weight: 700; }
.media-comment-delete { margin-left: auto; color: rgba(255, 255, 255, .5); }
.media-comment-delete:hover { color: #ffb4b4; }
.media-comments-empty { font-size: .8rem; color: rgba(255, 255, 255, .5); }
.media-comment-form { display: flex; align-items: center; gap: .5rem; }
.media-comment-form input { flex: 1; min-width: 0; padding: .45rem .85rem; border-radius: 9999px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1); color: #fff; font-size: .875rem; }
.media-comment-form input::placeholder { color: rgba(255, 255, 255, .55); }
.media-comment-form input:focus { outline: none; border-color: #8fbbe8; background: rgba(255, 255, 255, .16); }
.media-viewer-nav:active { transform: translateY(-50%) scale(.94); }

/* ---- Category panel (home page) ---- */
.category-panel-inner { position: sticky; top: calc(var(--header-height, 0px) + 1.5rem); max-height: calc(100vh - var(--header-height, 0px) - 3rem);
  overflow-y: auto; margin-top: 1.5rem; padding: .75rem .5rem; border-radius: 1.25rem; background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(164, 204, 241, .7); box-shadow: 0 14px 30px -20px rgba(47, 101, 156, .45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: top .3s ease; }
.category-panel-title { margin: 0 .5rem .4rem; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #64748b; }
.category-link { display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem; border-radius: .8rem; font-size: .85rem; font-weight: 600;
  color: #475569; transition: background-color .15s ease, color .15s ease; }
.category-link:hover { background: #eef6ff; color: #2f659c; }
.category-link.is-current { background: #dcecfb; color: #1f4f80; }
.category-link > svg { width: 22px; height: 22px; flex-shrink: 0; transform: none !important; }
.category-link-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-link-count { flex-shrink: 0; font-size: .7rem; font-weight: 700; color: #94a3b8; font-variant-numeric: tabular-nums; }
.category-link.is-current .category-link-count { color: #4a8acc; }

.category-fab { position: fixed; z-index: 35; left: 1rem; bottom: 1.25rem; display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem .9rem; border-radius: 9999px; background: rgba(255, 255, 255, .94); color: #2f659c; font-size: .8rem; font-weight: 700;
  border: 1px solid rgba(127, 180, 230, .7); box-shadow: 0 10px 24px -12px rgba(47, 101, 156, .6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none; transform: translateY(.5rem); transition: opacity .2s ease, transform .2s ease; }
.category-fab.is-shown { opacity: 1; pointer-events: auto; transform: none; }
@media (max-width: 639px) {
  body.has-tabbar .category-fab { bottom: calc(4.6rem + env(safe-area-inset-bottom)); padding: .6rem; }
  .category-fab span { display: none; }
}
.category-drawer { position: fixed; inset: 0 auto 0 0; width: min(19rem, 85vw); height: 100dvh; max-height: none; margin: 0; padding: 0;
  padding-top: env(safe-area-inset-top); border: 0; border-radius: 0 1.5rem 1.5rem 0; background: #fff; overflow-y: auto;
  box-shadow: 20px 0 50px -20px rgba(31, 65, 99, .45); }
.category-drawer[open] { animation: drawer-in .25s ease-out; }
.category-drawer::backdrop { background: rgba(31, 65, 99, .25); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.category-drawer .category-link { padding: .65rem .6rem; font-size: .95rem; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .category-drawer[open] { animation: none; } }
body:has(#search-nav) .category-fab { bottom: calc(4.4rem + env(safe-area-inset-bottom)); }
@media (max-width: 639px) { body.has-tabbar:has(#search-nav) .category-fab { bottom: calc(8rem + env(safe-area-inset-bottom)); } }
.category-add { margin-top: .35rem; padding-top: .4rem; border-top: 1px dashed rgba(164, 204, 241, .9); }
.category-add-toggle { list-style: none; display: flex; align-items: center; gap: .5rem; padding: .45rem .5rem; border-radius: .8rem; cursor: pointer;
  font-size: .85rem; font-weight: 700; color: #4a8acc; transition: background-color .15s ease; }
.category-add-toggle::-webkit-details-marker { display: none; }
.category-add-toggle:hover { background: #eef6ff; }
.category-add-toggle svg { box-sizing: content-box; padding: 2px; border-radius: 9999px; background: #dcecfb; transition: transform .2s ease; }
.category-add[open] .category-add-toggle svg { transform: rotate(45deg); }

/* ---- Photo albums ---- */
.album-strip { display: flex; gap: .6rem; overflow-x: auto; padding: .25rem .1rem .6rem; scroll-snap-type: x proximity; scrollbar-width: thin; }
.album-card { flex: 0 0 auto; width: 6.75rem; scroll-snap-align: start; display: flex; flex-direction: column; gap: .2rem; padding: .4rem;
  border-radius: 1rem; background: rgba(255, 255, 255, .82); border: 1px solid rgba(164, 204, 241, .7); color: #334155;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease; }
.album-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -14px rgba(47, 101, 156, .6); }
.album-card.is-current { background: #dcecfb; border-color: #8fbbe8; box-shadow: 0 0 0 2px rgba(143, 187, 232, .55); }
.album-cover { position: relative; display: grid; place-items: center; aspect-ratio: 1; overflow: hidden; border-radius: .7rem;
  background: linear-gradient(135deg, #e6f1fc, #ece6fb); color: #4a8acc; }
.album-cover img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.album-cover-icon { width: 42%; height: auto; }
.album-cover-new { background: #f4f9ff; border: 2px dashed #b9d6f2; color: #6fa8de; }
.album-name { font-size: .78rem; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 .1rem; }
.album-count { font-size: .68rem; font-weight: 700; color: #94a3b8; padding: 0 .1rem; }
.album-new > summary { list-style: none; display: flex; flex-direction: column; gap: .2rem; cursor: pointer; }
.album-new > summary::-webkit-details-marker { display: none; }
.album-new[open] { width: 14rem; }
.album-new[open] .album-cover { display: none; }
.album-new-form { margin-top: .35rem; }
.album-page-cover { width: 3.25rem; flex-shrink: 0; }

.media-tile-check { position: absolute; z-index: 3; top: .4rem; left: .4rem; display: none; place-items: center; width: 1.4rem; height: 1.4rem;
  border-radius: 9999px; border: 2px solid #fff; background: rgba(31, 49, 72, .25); color: transparent; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
body.is-selecting .media-tile-check { display: grid; }
.media-tile.is-selected { box-shadow: 0 0 0 3px #4a8acc; transform: scale(.94); }
.media-tile.is-selected .media-tile-check { background: #4a8acc; color: #fff; }
.select-bar { position: fixed; z-index: 45; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem .45rem 1rem; border-radius: 9999px; white-space: nowrap;
  background: rgba(255, 255, 255, .96); border: 1px solid rgba(143, 187, 232, .8); color: #27527f; box-shadow: 0 12px 30px -14px rgba(47, 101, 156, .65); }
.select-bar[hidden] { display: none; }
@media (max-width: 639px) { body.has-tabbar .select-bar { bottom: calc(4.75rem + env(safe-area-inset-bottom)); } }
.media-viewer-album { max-width: 9.5rem; padding: .3rem 1.6rem .3rem .7rem; border-radius: 9999px; border: 1px solid rgba(255, 255, 255, .25);
  background-color: rgba(255, 255, 255, .1); color: #fff; font-size: .8rem; }
.media-viewer-album option { color: #1e293b; }

/* Summary cards: the dollar and rupee totals share one size, as big as fits the card (up to 1.5rem). */
#summary .dreamy-lift { container-type: inline-size; }
.summary-amount { font-size: clamp(.95rem, 13.5cqi, 1.5rem); line-height: 1.25; }
