/* =========================================================================
   MUSECAT - design tokens
   Palette sampled straight off the shipped avatar/banner (flat vector,
   thick black linework, cream/peach body, mint laptop screen, coral cheeks).
   Type: Quicksand (kawaii display) + Space Mono (dashboard digits, this
   page IS the fund's own balance readout) + Nunito (body/labels).
   Motion idiom: one signature paw-swipe sweep, everything else quick and
   discrete (stamps, floaters, ticks) - no ambient particle wash.
   ========================================================================= */
:root{
  --ink:        #21140a;
  --cream:      #fff6e9;
  --cream-2:    #ffebd2;
  --peach:      #ffdcb3;
  --peach-deep: #f0aa79;
  --wall:       #e9946c;
  --mint:       #cdefc9;
  --mint-deep:  #3f9260;
  --mint-ink:   #1c4a30;
  --coral:      #ff9796;
  --coral-deep: #d84a4e;
  --gold:       #e8b23c;
  --gold-deep:  #a9731a;

  --radius-lg: 26px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --border-w: 3px;
  --shadow-off: 6px 6px 0 var(--ink);
  --shadow-off-sm: 4px 4px 0 var(--ink);

  --font-display: 'Quicksand', 'Baloo 2', sans-serif;
  --font-mono: 'Space Mono', 'IBM Plex Mono', monospace;
  --font-body: 'Nunito', sans-serif;
}

*, *::before, *::after{ box-sizing: border-box; }
html{ height: 100%; }
body{
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 6%, var(--cream) 0%, transparent 42%),
    radial-gradient(circle at 88% 96%, var(--peach-deep) 0%, transparent 46%),
    linear-gradient(160deg, var(--peach) 0%, var(--peach) 55%, var(--peach-deep) 100%);
  font-family: var(--font-body);
  color: var(--ink);
  padding: 20px 20px 0;
}

h1, h2, h3{ margin: 0; font-family: var(--font-display); }
p{ margin: 0; }
button{ font-family: inherit; }
ul{ list-style: none; margin: 0; padding: 0; }

#boot-error-banner{
  position: fixed; top: 0; left: 0; right: 0; z-index: 99999;
  background: #c92a2a; color: #fff; font-family: var(--font-mono);
  font-size: 13px; padding: 10px 14px; display: none;
}
#boot-error-banner:not(:empty){ display: block; }

/* -------------------------------------------------------------------------
   The dashboard IS the page: one fixed "device" panel, no nav, no scroll
   sections beneath it. It centers in the viewport at desktop widths and
   reflows to a single column that can scroll on narrow phones.
   ------------------------------------------------------------------------- */
.app{ width: 100%; display: flex; justify-content: center; margin-bottom: 40px; }

.dashboard{
  width: 100%;
  max-width: 720px;
  background: var(--cream);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 10px 10px 0 var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Account header row: identity, CA, X, FUND ------------------------- */
.acct-header{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--wall);
  border-bottom: var(--border-w) solid var(--ink);
  flex-wrap: wrap;
}

