/* ===========================================================================
   RentLedger — visual language
   ---------------------------------------------------------------------------
   Colour carries the meaning here, consistently, everywhere:
     green  = paid ahead / confirmed / all good
     amber  = due soon / waiting on someone
     rose   = behind / overdue / needs attention
     blue   = bond and neutral facts
     violet = the app itself (brand, primary actions)
   =========================================================================== */

:root {
  --bg: #f5f6fb;
  --bg-glow-1: #ded9ff;
  --bg-glow-2: #ffe4f0;
  --surface: #ffffff;
  --surface-2: #f3f5fb;
  --surface-3: #eceffa;
  --ink: #101322;
  --ink-2: #5c6480;
  --ink-3: #8a92ab;
  --line: #e7eaf4;

  --brand: #6d5efc;
  --brand-2: #a855f7;
  --brand-ink: #ffffff;

  --good: #04a97a;
  --good-ink: #036b4e;
  --good-bg: #e3f9f1;
  --good-line: #b6ecdb;

  --warn: #e08700;
  --warn-ink: #955900;
  --warn-bg: #fff4e2;
  --warn-line: #ffdfb0;

  --bad: #ef3f61;
  --bad-ink: #b31938;
  --bad-bg: #ffecf0;
  --bad-line: #ffc9d4;

  --info: #3b7ff6;
  --info-ink: #1f57bd;
  --info-bg: #eaf2ff;
  --info-line: #c5daff;

  --radius-xl: 26px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 19, 34, 0.05);
  --shadow: 0 2px 4px rgba(16, 19, 34, 0.04), 0 14px 34px -16px rgba(16, 19, 34, 0.28);
  --shadow-lg: 0 4px 8px rgba(16, 19, 34, 0.05), 0 30px 60px -24px rgba(16, 19, 34, 0.35);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tnum: 'tnum' 1, 'cv02' 1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d16;
    --bg-glow-1: #1e1a44;
    --bg-glow-2: #2c1830;
    --surface: #151827;
    --surface-2: #1b1f31;
    --surface-3: #232840;
    --ink: #f2f4fb;
    --ink-2: #a4abc4;
    --ink-3: #737b95;
    --line: #262b41;

    --brand: #8a7dff;
    --brand-2: #c084fc;

    --good: #23d6a0;
    --good-ink: #7ef0cb;
    --good-bg: #0e2b23;
    --good-line: #1c4c3e;

    --warn: #ffb43d;
    --warn-ink: #ffd08a;
    --warn-bg: #30220a;
    --warn-line: #563d10;

    --bad: #ff6683;
    --bad-ink: #ffa3b5;
    --bad-bg: #331420;
    --bad-line: #5c2338;

    --info: #6fa5ff;
    --info-ink: #a9caff;
    --info-bg: #10203c;
    --info-line: #1e3a68;
  }
}

/* --------------------------------------------------------------------- */

* { box-sizing: border-box; }

/*
 * Kill double-tap-to-zoom on anything tappable. Typing a PIN quickly reads as
 * a double tap, and the page zooming mid-code is maddening.
 *
 * touch-action rather than user-scalable=no in the viewport: this only affects
 * the controls themselves, so pinch-to-zoom still works everywhere on the page
 * for anyone who needs it.
 */
button, .key, .btn, .avatar, .paydetail, .segmented button, .freddy-mute, label {
  touch-action: manipulation;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-feature-settings: var(--tnum);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  overflow-x: hidden;
}

/* Soft ambient colour so the app never feels like a spreadsheet */
body::before {
  content: '';
  position: fixed;
  inset: -30vh -20vw auto -20vw;
  height: 80vh;
  background:
    radial-gradient(45vw 45vh at 20% 20%, var(--bg-glow-1), transparent 65%),
    radial-gradient(40vw 40vh at 85% 5%, var(--bg-glow-2), transparent 65%);
  filter: blur(20px);
  opacity: 0.75;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 18px 120px;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.022em; font-weight: 680; }
