:root {
  --bg: #f4efe7;
  --bg-accent: #efe2d1;
  --surface: rgba(255, 252, 247, 0.84);
  --surface-strong: #fffaf2;
  --ink: #201a16;
  --muted: #6f6257;
  --line: rgba(32, 26, 22, 0.1);
  --brand: #0b8f72;
  --brand-strong: #087862;
  --berry: #c04d5b;
  --gold: #d98c1d;
  --shadow: 0 24px 60px rgba(78, 52, 25, 0.12);
  --radius: 28px;
  --radius-sm: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(11, 143, 114, 0.14), transparent 34%),
    radial-gradient(circle at top right, rgba(192, 77, 91, 0.18), transparent 24%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 58%, #ece1d2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy,
.hero-card,
.surface {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: 32px;
  padding: 30px 28px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.eyebrow,
.hero-subtitle,
.surface-head p,
.item-meta,
.item-date,
.calendar-day-total,
.leader-note,
.story-next p,
.hero-caption {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.98;
  margin: 0;
}

.hero-subtitle {
  max-width: 36rem;
  font-size: 16px;
  line-height: 1.45;
  margin: 18px 0 0;
}

.hero-card {
  border-radius: 32px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(11, 143, 114, 0.92), rgba(5, 102, 87, 0.94)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  color: #f7fff8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-chip {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  text-transform: uppercase;
}

.hero-amount {
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
  font-weight: 700;
}

.hero-caption {
  color: rgba(247, 255, 248, 0.72);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  border-radius: 16px;
  min-height: 48px;
}

.tab.active {
  background: var(--ink);
  color: #fff8ef;
}

.panel {
  display: none;
  animation: rise 0.35s ease;
}

.panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 251, 245, 0.78);
  border: 1px solid rgba(32, 26, 22, 0.08);
  box-shadow: var(--shadow);
}

.metric-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  font-size: clamp(24px, 5vw, 28px);
  line-height: 1.1;
  word-break: break-word;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.content-grid > *,
.analytics-share-layout > * {
  min-width: 0;
}

