/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0 var(--sp-5);
  border-radius: var(--radius-pill);
  border: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-200);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-md); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: var(--surface-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-text { background: transparent; color: var(--accent); padding: 0 var(--sp-2); min-height: auto; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-300);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.chip:active { transform: scale(0.94); background: var(--accent-soft); }
.chip svg { width: 16px; height: 16px; flex-shrink: 0; }
.chip--ghost {
  border-style: dashed;
  color: var(--ink-muted);
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.92); }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}

/* ---------- Tab bar ---------- */
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-2) 0;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: color var(--dur-fast);
}
.tab svg { width: 24px; height: 24px; transition: transform var(--dur-fast) var(--ease-out); }
.tab span { font-size: var(--fs-100); font-weight: 600; font-family: var(--font-display); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { transform: translateY(-2px); }
.tab:active svg { transform: scale(0.9); }

/* ---------- Segmented control ---------- */
.segment {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  gap: 2px;
}
.segment button {
  border: none;
  background: transparent;
  padding: var(--sp-2) var(--sp-4);
  min-height: 36px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-200);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast);
}
.segment button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ---------- Toggle switch ---------- */
.toggle {
  position: relative;
  width: 48px; height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-med) var(--ease-out);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-med) var(--ease-out);
}
.toggle[aria-checked="true"] { background: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Row / list ---------- */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
}
.row + .row { border-top: 1px solid var(--border); }
.row__label { font-weight: 600; font-size: var(--fs-300); }
.row__hint { color: var(--ink-muted); font-size: var(--fs-100); margin-top: 2px; }

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field label { font-size: var(--fs-200); font-weight: 600; color: var(--ink-muted); display: inline-flex; align-items: center; gap: 4px; }
.field label svg { width: 14px; height: 14px; }
.field input[type="number"],
.field input[type="text"],
.field input[type="time"] {
  font-family: var(--font-display);
  font-size: var(--fs-400);
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  min-height: 44px;
  width: 100%;
  transition: border-color var(--dur-fast);
}
.field input:focus { border-color: var(--accent); outline: none; }

/* ---------- Wave animation (reused inside the glass liquid) ---------- */
@keyframes wave-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.wave-a { animation: wave-drift 7s linear infinite; }
.wave-b { animation: wave-drift 11s linear infinite reverse; opacity: 0.6; }

/* ---------- 3D glass hero (Home) ---------- */
.glass-hero {
  --level: 0%;
  position: relative;
  width: 200px;
  height: 260px;
}
.glass-hero__group {
  position: absolute;
  inset: 0;
  animation: glass-float 4.5s ease-in-out infinite;
  transform-origin: 50% 92%;
  filter: drop-shadow(0 0 22px var(--neon-pink-soft));
}
.glass-hero.is-pulsing .glass-hero__group { animation: glass-float 4.5s ease-in-out infinite, glass-pulse 420ms var(--ease-out); }
.glass-hero--filled .glass-hero__group { filter: drop-shadow(0 0 36px var(--neon-pink-soft)); }
@keyframes glass-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-7px) rotate(-1.1deg); }
}
@keyframes glass-pulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.05, 0.94); }
  100% { transform: scale(1); }
}

.glass-hero__shadow-svg,
.glass-hero__frame-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.glass-hero__shadow-svg svg,
.glass-hero__frame-svg svg { width: 100%; height: 100%; display: block; }

.glass-hero__liquid-wrap {
  position: absolute;
  left: 22%;
  top: 19.2%;
  width: 56%;
  height: 66.2%;
  overflow: hidden;
  clip-path: path('M0,0 L112,0 L94,172 L18,172 Z');
}
.glass-hero__liquid {
  position: absolute;
  left: -25%;
  width: 150%;
  height: 150%;
  bottom: calc(var(--level) - 150%);
  transition: bottom var(--dur-slow) var(--ease-out);
}
.glass-hero__liquid svg { width: 100%; height: 100%; display: block; }

.glass-hero__bubble { animation: bubble-rise 3.2s linear infinite; }
@keyframes bubble-rise {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: .85; }
  85% { opacity: .2; }
  100% { transform: translateY(-64px); opacity: 0; }
}

