/* ==========================================================================
   Tiki Tab — tropical design system
   --------------------------------------------------------------------------
   3 themes via html[data-theme]:
     island  "Island Time"    — sunset default
     tiki    "Midnight Tiki"  — dark neon night
     cabana  "Beach Cabana"   — bright day
   Mobile-first. Tap targets ≥ 44px, inputs ≥ 16px (no iOS zoom), safe-area
   insets everywhere, tabular-nums for money, glass cards over fixed SVG
   beach scenes. System fonts only — this app works on a boat with no bars.
   ========================================================================== */

/* ---------- theme tokens ---------- */

:root,
html[data-theme='island'] {
  --sky: linear-gradient(180deg, #ffc98a 0%, #ff9966 26%, #ff5e62 46%, #8e4b8e 63%, #0e7c86 78%, #0a5f6b 100%);
  --bg-art: url('/art/bg-island.svg');

  --card: rgba(255, 250, 240, 0.82);
  --card-solid: #fffaf0;
  --card-border: rgba(255, 255, 255, 0.55);
  --card-blur: 14px;
  --card-shadow: 0 10px 30px rgba(70, 32, 63, 0.18), 0 2px 8px rgba(70, 32, 63, 0.08);

  --ink: #26312e;
  --ink-soft: rgba(38, 49, 46, 0.62);
  --ink-faint: rgba(38, 49, 46, 0.42);
  --line: rgba(38, 49, 46, 0.1);

  --accent: #ff5e62;
  --accent-2: #ff9966;
  --accent-grad: linear-gradient(135deg, #ff9966 0%, #ff5e62 55%, #f0446d 100%);
  --accent-contrast: #ffffff;
  --accent-soft: rgba(255, 94, 98, 0.12);
  --glow: rgba(255, 94, 98, 0.38);
  --ring: rgba(255, 94, 98, 0.28);

  --pos: #0a8754;
  --neg: #d7263d;
  --pos-soft: rgba(10, 135, 84, 0.12);
  --neg-soft: rgba(215, 38, 61, 0.1);
  --pos-grad: linear-gradient(90deg, #0a8754, #22b573);
  --neg-grad: linear-gradient(90deg, #d7263d, #ff5e62);
  --warn: #b3831d;

  --chip: rgba(255, 255, 255, 0.65);
  --chip-active: #ff5e62;
  --chip-active-ink: #ffffff;

  --tabbar-bg: rgba(255, 250, 240, 0.9);
  --tab-active-bg: rgba(255, 94, 98, 0.12);
  --fab-ring: rgba(255, 250, 240, 0.85);

  --input-bg: rgba(255, 255, 255, 0.85);
  --backdrop: rgba(46, 20, 44, 0.45);
  --scrim-top: rgba(70, 32, 63, 0.18);
  --hero-ink: #ffffff;
  --hero-shadow: 0 4px 18px rgba(70, 32, 63, 0.55);
}

html[data-theme='tiki'] {
  --sky: linear-gradient(180deg, #0b1026 0%, #141b3f 55%, #1a2151 72%, #0b1026 100%);
  --bg-art: url('/art/bg-tiki.svg');

  --card: rgba(20, 28, 58, 0.75);
  --card-solid: #141c3a;
  --card-border: rgba(0, 229, 160, 0.18);
  --card-blur: 16px;
  --card-shadow: 0 10px 30px rgba(0, 0, 8, 0.5), 0 0 24px rgba(0, 229, 160, 0.1);

  --ink: #eef2ff;
  --ink-soft: rgba(238, 242, 255, 0.62);
  --ink-faint: rgba(238, 242, 255, 0.4);
  --line: rgba(238, 242, 255, 0.12);

  --accent: #00e5a0;
  --accent-2: #00b4d8;
  --accent-grad: linear-gradient(135deg, #00e5a0 0%, #00c9b7 55%, #00b4d8 100%);
  --accent-contrast: #06251a;
  --accent-soft: rgba(0, 229, 160, 0.14);
  --glow: rgba(0, 229, 160, 0.35);
  --ring: rgba(0, 229, 160, 0.3);

  --pos: #00e5a0;
  --neg: #ff7a5c;
  --pos-soft: rgba(0, 229, 160, 0.12);
  --neg-soft: rgba(255, 122, 92, 0.12);
  --pos-grad: linear-gradient(90deg, #00b487, #00e5a0);
  --neg-grad: linear-gradient(90deg, #e05a3c, #ff7a5c);
  --warn: #ffc94d;

  --chip: rgba(238, 242, 255, 0.09);
  --chip-active: #00e5a0;
  --chip-active-ink: #06251a;

  --tabbar-bg: rgba(11, 16, 38, 0.88);
  --tab-active-bg: rgba(0, 229, 160, 0.13);
  --fab-ring: rgba(11, 16, 38, 0.85);

  --input-bg: rgba(238, 242, 255, 0.07);
  --backdrop: rgba(0, 0, 10, 0.6);
  --scrim-top: rgba(4, 6, 18, 0.35);
  --hero-ink: #ffffff;
  --hero-shadow: 0 4px 22px rgba(0, 229, 160, 0.4);
}

html[data-theme='cabana'] {
  --sky: linear-gradient(180deg, #7fd8f7 0%, #c7ecf9 45%, #e8f7fb 62%, #00b4d8 78%, #f7ead7 100%);
  --bg-art: url('/art/bg-cabana.svg');

  --card: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --card-border: rgba(255, 255, 255, 0.75);
  --card-blur: 14px;
  --card-shadow: 0 10px 28px rgba(27, 58, 75, 0.14), 0 2px 6px rgba(27, 58, 75, 0.06);

  --ink: #1b3a4b;
  --ink-soft: rgba(27, 58, 75, 0.6);
  --ink-faint: rgba(27, 58, 75, 0.4);
  --line: rgba(27, 58, 75, 0.1);

  --accent: #00b4d8;
  --accent-2: #33c5e8;
  --accent-grad: linear-gradient(135deg, #33c5e8 0%, #00b4d8 55%, #0096c7 100%);
  --accent-contrast: #ffffff;
  --accent-soft: rgba(0, 180, 216, 0.12);
  --glow: rgba(0, 180, 216, 0.35);
  --ring: rgba(0, 180, 216, 0.28);

  --pos: #5c9400;
  --neg: #d7263d;
  --pos-soft: rgba(127, 184, 0, 0.14);
  --neg-soft: rgba(215, 38, 61, 0.1);
  --pos-grad: linear-gradient(90deg, #5c9400, #7fb800);
  --neg-grad: linear-gradient(90deg, #d7263d, #ff5e62);
  --warn: #cf8600;

  --chip: rgba(255, 255, 255, 0.75);
  --chip-active: #00b4d8;
  --chip-active-ink: #ffffff;

  --tabbar-bg: rgba(255, 255, 255, 0.9);
  --tab-active-bg: rgba(0, 180, 216, 0.12);
  --fab-ring: rgba(255, 255, 255, 0.9);

  --input-bg: rgba(255, 255, 255, 0.92);
  --backdrop: rgba(27, 58, 75, 0.42);
  --scrim-top: rgba(27, 58, 75, 0.12);
  --hero-ink: #1b3a4b;
  --hero-shadow: 0 2px 12px rgba(255, 255, 255, 0.65);
}

/* shared shape + motion tokens */
:root {
  --r-lg: 20px;
  --r-md: 16px;
  --r-sm: 12px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --shell-max: 560px;
}

/* ---------- base ---------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Author display declarations (.tabbar grid, .pill inline-flex) beat the UA's
   [hidden] rule, so re-assert it — app.js drives chrome via the hidden prop. */
[hidden] {
  display: none !important;
}

html {
  height: 100%;
  background: var(--sky);
}

body {
  min-height: 100%;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  /* the sky lives on <html> (overscroll) and on the fixed #bg layer —
     body itself stays transparent so the z-index:-1 scene shows through */
  background: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

::selection {
  background: var(--accent);
  color: var(--accent-contrast);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- background scene (fixed layer — iOS-safe, no bg-attachment) ---------- */

#bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--sky);
  pointer-events: none;
}

#bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-art);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* explicit per-theme art wiring (matches the --bg-art tokens above) */
html[data-theme='island'] #bg::after {
  background-image: url('/art/bg-island.svg');
}

html[data-theme='tiki'] #bg::after {
  background-image: url('/art/bg-tiki.svg');
}

html[data-theme='cabana'] #bg::after {
  background-image: url('/art/bg-cabana.svg');
}

/* faint top scrim so the status pill & headers read over bright skies */
#bg::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 140px;
  z-index: 1;
  background: linear-gradient(180deg, var(--scrim-top), transparent);
}

/* ---------- typography helpers ---------- */

.money {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- layout shell ---------- */

#view {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px
    calc(110px + env(safe-area-inset-bottom, 0px));
}

.screen {
  animation: screen-in 0.34s var(--ease-out) both;
}

/* Data-refresh re-renders of the same route (25s pull merges etc.) skip the
   entry animation so long lists don't visibly "replay" under the reader. */
.screen.no-anim {
  animation: none;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 8px;
}

.screen-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 1;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  font-size: 20px;
  border-radius: 14px;
  transition: transform 0.18s var(--spring), background-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--chip);
}

.section {
  margin-top: 20px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.section-link {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  padding: 4px 2px;
}

.muted {
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- glass cards ---------- */

.card {
  position: relative;
  background: var(--card);
  -webkit-backdrop-filter: blur(var(--card-blur)) saturate(1.35);
  backdrop-filter: blur(var(--card-blur)) saturate(1.35);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 14px;
}

/* solid-ish fallback when backdrop-filter is unsupported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card {
    background: var(--card-solid);
  }

  .tabbar {
    background: var(--card-solid);
  }
}

/* ---------- rows & lists ---------- */

.list {
  display: flex;
  flex-direction: column;
  padding: 4px 14px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 9px 0;
  text-align: left;
  border-bottom: 1px solid var(--line);
  transition: transform 0.18s var(--spring), opacity 0.12s ease;
}

button.row:active,
a.row:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.row:last-child {
  border-bottom: 0;
}

.row-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--chip);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 13px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-amt {
  font-weight: 750;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.pos {
  color: var(--pos);
}

.neg {
  color: var(--neg);
}

html[data-theme='tiki'] .stat-value.pos {
  text-shadow: 0 0 16px rgba(0, 229, 160, 0.45);
}

html[data-theme='tiki'] .stat-value.neg {
  text-shadow: 0 0 16px rgba(255, 122, 92, 0.45);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--chip);
  border: 1px solid transparent;
  transition: transform 0.18s var(--spring), box-shadow 0.18s ease, opacity 0.12s ease,
    filter 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent-grad);
  color: var(--accent-contrast);
  box-shadow: 0 6px 18px var(--glow);
}

.btn-primary:active {
  box-shadow: 0 3px 10px var(--glow);
}

.btn-secondary {
  background: var(--chip);
  color: var(--ink);
  border-color: var(--line);
}

.btn-danger {
  background: var(--neg-soft);
  color: var(--neg);
  border-color: var(--neg);
}

.btn-block {
  display: flex;
  width: 100%;
  margin-top: 16px;
}

.btn-small {
  min-height: 40px;
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 13px;
}

.btn-tiny {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 13px;
  border-radius: 10px;
  background: var(--chip);
  border: 1px solid var(--line);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}

.btn-row.wrap {
  flex-wrap: wrap;
}

.grow {
  flex: 1;
}

@media (hover: hover) {
  .btn:hover {
    filter: brightness(1.05);
  }

  .icon-btn:hover,
  .chip:hover,
  .tab:hover {
    background: var(--chip);
  }
}

/* ---------- trip home ---------- */

.trip-header {
  justify-content: space-between;
}

.trip-switch {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: calc(100% - 56px);
  border-radius: 14px;
  padding: 2px 6px 2px 2px;
  transition: transform 0.18s var(--spring);
}

.trip-switch:active {
  transform: scale(0.97);
}

.trip-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.trip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-caret {
  font-size: 13px;
  color: var(--ink-soft);
}

.trip-sub {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  padding: 14px 16px;
}

.stat-wide {
  grid-column: 1 / -1;
}

.stat-card.is-pos {
  background: linear-gradient(0deg, var(--pos-soft), var(--pos-soft)), var(--card);
  border-color: var(--pos);
}

.stat-card.is-neg {
  background: linear-gradient(0deg, var(--neg-soft), var(--neg-soft)), var(--card);
  border-color: var(--neg);
}

.stat-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 27px;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-wide .stat-value {
  font-size: 31px;
}

.avatar-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 16px 4px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.avatar-row::-webkit-scrollbar {
  display: none;
}

.avatar-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.avatar-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settled-banner {
  margin-top: 14px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  padding: 18px 16px;
  background: linear-gradient(0deg, var(--pos-soft), var(--pos-soft)), var(--card);
  border-color: var(--pos);
}

.settled-banner.big {
  margin-top: 16px;
  padding: 34px 18px;
  font-size: 19px;
}

/* ---------- avatars ---------- */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--chip);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 2px var(--card-border), 0 2px 6px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-emoji {
  line-height: 1;
}

/* ---------- tab bar + FAB ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 7px 8px calc(env(safe-area-inset-bottom, 0px) + 7px);
  background: var(--tabbar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--card-border);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border-radius: 14px;
  opacity: 0.6;
  transition: opacity 0.18s ease, transform 0.18s var(--spring), background-color 0.18s ease;
}

.tab.active {
  opacity: 1;
  background: var(--tab-active-bg);
}

.tab.active .tab-label {
  color: var(--accent);
}

.tab:active {
  transform: scale(0.94);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.18s var(--spring);
}

.tab.active .tab-icon {
  transform: translateY(-1px) scale(1.08);
}

.tab-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.fab {
  width: 60px;
  height: 60px;
  margin: -24px auto 0;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--accent-contrast);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  border: 3px solid var(--fab-ring);
  box-shadow: 0 8px 22px var(--glow), 0 3px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s var(--spring), box-shadow 0.18s ease;
}

.fab:active {
  transform: scale(0.9);
  box-shadow: 0 4px 12px var(--glow);
}

/* ---------- status pill ---------- */

.pill {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--card);
  -webkit-backdrop-filter: blur(12px) saturate(1.35);
  backdrop-filter: blur(12px) saturate(1.35);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  pointer-events: none;
  animation: pill-in 0.25s var(--ease-out) both;
}

@keyframes pill-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.pill::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
}

.pill[data-status='offline'] {
  color: var(--neg);
}

.pill[data-status='offline']::before {
  background: var(--neg);
}

.pill[data-status='pending'] {
  color: var(--warn);
}

.pill[data-status='pending']::before {
  background: var(--warn);
}

.pill[data-status='syncing']::before {
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.pill[data-status='synced'] {
  color: var(--pos);
}

.pill[data-status='synced']::before {
  background: var(--pos);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0.55;
  }
}

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px);
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 88vw;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--card);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  backdrop-filter: blur(14px) saturate(1.35);
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  opacity: 0;
  transform: translateY(14px) scale(0.95);
  transition: opacity 0.28s var(--ease-out), transform 0.32s var(--spring);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ---------- bottom sheets ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.open {
  opacity: 1;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  max-width: var(--shell-max);
  margin: 0 auto;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 22px);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0.25, 1);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
}