.surface {
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.surface-head {
  margin-bottom: 18px;
}

.surface-head.between {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.surface-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.surface-head p {
  margin: 0;
}

.chart {
  min-height: 280px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 2px 0;
}

.chart-bars {
  display: block;
}

.chart-bars-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 14px;
  align-items: end;
  min-width: 560px;
}

.chart-bar {
  display: grid;
  gap: 9px;
  align-items: end;
  text-align: center;
}

.chart-bar-shape {
  min-height: 24px;
  border-radius: 22px 22px 10px 10px;
  background: linear-gradient(180deg, #0b8f72 0%, #075e50 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    0 10px 22px rgba(32, 26, 22, 0.08);
}

.chart-bar.calm .chart-bar-shape {
  background: linear-gradient(180deg, #42b883 0%, #0b8f72 100%);
}

.chart-bar.warm .chart-bar-shape {
  background: linear-gradient(180deg, #e6b85f 0%, #c58932 100%);
}

.chart-bar.hot .chart-bar-shape {
  background: linear-gradient(180deg, #db766e 0%, #b24c59 100%);
}

.chart-bar strong {
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.02em;
}

.chart-bar span,
.chart-bar small {
  color: var(--muted);
  white-space: nowrap;
}

.chart-bar small {
  font-size: 12px;
}

.breakdown-list {
  display: grid;
  gap: 12px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.breakdown-pill {
  width: 12px;
  height: 42px;
  border-radius: 999px;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.9);
}

.item-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.item-title {
  margin: 0;
  font-size: 17px;
}

.item-meta,
.item-date {
  margin: 6px 0 0;
  font-size: 14px;
}

.item-side {
  text-align: right;
  min-width: 92px;
}

.item-amount {
  font-size: 18px;
}

.calendar-controls {
  display: flex;
  gap: 8px;
}

.calendar-month-total {
  margin-top: 8px !important;
  color: var(--brand-strong) !important;
  font-weight: 800;
}

.ghost-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

.primary-btn {
  background: var(--brand);
  border-color: transparent;
  color: #f4fff8;
}

.primary-btn:disabled,
.ghost-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.calendar-day {
  border: 1px solid rgba(32, 26, 22, 0.08);
  background: rgba(255, 251, 245, 0.84);
  border-radius: 18px;
  min-height: 96px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calendar-day.empty {
  background: rgba(255, 255, 255, 0.28);
}

.calendar-day.has-items {
  background:
    linear-gradient(180deg, rgba(11, 143, 114, 0.12), rgba(255, 255, 255, 0.8)),
    rgba(255, 251, 245, 0.92);
  cursor: pointer;
}

.calendar-day.selected {
  outline: 2px solid var(--berry);
}

.calendar-day-number {
  font-weight: 700;
}

.calendar-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.calendar-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.empty-state {
  color: var(--muted);
  padding: 10px 0;
}

.leaderboard-badge {
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 249, 241, 0.9);
  color: var(--ink);
  border: 1px solid rgba(32, 26, 22, 0.08);
  margin-bottom: 14px;
}

.leader-level {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(11, 143, 114, 0.1);
  border: 1px solid rgba(11, 143, 114, 0.16);
}

.leader-level b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.leader-level span,
.leader-level-inline {
  color: var(--brand-strong);
  font-weight: 700;
}

.leader-level small {
  color: var(--muted);
  line-height: 1.35;
}

.leader-level-inline {
  margin-top: 3px;
  font-size: 13px;
}

.leader-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.leader-row.me {
  border-color: rgba(11, 143, 114, 0.24);
  background: rgba(233, 247, 242, 0.95);
  box-shadow: 0 10px 30px rgba(11, 143, 114, 0.08);
}

.leader-rank {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(11, 143, 114, 0.12);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.leader-row.me .leader-rank {
  background: rgba(11, 143, 114, 0.2);
  color: var(--brand-strong);
}

.leader-avatar {
  width: 46px;
  height: 46px;
  border-radius: 18px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 24px rgba(20, 34, 31, 0.12);
  background: rgba(11, 143, 114, 0.12);
}

.leader-avatar-fallback {
  display: grid;
  place-items: center;
  padding: 6px;
  background: linear-gradient(180deg, rgba(227, 246, 241, 0.98), rgba(212, 238, 231, 0.94));
}

.leader-avatar-fallback-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(1.02);
}

.leader-person {
  min-width: 0;
}

.leader-person strong {
  overflow-wrap: anywhere;
}

.leader-you {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.leader-separator {
  margin: 8px 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.analytics-share-surface {
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(11, 143, 114, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(250, 245, 237, 0.98));
}

.analytics-share-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 26px;
  align-items: center;
}

.analytics-share-copy {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(32, 26, 22, 0.06);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(248, 244, 236, 0.82)),
    radial-gradient(circle at top left, rgba(11, 143, 114, 0.08), transparent 40%);
  box-shadow: 0 18px 46px rgba(32, 26, 22, 0.08);
}

.share-copy-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 9px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(11, 143, 114, 0.14), rgba(11, 143, 114, 0.08));
  color: var(--brand-strong);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.analytics-share-copy h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 0.94;
  max-width: 14ch;
}

.analytics-share-copy p {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.story-card {
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: 26px;
  overflow: hidden;
  background: rgba(15, 42, 43, 0.08);
}

.story-card-frame {
  box-shadow: var(--shadow);
}

.story-preview-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 26px;
  box-shadow: 0 24px 52px rgba(12, 34, 34, 0.22);
}

.story-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.story-actions-inline {
  justify-content: flex-start;
  margin-top: 0;
  flex-wrap: wrap;
}

.empty-onboarding,
.premium-surface,
.profile-surface {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.empty-onboarding {
  align-items: stretch;
  background:
    radial-gradient(circle at 88% 12%, rgba(11, 143, 114, 0.12), transparent 28%),
    linear-gradient(135deg, rgba(255, 252, 247, 0.98), rgba(245, 239, 229, 0.96));
}

.empty-onboarding h2,
.premium-surface h2,
.profile-surface h2 {
  margin: 8px 0 8px;
}

.empty-onboarding p,
.premium-surface p,
.profile-surface p,
.premium-status {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.premium-surface {
  background:
    radial-gradient(circle at 92% 12%, rgba(255, 209, 102, 0.28), transparent 24%),
    radial-gradient(circle at 5% 0%, rgba(11, 143, 114, 0.28), transparent 32%),
    linear-gradient(135deg, rgba(13, 87, 75, 0.96), rgba(9, 119, 94, 0.88) 46%, rgba(255, 248, 231, 0.98));
  color: #fffaf2;
  min-height: 168px;
  overflow: hidden;
  position: relative;
}

.premium-status {
  margin-top: 10px;
  font-weight: 700;
  color: inherit;
}

.premium-surface .share-copy-badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fffaf2;
}

.premium-surface p {
  max-width: 660px;
  color: rgba(255, 250, 242, 0.78);
}

.premium-surface .primary-btn {
  min-width: 166px;
  background: #fffaf2;
  color: #0b6f5e;
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 16px 36px rgba(5, 53, 47, 0.22);
}

.premium-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.premium-benefits span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 250, 242, 0.9);
  font-size: 13px;
  font-weight: 800;
}

.profile-surface {
  background:
    radial-gradient(circle at 86% 12%, rgba(11, 143, 114, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(255, 252, 247, 0.98), rgba(246, 240, 230, 0.94));
  align-items: stretch;
}

.settings-hero {
  background:
    radial-gradient(circle at 90% 12%, rgba(11, 143, 114, 0.12), transparent 28%),
    linear-gradient(135deg, rgba(255, 252, 247, 0.98), rgba(247, 239, 228, 0.96));
}

.settings-hero h2 {
  margin: 8px 0;
}

.settings-hero p,
.settings-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-card h3 {
  margin: 12px 0 8px;
  font-size: 22px;
}

.settings-premium-card {
  background:
    radial-gradient(circle at 92% 8%, rgba(255, 209, 102, 0.26), transparent 26%),
    radial-gradient(circle at 0% 0%, rgba(11, 143, 114, 0.22), transparent 34%),
    linear-gradient(135deg, rgba(255, 252, 247, 0.98), rgba(241, 248, 239, 0.94));
  overflow: hidden;
  position: relative;
}

.settings-premium-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -46px;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  background: rgba(11, 143, 114, 0.08);
  pointer-events: none;
}

.settings-premium-card .primary-btn {
  margin-top: 18px;
  min-width: 148px;
  background:
    linear-gradient(135deg, var(--brand), var(--brand-strong));
  box-shadow: 0 14px 30px rgba(8, 120, 98, 0.18);
}

.settings-premium-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.settings-premium-benefits span {
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(32, 26, 22, 0.08);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 850;
}

.profile-controls {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: end;
  min-width: min(100%, 540px);
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(32, 26, 22, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.profile-controls .setting-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.choice-pill {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  min-height: 46px;
  border: 1px solid rgba(32, 26, 22, 0.1);
  border-radius: 16px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(249, 244, 236, 0.86));
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 22px rgba(78, 52, 25, 0.06);
}

.choice-pill strong,
.choice-pill span {
  display: block;
}

.choice-pill span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.choice-pill.active {
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.2), transparent 34%),
    linear-gradient(135deg, var(--brand), var(--brand-strong));
  border-color: transparent;
  color: #fffaf2;
}

.choice-pill.active span {
  color: rgba(255, 250, 242, 0.78);
}

.settings-control-stack {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.settings-control-stack label:not(.toggle-row) {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.settings-control-stack select {
  min-height: 44px;
  width: 100%;
  border: 1px solid rgba(32, 26, 22, 0.12);
  border-radius: 14px;
  padding: 0 38px 0 12px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 18px / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(250, 246, 238, 0.94));
  color: var(--ink);
  font: inherit;
  appearance: none;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(32, 26, 22, 0.08);
}

.toggle-row strong,
.toggle-row small {
  display: block;
}

.toggle-row small {
  margin-top: 4px;
  color: var(--muted);
}

.toggle-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

.insight-list {
  display: grid;
  gap: 12px;
}

.insight-card {
  border: 1px solid rgba(32, 26, 22, 0.08);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 251, 245, 0.78);
}

.insight-card strong {
  display: block;
  margin-bottom: 6px;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.item-row {
  cursor: pointer;
}

.item-row:hover {
  border-color: rgba(11, 143, 114, 0.22);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  min-width: min(520px, 100%);
}

.choice-card {
  border: 1px solid rgba(32, 26, 22, 0.08);
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(240, 248, 244, 0.82));
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  text-align: left;
  box-shadow: 0 14px 34px rgba(32, 26, 22, 0.08);
}

.choice-card:hover {
  transform: translateY(-1px);
  border-color: rgba(11, 143, 114, 0.24);
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.choice-card small {
  color: var(--muted);
  line-height: 1.35;
}

.premium-lock-note {
  margin: 6px 0 10px;
  color: var(--berry);
  font-size: 13px;
  font-weight: 700;
}

.check-grid input:disabled ~ span,
.check-grid label.is-disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(20, 16, 12, 0.38);
  overflow-x: hidden;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  width: min(680px, 100%);
  min-width: 0;
  max-width: 100%;
  max-height: min(92vh, 920px);
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 28px;
  padding: 22px;
  background: var(--surface-strong);
  box-shadow: 0 28px 80px rgba(20, 16, 12, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.item-form,
.item-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.item-form {
  gap: 14px;
  min-width: 0;
}

.item-form input,
.item-form select,
.item-form textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(32, 26, 22, 0.12);
  border-radius: 14px;
  min-height: 48px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.item-form input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  inline-size: 100%;
  text-align: left;
}

.item-form textarea {
  min-height: 86px;
  padding-top: 12px;
  resize: vertical;
}

.field-title,
.item-form label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.segmented,
.check-grid {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented label,
.check-grid label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(11, 143, 114, 0.08);
  border: 1px solid rgba(32, 26, 22, 0.06);
  color: var(--ink);
  font-weight: 800;
  overflow: hidden;
}

.segmented input,
.check-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label::before,
.check-grid label::before {
  content: "";
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 999px;
  border: 2px solid rgba(32, 26, 22, 0.36);
  background: rgba(255, 255, 255, 0.72);
}

.check-grid label::before {
  border-radius: 7px;
}

.segmented label.is-checked,
.check-grid label.is-checked {
  background:
    radial-gradient(circle at 92% 10%, rgba(255, 255, 255, 0.28), transparent 36%),
    linear-gradient(135deg, var(--brand), var(--brand-strong));
  border-color: transparent;
  color: #fffaf2;
}

.segmented label.is-checked span,
.check-grid label.is-checked span {
  color: #fffaf2;
}

.segmented label.is-checked::before {
  border-color: #fffaf2;
  background:
    radial-gradient(circle, #fffaf2 0 38%, transparent 42%),
    rgba(255, 255, 255, 0.22);
}

.check-grid label.is-checked::before {
  content: "✓";
  border-color: #fffaf2;
  background: #fffaf2;
  color: var(--brand-strong);
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
}

.icon-btn {
  min-width: 44px;
  padding: 0;
  font-size: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.danger-btn {
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background: var(--berry);
  font-weight: 700;
}

.leaderboard-share {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(32, 26, 22, 0.08);
  background: linear-gradient(135deg, rgba(11, 143, 114, 0.08), rgba(255, 252, 247, 0.96));
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.leaderboard-share strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

.leaderboard-share p {
  margin: 0;
  color: var(--muted);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero,
  .content-grid,
  .analytics-share-layout {
    grid-template-columns: 1fr;
  }

  .analytics-share-copy {
    padding: 22px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leaderboard-share {
    flex-direction: column;
    align-items: flex-start;
  }

  .empty-onboarding,
  .premium-surface,
  .profile-surface {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .premium-surface .primary-btn,
  .profile-controls .ghost-btn {
    width: 100%;
  }

  .choice-grid {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 12px 28px;
  }

  .hero-copy,
  .hero-card,
  .surface {
    border-radius: 24px;
  }

  .tabbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .tab {
    font-size: 13px;
    min-height: 44px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 110px;
  }

  .surface {
    padding: 18px;
  }

  .calendar-day {
    min-height: 74px;
    padding: 8px;
  }

  .calendar-day-total {
    display: none;
  }

  .list-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .breakdown-row {
    grid-template-columns: auto 1fr;
    align-items: start;
  }

  .breakdown-row > strong {
    grid-column: 2;
    margin-top: 4px;
    font-size: 16px;
  }

  .item-side {
    min-width: 0;
    text-align: left;
  }

  .item-amount {
    display: block;
    margin-top: 4px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 6px;
  }

  .chart-bars-track {
    min-width: 0;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
  }

  .chart-bar strong {
    font-size: 11px;
  }

  .chart-bar span {
    font-size: 12px;
  }

  .chart-bar small {
    display: none;
  }

  .story-actions {
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal-sheet {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    max-height: calc(100vh - 96px);
    border-radius: 28px 28px 0 0;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }

  .modal-sheet .surface-head.between {
    position: sticky;
    top: -18px;
    z-index: 2;
    margin: -18px -18px 16px;
    padding: 18px;
    background: rgba(255, 250, 242, 0.94);
    backdrop-filter: blur(16px);
  }

  .modal-actions {
    position: sticky;
    bottom: calc(-18px - env(safe-area-inset-bottom));
    z-index: 2;
    margin: 8px -18px calc(-18px - env(safe-area-inset-bottom));
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 250, 242, 0.94);
    backdrop-filter: blur(16px);
  }

  .modal-actions > * {
    flex: 1;
  }

  .segmented,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .segmented label,
  .check-grid label {
    min-height: 52px;
    border-radius: 18px;
    padding: 12px 14px;
  }
}