.acct-id{ display: flex; align-items: center; gap: 10px; min-width: 0; }
.acct-avatar{
  width: 52px; height: 52px; border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: var(--peach);
  object-fit: cover;
  flex-shrink: 0;
}
.acct-id-text{ display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acct-name{
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em; color: var(--ink);
  white-space: nowrap;
}
.acct-sub{
  font-size: 11.5px; color: #4a3220; display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}

.live-dot{
  width: 7px; height: 7px; border-radius: 50%; background: var(--mint-deep);
  box-shadow: 0 0 0 2px rgba(63,146,96,0.28);
  display: inline-block;
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse{ 0%,100%{ opacity: 1; } 50%{ opacity: 0.35; } }

/* CA lives right in this header row, per spec */
.acct-ca{
  position: relative;
  display: flex; align-items: baseline; gap: 8px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-off-sm);
  flex: 1 1 220px;
  min-width: 0;
  transition: transform 0.12s ease;
}
.acct-ca:active{ transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.ca-label{
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  background: var(--ink); color: var(--cream); padding: 2px 5px; border-radius: 4px;
  flex-shrink: 0;
}
.ca-value{
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ca-hint{
  margin-left: auto; font-size: 10.5px; color: #7a5a3f; flex-shrink: 0;
  white-space: nowrap;
}
.acct-ca.is-copied .ca-hint{ color: var(--mint-ink); font-weight: 700; }

.paw-stamp{
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px;
  fill: var(--coral-deep);
  transform: translate(-50%, -50%) scale(1.6) rotate(-10deg);
  opacity: 0;
  pointer-events: none;
}
.paw-stamp.is-stamping{ animation: stampIn 1.1s ease-out forwards; }
@keyframes stampIn{
  0%{ transform: translate(-50%,-50%) scale(1.8) rotate(-14deg); opacity: 0; }
  22%{ opacity: 0.9; }
  45%{ transform: translate(-50%,-50%) scale(0.94) rotate(-6deg); opacity: 0.85; }
  75%{ opacity: 0.7; }
  100%{ transform: translate(-50%,-50%) scale(1) rotate(-8deg); opacity: 0; }
}

.acct-controls{ display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-btn{
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-off-sm);
  transition: transform 0.12s ease;
}
.icon-btn:hover{ transform: translate(-1px,-1px); }
.icon-btn:active{ transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.x-btn svg{ width: 20px; height: 20px; }
.whisker{ fill: none; stroke: var(--ink); stroke-linecap: round; }
.whisker--thick{ stroke-width: 3.4; }
.whisker--thin{ stroke-width: 1.6; opacity: 0.7; }

.fund-btn{
  display: flex; align-items: center; gap: 7px;
  background: var(--gold);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 7px 14px 7px 7px;
  box-shadow: var(--shadow-off-sm);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.fund-btn:hover{ transform: translate(-1px,-1px); }
.fund-btn:active{ transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.fund-slot{
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gold-deep);
  border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.fund-slot::after{
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 14px; height: 3px; background: var(--ink);
  border-radius: 2px; transform: translate(-50%,-50%);
}
.fund-coin{
  width: 16px; height: 16px; fill: var(--gold); stroke: var(--ink);
  stroke-width: 1.4;
  position: relative;
  animation: coinBob 2.4s ease-in-out infinite;
}
.fund-coin path{ stroke: var(--ink); stroke-width: 1.3; }
@keyframes coinBob{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-2px); } }
.fund-label{
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  color: var(--ink);
}
.fund-btn.is-dropping .fund-coin{ animation: coinDrop 0.5s ease-in forwards; }
@keyframes coinDrop{ 0%{ transform: translateY(0) scale(1); opacity: 1; } 100%{ transform: translateY(9px) scale(0.4); opacity: 0; } }

/* --- Main panel body ----------------------------------------------------- */
.panel-main{ padding: 20px 20px 6px; display: flex; flex-direction: column; gap: 16px; }

.balance-stage{
  background: var(--cream-2);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-md);
  padding: 16px 18px 14px;
  position: relative;
}
.balance-top{ display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stage-label{
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: #6b4a30;
}
.status-chip{
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--mint); color: var(--mint-ink);
  border: 2px solid var(--ink);
  border-radius: 999px; padding: 3px 9px;
}

.balance-readout-wrap{
  position: relative;
  padding: 10px 0 4px;
  overflow: hidden;
}
.balance-readout{
  font-family: var(--font-mono);
  font-size: clamp(34px, 8vw, 54px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}
.balance-readout.is-clawed{ animation: clawShake 0.32s ease; }
@keyframes clawShake{
  0%,100%{ transform: translateX(0); }
  20%{ transform: translateX(-4px) rotate(-0.6deg); }
  45%{ transform: translateX(3px) rotate(0.4deg); }
  70%{ transform: translateX(-2px); }
}

.floaters{ position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.floater{
  position: absolute;
  font-family: var(--font-mono); font-weight: 700; font-size: 17px;
  color: var(--coral-deep);
  text-shadow: 1px 1px 0 var(--cream-2);
  animation: floatUp 1.5s ease-out forwards;
}
@keyframes floatUp{
  0%{ transform: translateY(6px) scale(0.8); opacity: 0; }
  18%{ opacity: 1; transform: translateY(-2px) scale(1.05); }
  100%{ transform: translateY(-56px) scale(1); opacity: 0; }
}

.paw-track{
  position: absolute; top: 6px; bottom: 6px; left: 0; right: 0;
  pointer-events: none;
}
.paw-icon{
  position: absolute; top: 50%; left: -18%;
  width: 92px; height: auto;
  transform: translate(0, -50%) rotate(-10deg);
  opacity: 0;
}
.paw-pad{ fill: var(--ink); opacity: 0.92; }
.paw-toe{ fill: var(--ink); opacity: 0.92; }
.paw-claw{ fill: none; stroke: var(--coral-deep); stroke-width: 2.4; stroke-linecap: round; }
.paw-icon.is-swiping{ animation: pawSwipe 1.05s cubic-bezier(.4,.02,.3,1) both; }
@keyframes pawSwipe{
  0%{ left: -18%; opacity: 0; transform: translate(0,-50%) rotate(-14deg) scale(0.9); }
  10%{ opacity: 1; }
  48%{ left: 46%; transform: translate(0,-50%) rotate(6deg) scale(1.05); }
  55%{ left: 52%; transform: translate(0,-50%) rotate(10deg) scale(1.08); }
  90%{ opacity: 1; }
  100%{ left: 116%; opacity: 0; transform: translate(0,-50%) rotate(16deg) scale(0.95); }
}

.sparkline-wrap{ margin-top: 6px; }
#sparkline{ width: 100%; height: 56px; display: block; }
#sparklineLine{
  fill: none; stroke: var(--coral-deep); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}

.balance-caption{ margin-top: 8px; font-size: 12.5px; color: #6b4a30; }

/* --- Stat row -------------------------------------------------------- */
.stat-row{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat-card{
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 10px 9px;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-off-sm);
}
.stat-card--claw{ background: var(--coral); }
.stat-label{
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em;
  text-transform: uppercase; color: #6b4a30; line-height: 1.2;
}
.stat-card--claw .stat-label{ color: #611f21; }
.stat-value{
  font-family: var(--font-mono); font-weight: 700; font-size: 17px;
  color: var(--ink);
}
.stat-sub{ font-size: 10px; color: #6b4a30; }
.stat-card--claw .stat-sub{ color: #7a2d2f; }

/* --- Activity log ------------------------------------------------------ */
.swipe-log{
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px 12px;
  max-height: 152px;
  display: flex; flex-direction: column;
}
.log-head{
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: #6b4a30;
  padding-bottom: 6px; border-bottom: 1.5px dashed rgba(33,20,10,0.25);
  margin-bottom: 6px;
}
.log-live{ display: flex; align-items: center; gap: 5px; color: var(--mint-ink); }
.log-list{ overflow-y: auto; display: flex; flex-direction: column-reverse; gap: 5px; }
.log-list li{
  font-size: 12px; line-height: 1.35;
  padding: 4px 0;
  border-bottom: 1px dotted rgba(33,20,10,0.15);
}
.log-list li:first-child{ border-bottom: none; }
.log-empty{ color: #8a6a4c; font-style: italic; }
.log-entry{ animation: logIn 0.35s ease; }
@keyframes logIn{ 0%{ opacity: 0; transform: translateY(-4px); } 100%{ opacity: 1; transform: translateY(0); } }
.log-amount{ font-family: var(--font-mono); font-weight: 700; color: var(--coral-deep); }
.log-time{ font-family: var(--font-mono); color: #8a6a4c; font-size: 10.5px; }

/* --- Footer -------------------------------------------------------------- */
.panel-footer{
  margin-top: auto;
  padding: 10px 20px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.footer-disclosure{ font-size: 10.5px; color: #8a6a4c; max-width: 380px; }
.canary{
  font-family: var(--font-mono); font-size: 10px; color: #8a6a4c;
  white-space: nowrap;
}
.canary.is-ok{ color: var(--mint-ink); }

/* -------------------------------------------------------------------------
   DEPTH - the scroll content beneath the panel. Same card language as the
   dashboard above (thick ink border, flat offset shadow, cream/peach/mint/
   coral/gold), stretched into four reading sections instead of one device.
   ------------------------------------------------------------------------- */
.depth{
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 52px;
  padding-bottom: 56px;
}

.depth-section{ scroll-margin-top: 24px; }

.reveal{
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible{ opacity: 1; transform: none; }

.section-head{ margin-bottom: 18px; max-width: 560px; }
.eyebrow{
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-deep);
  margin-bottom: 8px;
}
.section-head h2{
  font-size: clamp(22px, 4.6vw, 30px); font-weight: 700; line-height: 1.18;
  color: var(--ink);
}
.section-lede{ margin-top: 10px; font-size: 14px; color: #6b4a30; line-height: 1.5; }

/* --- Incident history ---------------------------------------------------- */
.incident-list{ display: flex; flex-direction: column; gap: 14px; }
.incident-card{
  background: var(--cream);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-off-sm);
}
.incident-meta{
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.incident-case{
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  background: var(--ink); color: var(--cream); padding: 2px 7px; border-radius: 4px;
}
.incident-date{
  font-family: var(--font-mono); font-size: 11px; color: #6b4a30;
}
.incident-sev{
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em;
  border: 2px solid var(--ink);
  border-radius: 999px; padding: 2px 9px;
}
.incident-sev--minor{ background: var(--mint); color: var(--mint-ink); }
.incident-sev--moderate{ background: var(--gold); color: var(--gold-deep); }
.incident-sev--severe{ background: var(--coral); color: var(--coral-deep); }
.incident-sev--permanent{ background: var(--ink); color: var(--cream); }
.incident-card h3{ font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.incident-card p{ font-size: 13.5px; line-height: 1.55; color: #3a2414; }

/* --- About the agent ------------------------------------------------------ */
.bio-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.bio-card{
  background: var(--cream-2);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-off-sm);
}
.spec-list{ display: flex; flex-direction: column; gap: 11px; }
.spec-list > div{
  display: flex; flex-direction: column; gap: 2px;
  padding-bottom: 9px; border-bottom: 1px dotted rgba(33,20,10,0.2);
}
.spec-list > div:last-child{ border-bottom: none; padding-bottom: 0; }
.spec-list dt{
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--mint-deep);
}
.spec-list dd{ margin: 0; font-size: 13px; color: var(--ink); line-height: 1.35; }
.bio-prose{
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding: 4px 4px;
}
.bio-prose p{ font-size: 14px; line-height: 1.6; color: #3a2414; }

/* --- Leaderboard ----------------------------------------------------------- */
.rank-list{ display: flex; flex-direction: column; gap: 8px; }
.rank-row{
  display: flex; align-items: center; gap: 14px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-off-sm);
}
.rank-row--self{ background: var(--peach); border-color: var(--ink); }
.rank-num{
  font-family: var(--font-mono); font-weight: 700; font-size: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--cream);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-row--self .rank-num{ background: var(--coral-deep); }
.rank-body{ display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rank-name{
  font-weight: 700; font-size: 13.5px; color: var(--ink);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.rank-tag{
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  background: var(--coral-deep); color: var(--cream);
  padding: 2px 6px; border-radius: 4px; letter-spacing: 0.03em;
}
.rank-cause{ font-size: 12px; color: #6b4a30; line-height: 1.4; }
.rank-loss{
  font-family: var(--font-mono); font-weight: 700; font-size: 13.5px;
  color: var(--coral-deep); flex-shrink: 0; white-space: nowrap;
}
.rank-foot{ margin-top: 14px; font-size: 12.5px; color: #6b4a30; font-style: italic; }

/* --- FAQ -------------------------------------------------------------------- */
.faq-list{ display: flex; flex-direction: column; gap: 10px; }
.faq-item{
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 4px 16px;
  box-shadow: var(--shadow-off-sm);
}
.faq-item summary{
  list-style: none;
  cursor: pointer;
  padding: 13px 26px 13px 0;
  font-weight: 700; font-size: 14px; color: var(--ink);
  position: relative;
}
.faq-item summary::-webkit-details-marker{ display: none; }
.faq-item summary::after{
  content: "+";
  position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 18px; font-weight: 700;
  color: var(--mint-deep);
  transition: transform 0.2s ease;
}
.faq-item[open] summary::after{ transform: translateY(-50%) rotate(45deg); }
.faq-item p{
  font-size: 13.5px; line-height: 1.55; color: #3a2414;
  padding: 0 0 14px;
}

/* --- Depth close ------------------------------------------------------------ */
.depth-close{
  text-align: center;
  font-size: 13px; color: #6b4a30;
  padding-top: 6px;
}
.back-to-panel{
  color: var(--coral-deep); font-weight: 700; text-decoration: none;
  border-bottom: 2px solid var(--coral-deep);
}
.back-to-panel:hover{ color: var(--ink); border-color: var(--ink); }

/* --- Reduced motion ------------------------------------------------------ */
.reduced-motion .live-dot,
.reduced-motion .fund-coin{ animation: none; }
.reduced-motion .paw-icon.is-swiping{ animation: none; opacity: 0; }
.reduced-motion .floater{ animation: floatUpReduced 1.2s ease-out forwards; }
@keyframes floatUpReduced{ 0%{ opacity: 0; } 20%{ opacity: 1; } 100%{ opacity: 0; } }
.reduced-motion .balance-readout.is-clawed{ animation: none; }
.reduced-motion .reveal{ transition: opacity 0.25s ease; transform: none; }
.reduced-motion .paw-stamp.is-stamping{ animation: stampInReduced 0.9s ease-out forwards; }
@keyframes stampInReduced{ 0%{ opacity: 0; transform: translate(-50%,-50%) scale(1) rotate(-8deg);} 25%{ opacity: 0.85; } 100%{ opacity: 0; transform: translate(-50%,-50%) scale(1) rotate(-8deg);} }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 560px){
  body{ padding: 12px; align-items: flex-start; }
  .dashboard{ box-shadow: 6px 6px 0 var(--ink); }
  .acct-header{ padding: 12px 14px; }
  .acct-name{ font-size: 13.5px; }
  .panel-main{ padding: 16px 14px 4px; }
  .stat-row{ grid-template-columns: repeat(2, 1fr); }
  .balance-readout{ font-size: clamp(28px, 11vw, 40px); }
  .fund-label{ display: none; }
  .fund-btn{ padding: 7px; }

  .depth{ gap: 40px; padding-bottom: 40px; }
  .bio-grid{ grid-template-columns: 1fr; }
  .rank-row{ flex-wrap: wrap; }
  .rank-loss{ margin-left: 42px; }
  .incident-sev{ margin-left: 0; }
}

@media (min-width: 920px){
  .dashboard{ max-width: 780px; }
  .balance-readout{ font-size: 58px; }
}