.sheet.open {
  transform: translateY(0);
}

/* Sticky grab header: handle + title + ✕ stay put while the form scrolls,
   and the whole strip is a drag-to-dismiss target (touch-action: none). */
.sheet-grab {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -8px -18px 0;
  padding: 8px 18px 2px;
  background: var(--card-solid);
  border-radius: 26px 26px 0 0;
  touch-action: none;
  cursor: grab;
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  margin: 8px auto 12px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: 12px;
  padding: 0 44px; /* keep long titles clear of the ✕ button */
}

.sheet-close {
  position: absolute;
  top: 16px;
  right: 14px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.15s var(--spring), background-color 0.15s ease;
}

.sheet-close:active {
  transform: scale(0.9);
}

.sheet-body {
  padding-bottom: 8px;
}

body.sheet-open {
  overflow: hidden;
}

/* ---------- forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.field-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-emoji {
  width: 76px;
  flex-shrink: 0;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--input-bg);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--ink-faint);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.input-emoji {
  text-align: center;
  font-size: 22px;
}

.textarea {
  min-height: 72px;
  resize: vertical;
}

.select {
  appearance: none;
  -webkit-appearance: none;
}

.amount-wrap {
  display: flex;
  justify-content: center;
}

.input-amount {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-height: 68px;
  max-width: 260px;
  border-radius: 18px;
}

.file-input {
  font-size: 14px;
  max-width: 220px;
}

/* ---------- chips / segmented control ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 2px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chips-scroll::-webkit-scrollbar {
  display: none;
}

.chip {
  min-height: 44px;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  transition: transform 0.18s var(--spring), background-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}

.chip:active {
  transform: scale(0.94);
}

.chip.active {
  background: var(--chip-active);
  color: var(--chip-active-ink);
  border-color: var(--chip-active);
  box-shadow: 0 3px 12px var(--glow);
}

.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}

.seg-btn {
  min-height: 40px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: transform 0.18s var(--spring), background-color 0.15s ease, color 0.15s ease;
}

.seg-btn:active {
  transform: scale(0.95);
}

.seg-btn.active {
  background: var(--accent-grad);
  color: var(--accent-contrast);
  box-shadow: 0 2px 10px var(--glow);
}

/* ---------- expense sheet: payers + splits ---------- */

