/* =========================================================
   1. COLOUR PALETTE (variables)
   Define colours once here, then reuse them everywhere with var(--name).
   The look: Spotify's deep black and rounded cards,
   with Apple Music's red-pink as the main colour.
   ========================================================= */
:root {
  --bg: #121212;            /* page background (Spotify black) */
  --card: #1c1c1e;          /* cards (Apple's dark grey) */
  --card-hover: #252528;    /* cards when you hover them */
  --inset: #141416;         /* things inside cards: inputs, list rows */
  --border: #2c2c30;        /* thin lines */
  --text: #f5f5f7;          /* main text (Apple off-white) */
  --muted: #a1a1a6;         /* secondary text (Apple grey) */

  --accent: #e63946;        /* main colour (SubTrack red) */
  --accent-hover: #ef4f5b;
  --accent-soft: #e6394622; /* the same red, see-through, for backgrounds */
  --gradient: linear-gradient(135deg, #e63946, #a4161a);   /* red to deep red */

  /* The logo: a white square with a red "S", so it stands out on the red header.
     Want to try blue? Change these two lines to:  --logo: #0a84ff;  --logo-text: white; */
  --logo: #ffffff;
  --logo-text: var(--accent);

  --save: #1ed760;          /* money saved (Spotify green) */
  --save-soft: #1ed76022;
  --warn: #ffb547;          /* due soon (orange) */
  --info: #4cc2ff;          /* trial / yearly (blue) */

  --radius: 16px;           /* how round card corners are */
  --pill: 999px;            /* fully round ends, for buttons and tags */
}

/* =========================================================
   2. BASE STYLES: the whole page
   ========================================================= */
* {
  box-sizing: border-box;   /* makes widths include padding (easier sizing) */
}

/* Anything with the "hidden" attribute stays hidden,
   even if another rule gives it a display value */
[hidden] {
  display: none !important;
}

/* Hidden on screen, but still read out by screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body {
  margin: 0;
  /* Very dark, with a hint of purple. The coloured glow on top is the #ambient layer (below). */
  background: linear-gradient(180deg, #0f0d14, #09080c) fixed;
  background-color: var(--bg);
  color: var(--text);
  /* Figtree comes from Google Fonts (see index.html); the rest are backups */
  font-family: "Figtree", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Jumping to a part of the page (e.g. "See how") scrolls there smoothly */
html {
  scroll-behavior: smooth;
}

/* ---------- The glow behind every page ----------
   Big soft blobs of colour that slowly drift. Their colour is --ambient:
   SubTrack red, or the app you're looking at on Deals (setAmbient in helpers.js).
   "@property" tells the browser --ambient is a colour, so it can fade smoothly
   from one colour to the next instead of jumping. */
@property --ambient {
  syntax: "<color>";
  inherits: true;
  initial-value: #e63946;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;                     /* behind everything */
  pointer-events: none;            /* clicks go straight through it */
  overflow: hidden;
  transition: --ambient 1.2s ease;
  background:
    radial-gradient(60% 45% at 12% -5%, color-mix(in srgb, var(--ambient) 34%, transparent), transparent 70%),
    radial-gradient(45% 40% at 95% 8%, color-mix(in srgb, var(--ambient) 20%, transparent), transparent 70%),
    radial-gradient(70% 50% at 50% 115%, #3a0ca322, transparent 70%);
}

.ambient::after {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(28% 28% at 30% 40%, color-mix(in srgb, var(--ambient) 16%, transparent), transparent 70%),
    radial-gradient(24% 24% at 75% 65%, #4361ee14, transparent 70%);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6%, 4%) scale(1.1); }
}

/* Switching tabs: a soft cross-fade (where the browser supports View Transitions) */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
}

h1, h2, h3 {
  margin-top: 0;
}

h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* =========================================================
   3. HEADER: logo on the left, bell + currency on the right.
   "sticky" keeps it at the top while you scroll.
   ========================================================= */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  padding-top: calc(12px + env(safe-area-inset-top));   /* room for the iPhone notch when opened from the home screen */
  /* The same deep red all the way across, a little lighter at the top */
  background: linear-gradient(180deg, #b9161f 0%, #8e1017 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* ---- Page tabs (in the middle of the header on big screens) ---- */
#tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.3);              /* darker, see-through, so the red shows through */
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--pill);
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--pill);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;      /* links are underlined by default; not these */
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;   /* no grey/red flash when tapped on phones */
}

.tab:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

/* The page you're on: a white pill with red text */
.tab.active {
  background: white;
  color: var(--accent);
}

.tab-icon {
  font-size: 0.95rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* The logo: a square with "S" in it (colours set at the top of this file) */
.logo-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;       /* centre the letter */
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--logo);
  color: var(--logo-text);
  font-weight: 800;
  font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

header select {
  width: auto;               /* the currency dropdown only needs to fit "AUD" */
  padding: 8px 12px;
  border-radius: var(--pill);
  background: rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.15);
}

header select option {
  background: var(--card);  /* the drop-down list itself stays dark */
}

/* ---- The 🔔 bell and its alerts panel ---- */
#bell-wrap {
  position: relative;        /* the panel is positioned relative to this box */
}

#bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 1.05rem;
}

#bell:hover {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.4);
}

/* The number in the bell's corner: white with red text, so it shows up on the red header */
#bell-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--pill);
  background: white;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* The panel drops down under the bell, on top of everything else */
#bell-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(400px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  z-index: 30;               /* higher number = drawn on top */
}

#bell-panel h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

#bell-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#bell-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

#bell-list li:last-child {
  border-bottom: none;
}

#bell-list li span {
  flex: 1;
}

#bell-list button {
  font-size: 0.8rem;
  padding: 6px 12px;
  white-space: nowrap;
}

#bell-list .empty {
  color: var(--muted);
}

/* =========================================================
   4. LAYOUT: one centred column of cards
   ========================================================= */
main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1180px;
  margin: 28px auto;          /* "auto" centres it on the page */
  padding: 0 32px;
}

/* Every section looks like a card made of see-through "glass",
   so the coloured glow behind the page shows through a little */
section {
  scroll-margin-top: 84px;    /* when we jump to a section, leave room for the sticky header */
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px;
  padding: 24px;
}

/* A section's heading row: title on the left, a button on the right */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
}


