*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #e8f4fc;
  --color-bg-deep: #c5e3f6;
  --color-surface: rgba(255, 255, 255, 0.85);
  --color-primary: #1a8fe3;
  --color-primary-dark: #0d6ebd;
  --color-primary-light: #5eb8f0;
  --color-text: #1a2b3c;
  --color-text-muted: #5a7a94;
  --color-border: rgba(26, 143, 227, 0.15);
  --color-success: #22c55e;
  --shadow-sm: 0 2px 8px rgba(26, 143, 227, 0.1);
  --shadow-md: 0 8px 32px rgba(26, 143, 227, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Noto Sans TC", system-ui, sans-serif;
  --ring-size: 220px;
  --ring-stroke: 14;
  --ring-radius: 88;
  --ring-circumference: calc(2 * 3.14159 * var(--ring-radius));
}

body {
  font-family: var(--font);
  background: linear-gradient(160deg, var(--color-bg) 0%, var(--color-bg-deep) 50%, #a8d4f0 100%);
  min-height: 100vh;
  color: var(--color-text);
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.header__icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(26, 143, 227, 0.3));
}

.header__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

.header__date {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Cards & sections */
.progress-card,
.quick-add,
.history {
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 16px;
}

/* Progress ring */
.progress-ring {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  margin: 0 auto 24px;
}

.progress-ring__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: rgba(26, 143, 227, 0.12);
  stroke-width: var(--ring-stroke);
}

.progress-ring__fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: var(--ring-stroke);
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circumference);
  stroke-dashoffset: var(--ring-circumference);
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}

.progress-ring--complete .progress-ring__fill {
  stroke: var(--color-success);
}

.progress-ring__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.progress-ring__amount {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  line-height: 1;
}

.progress-ring__unit {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.progress-ring__goal {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.progress-ring__percent {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 2px;
}

/* Goal setting */
.goal-setting {
  border-top: 1px solid var(--color-border);
  padding-top: 20px;
}

.goal-setting__label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.goal-setting__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.goal-setting__input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
  color: var(--color-text);
}

.goal-setting__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 143, 227, 0.2);
}

.goal-setting__unit {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  animation: btnBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: none;
}

@keyframes btnBounce {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(0.9);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

.btn--water {
  flex: 1;
  min-width: calc(50% - 6px);
  padding: 14px 12px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn--water:hover {
  box-shadow: 0 4px 16px rgba(26, 143, 227, 0.35);
}

.btn--primary {
  padding: 12px 20px;
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.btn--ghost {
  padding: 10px 16px;
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn--ghost:hover {
  background: rgba(26, 143, 227, 0.08);
}

.btn--text {
  padding: 6px 12px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.btn--text:hover {
  color: #e53e3e;
}

.btn--icon {
  padding: 6px 10px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1;
}

.btn--icon:hover {
  color: #e53e3e;
}

/* Quick add */
.quick-add__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.custom-add {
  display: flex;
  gap: 10px;
}

.custom-add__input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
}

.custom-add__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 143, 227, 0.2);
}

/* Stats */
.stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  background: var(--color-surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  text-align: center;
}

.stat-card--highlight {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border-color: rgba(34, 197, 94, 0.3);
}

.stat-card__value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.stat-card--highlight .stat-card__value {
  font-size: 1.75rem;
}

.stat-card__label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* History */
.history__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.history__header .section-title {
  margin-bottom: 0;
}

.history__list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}

.history__empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.history__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  animation: slideIn 0.3s ease;
}

.history__item:last-child {
  border-bottom: none;
}

.history__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history__amount {
  font-weight: 600;
  color: var(--color-primary-dark);
}

.history__time {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 8px;
}

.footer__note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 12px;
}

.btn--reset {
  width: 100%;
  padding: 14px 20px;
  background: transparent;
  color: #e53e3e;
  border: 2px solid #fca5a5;
  font-size: 0.95rem;
}

.btn--reset:hover {
  background: #fef2f2;
  border-color: #e53e3e;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--color-text);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  z-index: 100;
}

.toast--show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 380px) {
  .header__title {
    font-size: 1.5rem;
  }

  .progress-ring {
    --ring-size: 190px;
  }

  .progress-ring__amount {
    font-size: 2rem;
  }

  .btn--water {
    min-width: 100%;
  }
}