.payer-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 3px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.payer-row::-webkit-scrollbar {
  display: none;
}

.payer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 64px;
  min-height: 74px;
  padding: 7px 6px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: transform 0.18s var(--spring), border-color 0.15s ease, background-color 0.15s ease;
}

.payer:active {
  transform: scale(0.94);
}

.payer.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.payer-name {
  font-size: 12px;
  font-weight: 650;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-section {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.split-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.split-row:last-of-type {
  border-bottom: 0;
}

.split-row input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.split-name {
  flex: 1;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.split-amt {
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.split-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-mini {
  width: 104px;
  min-height: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.split-suffix {
  color: var(--ink-soft);
  font-weight: 700;
  width: 18px;
}

.split-validation {
  min-height: 24px;
  padding-top: 8px;
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.split-validation.invalid {
  color: var(--neg);
}

.split-validation.valid {
  color: var(--pos);
}

/* ---------- balances ---------- */

.balances-list {
  padding: 10px 14px;
}

.net-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.net-row:last-child {
  border-bottom: 0;
}

.net-main {
  flex: 1;
  min-width: 0;
}

.net-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 7px;
}

.net-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.net-amt {
  font-weight: 750;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.net-bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--chip);
  border: 1px solid var(--line);
  overflow: hidden;
}

.net-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.45s var(--ease-out);
}

.net-bar.pos {
  background: var(--pos-grad);
}

.net-bar.neg {
  background: var(--neg-grad);
}

.transfer-row .row-sub {
  font-size: 15px;
  font-weight: 750;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.venmo-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-size: 14px;
  flex-wrap: wrap;
}

.venmo-handle {
  font-weight: 750;
  color: var(--accent);
}

/* ---------- crew ---------- */

.crew-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crew-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.crew-info {
  flex: 1;
  min-width: 0;
}

.crew-name {
  font-size: 17px;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.crew-sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.badge-owner {
  background: var(--accent-grad);
  border-color: transparent;
  color: var(--accent-contrast);
}

.profile-preview {
  display: flex;
  justify-content: center;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}

.emoji-cell {
  min-height: 44px;
  font-size: 22px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--chip);
  transition: transform 0.18s var(--spring), border-color 0.15s ease;
}

.emoji-cell:active {
  transform: scale(0.88);
}

.emoji-cell.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- settings ---------- */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 8px;
  border: 2px solid var(--card-border);
  min-height: 84px;
  transition: transform 0.18s var(--spring), border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-swatch:active {
  transform: scale(0.95);
}

.theme-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring), var(--card-shadow);
}

.swatch-dots {
  display: flex;
  gap: 5px;
}

.swatch-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.12);
}