.section-note {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Each page fades and slides in a little when you open it */
.page {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: page-in 0.25s ease-out;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   5. HOME DASHBOARD
   ========================================================= */

/* Home is one column of rows, top to bottom, like a streaming app's home screen.
   Bigger gaps between the rows give it room to breathe. */
#page-home {
  gap: 34px;
}

/* ---- The greeting (inside the banner): "Good evening 👋 · Tuesday 20 October" ---- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 26px;
  font-size: 0.95rem;
  font-weight: 600;
}

.page-head #today-date {
  color: rgba(255, 255, 255, 0.65);
}

.page-head #today-date::before {
  content: "·";
  margin-right: 10px;
}

/* ---- Four quick-fact tiles ---- */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

/* Each tile: see-through "glass", so the glow behind the page shows through */
.quick-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  transition: transform 0.5s var(--ease), background 0.3s, border-color 0.3s;
}

.quick-stat:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}

/* The round icon at the top of each tile: red and white, taking turns */
.quick-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #ff8a93;
}

.quick-icon svg {
  width: 18px;
  height: 18px;
}

.quick-stat:nth-child(even) .quick-icon {
  background: #ffffff14;      /* every 2nd tile: soft white */
  color: var(--text);
}

.quick-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-value {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;    /* "…" if it's too long to fit */
}

.quick-note {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- The welcome message: small and quiet, with a red edge ---- */
.intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(90deg, #e6394614, transparent 70%), var(--card);
  border-left: 3px solid var(--accent);
}

.intro-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-hover);
}

.intro p {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 640px;
}

