@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --primary-light: #60a5fa;
  --primary-dark: #1e40af;
  --accent: #0ea5e9;
  --bg: linear-gradient(135deg, #f0f9ff 0%, #dbeafe 50%, #e0f2fe 100%);
  --card: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.45);
  --text: #1e293b;
  --text-sub: #64748b;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

html { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100%;
  padding-bottom: calc(32px + var(--safe-bottom));
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 16px 12px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-text h1 {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.header-text p {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-top: 1px;
}

.settings-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1.5px solid rgba(37, 99, 235, 0.2);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-sub);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.settings-btn:active { transform: scale(0.92); }

/* ── Main layout ── */
main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px;
}

/* ── Summary stats ── */
.stats-grid {
  margin-bottom: 16px;
}

.stat-card--hero {
  position: relative;
  padding: 16px 14px 28px 18px;
  border-color: rgba(37, 99, 235, 0.18);
  background: rgba(239, 246, 255, 0.72);
  overflow: hidden;
}

.stat-hero-as-of {
  position: absolute;
  bottom: 10px;
  left: 14px;
  right: auto;
  top: auto;
  max-width: min(48%, 11rem);
  font-size: 0.5rem;
  line-height: 1.25;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  letter-spacing: 0.01em;
  z-index: 1;
}

.stat-hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, min(calc(19rem * 0.8), calc(46vw * 0.8)));
  gap: 12px 18px;
  align-items: start;
}

.stat-hero-bottle-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 0 6px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.stat-hero-metrics {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  align-self: stretch;
  justify-self: end;
  margin-bottom: 0.25rem;
}

.stat-hero-bottle-col .stat-stock-foot {
  margin-bottom: 12px;
}

.stat-hero-metrics .stat-card--nest {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.stat-card--nest {
  margin: 0;
  border-radius: 16px;
  box-shadow: 0 2px 14px rgba(37, 99, 235, 0.05);
  background: rgba(255, 255, 255, 0.82);
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.stat-hero-metrics .stat-card--nest .stat-label {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.stat-hero-metrics .stat-card--nest .stat-value {
  font-size: 1.12rem;
  flex-shrink: 0;
  text-align: right;
}

@media (max-width: 380px) {
  .stat-hero-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .stat-hero-bottle-col {
    align-items: center;
  }

  .stat-stock-center {
    justify-content: center;
    width: 100%;
  }

  .stat-hero-metrics {
    width: 100%;
    max-width: none;
    justify-self: stretch;
  }
}

.stat-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 14px 12px;
  box-shadow: 0 4px 24px rgba(37, 99, 235, 0.06);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-sub);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-sub);
  margin-left: 2px;
}

.stat-stock-center {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 4px 0 2px;
}

.stat-stock-bottle {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 10px 22px rgba(14, 116, 144, 0.22));
}

.stat-stock-bottle-cap {
  width: 51px;
  height: 12px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.stat-stock-bottle-neck {
  width: 33px;
  height: 9px;
  background: linear-gradient(90deg, rgba(255,255,255,0.55), rgba(148, 163, 184, 0.38));
  border-left: 1px solid rgba(37, 99, 235, 0.16);
  border-right: 1px solid rgba(37, 99, 235, 0.16);
}

.stat-stock-bottle-body {
  position: relative;
  width: 177px;
  height: 168px;
  margin-top: -1px;
  border-radius: 28px 28px 34px 34px;
  border: 2.5px solid rgba(37, 99, 235, 0.22);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.78) 0%, rgba(224, 242, 254, 0.48) 45%, rgba(186, 230, 253, 0.38) 100%);
  overflow: hidden;
  box-shadow: inset 0 14px 22px rgba(255, 255, 255, 0.55), inset 0 -8px 16px rgba(14, 165, 233, 0.09);
}