p { margin: 0; }

.stack   { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.row     { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow    { flex: 1; }
.center  { text-align: center; }
.hidden  { display: none !important; }

.muted   { color: var(--ink-2); }
.tiny    { font-size: 12.5px; }
.small   { font-size: 13.5px; }
.label {
  font-size: 11.5px;
  font-weight: 660;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Top bar ---------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 11px; }

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 19px;
  box-shadow: 0 8px 20px -8px var(--brand);
}

.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub  { font-size: 12px; color: var(--ink-3); margin-top: -2px; }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-weight: 680; font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.avatar:hover { border-color: var(--brand); color: var(--brand); }

/* --- Cards ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-pad-lg { padding: 22px; }

/* --- The hero status card, tinted by how the rent is tracking --------- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: 26px 24px 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--accent, var(--brand));
}
.hero::before {
  content: '';
  position: absolute;
  right: -70px; top: -90px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: var(--accent, var(--brand));
  opacity: 0.09;
  pointer-events: none;
}

.hero.is-ahead      { --accent: var(--good); }
.hero.is-due-soon   { --accent: var(--warn); }
.hero.is-behind     { --accent: var(--bad);  }
.hero.is-not-started{ --accent: var(--info); }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 660;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent, var(--brand));
  margin-bottom: 12px;
}
.hero-eyebrow .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent, var(--brand));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, var(--brand)) 22%, transparent);
}

.hero-date {
  font-size: clamp(30px, 8.5vw, 42px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.hero-caption { color: var(--ink-2); font-size: 15px; margin-top: 8px; }
.hero-caption strong { color: var(--ink); font-weight: 640; }

.hero-figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.figure {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
}
.figure .label { margin-bottom: 3px; }
.figure .value { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.figure.tone-good { background: var(--good-bg); border-color: var(--good-line); }
.figure.tone-good .value { color: var(--good-ink); }
.figure.tone-warn { background: var(--warn-bg); border-color: var(--warn-line); }
.figure.tone-warn .value { color: var(--warn-ink); }
.figure.tone-bad  { background: var(--bad-bg);  border-color: var(--bad-line);  }
.figure.tone-bad .value  { color: var(--bad-ink);  }
.figure.tone-info { background: var(--info-bg); border-color: var(--info-line); }
.figure.tone-info .value { color: var(--info-ink); }

/* --- Progress bar through the current 4-week block -------------------- */

.progress {
  margin-top: 18px;
}
.progress-track {
  height: 9px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent, var(--brand)), color-mix(in srgb, var(--accent, var(--brand)) 55%, var(--brand-2)));
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Badges ----------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 12px; font-weight: 650;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.good { background: var(--good-bg); color: var(--good-ink); border-color: var(--good-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad-ink);  border-color: var(--bad-line); }
.badge.info { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }
.badge.plain{ background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }

/* --- Buttons ---------------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 640;
  padding: 13px 18px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover  { box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
  color: var(--brand-ink);
  box-shadow: 0 10px 24px -12px var(--brand);
}
.btn-good {
  background: linear-gradient(135deg, var(--good), color-mix(in srgb, var(--good) 60%, #3ddc9a));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 24px -12px var(--good);
}
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad-ink); border-color: var(--bad-line); background: var(--bad-bg); }
.btn-lg  { font-size: 17px; padding: 17px 22px; border-radius: 17px; }
.btn-block { width: 100%; }

/* --- Floating action bar ---------------------------------------------- */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.actionbar > * { pointer-events: auto; }
.actionbar-inner { max-width: 720px; margin: 0 auto; }

/* --- Ledger ----------------------------------------------------------- */