.intro-points {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.intro-points span {
  padding: 3px 10px;
  border-radius: var(--pill);
  background: #ffffff0f;
  font-size: 0.8rem;
  font-weight: 600;
}

/* The ✕ in the corner */
.intro-close {
  margin-left: auto;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
}

.intro-close:hover {
  background: #ffffff14;
  color: var(--text);
}

/* A smaller button, e.g. in Settings */
button.small {
  margin-top: 12px;
  padding: 7px 14px;
  font-size: 0.85rem;
}

/* ---- The big banner at the top of Home ----
   Like the Spotlight on Deals: SubTrack red glowing on the right, fading to near-black,
   with your app logos fanned out on the right. */
.home-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 380px;
  padding: 40px 48px;
  border: none;
  border-radius: 28px;
  overflow: hidden;
  color: white;
  background:
    radial-gradient(60% 90% at 85% 20%, #ff6b6bcc, transparent 70%),
    radial-gradient(50% 80% at 70% 100%, #a4161acc, transparent 70%),
    linear-gradient(100deg, #120a0e 30%, #6b0f16);
  box-shadow: 0 40px 80px -40px #000;
}

.home-hero-text {
  position: relative;
  z-index: 1;                 /* text above the logos */
  flex: 1;
  min-width: 0;
  max-width: 560px;
}

/* Things in the banner rise in one after another when the page opens */
.home-hero-text > * {
  animation: rise 0.8s var(--ease) both;
}
.home-hero-text > :nth-child(2) { animation-delay: 0.06s; }
.home-hero-text > :nth-child(3) { animation-delay: 0.12s; }
.home-hero-text > :nth-child(4) { animation-delay: 0.18s; }
.home-hero-text > :nth-child(5) { animation-delay: 0.24s; }
.home-hero-text > :nth-child(6) { animation-delay: 0.3s; }
.home-hero-text > :nth-child(7) { animation-delay: 0.36s; }

.home-hero .hero-label,
.home-hero .hero-sub,
.home-hero .hero-total span,
.home-hero .category-legend .amount {
  color: rgba(255, 255, 255, 0.75);   /* white, slightly see-through */
}

.home-hero .category-bar {
  max-width: 420px;
  background: rgba(255, 255, 255, 0.12);
}

/* ---- Your logos, fanned out like album covers ----
   --n is each cover's place (0 = front). Each one sits a bit further left,
   turned a little more, and they gently float up and down at different times. */
.hero-covers {
  position: relative;
  flex-shrink: 0;
  width: 300px;
  height: 260px;
}

.cover {
  position: absolute;
  top: 50%;
  right: 10px;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  margin-top: -75px;
  border-radius: 32px;
  background:
    radial-gradient(120% 90% at 20% 0%, color-mix(in srgb, var(--brand), white 22%), transparent 60%),
    linear-gradient(160deg, var(--brand), color-mix(in srgb, var(--brand) 45%, #050507));
  box-shadow:
    0 24px 50px -16px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  transform: translateX(calc(var(--n) * -38px)) rotate(calc(var(--n) * -7deg)) scale(calc(1 - var(--n) * 0.07));
  animation:
    cover-in 0.9s var(--ease) both calc(var(--n) * 0.1s + 0.15s),
    float 5s ease-in-out infinite alternate calc(var(--n) * -1.1s);
  transition: transform 0.6s var(--ease);
}

.cover img {
  width: 46%;
  height: 46%;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
}

/* Hover the banner: the covers spread out further */
.home-hero:hover .cover {
  transform: translateX(calc(var(--n) * -52px)) rotate(calc(var(--n) * -10deg)) scale(calc(1 - var(--n) * 0.07));
}

/* No subscriptions yet: one white "S" cover */
.cover-empty {
  background: #fff;
  color: var(--accent);
  font-size: 4rem;
  font-weight: 800;
}

/* "translate" moves it up and down without touching the "transform" above */
@keyframes float {
  from { translate: 0 6px; }
  to   { translate: 0 -10px; }
}

@keyframes cover-in {
  from { opacity: 0; translate: 80px 0; }
  to   { opacity: 1; translate: 0 0; }
}

.hero-label {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.hero-total {
  display: flex;
  align-items: baseline;      /* line "/month" up with the bottom of the big number */
  gap: 6px;
  margin-top: 2px;
}

.hero-total strong {
  font-size: clamp(2.8rem, 6vw, 4.2rem);   /* grows with the screen */
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;      /* every digit the same width, so counting up doesn't wobble */
}

.hero-total span {
  color: var(--muted);
  font-weight: 600;
}

.hero-sub {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- Spending bar: one bar split into coloured parts ---- */
.category-bar {
  display: flex;
  height: 12px;
  margin: 20px 0 12px;
  border-radius: var(--pill);
  overflow: hidden;           /* round off the ends of the coloured parts */
  background: var(--inset);
  gap: 3px;
}

.category-bar span {
  height: 100%;
  transition: width 0.4s ease;
}

.category-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.85rem;
}

.category-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.category-legend .amount {
  color: var(--muted);
}

/* ---- "You could save": a see-through glass panel inside the banner ---- */
.save-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 420px;
  margin-top: 22px;
  padding: 12px 12px 12px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
}

.save-card .hero-label {
  font-size: 0.8rem;
}

.save-card strong {
  color: var(--save);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.save-card .per-year {
  margin-left: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

.save-card button {
  flex-shrink: 0;
}

/* ---- The 14-day strip: one small tile per day ---- */
.day-strip {
  display: grid;
  grid-template-columns: repeat(14, minmax(44px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
  overflow-x: auto;           /* scroll sideways on small screens */
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px;
  border-radius: 12px;
  background: var(--inset);
  border: 1px solid var(--border);
}

.day .weekday {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.day .date {
  font-size: 1.1rem;
  font-weight: 800;
}

.day .dots {
  display: flex;
  gap: 3px;
  height: 7px;                /* keeps every tile the same height, dots or not */
}

.day .dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* A day with something on: red-tinted */
.day.busy {
  background: var(--accent-soft);
  border-color: #e6394666;
  cursor: help;               /* the tooltip says what's on */
}

/* Today: solid red */
.day.today {
  background: var(--accent);
  border-color: var(--accent);
}

.day.today .weekday {
  color: rgba(255, 255, 255, 0.85);
}

/* ---- "Coming up": a row of cards you can swipe, each glowing in its app's colour ----
   (the row itself is a .shelf-track, like on Deals; two classes = this rule wins) */
.shelf-track.upcoming-list {
  grid-auto-columns: 210px;
}

.upcoming-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border-radius: 20px;
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--brand) 50%, transparent), transparent 70%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.upcoming-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 22px 40px -18px color-mix(in srgb, var(--brand) 85%, transparent);
}

.upcoming-card .app-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 0.95rem;
  margin-bottom: 10px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
}

.upcoming-card .when {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.upcoming-card.soon .when {
  color: var(--warn);         /* orange when it's 3 days away or less */
}

.upcoming-card .name {
  font-weight: 700;
  line-height: 1.25;
}

.upcoming-card .what {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- Next 6 months: a simple bar chart ----
   One colour (it's one series: your spending), thin bars with rounded tops,
   and the amount shows on the biggest month, or when you hover/tap a month */
.forecast-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.forecast-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border-radius: 10px;
  outline: none;
  cursor: default;
}

.forecast-col:hover,
.forecast-col:focus-visible {
  background: #ffffff08;    /* a faint highlight behind the month you're on */
}

/* The amount above the bar: hidden, except on the biggest month or the one you hover/tap */
.forecast-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  visibility: hidden;
}

.forecast-col.peak .forecast-value,
.forecast-col:hover .forecast-value,
.forecast-col:focus .forecast-value {
  visibility: visible;
}

/* The tall box the bar grows up from, with a thin line at the bottom (the baseline) */
.forecast-track {
  display: flex;
  align-items: flex-end;    /* bars grow from the bottom */
  justify-content: center;
  width: 100%;
  height: 140px;
  border-bottom: 1px solid var(--border);
}

.forecast-bar {
  width: min(44px, 70%);
  background: linear-gradient(180deg, #ff6b6b, #e63946b3);   /* our red, lighter at the top */
  border-radius: 8px 8px 2px 2px;
  transform-origin: bottom;
  transition: height 0.4s ease, background 0.15s, transform 1s var(--ease);
  transition-delay: 0s, 0s, calc(var(--i, 0) * 80ms + 150ms);
}

/* Before you scroll to the chart, the bars are flat; then they grow up one after another */
#forecast.reveal:not(.shown) .forecast-bar {
  transform: scaleY(0);
}

.forecast-col.peak .forecast-bar,
.forecast-col:hover .forecast-bar,
.forecast-col:focus .forecast-bar {
  background: var(--accent);   /* full red on the biggest month and the one you hover */
}

.forecast-month {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

/* ---- "Ways to save": a row of cards, each tinted in its app's colour ---- */
.shelf-track.savings-list {
  grid-auto-columns: 300px;
}

.saving-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: 22px;
  background:
    radial-gradient(110% 90% at 100% 0%, color-mix(in srgb, var(--brand) 40%, transparent), transparent 70%),
    linear-gradient(160deg, #1ed76014, rgba(255, 255, 255, 0.03));
  border: 1px solid #1ed76033;
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.saving-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 22px 40px -18px #1ed76055;
}

.saving-card .app-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  margin-bottom: 6px;
}

.saving-amount {
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--pill);
  background: var(--save-soft);
  color: var(--save);
  font-weight: 800;
  font-size: 0.85rem;
}

/* Before → after: old price crossed out, new price big and green */
.saving-compare {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.saving-compare .old {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 600;
}

.saving-compare .arrow {
  color: var(--muted);
}

.saving-compare .new {
  color: var(--save);
  font-size: 1.35rem;
  font-weight: 800;
}

.saving-text {
  margin: 0;
  flex: 1;
  font-size: 0.88rem;
  color: var(--muted);
}

.saving-card button {
  align-self: flex-start;
  padding: 7px 14px;
  font-size: 0.85rem;
}

/* ---- The two cards at the end of Home (links to Deals and TrackBot) ----
   Compact: icon on the left, words in the middle, an arrow on the right */
.cta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.cta-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cta-card:hover {
  transform: translateY(-2px);   /* lifts up a little */
}

.cta-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.2rem;
}

.cta-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.cta-card strong {
  font-size: 1.02rem;
  font-weight: 800;
}

.cta-text span {
  font-size: 0.85rem;
}

.cta-go {
  font-size: 1.3rem;
  font-weight: 700;
  transition: transform 0.15s;
}

.cta-card:hover .cta-go {
  transform: translateX(4px);    /* the arrow nudges right on hover */
}

/* Red card: white text */
.cta-red {
  background: linear-gradient(135deg, #e63946, #8a0f14);
  color: white;
}

.cta-red:hover {
  box-shadow: 0 12px 30px #e6394640;
}

.cta-red .cta-icon {
  background: rgba(255, 255, 255, 0.18);
}

.cta-red .cta-text span {
  color: rgba(255, 255, 255, 0.85);
}

/* White card: black text, red arrow */
.cta-white {
  background: var(--text);
  color: #121212;
}

.cta-white:hover {
  box-shadow: 0 12px 30px rgba(255, 255, 255, 0.1);
}

.cta-white .cta-icon {
  background: var(--accent-soft);
}

.cta-white .cta-text span {
  color: #3a3a3c;
}

.cta-white .cta-go {
  color: var(--accent);
}

.see-all {
  display: inline-block;
  white-space: nowrap;
  color: var(--accent-hover);
  font-weight: 700;
  text-decoration: none;
}

.see-all:hover {
  text-decoration: underline;
}

.optional {
  color: var(--muted);
  font-weight: 400;
  opacity: 0.7;
}

/* =========================================================
   6. FORMS: inputs, dropdowns and buttons
   ========================================================= */
form {
  display: flex;
  flex-direction: column;     /* stack items top to bottom */
  gap: 8px;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

select,
input {
  background: var(--inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;              /* use the same font as the page */
  color-scheme: dark;         /* makes the date picker dark too */
  width: 100%;                /* fill the form's width, never wider */
  transition: border-color 0.15s;
}

select:hover,
input:hover {
  border-color: #3a3a40;
}

select:focus,
input:focus {
  outline: 2px solid var(--accent);   /* red ring when you click in */
  outline-offset: 1px;
  border-color: transparent;
}

/* Buttons: red pills, like Apple Music and Spotify */
button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--pill);
  padding: 10px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;            /* hand cursor = "you can click this" */
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: scale(0.97);     /* tiny "press" effect when clicked */
}

button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* A quieter button, e.g. "Cancel" */
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

button.secondary:hover {
  background: var(--card-hover);
  border-color: #3a3a40;
}

/* A group of label + input that stacks like the rest of the form */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- "More options" (a <details> box) ---- */
.more-options {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.more-options summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.more-options[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.more-options[open] summary {
  margin-bottom: 2px;
}

/* A checkbox with its text next to it */
label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
}

label.check input {
  width: auto;                /* checkboxes shouldn't stretch like text boxes */
  accent-color: var(--accent);
  transform: scale(1.15);
}

/* =========================================================
   7. SUBSCRIPTION LIST
   ========================================================= */
/* ---- "My subscriptions" looks like a music playlist ----
   A red glow at the top, a big title, a round + button (like a Play button),
   and numbered rows like songs. */
.playlist {
  padding: 30px 28px 22px;
  background:
    linear-gradient(180deg, #e6394629, transparent 260px),
    rgba(255, 255, 255, 0.03);
}

.playlist-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.playlist-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.playlist-head h2 {
  margin: 2px 0 6px;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.playlist-head .section-note {
  margin: 0;
}

/* The big round + button */
.add-round {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  padding: 0 0 3px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 14px 30px -10px #e63946cc;
  transition: transform 0.35s var(--ease), background 0.2s;
}

.add-round:hover {
  transform: scale(1.08);
}

#sub-list {
  list-style: none;           /* remove the bullet points */
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: row;         /* a counter for the row numbers (1, 2, 3...) */
}

/* ---- Quick add picks in the "+ Add" pop-up ---- */
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.chip.pick {
  padding: 5px 12px 5px 5px;
  font-size: 0.82rem;
}

.chip.pick .app-icon {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 0.7rem;
  box-shadow: none;
}

.chip.pick:hover {
  border-color: var(--accent);
}

/* ---- Filter chips above the list ---- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}

.chip:hover {
  background: var(--card-hover);
}

.chip .count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--pill);
  background: #ffffff14;
  font-size: 0.78rem;
  text-align: center;
}

/* The chosen filter: white, like Spotify's selected chips */
.chip.active {
  background: var(--text);
  color: #121212;
  border-color: var(--text);
}

.chip.active .count {
  background: var(--accent);
  color: white;
}

/* One row, like a song in a playlist: no box until you hover it */
#sub-list li {
  position: relative;         /* so the renewal bar can sit along the bottom edge */
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 16px;
  counter-increment: row;
  transition: background 0.25s;
}

#sub-list li:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* The row number in front, made by the counter (no extra HTML needed) */
#sub-list li::before {
  content: counter(row);
  flex-shrink: 0;
  width: 20px;
  text-align: right;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#sub-list li.empty::before {
  content: none;
}

#sub-list li .app-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

#sub-list li > div {
  flex: 1;                    /* name + details take the free space, pushing price and buttons right */
  min-width: 0;
}

/* The coloured circle with the app's first letter */
.app-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);  /* script.js sets each app's own colour */
  color: white;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* The white logo inside the coloured square */
.app-icon .app-logo {
  width: 56%;
  height: 56%;
}

/* Letters instead of a logo (e.g. "D+"). Every box a logo sits in is a "container",
   so "cqmin" can size the letters to the box: 46cqmin = 46% of the box's shorter side. */
.app-icon,
.poster-art,
.slide-art,
.sheet-logo,
.cover {
  container-type: size;
}

.logo-letters {
  display: grid;
  place-items: center;
  width: auto !important;          /* letters take their own width, not the logo's */
  height: auto !important;
  color: #fff;
  font-size: 46cqmin;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.sub-name {
  font-weight: 700;
}

.sub-details {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.sub-price {
  font-weight: 700;
  white-space: nowrap;
}

/* ---- Status tags: small coloured pills ---- */
.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--pill);
  background: #ffffff14;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag-student { background: var(--save-soft); color: var(--save); }
.tag-info    { background: #4cc2ff22; color: var(--info); }
.tag-warn    { background: #ffb54722; color: var(--warn); }
.tag-ending  { background: var(--accent-soft); color: var(--accent-hover); }

/* The ✎ and ✕ buttons: subtle until you hover them */
#sub-list .edit,
#sub-list .delete {
  background: transparent;
  color: var(--muted);
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
}

#sub-list .edit:hover {
  background: #ffffff14;
  color: var(--text);
}

#sub-list .delete:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* On computers (with a mouse), ✎ and ✕ only appear when you point at the row, like in Spotify.
   Phones have no hover, so there they always show. */
@media (hover: hover) {
  #sub-list .edit,
  #sub-list .delete {
    opacity: 0;
    transition: opacity 0.2s, background 0.15s;
  }

  #sub-list li:hover .edit,
  #sub-list li:hover .delete,
  #sub-list li:focus-within .edit,
  #sub-list li:focus-within .delete {
    opacity: 1;
  }
}

/* "No subscriptions yet": a friendly message in the middle */
#sub-list .empty {
  flex-direction: column;
  gap: 4px;
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.14);
}

#sub-list .empty:hover {
  background: transparent;
}

.empty-icon {
  font-size: 2rem;
}

#sub-list .empty strong {
  color: var(--text);
  font-size: 1.05rem;
}