.stat-stock-bottle-fill {
  position: absolute;
  bottom: 5px;
  left: 5px;
  right: 5px;
  height: 0%;
  max-height: calc(100% - 10px);
  border-radius: 22px 22px 28px 28px;
  background: linear-gradient(180deg, #bae6fd 0%, #38bdf8 42%, #0284c7 100%);
  transition: height 0.45s cubic-bezier(0.33, 1, 0.68, 1);
}

.stat-stock-bottle.is-empty .stat-stock-bottle-body {
  opacity: 0.55;
}

.stat-stock-bottle.is-empty .stat-stock-bottle-fill {
  opacity: 0;
}

.stat-stock-bottle.is-low:not(.is-empty) .stat-stock-bottle-fill {
  background: linear-gradient(180deg, #fed7aa 0%, #fb923c 50%, #ea580c 100%);
}

.bottle-wave-svg {
  position: absolute;
  top: -12px;
  left: 0;
  width: 100%;
  height: 26px;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.bottle-parallax > use {
  animation: bottle-wave-move 12s cubic-bezier(.55,.5,.45,.5) infinite;
}
.bottle-parallax > use:nth-child(1) { animation-delay: -2s;  animation-duration: 5s; }
.bottle-parallax > use:nth-child(2) { animation-delay: -2s;  animation-duration: 8s; }
.bottle-parallax > use:nth-child(3) { animation-delay: -4s;  animation-duration: 10s; }
.bottle-parallax > use:nth-child(4) { animation-delay: -3s;  animation-duration: 14s; }

@keyframes bottle-wave-move {
  0%   { transform: translate3d(-90px, 0, 0); }
  100% { transform: translate3d(85px,  0, 0); }
}

.stat-stock-bottle-gloss {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0) 100%);
  mix-blend-mode: soft-light;
  z-index: 1;
}

.stat-stock-bottle-text {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 16px 18px;
}

.stat-stock-bottle-label {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.72);
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 1px 1px rgba(255, 255, 255, 0.85);
}

.stat-stock-bottle-metric {
  font-size: clamp(1.4rem, 5.5vw, 1.78rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.95), 0 1px 2px rgba(255, 255, 255, 0.9);
}

.stat-stock-bottle-metric .stat-unit {
  font-size: 0.58em;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.55);
  margin-left: 1px;
}

.stat-stock-foot {
  margin: 0;
  width: 100%;
  max-width: 177px;
  text-align: center;
  font-size: 0.62rem;
  line-height: 1.35;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-sub);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── Tab nav ── */
.tab-nav {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 4px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.12);
}

.tab-icon { font-size: 0.9rem; }

/* ── Amazon hint banner ── */
.amazon-hint {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.amazon-hint-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.amazon-hint-body {
  font-size: 0.8rem;
  color: var(--primary-dark);
  line-height: 1.55;
  opacity: 0.85;
}

.stat-hero-metrics .amazon-hint,
.stat-hero-metrics .depletion-hint {
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
  padding: 11px 12px;
  border-radius: 14px;
  box-sizing: border-box;
}

.stat-hero-metrics .amazon-hint-title,
.stat-hero-metrics .depletion-hint-title {
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.stat-hero-metrics .amazon-hint-body,
.stat-hero-metrics .depletion-hint-body {
  font-size: 0.72rem;
  line-height: 1.5;
}

.stat-hero-metrics .amazon-hint + .depletion-hint {
  margin-top: 2px;
}

/* ── Record card ── */
.record-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 26px;
  padding: 18px 16px 20px;
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.07);
  margin-bottom: 14px;
}

.record-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.date-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  flex-shrink: 0;
}

.date-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid rgba(37, 99, 235, 0.18);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s;
}
.date-input:focus { border-color: var(--primary); }

/* ── Mode toggle (bottle / ml) ── */
.mode-toggle {
  display: flex;
  gap: 4px;
  background: rgba(37, 99, 235, 0.07);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 16px;
}

.mode-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

/* ── Steppers (ボトルサイズ行を含む同一トラックで右端を揃える) ── */
.stepper-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stepper-rows > .stepper-row:first-child {
  margin-bottom: 6px;
}

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stepper-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
  min-width: 68px;
}

/* 右列：ステッパー幅を固定し、ボトルサイズボタンも同じ右端に揃える */
.stepper-rows .stepper-right {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  min-width: calc(48px + 48px + 44px + 3px);
  justify-content: flex-end;
}