.entry {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.entry:last-child { border-bottom: none; }

.entry-icon {
  width: 40px; height: 40px; flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 17px;
}
.entry-icon.good { background: var(--good-bg); color: var(--good-ink); }
.entry-icon.warn { background: var(--warn-bg); color: var(--warn-ink); }
.entry-icon.bad  { background: var(--bad-bg);  color: var(--bad-ink); }
.entry-icon.info { background: var(--info-bg); color: var(--info-ink); }
.entry-icon.plain{ background: var(--surface-2); color: var(--ink-3); }

.entry-title { font-weight: 620; font-size: 15px; }
.entry-sub   { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.entry-amount{ font-weight: 700; font-size: 16px; text-align: right; white-space: nowrap; }
.entry-note {
  font-size: 12.5px; font-style: italic; color: var(--ink-2);
  background: var(--surface-2);
  border-left: 2px solid var(--line);
  border-radius: 0 8px 8px 0;
  padding: 5px 9px;
  margin-top: 5px;
}
.entry-note-who { font-style: normal; color: var(--ink-3); margin-left: 6px; white-space: nowrap; }
.entry.is-void .entry-title,
.entry.is-void .entry-amount { text-decoration: line-through; color: var(--ink-3); }

/* --- Bills ------------------------------------------------------------ */

.bill {
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.bill:last-of-type { border-bottom: none; }
.bill.is-void { opacity: 0.55; }
.bill.is-void .entry-title,
.bill.is-void .entry-amount { text-decoration: line-through; }

.bill-head { display: flex; align-items: flex-start; gap: 12px; }
.bill-head .entry-amount { padding-top: 2px; }

.bill-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 6px 52px;
}
.bill-actions { display: flex; gap: 8px; margin: 12px 0 2px 52px; }

@media (max-width: 400px) {
  .bill-meta, .bill-actions { margin-left: 0; }
}

/* --- Tap-to-copy payment details -------------------------------------- */

.paydetail {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  appearance: none; border: none; background: transparent;
  font-family: inherit; text-align: left;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.paydetail:last-child { border-bottom: none; }
.paydetail:active { background: var(--surface-2); }

.paydetail-label { font-size: 12.5px; color: var(--ink-3); width: 60px; flex: none; }
.paydetail-value {
  flex: 1; font-size: 16px; font-weight: 660;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
.paydetail-copy {
  font-size: 11.5px; font-weight: 650;
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 10px;
  flex: none;
}
.paydetail:active .paydetail-copy { background: var(--brand); color: #fff; border-color: transparent; }

/* --- Schedule strip --------------------------------------------------- */

.sched {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}
.sched:last-child { border-bottom: none; }
.sched-pip {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--ink-3);
}
.sched.paid     .sched-pip { background: var(--good); box-shadow: 0 0 0 4px var(--good-bg); }
.sched.overdue  .sched-pip { background: var(--bad);  box-shadow: 0 0 0 4px var(--bad-bg); }
.sched.part     .sched-pip { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.sched.upcoming .sched-pip { background: var(--ink-3); box-shadow: 0 0 0 4px var(--surface-2); }

/* --- The PIN, shown big on the collector's screen --------------------- */

.pin-display {
  display: flex; justify-content: center; gap: 12px;
  margin: 6px 0 4px;
}
.pin-digit {
  width: 74px; height: 92px;
  border-radius: 20px;
  display: grid; place-items: center;
  font-size: 46px; font-weight: 720;
  letter-spacing: -0.03em;
  background: linear-gradient(160deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--line);
  color: var(--ink);
  animation: pop 0.45s cubic-bezier(0.22, 1.4, 0.4, 1) backwards;
}
.pin-digit:nth-child(2) { animation-delay: 0.07s; }
.pin-digit:nth-child(3) { animation-delay: 0.14s; }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}

/* --- Daniel's keypad -------------------------------------------------- */

.pin-slots { display: flex; justify-content: center; gap: 14px; margin: 4px 0 20px; }
.pin-slot {
  width: 60px; height: 74px;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 34px; font-weight: 720;
  background: var(--surface-2);
  border: 2px solid var(--line);
  color: var(--ink);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.pin-slot.filled { border-color: var(--brand); background: var(--surface); transform: translateY(-2px); }
.pin-slot.active { border-color: var(--brand); border-style: dashed; }
.pin-slot-sm { width: 42px; height: 56px; font-size: 26px; border-radius: 14px; }
.pin-slots.is-wrong { animation: shake 0.42s ease; }
.pin-slots.is-wrong .pin-slot { border-color: var(--bad); background: var(--bad-bg); color: var(--bad-ink); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 380px;
  margin: 0 auto;
}
.key {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 30px;
  font-weight: 600;
  height: 74px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.key:active { transform: scale(0.93); background: var(--surface-3); }
.key.key-soft { font-size: 22px; color: var(--ink-2); background: transparent; box-shadow: none; border-color: transparent; }
.key.key-soft:active { background: var(--surface-2); }

/* --- Big friendly confirmation sheet ---------------------------------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.25s ease;
}
@media (min-width: 600px) { .sheet-backdrop { align-items: center; } }

.sheet {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 92vh; overflow-y: auto;
}
@media (min-width: 600px) { .sheet { border-radius: 28px; padding-bottom: 26px; } }

@keyframes slide-up { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-grab {
  width: 42px; height: 5px; border-radius: 99px;
  background: var(--line);
  margin: -8px auto 18px;
}

/* --- Celebration ------------------------------------------------------ */

.success-mark {
  width: 96px; height: 96px;
  margin: 4px auto 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 46px;
  background: var(--good-bg);
  color: var(--good-ink);
  border: 2px solid var(--good-line);
  animation: pop-in 0.55s cubic-bezier(0.22, 1.5, 0.4, 1);
}
@keyframes pop-in {
  from { transform: scale(0.4); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.confetti {
  position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden;
}
.confetti i {
  position: absolute; top: -14px;
  width: 9px; height: 15px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.1; }
}

/* --- Waiting pulse ---------------------------------------------------- */

.waiting-orb {
  width: 84px; height: 84px;
  margin: 6px auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 34px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 2px solid var(--warn-line);
  animation: breathe 1.9s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 34%, transparent); }
  50%      { transform: scale(1.05); box-shadow: 0 0 0 16px transparent; }
}

/* --- Inputs ----------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.input {
  font-family: inherit; font-size: 16px;
  padding: 13px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  width: 100%;
}
.input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 1px; border-color: var(--brand); }

.amount-row {
  display: flex; align-items: center; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding-left: 16px;
}
.amount-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.amount-symbol {
  font-size: 30px; font-weight: 640; color: var(--ink-3);
  line-height: 1;
}
.amount-input {
  font-size: 40px; font-weight: 720; letter-spacing: -0.03em;
  text-align: left; padding: 16px 12px;
  border: none; background: transparent; border-radius: 18px;
}
.amount-input:focus { outline: none; }

/* --- Toast ------------------------------------------------------------ */

.toast-wrap {
  position: fixed; left: 0; right: 0; top: 14px; z-index: 90;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 560;
  max-width: 460px;
  animation: drop 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.good { border-left-color: var(--good); }
.toast.bad  { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Empty & loading -------------------------------------------------- */

.empty { text-align: center; padding: 30px 16px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.splash {
  min-height: 70vh;
  display: grid; place-items: center;
  color: var(--ink-3);
}

/* --- Sign in ---------------------------------------------------------- */

.signin {
  max-width: 420px; margin: 8vh auto 0;
  text-align: center;
}
.signin .brand-mark { width: 60px; height: 60px; border-radius: 20px; font-size: 29px; margin: 0 auto 20px; }

/* --- Segmented control ------------------------------------------------ */

.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.segmented button {
  flex: 1; appearance: none; border: none; background: transparent;
  font-family: inherit; font-size: 13.5px; font-weight: 620;
  color: var(--ink-2); padding: 9px 10px; border-radius: 11px; cursor: pointer;
}
.segmented button.on {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ===========================================================================
   Freddy
   ---------------------------------------------------------------------------
   Daniel's bichon-poodle. He pops up when a payment lands, sulks when the rent
   is behind, and gets extremely excited about bills. Everything below is his.
   =========================================================================== */

.freddy { width: 100%; height: auto; display: block; overflow: visible; }

/* --- idle life: he's never completely still ---------------------------- */

.f-all { transform-origin: 130px 230px; animation: f-breathe 2.6s ease-in-out infinite; }
@keyframes f-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3px) scale(1.015); }
}

.f-tail { transform-origin: 84px 166px; animation: f-wag 0.42s ease-in-out infinite alternate; }
@keyframes f-wag { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }

.f-ear-l { transform-origin: 90px 92px; animation: f-flop 2.3s ease-in-out infinite; }
.f-ear-r { transform-origin: 170px 92px; animation: f-flop 2.3s ease-in-out infinite reverse; }
@keyframes f-flop { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(6deg); } }

.f-eyes { animation: f-blink 4.4s infinite; transform-origin: 130px 90px; }
@keyframes f-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.08); }
}

.f-tongue { transform-origin: 130px 127px; animation: f-pant 0.7s ease-in-out infinite alternate; }
@keyframes f-pant { from { transform: scaleY(0.75); } to { transform: scaleY(1.15); } }

.f-prop { transform-origin: center; animation: f-bob 1.5s ease-in-out infinite; }
@keyframes f-bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-7px) rotate(4deg); } }