/* Savings tip under a subscription, in green */
.sub-tip {
  display: block;
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--save);
}

.sub-tip.info {
  color: var(--muted);        /* general info, not a saving */
}

.sub-tip:empty {
  display: none;              /* hide it when there's no tip */
}

/* The renewal bar under a row, like a song's progress bar: fills up as the next payment gets closer.
   It starts under the name (after the number and logo). */
.cycle {
  position: absolute;
  left: 112px;
  right: 14px;
  bottom: 6px;
  height: 3px;
  border-radius: var(--pill);
  overflow: hidden;
  background: #ffffff12;
}

.cycle span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #e6394666, var(--accent));
  border-radius: 0 3px 3px 0;
}

#sub-list li.soon .cycle span {
  background: linear-gradient(90deg, #ffb54766, var(--warn));   /* orange when it's due very soon */
}

/* Due very soon: orange edge */
#sub-list li.soon {
  box-shadow: inset 3px 0 0 var(--warn);
}

/* On a trial: blue edge */
#sub-list li.trial {
  box-shadow: inset 3px 0 0 var(--info);
}

/* Being cancelled: faded, price crossed out */
#sub-list li.ending {
  opacity: 0.6;
}

#sub-list li.ending .sub-price {
  text-decoration: line-through;
}

/* =========================================================
   8. DEALS PAGE: built like a streaming app
   (Spotlight banner, rows of app posters, and the app pop-up in section 9)
   ========================================================= */

