:root {
  --bg: #061725;
  --bg-soft: #08293b;
  --card: rgba(10, 36, 53, 0.68);
  --card-strong: rgba(9, 31, 46, 0.88);
  --line: rgba(148, 210, 235, 0.16);
  --line-strong: rgba(148, 210, 235, 0.28);
  --text: #eaf7ff;
  --muted: #8fb3c6;
  --faint: #638ba0;
  --cyan: #38bdf8;
  --teal: #5eead4;
  --violet: #818cf8;
  --radius: 26px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  background:
    radial-gradient(1100px 700px at 12% -10%, #0b3b54 0%, transparent 55%),
    radial-gradient(900px 620px at 88% 8%, #102a4c 0%, transparent 52%),
    linear-gradient(160deg, #061725 0%, #061c2b 48%, #04121d 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

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

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.34;
}

.blob-a {
  width: 440px;
  height: 440px;
  top: -160px;
  left: -120px;
  background: #0ea5e9;
  animation: float 18s ease-in-out infinite alternate;
}

.blob-b {
  width: 380px;
  height: 380px;
  top: 18%;
  right: -140px;
  background: #2dd4bf;
  opacity: 0.2;
  animation: float 22s ease-in-out infinite alternate-reverse;
}

.blob-c {
  width: 420px;
  height: 420px;
  bottom: -200px;
  left: 32%;
  background: #6366f1;
  opacity: 0.18;
  animation: float 26s ease-in-out infinite alternate;
}

@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(40px, 36px, 0) scale(1.1); }
}

.topbar {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 26px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: #062130;
  background: linear-gradient(140deg, var(--teal), var(--cyan) 62%, var(--violet));
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.28);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.today {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 42px 24px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 34px;
  align-items: center;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.6rem, 5.4vw, 4.15rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.025em;
  background: linear-gradient(140deg, #ffffff 10%, #d6f1ff 55%, #9fdcf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  max-width: 33rem;
  margin-top: 20px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.8;
}

.calc-card {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(20, 56, 78, 0.62), rgba(6, 25, 38, 0.72));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.field-label em {
  color: var(--faint);
  font-size: 0.82em;
  font-style: normal;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 12px 13px;
  color: var(--text);
  background: rgba(3, 17, 27, 0.62);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input::placeholder {
  color: var(--faint);
}

input:hover,
select:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus {
  background: rgba(3, 17, 27, 0.86);
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

select {
  appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

select option {
  color: #0b2434;
  background: #e8f6ff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #04141f;
  background: linear-gradient(130deg, var(--teal) 0%, var(--cyan) 52%, var(--violet) 100%);
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 16px 36px rgba(56, 189, 248, 0.36);
  filter: brightness(1.04);
}

.btn-ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--text);
  background: rgba(148, 210, 235, 0.08);
  border-color: var(--line-strong);
}

.btn-soft {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.24);
}

.btn-soft:hover {
  background: rgba(56, 189, 248, 0.22);
}

.btn-small {
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 0.78rem;
}

.calc-btn {
  width: 100%;
  margin-top: 14px;
}

.calc-hint {
  margin-top: 11px;
  color: var(--faint);
  font-size: 0.76rem;
  line-height: 1.6;
  text-align: center;
}

.goal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(165deg, rgba(17, 54, 74, 0.74), rgba(5, 24, 37, 0.86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}

.goal-card::before {
  content: "";
  position: absolute;
  top: -40%;
  left: 50%;
  width: 320px;
  height: 320px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.2), transparent 66%);
  pointer-events: none;
}

.goal-head {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.goal-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.goal-badge {
  padding: 5px 11px;
  color: #99f6e4;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(45, 212, 191, 0.13);
  border: 1px solid rgba(94, 234, 212, 0.26);
  border-radius: 999px;
}

.ring-wrap {
  position: relative;
  width: 226px;
  max-width: 72vw;
  aspect-ratio: 1;
  margin: 14px 0 8px;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 13;
}

.ring-track {
  stroke: rgba(148, 210, 235, 0.12);
}

.ring-fill {
  stroke: url(#ringGradient);
  stroke-linecap: round;
  stroke-dasharray: 427.26;
  stroke-dashoffset: 427.26;
  transform: rotate(-90deg);
  transform-origin: 80px 80px;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
  transition: stroke-dashoffset 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-percent {
  font-size: 2.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.ring-sub {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
}

.goal-meta {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin-top: 6px;
  padding: 14px 8px;
  text-align: center;
  background: rgba(3, 17, 27, 0.42);
  border: 1px solid var(--line);
  border-radius: 17px;
}

.meta-label {
  display: block;
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.meta-value {
  font-size: 1.06rem;
  font-weight: 700;
}

.meta-divider {
  width: 1px;
  height: 30px;
  background: var(--line);
}

.goal-foot {
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  gap: 24px;
  margin-top: 30px;
}

.card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(15, 46, 65, 0.6), rgba(5, 23, 35, 0.76));
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-head .eyebrow {
  margin-bottom: 6px;
  font-size: 0.68rem;
}

.card h2 {
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.consumed {
  margin-top: 18px;
  padding: 18px;
  background: rgba(3, 17, 27, 0.34);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.consumed-main {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.consumed-num {
  font-size: 3.05rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(140deg, #ffffff, #8ee7ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.consumed-unit {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.consumed-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.quick-add {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 12px 6px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.07);
  border: 1px solid var(--line);
  border-radius: 15px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.quick span {
  color: var(--faint);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.quick:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.34);
  transform: translateY(-2px);
}

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

.custom-add {
  display: flex;
  gap: 10px;
  margin-top: 11px;
}

.custom-add input {
  flex: 1;
}

.custom-add .btn {
  padding: 12px 20px;
  white-space: nowrap;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.link-btn {
  padding: 4px;
  color: var(--faint);
  font-size: 0.76rem;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.18s ease;
}

.link-btn:hover:not(:disabled) {
  color: var(--teal);
}

.link-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 186px;
  margin: 12px 0 0;
  padding: 0 4px 2px 0;
  overflow-y: auto;
  list-style: none;
}

.history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(3, 17, 27, 0.36);
  border: 1px solid rgba(148, 210, 235, 0.09);
  border-radius: 12px;
  font-size: 0.9rem;
  animation: slideIn 0.28s ease both;
}

.history li strong {
  font-weight: 700;
}

.history li time {
  color: var(--faint);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.history .empty {
  justify-content: center;
  padding: 18px 10px;
  color: var(--faint);
  font-size: 0.82rem;
  border-style: dashed;
  background: transparent;
  animation: none;
}

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

.history::-webkit-scrollbar {
  width: 6px;
}

.history::-webkit-scrollbar-thumb {
  background: rgba(148, 210, 235, 0.18);
  border-radius: 999px;
}

.reminder {
  position: relative;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: rgba(148, 210, 235, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill i {
  width: 7px;
  height: 7px;
  background: #64748b;
  border-radius: 50%;
}

.status-pill.is-on {
  color: #99f6e4;
  background: rgba(45, 212, 191, 0.13);
  border-color: rgba(94, 234, 212, 0.26);
}

.status-pill.is-on i {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.14);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.reminder-status {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  background: rgba(3, 17, 27, 0.36);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.drop-pulse {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  color: #8ef2e2;
  background: radial-gradient(circle at 30% 25%, rgba(56, 189, 248, 0.34), rgba(45, 212, 191, 0.13));
  border: 1px solid rgba(94, 234, 212, 0.26);
  border-radius: 15px;
}

.drop-pulse svg {
  width: 25px;
  height: 25px;
}

.reminder.is-active .drop-pulse {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.24); }
  50% { box-shadow: 0 0 0 10px rgba(94, 234, 212, 0); }
}

.status-title {
  font-size: 0.94rem;
  font-weight: 600;
}

.status-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.time-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reminder-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.reminder-actions .btn-primary {
  flex: 1.2;
}

.reminder-actions .btn-ghost {
  flex: 0.8;
  padding-inline: 12px;
}

.note {
  margin-top: 14px;
  color: var(--faint);
  font-size: 0.72rem;
  line-height: 1.65;
}

.footer {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 38px 24px 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--faint);
  font-size: 0.74rem;
}

.footer-tip {
  text-align: right;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 20px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.55;
  background: rgba(8, 35, 50, 0.96);
  border: 1px solid rgba(94, 234, 212, 0.3);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.8);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .goal-card {
    max-width: 520px;
    width: 100%;
    justify-self: center;
  }

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

  .history {
    max-height: 240px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 20px 18px 0;
  }

  .page {
    padding: 30px 18px 0;
  }

  .today {
    font-size: 0.74rem;
  }

  h1 {
    font-size: clamp(2.35rem, 12vw, 3.1rem);
  }

  .lede {
    font-size: 0.94rem;
    line-height: 1.75;
  }

  .calc-card,
  .card,
  .goal-card {
    padding: 18px;
    border-radius: 22px;
  }

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

  .calc-grid .field:last-child {
    grid-column: 1 / -1;
  }

  .quick-add {
    grid-template-columns: repeat(2, 1fr);
  }

  .consumed-num {
    font-size: 2.6rem;
  }

  .ring-wrap {
    width: 200px;
  }

  .reminder-actions {
    flex-wrap: wrap;
  }

  .reminder-actions .btn {
    flex: 1 1 140px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    padding: 30px 18px 38px;
  }

  .footer-tip {
    text-align: left;
  }

  .toast {
    bottom: 18px;
  }
}

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