.glass-hero-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: calc(var(--sp-2) * -1);
}
.wave-fill__value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-600); line-height: 1; }
.wave-fill__goal { font-size: var(--fs-100); color: var(--ink-muted); font-weight: 600; }

/* ---------- Streak badge ---------- */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px var(--sp-3) 6px 6px;
  border-radius: var(--radius-pill);
  background: var(--warm-soft);
  color: var(--warm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-200);
}
.streak svg { width: 20px; height: 20px; }

/* ---------- Quick add ---------- */
.quick-add {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: 2px;
}

/* ---------- Today list ---------- */
.log-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
}
.log-item + .log-item { border-top: 1px solid var(--border); }
.log-item__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.log-item__icon svg { width: 18px; height: 18px; }
.log-item__body { flex: 1; min-width: 0; }
.log-item__amount { font-weight: 700; font-size: var(--fs-300); }
.log-item__time { color: var(--ink-muted); font-size: var(--fs-100); }
.log-item__delete {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.log-item:hover .log-item__delete,
.log-item:focus-within .log-item__delete { opacity: 1; }
.log-item__delete:hover { background: var(--danger-soft); color: var(--danger); }
@media (hover: none) {
  .log-item__delete { opacity: 0.6; }
}

/* ---------- Empty state ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  color: var(--ink-muted);
}
.empty-state svg { width: 72px; height: 72px; color: var(--accent-soft); }
.empty-state h3 { font-size: var(--fs-300); color: var(--ink); }
.empty-state p { font-size: var(--fs-200); max-width: 32ch; }

/* ---------- Bottom sheet ---------- */
.sheet-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out);
}
.sheet-scrim.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  background: var(--bg-elevated);
  border-radius: 28px 28px 0 0;
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform var(--dur-med) var(--ease-out);
}
.sheet.is-open { transform: translateY(0); }
.sheet__handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: var(--radius-pill);
  margin: var(--sp-2) auto var(--sp-4);
}
.sheet__title { font-size: var(--fs-400); font-weight: 700; margin-bottom: var(--sp-4); }

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-5);
  margin: var(--sp-5) 0;
}
.stepper__value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-700); min-width: 3ch; text-align: center; }
.stepper__unit { font-size: var(--fs-300); color: var(--ink-muted); font-weight: 600; }
.stepper__btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: var(--fs-500);
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--dur-fast);
}
.stepper__btn:active { transform: scale(0.9); }

/* ---------- Toast (reminder preview) ---------- */
.toast-layer {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 95;
  padding: calc(var(--sp-3) + env(safe-area-inset-top, 0px)) var(--sp-3) 0;
  pointer-events: none;
}
.toast {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  box-shadow: var(--shadow-lg);
  transform: translateY(-140%);
  transition: transform var(--dur-med) var(--ease-out);
}
.toast.is-open { transform: translateY(0); }
.toast__avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--accent), var(--accent-strong));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.toast__avatar svg { width: 22px; height: 22px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title-row { display: flex; justify-content: space-between; gap: var(--sp-2); }
.toast__title { font-weight: 700; font-size: var(--fs-200); }
.toast__time { font-size: var(--fs-100); color: var(--ink-faint); flex-shrink: 0; }
.toast__text { font-size: var(--fs-200); color: var(--ink-muted); margin-top: 2px; }

/* ---------- Weekly chart ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  height: 160px;
  padding-top: var(--sp-4);
}
.chart__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  height: 100%;
  justify-content: flex-end;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.chart__bar-track {
  width: 100%;
  max-width: 28px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.chart__bar {
  width: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  transition: height var(--dur-slow) var(--ease-out), background var(--dur-fast);
}
.chart__col[aria-pressed="true"] .chart__bar { background: var(--accent); }
.chart__col--met .chart__bar { background: var(--success); }
.chart__col[aria-pressed="true"].chart__col--met .chart__bar { background: var(--success); }
.chart__label { font-size: var(--fs-100); color: var(--ink-muted); font-weight: 600; }
.chart__col[aria-pressed="true"] .chart__label { color: var(--ink); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.stat-tile {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  text-align: center;
}
.stat-tile__value { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-400); }
.stat-tile__label { font-size: var(--fs-100); color: var(--ink-muted); font-weight: 600; margin-top: 2px; }