/* The banner at the top of TrackBot / Settings: dark, with a red glow */
.page-banner {
  background:
    radial-gradient(circle at 100% 0%, #e6394640, transparent 55%),
    var(--card);
  border-color: #e6394633;
}

.page-banner .banner-title {
  margin: 4px 0 4px;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-banner .banner-title::before {
  display: none;               /* no red bar on the big banner title */
}

/* Our "smooth" curve: starts fast, settles gently (used for most movement) */
:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------- The Spotlight: big swipeable banner ---------- */
.spotlight {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 28px;
  overflow: hidden;
  background: #0c0b10;
  box-shadow: 0 40px 80px -40px #000;
}

/* The slides sit side by side. scroll-snap makes each swipe stop exactly on a slide. */
.spotlight-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;  /* swiping here doesn't make the browser go "back" */
  scrollbar-width: none;           /* hide the scrollbar (Firefox) */
}

.spotlight-track::-webkit-scrollbar {
  display: none;                   /* hide the scrollbar (Chrome, Safari) */
}

.slide {
  flex: 0 0 100%;                  /* each slide is exactly as wide as the banner */
  scroll-snap-align: start;
  position: relative;
  isolation: isolate;              /* keeps the z-index layers below inside this slide */
  display: flex;
  align-items: flex-end;
  min-height: 400px;
  padding: 44px 48px 64px;
  overflow: hidden;
  /* The app's colour glowing on the right, fading to near-black on the left.
     color-mix() blends two colours, e.g. 55% brand colour + 45% black. */
  background:
    radial-gradient(70% 100% at 80% 30%, color-mix(in srgb, var(--brand) 85%, transparent), transparent 70%),
    linear-gradient(100deg, #0c0b10 30%, color-mix(in srgb, var(--brand) 55%, #0c0b10));
}

/* A dark shade behind the text, so it's easy to read on bright colours */
.slide::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(8, 8, 12, 0.8) 0%, rgba(8, 8, 12, 0.35) 50%, transparent 75%);
}

/* The huge logo on the right */
.slide-art {
  position: absolute;
  z-index: -2;
  right: 7%;
  top: 50%;
  width: min(280px, 34%);
  aspect-ratio: 1;
  transform: translateY(-50%);
}

.slide-art img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 24px 60px rgba(0, 0, 0, 0.45));
}

/* When a slide becomes the current one, its logo floats in and gently bobs */
.slide.active .slide-art img {
  animation: art-in 1.2s var(--ease) both, bob 6s ease-in-out 1.2s infinite alternate;
}

@keyframes art-in {
  from { opacity: 0; transform: translateX(60px) scale(0.85) rotate(-6deg); }
  to   { opacity: 1; transform: none; }
}

@keyframes bob {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(-14px) rotate(2deg); }
}

.slide-text {
  max-width: 520px;
}

/* ...and its text rises in, one line after another */
.slide.active .slide-text > * {
  animation: rise 0.8s var(--ease) both;
}
.slide.active .slide-text > :nth-child(2) { animation-delay: 0.08s; }
.slide.active .slide-text > :nth-child(3) { animation-delay: 0.16s; }
.slide.active .slide-text > :nth-child(4) { animation-delay: 0.24s; }
.slide.active .slide-text > :nth-child(5) { animation-delay: 0.32s; }
.slide.active .slide-text > :nth-child(6) { animation-delay: 0.4s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

.slide-kicker {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.slide-title {
  margin: 14px 0 0;
  font-size: clamp(2.2rem, 5vw, 3.6rem);   /* grows with the screen, between 2.2rem and 3.6rem */
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
}

.slide-plan {
  margin: 8px 0 0;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.8);
}

.slide-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 14px 0 0;
}

.slide-price strong {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.slide-price .per {
  margin-left: -8px;
  color: rgba(255, 255, 255, 0.8);
}

.slide-price s {
  color: rgba(255, 255, 255, 0.55);
}

.save-pill {
  align-self: center;
  padding: 3px 10px;
  border-radius: var(--pill);
  background: var(--save);
  color: #04210f;
  font-size: 0.8rem;
  font-weight: 800;
}

/* The tip: at most 2 lines, then "..." */
.slide-note {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-note:empty {
  display: none;
}

.slide-buttons {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

/* White main button, like "Play" on a streaming app */
.slide-buttons .see {
  background: #fff;
  color: #111;
  padding: 12px 24px;
}

.slide-buttons .see:hover {
  background: #e8e8ed;
}

/* See-through "glass" button */
button.glass {
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 22px;
}

button.glass:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* The dots at the bottom: the current one stretches into a pill */
.spotlight-dots {
  position: absolute;
  left: 48px;
  bottom: 24px;
  display: flex;
  gap: 8px;
}

.spotlight-dots .dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.35);
  transition: width 0.4s var(--ease), background 0.4s;
}

.spotlight-dots .dot[aria-current="true"] {
  width: 28px;
  background: #fff;
}

/* ---------- Search ---------- */
.browse-search input {
  max-width: 520px;
  padding: 14px 20px 14px 48px;
  border-radius: var(--pill);
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  /* a small magnifying glass drawn with SVG, on the left */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 18px center;
  background-size: 18px;
}

/* ---------- Shelves: rows of posters ---------- */
.shelves {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.shelf {
  background: none;
  border: none;
  padding: 0;
}

.shelf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.shelf-head h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.shelf-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.shelf-note:empty {
  display: none;
}

.shelf-arrows {
  display: flex;
  gap: 8px;
}

.shelf-arrow {
  width: 38px;
  height: 38px;
  padding: 0 0 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 1.5rem;
  line-height: 1;
}

.shelf-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}

.shelf-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

/* The row itself: posters side by side, scroll (or swipe) sideways, snapping to each poster.
   The extra padding leaves room for the hover lift and glow, so they aren't cut off. */
.shelf-track {
  display: grid;
  grid-auto-flow: column;          /* new items go to the right, not underneath */
  grid-auto-columns: 176px;
  gap: 18px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 6px;           /* snap posters to the edge of the content, not the padding */
  padding: 14px 6px 22px;
  margin: 0 -6px;
  scrollbar-width: none;
  /* fade out the right edge, a hint that there's more to scroll */
  mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent);
}

