:root {
  --ink: #102a32;
  --muted: #4a6b75;
  --paper: rgba(255, 252, 248, 0.82);
  --paper-solid: #fffaf4;
  --line: rgba(16, 42, 50, 0.1);
  --water: #0f7a8a;
  --water-deep: #0a4d5c;
  --water-soft: #b8e4ea;
  --cal: #c45c26;
  --cal-deep: #8f3d14;
  --cal-soft: #f3d0b8;
  --shadow: 0 18px 50px rgba(10, 77, 92, 0.18);
  --radius: 28px;
  --font: "Outfit", sans-serif;
  --display: "Syne", sans-serif;
  --ring: 326.56;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: #0a4d5c;
  line-height: 1.45;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, #1a8a9a 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 10%, #d97845 0%, transparent 50%),
    linear-gradient(165deg, #0a4d5c 0%, #136b7a 42%, #1f6d62 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(184, 228, 234, 0.18), transparent 35%),
    radial-gradient(circle at 80% 70%, rgba(243, 208, 184, 0.16), transparent 40%);
  animation: pulse-soft 10s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(1.04) translateY(-1.5%); }
}

@keyframes pulse-soft {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.app {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3.5rem;
}

.hero {
  max-width: 34rem;
  margin-bottom: 2.25rem;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0 0 0.85rem;
  font-family: var(--display);
  font-size: clamp(3.2rem, 10vw, 5.4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.9;
  color: #fffaf4;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}

.headline {
  margin: 0 0 0.65rem;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fffaf4;
}

.lede {
  margin: 0 0 1rem;
  color: rgba(255, 250, 244, 0.82);
  font-size: 1.05rem;
  max-width: 28rem;
}

.plan {
  margin: 0 0 0.65rem;
  color: rgba(255, 250, 244, 0.9);
  font-size: 0.95rem;
  font-weight: 600;
}

.date {
  margin: 0;
  display: inline-block;
  color: rgba(255, 250, 244, 0.72);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.hero-actions {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
  max-width: 22rem;
}

.btn-install {
  background: #fffaf4;
  color: var(--water-deep);
  width: fit-content;
}

.btn-install:hover {
  filter: brightness(0.97);
}

.install-tip {
  margin: 0;
  color: rgba(255, 250, 244, 0.68);
  font-size: 0.86rem;
}

.trackers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.75s ease both;
}

.panel-water { animation-delay: 0.08s; }
.panel-cal { animation-delay: 0.16s; }

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

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.goal-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.goal-btn:hover {
  background: #fff;
  color: var(--ink);
}

.goal-btn:active {
  transform: scale(0.97);
}

.meter {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  margin-bottom: 1.15rem;
}

.meter-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.ring-track {
  stroke: rgba(16, 42, 50, 0.08);
}

.ring-fill {
  stroke-dasharray: var(--ring);
  stroke-dashoffset: var(--ring);
  transition: stroke-dashoffset 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.water-ring .ring-fill {
  stroke: var(--water);
}

.cal-ring .ring-fill {
  stroke: var(--cal);
}

.meter-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.meter-center strong {
  font-family: var(--display);
  font-size: 1.85rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.meter-center span {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.quick-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.chip {
  border: 0;
  background: var(--water-soft);
  color: var(--water-deep);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.chip:hover {
  background: #9fd5dd;
  box-shadow: 0 8px 20px rgba(15, 122, 138, 0.2);
}

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

.inline-form,
.meal-form {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

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

.meal-form {
  grid-template-columns: 1.4fr 0.7fr auto;
}

input[type="number"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  border-color: var(--water);
  box-shadow: 0 0 0 3px rgba(15, 122, 138, 0.15);
}

.panel-cal input:focus {
  border-color: var(--cal);
  box-shadow: 0 0 0 3px rgba(196, 92, 38, 0.15);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease, background 0.2s ease;
}

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

.btn-water {
  background: var(--water);
  color: #fff;
}

.btn-water:hover {
  filter: brightness(1.08);
}

.btn-cal {
  background: var(--cal);
  color: #fff;
}

.btn-cal:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: rgba(255, 250, 244, 0.85);
  border: 1px solid rgba(255, 250, 244, 0.28);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  max-height: 220px;
  overflow: auto;
}

.log li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
  animation: item-in 0.35s ease both;
}

@keyframes item-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log .meta {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.log .meta strong {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log .meta span {
  font-size: 0.78rem;
  color: var(--muted);
}

.log .amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--water-deep);
  white-space: nowrap;
}

.panel-cal .amount {
  color: var(--cal-deep);
}

.log .remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: 8px;
}

.log .remove:hover {
  background: rgba(16, 42, 50, 0.06);
  color: var(--ink);
}

.log .empty {
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: transparent;
  border: 1px dashed var(--line);
}

.history-panel {
  margin-top: 1.25rem;
  animation: rise 0.8s ease both;
  animation-delay: 0.2s;
}

.history-lead {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-streak {
  margin: 0;
  color: var(--water-deep);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: right;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: 340px;
  overflow: auto;
}

.history-item,
.history-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
}

.history-item.is-complete {
  border-color: rgba(15, 122, 138, 0.28);
  background: rgba(184, 228, 234, 0.35);
}

.history-main {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.history-main strong {
  font-size: 0.95rem;
  text-transform: capitalize;
}

.history-main span {
  color: var(--muted);
  font-size: 0.8rem;
}

.history-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  white-space: nowrap;
}

.badge.ok {
  background: rgba(15, 122, 138, 0.16);
  color: var(--water-deep);
}

.badge.miss {
  background: rgba(16, 42, 50, 0.06);
  color: var(--muted);
}

.history-empty {
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1px dashed var(--line);
  background: transparent;
}

.footer {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  animation: rise 0.8s ease both;
  animation-delay: 0.22s;
}

.hint {
  margin: 0;
  color: rgba(255, 250, 244, 0.65);
  font-size: 0.88rem;
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: calc(100% - 2rem);
}

.modal::backdrop {
  background: rgba(8, 35, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(360px, 100%);
  background: var(--paper-solid);
  border-radius: 22px;
  padding: 1.35rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.65rem;
}

.modal-card h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
}

.modal-card label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.modal-actions .btn-ghost {
  color: var(--muted);
  border-color: var(--line);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 800px) {
  .app {
    width: min(100% - 1.25rem, 1100px);
    padding-top: 1.75rem;
  }

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

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

  .meal-form .btn {
    grid-column: 1 / -1;
  }

  .brand {
    font-size: clamp(2.8rem, 14vw, 4.2rem);
  }
}

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