.size-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: 50px;
  border: 2px solid var(--primary);
  background: white;
  color: var(--primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.14);
  user-select: none;
  max-width: 100%;
}

.size-toggle-btn:active {
  transform: scale(0.94);
  background: var(--primary);
  color: white;
}

.size-toggle-btn:active .cycle-icon { stroke: white; }

.cycle-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: var(--primary);
  transition: stroke 0.15s;
}

.stepper {
  display: flex;
  align-items: center;
  background: rgba(37, 99, 235, 0.05);
  border-radius: 16px;
  overflow: hidden;
  border: 1.5px solid rgba(37, 99, 235, 0.15);
}

.step-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  flex-shrink: 0;
}
.step-btn:active { background: rgba(37, 99, 235, 0.12); }

.step-val {
  min-width: 44px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* リットル直接入力：ボトル記録と同じ右端トラック */
#ml-inputs .stepper-right {
  min-width: calc(48px + 48px + 44px + 3px);
  justify-content: flex-end;
}

/* ── リットル直接入力（DB は ml 整数） ── */
.ml-step-display {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 72px;
  justify-content: center;
}

.ml-step-display span:first-child {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.ml-step-unit {
  font-size: 0.65rem;
  color: var(--text-sub);
}

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Consumption display ── */
.consumption-display {
  margin-top: 16px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(14, 165, 233, 0.06));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.consumption-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
}

.consumption-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

.consumption-value.uncertain {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Memo ── */
.memo-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.05);
}

.memo-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.memo-textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.5;
}

.memo-textarea::placeholder { color: var(--text-muted); }

/* ── History ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.05);
}

.history-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.history-date {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.history-delete {
  padding: 4px 10px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  background: transparent;
  color: var(--danger);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.history-delete:active { background: rgba(239, 68, 68, 0.08); }

.history-detail {
  font-size: 0.78rem;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.history-detail-row { display: flex; gap: 6px; }
.history-memo {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* ── Analysis ── */
.analysis-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.analysis-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.05);
}

.analysis-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.analysis-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.chart-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 18px 16px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.06);
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.8rem;
}