.shelf-track::-webkit-scrollbar {
  display: none;
}

.shelf-track > * {
  scroll-snap-align: start;
}

/* ---------- A poster (one app) ---------- */
.poster {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  background: none;
  border-radius: 0;
  color: var(--text);
  text-align: left;
  font-weight: 400;
}

.poster:hover {
  background: none;
}

.poster:active {
  transform: none;
}

.poster:focus-visible {
  outline: none;
}

.poster:focus-visible .poster-art {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* The square "cover" in the app's colour, with its logo in the middle */
.poster-art {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  margin-bottom: 10px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 0%, color-mix(in srgb, var(--brand), white 22%), transparent 60%),
    linear-gradient(160deg, var(--brand), color-mix(in srgb, var(--brand) 40%, #050507));
  box-shadow:
    0 12px 30px -14px color-mix(in srgb, var(--brand) 70%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

.poster-art img {
  width: 42%;
  height: 42%;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
  transition: transform 0.5s var(--ease);
}

/* Hover: the cover lifts, glows in the app's colour, and the logo grows a little */
.poster:hover .poster-art,
.poster:focus-visible .poster-art {
  transform: translateY(-6px) scale(1.03);
  box-shadow:
    0 24px 44px -14px color-mix(in srgb, var(--brand) 90%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.poster:hover .poster-art img {
  transform: scale(1.1);
}

/* A shiny streak that sweeps across the cover on hover */
.poster-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.25) 50%, transparent 65%);
  transform: translateX(-120%);
  transition: transform 0.9s ease;
}

.poster:hover .poster-shine {
  transform: translateX(120%);
}

.poster-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: var(--pill);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.poster-check {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--save);
  color: #04210f;
  font-size: 0.8rem;
  font-weight: 900;
}

.poster-name {
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;          /* a long name ends with "..." */
}

.poster-note {
  font-size: 0.84rem;
  color: var(--muted);
}

/* Search results: posters in a grid instead of a row */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 24px 18px;
  margin-top: 14px;
}

/* ---------- Scroll-in animation (reveal() in helpers.js) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s var(--ease);
}

.reveal.shown {
  opacity: 1;
  transform: none;
}

/* Posters in a shelf glide in from the right, one after another (--i = their position) */
.reveal .poster {
  opacity: 0;
}

.reveal.shown .poster {
  animation: poster-in 0.7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}

@keyframes poster-in {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   9. POP-UPS (<dialog>): Add, Edit and Compare
   ========================================================= */
dialog {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  width: min(480px, 92vw);    /* 480px, or 92% of the screen if that's smaller */
  max-height: 90vh;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);   /* darken the page behind the pop-up */
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 26px;
}

/* ---------- The app pop-up ("sheet"): opened from a poster on Deals ---------- */
dialog.sheet {
  width: min(780px, 94vw);
  max-height: 88vh;
  overflow-y: auto;                /* the whole pop-up scrolls, banner included */
  overscroll-behavior: contain;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  background: #121116;
  scrollbar-width: thin;
}

dialog.sheet::backdrop {
  background: rgba(5, 5, 8, 0.6);
  backdrop-filter: blur(12px);
}

/* Opening: rises and grows into place. Closing (class "closing", added by deals.js): the reverse. */
dialog.sheet[open] {
  animation: sheet-in 0.55s var(--ease);
}

dialog.sheet[open]::backdrop {
  animation: fade-in 0.4s ease;
}

dialog.sheet.closing {
  animation: sheet-out 0.28s ease-in forwards;
}

dialog.sheet.closing::backdrop {
  animation: fade-out 0.28s ease-in forwards;
}

/* Tapping "More like this" swaps the app: the new one fades up into place */
dialog.sheet.swap .sheet-hero > *,
dialog.sheet.swap .sheet-body {
  animation: rise 0.5s var(--ease) both;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(48px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

@keyframes sheet-out {
  to { opacity: 0; transform: translateY(36px) scale(0.97); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes fade-out {
  to { opacity: 0; }
}

/* The banner at the top, in the app's colour */
.sheet-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 24px;
  min-height: 250px;
  padding: 40px 34px 28px;
  background:
    radial-gradient(80% 120% at 90% 0%, color-mix(in srgb, var(--brand) 90%, transparent), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--brand) 55%, #121116), #121116);
}

.sheet-logo {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 108px;
  height: 108px;
  border-radius: 28px;
  background: var(--brand);
  box-shadow:
    0 20px 40px -12px color-mix(in srgb, var(--brand) 70%, black),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font-size: 2.6rem;
  font-weight: 800;
}

.sheet-logo img {
  width: 54%;
  height: 54%;
}

.sheet-category {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.sheet-heading h2 {
  margin: 4px 0 6px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.sheet-summary {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
}

.sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  font-size: 1rem;
}

.sheet-close:hover {
  background: rgba(0, 0, 0, 0.65);
}

.sheet-body {
  padding: 4px 34px 30px;
}

.sheet-body h3 {
  margin: 26px 0 12px;
  font-size: 1.1rem;
  font-weight: 800;
}

.sheet-tip {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  font-size: 0.92rem;
}

.sheet-tip:empty {
  display: none;
}

/* The plan tiles: tap one to pick it */
.plan-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.plan-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-align: left;
  font-weight: 400;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.3s var(--ease);
}

.plan-tile:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-2px);
}

/* The picked tile: outlined and tinted in the app's colour (mixed with white, so dark brands still show) */
.plan-tile[aria-checked="true"] {
  border-color: color-mix(in srgb, var(--brand) 65%, white);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent);
}

.tile-name {
  font-weight: 700;
}

.tile-price {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tile-yearly {
  font-size: 0.82rem;
  color: var(--muted);
}

.tile-yearly:empty {
  display: none;
}

.tile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tile-badges:empty {
  display: none;
}

.tile-badge {
  padding: 2px 9px;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.tile-badge.student,
.tile-badge.cheap {
  background: var(--save-soft);
  color: var(--save);
}

.tile-badge.yours {
  background: var(--accent-soft);
  color: #ff8a93;
}

/* The Add button sticks to the bottom while you scroll the pop-up */
.sheet-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  padding: 18px 0 6px;
  background: linear-gradient(transparent, #121116 40%);
}

.sheet-actions button {
  background: #fff;
  color: #111;
  padding: 13px 26px;
  font-size: 1rem;
}

.sheet-actions button:hover {
  background: #e8e8ed;
}

/* "More like this": smaller posters */
.shelf-track.mini {
  grid-auto-columns: 130px;
  gap: 14px;
}

.shelf-track.mini .poster-name {
  font-size: 0.9rem;
}

.shelf-track.mini .poster-note {
  font-size: 0.78rem;
}

.dialog-body h2 {
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.dialog-buttons button {
  margin-top: 0;
}

/* =========================================================
   10. TRACKBOT: looks like a chat app
   ========================================================= */
.chat {
  padding: 0;                 /* the parts inside have their own padding */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* The top of the chat: avatar, name, "Online" */
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #e639461f, transparent 70%);
}

.chat-head strong {
  display: block;
  font-size: 1.05rem;
}

/* A little green dot before "Online" */
.online {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.online::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--save);
}

/* "✨ AI answers on · 20 questions left today" */
.ai-status {
  display: block;
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--accent-hover);
  font-weight: 600;
}

.ai-status:empty {
  display: none;
}

/* TrackBot's round avatar */
.bot-avatar {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 0.95rem;
}

.bot-avatar.big {
  width: 42px;
  height: 42px;
  font-size: 1.3rem;
  background: var(--gradient);
}

/* The messages: they scroll inside a fixed-height area, like a real chat */
#bot-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: min(460px, 55vh);
  overflow-y: auto;           /* scrollbar only when needed */
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* One message row: [avatar] [bubble] for TrackBot, [bubble] on the right for you */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.msg.you {
  justify-content: flex-end;
}

.bubble {
  max-width: 78%;
  padding: 10px 14px;
  white-space: pre-line;      /* respect line breaks (\n) in the text */
  animation: pop-in 0.2s ease-out;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* TrackBot's messages: dark grey, with a "tail" corner */
.bubble.bot {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
}

/* Your messages: red, on the right */
.bubble.you {
  background: var(--gradient);
  color: white;
  border-radius: 18px 18px 4px 18px;
}

/* Suggestion buttons: one row you can scroll sideways */
#bot-options {
  display: flex;
  gap: 8px;
  padding: 0 18px 12px;
  overflow-x: auto;
  scrollbar-width: none;      /* hide the scrollbar; you can still swipe */
}

#bot-options:empty {
  display: none;
}

#bot-options button {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 14px;
  white-space: nowrap;
}