.swatch-label {
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.version-line {
  text-align: center;
  margin-top: 26px;
  color: var(--ink-faint);
}

/* ---------- welcome / claim ---------- */

.view-welcome {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 78vh;
  min-height: 78dvh;
  gap: 26px;
}

.welcome-hero {
  text-align: center;
}

.welcome-emoji {
  font-size: 76px;
  line-height: 1.15;
  display: inline-block;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.22));
  animation: float 4.5s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-9px) rotate(2deg);
  }
}

.welcome-title {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--hero-ink);
  text-shadow: var(--hero-shadow);
}

.welcome-tagline {
  font-size: 16px;
  font-weight: 650;
  color: var(--ink);
  opacity: 0.85;
  margin-top: 4px;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.25);
}

html[data-theme='tiki'] .welcome-tagline {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.welcome-card {
  text-align: center;
  padding: 26px 20px;
}

.welcome-invite {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.welcome-sub {
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- expense detail ---------- */

.detail-card {
  text-align: center;
  padding: 26px 18px;
}

.detail-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  background: var(--chip);
  border: 1px solid var(--line);
}

.detail-desc {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-top: 10px;
  overflow-wrap: break-word;
}

.detail-amount {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent);
}

.detail-meta {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  margin-top: 6px;
}

.detail-notes {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.detail-added {
  text-align: center;
  margin-top: 12px;
  font-size: 13px;
}

/* ---------- empty states ---------- */

.empty-state {
  text-align: center;
  padding: 36px 18px;
  border-style: dashed;
  border-width: 2px;
  border-color: var(--line);
  box-shadow: none;
}

.empty-emoji {
  font-size: 52px;
  line-height: 1.2;
  display: inline-block;
  animation: bob 3.2s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.empty-title {
  font-size: 18px;
  font-weight: 800;
  margin-top: 10px;
}

.empty-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- confetti + boot ---------- */

.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  min-height: 70dvh;
  gap: 10px;
}

.boot-emoji {
  font-size: 60px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.22));
  animation: float 4.5s ease-in-out infinite;
}

.boot-name {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--hero-ink);
  text-shadow: var(--hero-shadow);
}

/* ---------- trip switcher rows ---------- */

.trip-row.active .row-title {
  color: var(--accent);
}

.trip-row.archived {
  opacity: 0.55;
}

/* ---------- desktop niceties ---------- */

@media (min-width: 700px) {
  #view {
    padding-top: 32px;
  }

  ::-webkit-scrollbar {
    width: 10px;
  }

  ::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 5px;
  }

  ::-webkit-scrollbar-track {
    background: transparent;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .screen,
  .welcome-emoji,
  .boot-emoji,
  .empty-emoji {
    animation: none;
  }
}