.chart-month {
  width: 48px;
  flex-shrink: 0;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.chart-bar-bg {
  flex: 1;
  height: 28px;
  background: rgba(37, 99, 235, 0.07);
  border-radius: 8px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chart-val {
  width: 44px;
  flex-shrink: 0;
  text-align: right;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Settings modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--safe-bottom);
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  background: white;
  border-radius: 28px 28px 0 0;
  padding: 20px 18px calc(28px + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(37, 99, 235, 0.12);
}

.modal-handle {
  width: 38px;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 0 auto 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  padding: 6px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-close:active { background: #f8fafc; }

.settings-group {
  margin-bottom: 22px;
}

.settings-group-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-group-label::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.settings-input-label {
  font-size: 0.73rem;
  color: var(--text-sub);
  font-weight: 500;
}

.settings-input {
  padding: 11px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 13px;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s;
  width: 100%;
}
.settings-input:focus { border-color: var(--primary); }

.settings-select {
  padding: 11px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 13px;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  outline: none;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.size-settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.size-settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
}

.size-settings-item .settings-input {
  background: white;
}

.size-settings-item-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.size-col-name { flex: 1; }
.size-col-liters { width: 80px; }

.save-btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 18px;
  background: var(--primary);
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
  transition: all 0.18s;
  margin-top: 6px;
}
.save-btn:active { transform: scale(0.97); box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2); }

.danger-btn {
  width: 100%;
  padding: 13px;
  border: 1.5px solid rgba(239, 68, 68, 0.3);
  border-radius: 14px;
  background: transparent;
  color: var(--danger);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.18s;
}
.danger-btn:active { background: rgba(239, 68, 68, 0.06); }

.logout-btn {
  width: 100%;
  padding: 13px;
  border: 1.5px solid rgba(100, 116, 139, 0.3);
  border-radius: 14px;
  background: transparent;
  color: var(--text-secondary, #64748b);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.18s;
}
.logout-btn:active { background: rgba(100, 116, 139, 0.06); }

/* ── Footer waves ── */
footer {
  position: relative;
  margin-top: 40px;
  min-height: 120px;
  overflow: hidden;
}

.waves {
  display: block;
  width: 100%;
  height: 60px;
  position: relative;
  margin-bottom: -8px;
}

.parallax > use {
  animation: wave-move 25s cubic-bezier(.55,.5,.45,.5) infinite;
}
.parallax > use:nth-child(1) { animation-delay: -2s; animation-duration: 7s; }
.parallax > use:nth-child(2) { animation-delay: -3s; animation-duration: 10s; }
.parallax > use:nth-child(3) { animation-delay: -4s; animation-duration: 13s; }
.parallax > use:nth-child(4) { animation-delay: -5s; animation-duration: 20s; }

@keyframes wave-move {
  0% { transform: translate3d(-90px, 0, 0); }
  100% { transform: translate3d(85px, 0, 0); }
}

.footer-bottom {
  background: var(--primary);
  padding: 20px 20px calc(20px + var(--safe-bottom));
  text-align: center;
  color: white;
}

.footer-bottom p {
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.8;
}

/* ── Sync error banner ── */
.sync-error-banner {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: #dc2626;
  color: white;
  padding: 10px 20px;
  border-radius: 0 0 14px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(220, 38, 38, 0.35);
  transition: top 0.3s ease;
  white-space: nowrap;
  max-width: 90vw;
}

.sync-error-banner.visible { top: 0; }

/* ── Depletion hint ── */
.depletion-hint {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(251, 191, 36, 0.08));
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.depletion-hint.depletion-urgent {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(248, 113, 113, 0.08));
  border-color: rgba(239, 68, 68, 0.35);
}

.depletion-hint-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 5px;
}

.depletion-hint.depletion-urgent .depletion-hint-title { color: #991b1b; }

.depletion-hint-body {
  font-size: 0.8rem;
  color: #92400e;
  line-height: 1.55;
  opacity: 0.85;
}

.depletion-hint.depletion-urgent .depletion-hint-body { color: #991b1b; }

/* ── Copy previous button ── */
.copy-prev-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1.5px dashed rgba(37, 99, 235, 0.25);
  border-radius: 13px;
  background: transparent;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.copy-prev-btn:active {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Anomaly badges in history ── */
.history-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.anomaly-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
}

.anomaly-high {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.anomaly-low {
  background: rgba(14, 165, 233, 0.1);
  color: #0284c7;
  border: 1px solid rgba(14, 165, 233, 0.25);
}

.history-item-anomaly {
  border-color: rgba(239, 68, 68, 0.2);
  background: linear-gradient(135deg, rgba(255,255,255,0.72), rgba(254, 242, 242, 0.5));
}

/* ── Utilities ── */
.hidden { display: none !important; }

.tab-content { animation: fade-in 0.2s ease; }

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

/* ── Auth ── */
.auth-screen {
  padding: 14px 10px;
}

.auth-card {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.06);
}

.auth-title {
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.auth-sub {
  margin: 8px 0 12px;
  color: var(--text-sub);
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.78rem;
  color: var(--text-sub);
  font-weight: 700;
}

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

.auth-input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255,255,255,0.9);
  font-family: inherit;
  font-weight: 700;
  outline: none;
}

.auth-input:focus {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.auth-btn {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.10);
  color: var(--primary);
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.12s ease;
}

.auth-btn:active {
  transform: translateY(1px);
  background: rgba(37, 99, 235, 0.16);
}

.auth-hint {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-sub);
  min-height: 1.2em;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(15, 23, 42, 0.10);
}

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}
.auth-google-btn:active {
  transform: translateY(1px);
  background: rgba(15, 23, 42, 0.04);
}

@media (max-width: 400px) {
  .analysis-summary { grid-template-columns: 1fr 1fr; }
  .analysis-summary .analysis-card:last-child { grid-column: 1 / -1; }
}