.f-float { animation: f-rise 2.4s ease-out infinite; }
@keyframes f-rise {
  0%   { transform: translateY(8px) scale(.7); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: translateY(-34px) scale(1.1); opacity: 0; }
}

.f-steam { animation: f-rise 2s ease-out infinite; }
.f-sparkle { animation: f-twinkle 1.5s ease-in-out infinite; }
@keyframes f-twinkle { 0%, 100% { opacity: .35; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.12); } }

.f-hat, .f-crown, .f-ears-bunny { transform-origin: 130px 60px; animation: f-flop 2.9s ease-in-out infinite; }

/* --- what he's doing --------------------------------------------------- */

.freddy[data-action="zoomies"] .f-all { animation: f-zoom 0.6s ease-in-out infinite; }
@keyframes f-zoom {
  0%, 100% { transform: translateX(-10px) rotate(-4deg); }
  50%      { transform: translateX(10px) rotate(4deg); }
}

.freddy[data-action="jump"] .f-all { animation: f-hop 0.62s cubic-bezier(.3,.9,.4,1) infinite; }
@keyframes f-hop {
  0%, 100% { transform: translateY(0) scaleY(1); }
  30%      { transform: translateY(-24px) scaleY(1.06); }
  55%      { transform: translateY(0) scaleY(.94); }
}
.freddy[data-action="jump"] .f-shadow { animation: f-shadow-hop 0.62s cubic-bezier(.3,.9,.4,1) infinite; }
@keyframes f-shadow-hop {
  0%, 100% { transform: scale(1); opacity: .12; }
  30%      { transform: scale(.74); opacity: .06; }
}