#bot-options button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* "Typing..." bubble: three dots that bounce one after another */
.bubble.typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1s infinite;
}

.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }

/* @keyframes describes an animation: where things are at each moment */
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* The message bar at the bottom */
#bot-form {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--inset);
}

#bot-form input {
  flex: 1;
  border-radius: var(--pill);
  background: var(--card);
  padding-left: 18px;
}

/* The round red send button */
#bot-form button {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1rem;
}

/* =========================================================
   11. SETTINGS: a grid of setting cards
   ========================================================= */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.setting-card.wide {
  grid-column: 1 / -1;        /* stretch across both columns */
}

/* The "Email me reminders" box inside the Account card */
.email-reminders {
  border-top: 1px solid var(--border);
  margin: 14px 0;
  padding-top: 14px;
}

/* Icon on the left, title + description on the right */
.setting-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.setting-head h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.setting-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 1.2rem;
}

/* ---- Account ---- */
.login-form {
  max-width: 420px;
}

/* A button that looks like a plain link, e.g. "Forgot password?" */
button.link-button {
  display: block;
  margin: 6px 0 4px auto;     /* "auto" on the left pushes it to the right edge */
  padding: 2px 0;
  background: none;
  color: var(--accent-hover);
  font-weight: 600;
  font-size: 0.85rem;
}

button.link-button:hover {
  background: none;
  text-decoration: underline;
}

/* The "Choose a new password" box: outlined, so it stands out */
.new-password {
  margin: 4px 0 16px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid #e6394666;
  background: var(--accent-soft);
}

.new-password h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.privacy {
  margin-top: 14px;
  font-size: 0.8rem;
}

/* The round account button in the header, next to the bell */
.account-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  text-decoration: none;
  font-weight: 800;
  font-size: 1rem;
}

.account-chip:hover {
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(255, 255, 255, 0.4);
}

/* Logged in: a white circle with your first letter in red */
.account-chip.in {
  background: white;
  color: var(--accent);
  border-color: white;
}

/* AUD / USD: two buttons joined together, the chosen one is white */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--pill);
}

.seg {
  background: transparent;
  color: var(--muted);
  padding: 8px 18px;
}

.seg:hover {
  background: var(--card-hover);
  color: var(--text);
}

.seg.active {
  background: var(--text);
  color: #121212;
}

/* Numbered steps (Install the app) */
.steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.steps strong {
  color: var(--text);
}

code {
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.85em;
}

/* A row of buttons that wraps on small screens */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#cloud-form button {
  align-self: flex-start;
  margin-top: 6px;
}

#cloud-status {
  margin-top: 10px;
}

#cloud-status:empty {
  display: none;
}

/* =========================================================
   12. FOOTER
   ========================================================= */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 8px 24px 32px;
  max-width: 700px;
  margin: 0 auto;
}

/* =========================================================
   13. SMALLER SCREENS
   "If the screen is narrower than ___, use these rules instead"
   ========================================================= */

/* Medium screens: no room for the slogan next to the tabs */
@media (max-width: 1100px) {
  header p {
    display: none;
  }
}

/* Narrower: tabs without icons, so the header still fits on one line */
@media (max-width: 1000px) and (min-width: 701px) {
  .tab-icon {
    display: none;
  }

  .tab {
    padding: 8px 14px;
  }
}