.freddy[data-action="spin"] .f-all { animation: f-spin 1.6s cubic-bezier(.5,0,.5,1) infinite; transform-origin: 130px 170px; }
@keyframes f-spin {
  0%, 45%  { transform: rotateY(0deg); }
  75%      { transform: rotateY(360deg); }
  100%     { transform: rotateY(360deg); }
}

.freddy[data-action="paw"] .f-head { transform-origin: 130px 140px; animation: f-tilt 1.7s ease-in-out infinite; }
@keyframes f-tilt { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }

.freddy[data-action="beg"] .f-all { animation: f-beg 0.9s ease-in-out infinite; }
@keyframes f-beg {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-12px) rotate(2deg); }
}

/* Sad Freddy: everything slows down and sags. */
.freddy[data-mood="sad"] .f-all { animation: f-mope 3.4s ease-in-out infinite; }
@keyframes f-mope {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(4px) rotate(1.5deg); }
}
.freddy[data-mood="sad"] .f-tail { animation: f-wag-slow 2.2s ease-in-out infinite alternate; }
@keyframes f-wag-slow { from { transform: rotate(-4deg) translateY(6px); } to { transform: rotate(4deg) translateY(6px); } }
.freddy[data-mood="sad"] .f-ear-l { animation: f-droop-l 3.4s ease-in-out infinite; }
.freddy[data-mood="sad"] .f-ear-r { animation: f-droop-r 3.4s ease-in-out infinite; }
@keyframes f-droop-l { 0%, 100% { transform: rotate(16deg) translateY(9px); } 50% { transform: rotate(21deg) translateY(12px); } }
@keyframes f-droop-r { 0%, 100% { transform: rotate(-16deg) translateY(9px); } 50% { transform: rotate(-21deg) translateY(12px); } }

.f-tear { animation: f-tear-fall 2.6s ease-in infinite; }
@keyframes f-tear-fall {
  0%, 45%  { transform: translateY(0) scale(.5); opacity: 0; }
  60%      { transform: translateY(0) scale(1); opacity: .95; }
  100%     { transform: translateY(34px) scale(.7); opacity: 0; }
}

.f-watch { animation: f-watch-tap 1.9s ease-in-out infinite; transform-origin: center; }
@keyframes f-watch-tap {
  0%, 100% { transform: rotate(-8deg) translateY(0); }
  50%      { transform: rotate(8deg) translateY(-5px); }
}

/* --- the pop-up -------------------------------------------------------- */

.freddy-pop {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(7px);
  animation: fade 0.25s ease;
}
.freddy-pop.is-leaving { animation: fade 0.25s ease reverse forwards; }

.freddy-card {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 20px 22px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: f-pop-in 0.55s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes f-pop-in {
  0%   { transform: scale(.55) translateY(40px) rotate(-6deg); opacity: 0; }
  60%  { transform: scale(1.04) translateY(0) rotate(1.5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.freddy-pop[data-mood="happy"]   .freddy-card { background: linear-gradient(170deg, var(--good-bg), var(--surface) 62%); }
.freddy-pop[data-mood="excited"] .freddy-card { background: linear-gradient(170deg, var(--info-bg), var(--surface) 62%); }
.freddy-pop[data-mood="sad"]     .freddy-card { background: linear-gradient(170deg, var(--warn-bg), var(--surface) 62%); }

.freddy-stage { width: 190px; margin: 0 auto 6px; }

.freddy-msg {
  font-size: 19px; font-weight: 680; letter-spacing: -.02em;
  line-height: 1.3;
  margin: 4px 0 6px;
  text-wrap: balance;
}
.freddy-theme {
  font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 16px;
}

.freddy-mute {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
}

/* --- the small one that lives on Daniel's home screen ------------------ */

.freddy-inline {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 12px 16px 12px 10px;
  background: var(--surface);
}
.freddy-inline.is-happy   { background: var(--good-bg); border-color: var(--good-line); }
.freddy-inline.is-sad     { background: var(--warn-bg); border-color: var(--warn-line); }
.freddy-inline.is-excited { background: var(--info-bg); border-color: var(--info-line); }

.freddy-inline-art { width: 92px; flex: none; }
.freddy-inline-msg { font-size: 15px; font-weight: 640; line-height: 1.35; }
.freddy-inline-theme {
  font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); margin-top: 4px;
}

/* --- Freddy's diary, in Emily's portal --------------------------------- */

.freddy-log {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 14px 10px;
  box-shadow: var(--shadow-sm);
}
.freddy-log-art { width: 88px; flex: none; }
.freddy-log-body { flex: 1; min-width: 0; }
.freddy-log-msg { font-size: 15px; font-weight: 640; line-height: 1.35; }

/* The tab strip earns a fifth entry once Freddy moves in. */
.segmented { overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { white-space: nowrap; flex: 1 0 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .f-all, .f-tail, .f-ear-l, .f-ear-r, .f-eyes, .f-tongue, .f-prop, .f-float { animation: none !important; }
}