@media (max-width: 800px) and (min-width: 701px) {
  header h1 {
    display: none;            /* the red "S" logo is enough here */
  }
}

@media (max-width: 800px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cta-row {
    grid-template-columns: minmax(0, 1fr);   /* stacked instead of side by side */
  }

  .quick-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));   /* 2 x 2 tiles */
  }
}

/* Phones */
@media (max-width: 700px) {
  header {
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
  }

  .logo-mark {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
    border-radius: 10px;
  }

  header h1 {
    font-size: 1.25rem;
  }

  /* The tabs become a dark navy bar fixed to the bottom of the screen
     (dark, so your eyes stay on the page, not the bar) */
  #tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    justify-content: space-around;
    gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));   /* room for the iPhone home bar */
    background: linear-gradient(180deg, #14213d 0%, #0c1529 100%);   /* dark navy blue */
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
    border-radius: 0;
  }

  .tab {
    flex: 1;
    flex-direction: column;   /* icon above the word */
    gap: 2px;
    padding: 6px 4px;
    border-radius: 12px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);   /* soft white text on the navy bar */
  }

  .tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.06);
  }

  .tab-icon {
    font-size: 1.25rem;
  }

  /* The current tab: a red pill with white text */
  .tab.active {
    background: var(--accent);
    color: white;
  }

  /* Leave space at the bottom so the tab bar doesn't cover the page */
  body {
    padding-bottom: 76px;
  }

  main {
    padding: 0 12px;
    margin-top: 16px;
  }

  .page {
    gap: 14px;
  }

  section {
    padding: 18px;
  }

  #page-home {
    gap: 26px;
  }

  /* The banner: logos small at the top right, text underneath */
  .home-hero {
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding: 26px 22px 24px;
    border-radius: 24px;
  }

  .hero-covers {
    position: absolute;
    top: 18px;
    right: 14px;
    width: 150px;
    height: 110px;
  }

  .cover {
    width: 82px;
    height: 82px;
    margin-top: -41px;
    border-radius: 20px;
    transform: translateX(calc(var(--n) * -20px)) rotate(calc(var(--n) * -7deg)) scale(calc(1 - var(--n) * 0.07));
  }

  .home-hero:hover .cover {
    transform: translateX(calc(var(--n) * -20px)) rotate(calc(var(--n) * -7deg)) scale(calc(1 - var(--n) * 0.07));
  }

  .cover-empty {
    font-size: 2.4rem;
  }

  .page-head {
    flex-direction: column;
    gap: 0;
    max-width: 55%;           /* leave room for the logos */
    margin-bottom: 40px;
  }

  .page-head #today-date::before {
    content: none;
  }

  .save-card strong {
    font-size: 1.25rem;
  }

  .shelf-track.upcoming-list {
    grid-auto-columns: 170px;
  }

  .shelf-track.savings-list {
    grid-auto-columns: 82%;   /* most of the screen, with a peek of the next card */
  }

  .playlist {
    padding: 22px 14px 14px;
  }

  .playlist-head {
    padding: 0 6px;
  }

  /* No row numbers on phones: the space goes to the text */
  #sub-list li::before {
    content: none;
  }

  .cycle {
    left: 10px;
    right: 10px;
    bottom: 4px;
  }

  /* List rows become a small grid, so the text gets the full width:
       [icon] [name, tags, details, tip] [✎] [✕]
       [icon] [price                   ]          */
  #sub-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    column-gap: 10px;
    row-gap: 4px;
    padding: 12px 10px;
  }

  #sub-list li .app-icon  { grid-row: 1 / span 2; align-self: start; width: 38px; height: 38px; }
  #sub-list li > div      { grid-column: 2; grid-row: 1; }
  #sub-list li .sub-price { grid-column: 2; grid-row: 2; }
  #sub-list li .edit      { grid-column: 3; grid-row: 1; align-self: start; }
  #sub-list li .delete    { grid-column: 4; grid-row: 1; align-self: start; }

  #sub-list .empty {
    display: flex;
  }

  /* Tags go on their own line under the name */
  .tags {
    display: flex;
    margin: 4px 0 0;
  }

  .bubble {
    max-width: 90%;
  }

  /* ---- Deals on phones ---- */
  .spotlight {
    border-radius: 22px;
  }

  .slide {
    min-height: 460px;
    padding: 24px 22px 52px;
  }

  /* The big logo moves to the top right, smaller */
  .slide-art {
    top: 26px;
    right: 22px;
    width: 120px;
    transform: none;
  }

  .slide::after {
    background: linear-gradient(0deg, rgba(8, 8, 12, 0.85) 0%, rgba(8, 8, 12, 0.3) 60%, transparent 85%);
  }

  .slide-price strong {
    font-size: 1.7rem;
  }

  .spotlight-dots {
    left: 22px;
    bottom: 20px;
  }

  .shelves {
    gap: 28px;
  }

  .shelf-head h2 {
    font-size: 1.2rem;
  }

  /* No arrows on phones: you swipe instead */
  .shelf-arrows {
    display: none;
  }

  /* Rows run right to the edges of the screen, like a streaming app */
  .shelf-track {
    grid-auto-columns: 136px;
    gap: 14px;
    margin: 0 -12px;
    padding: 12px 12px 18px;
    scroll-padding: 0 12px;
    mask-image: none;
  }

  .poster-art {
    border-radius: 16px;
  }

  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }

  /* The app pop-up becomes a sheet that slides up from the bottom */
  dialog.sheet {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 26px 26px 0 0;
    border-bottom: none;
  }

  dialog.sheet[open] {
    animation: sheet-up 0.5s var(--ease);
  }

  dialog.sheet.closing {
    animation: sheet-down 0.3s ease-in forwards;
  }

  .sheet-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    min-height: 0;
    padding: 30px 20px 22px;
  }

  .sheet-logo {
    width: 80px;
    height: 80px;
    border-radius: 22px;
  }

  .sheet-body {
    padding: 0 20px 24px;
  }

  .plan-tiles {
    grid-template-columns: 1fr 1fr;
  }

  .plan-tile {
    padding: 14px 12px;
  }

  .tile-price {
    font-size: 1.15rem;
  }

  .sheet-actions button {
    width: 100%;
  }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

@keyframes sheet-down {
  to { transform: translateY(100%); }
}

/* =========================================================
   14. LESS MOTION
   If someone turned on "reduce motion" on their device (it can make some
   people feel sick), switch the animations off and show everything straight away.
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .reveal,
  .reveal .poster {
    opacity: 1;
    transform: none;
  }
}
