* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 0;
  overflow-x: hidden;

  background: #f4f3f0;
  color: #373633;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  border: 0;
}

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

[hidden] {
  display: none !important;
}

.water-shell {
  width: 100%;
  max-width: 560px;
  min-height: 100vh;
  min-height: 100dvh;

  margin: 0 auto;

  padding:
    calc(22px + env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    calc(48px + env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.water-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 56px;
  align-items: center;

  gap: 12px;

  margin-bottom: 30px;
}

.water-back,
.water-view-toggle {
  display: grid;
  place-items: center;

  min-width: 44px;
  height: 44px;

  padding: 0;

  border-radius: 50%;

  background: rgba(255, 255, 255, 0.72);
  color: #6b6964;

  cursor: pointer;
}

.water-back {
  font-size: 27px;
  font-weight: 300;
}

.water-view-toggle {
  width: 56px;
  border-radius: 16px;
  font-size: 0.78rem;
}

.water-back:active,
.water-view-toggle:active,
.water-goal-button:active,
.water-quick-button:active,
.water-custom-toggle:active,
.water-custom-form button:active,
.water-record-edit:active,
.water-record-delete:active,
.water-sheet button:active {
  transform: scale(0.97);
}

.water-title {
  min-width: 0;
}

.water-title span,
.water-date-heading span,
.water-section-heading > span,
.water-section-heading > div > span,
.water-sheet header span {
  color: #a29f98;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.17em;
}

.water-title h1 {
  margin: 3px 0 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.water-date-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: 18px;

  margin: 0 3px 14px;
}

.water-date-heading h2,
.water-section-heading h2 {
  margin: 4px 0 0;
  font-size: 1.08rem;
  font-weight: 600;
}

.water-date-heading time,
.water-history-note {
  color: #8b8983 !important;
  font-size: 0.78rem !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
  white-space: nowrap;
}

.water-summary {
  padding: 27px 24px 22px;

  border: 1px solid rgba(55, 53, 49, 0.06);
  border-radius: 28px;

  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(240, 245, 245, 0.78));

  box-shadow: 0 14px 34px rgba(45, 43, 39, 0.035);
}

.water-total-line {
  display: flex;
  align-items: baseline;

  gap: 8px;
}

.water-total-line strong {
  color: #485354;
  font-size: clamp(3rem, 16vw, 4.4rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.water-total-line > span {
  color: #7d8989;
  font-size: 1rem;
}

.water-goal-button {
  display: flex;
  align-items: center;

  min-height: 44px;

  margin: 12px 0 18px;
  padding: 0;

  background: transparent;
  color: #777671;

  cursor: pointer;
}

.water-goal-button span {
  margin-right: 7px;
  font-size: 0.82rem;
}

.water-goal-button strong {
  color: #5b6464;
  font-size: 0.86rem;
  font-weight: 600;
}

.water-goal-button em {
  margin-left: 9px;
  color: #a09e98;
  font-size: 0.72rem;
  font-style: normal;
}

.water-progress-track {
  width: 100%;
  height: 8px;

  overflow: hidden;

  border-radius: 999px;
  background: rgba(99, 112, 113, 0.11);
}

.water-progress-track > span {
  display: block;

  width: 0;
  height: 100%;

  border-radius: inherit;
  background: linear-gradient(90deg, #aebfc0, #829b9c);

  transition: width 180ms ease;
}

.water-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 12px;

  margin-top: 10px;
}

.water-progress-meta > span:first-child {
  color: #657173;
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.water-complete-mark {
  color: #667876;
  font-size: 0.75rem;
}

.water-add-section,
.water-records-section,
.water-history-view {
  margin-top: 34px;
}

.water-section-heading {
  margin: 0 3px 14px;
}

.water-quick-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));

  gap: 9px;
}

.water-quick-button {
  min-width: 0;
  min-height: 54px;

  padding: 0 5px;

  border: 1px solid rgba(61, 66, 65, 0.055);
  border-radius: 18px;

  background: rgba(255, 255, 255, 0.78);
  color: #566364;

  font-size: 0.9rem;
  font-weight: 600;

  cursor: pointer;
  transition: transform 100ms ease, background 120ms ease;
}

.water-quick-button small {
  color: #929b9b;
  font-size: 0.68rem;
  font-weight: 500;
}

.water-quick-button:disabled,
.water-custom-form button:disabled {
  opacity: 0.58;
  cursor: default;
}

.water-custom-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;

  width: 100%;
  min-height: 48px;

  margin-top: 11px;
  padding: 0 16px;

  border-radius: 17px;

  background: rgba(80, 83, 80, 0.055);
  color: #686963;

  font-size: 0.84rem;
  cursor: pointer;
}

.water-custom-toggle span {
  color: #9b9993;
  font-size: 1.1rem;
  transition: transform 140ms ease;
}

.water-custom-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

.water-custom-form {
  margin-top: 10px;
  padding: 17px;

  border: 1px solid rgba(61, 66, 65, 0.055);
  border-radius: 19px;

  background: rgba(255, 255, 255, 0.62);
}

.water-custom-form > label,
.water-sheet form > label {
  display: block;

  margin-bottom: 9px;

  color: #777770;
  font-size: 0.78rem;
}

.water-custom-amount-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 72px;
  align-items: center;

  gap: 8px;
}

.water-custom-form input,
.water-goal-control input {
  width: 100%;
  min-width: 0;
  height: 46px;

  border: 1px solid rgba(69, 72, 69, 0.1);
  border-radius: 14px;
  outline: none;

  background: rgba(255, 255, 255, 0.9);
  color: #454743;

  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.water-custom-form input {
  padding: 0 13px;
}

.water-custom-form input:focus,
.water-goal-control input:focus {
  border-color: rgba(94, 119, 120, 0.36);
  box-shadow: 0 0 0 3px rgba(118, 145, 146, 0.09);
}

.water-custom-amount-row > span,
.water-goal-control span {
  color: #8d918d;
  font-size: 0.78rem;
}

.water-custom-time-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(132px, 0.85fr);
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(69, 72, 69, 0.07);
}

.water-custom-time-row label {
  color: #777770;
  font-size: 0.78rem;
}

.water-custom-time-row label small {
  display: block;
  margin-top: 3px;
  color: #a09e98;
  font-size: 0.68rem;
  font-weight: 400;
}

.water-custom-time-row input,
.water-edit-fields input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid rgba(69, 72, 69, 0.1);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.9);
  color: #454743;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.water-custom-time-row input:focus,
.water-edit-fields input:focus {
  border-color: rgba(94, 119, 120, 0.36);
  box-shadow: 0 0 0 3px rgba(118, 145, 146, 0.09);
}

.water-custom-form button {
  min-height: 46px;
  border-radius: 14px;
  background: #647879;
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
}

.water-custom-form p,
.water-sheet form > p {
  margin: 10px 0 0;
  color: #9a6661;
  font-size: 0.75rem;
}

.water-records-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;

  gap: 16px;
}

.water-records-heading > strong {
  color: #8d8b85;
  font-size: 0.75rem;
  font-weight: 500;
}

.water-record-list,
.water-history-list {
  display: grid;
  gap: 9px;
}

.water-record-item,
.water-history-item {
  min-width: 0;

  border: 1px solid rgba(55, 53, 49, 0.055);
  border-radius: 19px;

  background: rgba(255, 255, 255, 0.68);
}

.water-record-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;

  min-height: 62px;

  padding: 7px 8px 7px 15px;
}

.water-record-item time {
  color: #8c8a84;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.water-record-item strong {
  color: #505a5a;
  font-size: 0.94rem;
  font-weight: 600;
}

.water-record-actions {
  display: flex;
  align-items: center;
}

.water-record-edit,
.water-record-delete {
  width: 44px;
  height: 44px;

  border-radius: 14px;

  background: transparent;
  color: #aaa69e;

  font-size: 1rem;
  cursor: pointer;
}

.water-record-edit {
  color: #858d8b;
  font-size: 0.74rem;
}

.water-edit-fields {
  display: grid;
  gap: 17px;
}

.water-edit-fields > label {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: #777770;
  font-size: 0.78rem;
}

.water-input-with-unit {
  position: relative;
  display: block;
}

.water-input-with-unit input {
  padding-right: 42px;
}

.water-input-with-unit small {
  position: absolute;
  top: 50%;
  right: 13px;
  color: #8d918d;
  font-size: 0.72rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.water-empty {
  padding: 25px 18px;

  border: 1px dashed rgba(74, 73, 69, 0.11);
  border-radius: 19px;

  color: #96938d;
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
}

.water-history-item {
  padding: 17px 18px 15px;
}

.water-history-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;

  gap: 16px;
}

.water-history-main strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.water-history-main span {
  color: #697374;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.water-history-progress {
  height: 4px;

  margin-top: 12px;
  overflow: hidden;

  border-radius: 999px;
  background: rgba(99, 112, 113, 0.09);
}

.water-history-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #9eaeae;
}

.water-history-meta {
  display: flex;
  justify-content: space-between;

  gap: 12px;

  margin-top: 8px;

  color: #a09d96;
  font-size: 0.68rem;
}

.water-sheet-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;

  display: flex;
  align-items: flex-end;
  justify-content: center;

  padding-top: env(safe-area-inset-top);

  background: rgba(31, 31, 29, 0.2);
  backdrop-filter: blur(3px);
}

.water-sheet {
  width: min(100%, 560px);

  padding:
    10px
    max(22px, env(safe-area-inset-right))
    calc(22px + env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));

  border-radius: 28px 28px 0 0;
  background: #f7f6f3;
}

.water-sheet-handle {
  width: 38px;
  height: 4px;

  margin: 0 auto 15px;

  border-radius: 999px;
  background: #d5d2cc;
}

.water-sheet header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 16px;

  margin-bottom: 23px;
}

.water-sheet header h2 {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.water-sheet header button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(75, 74, 70, 0.055);
  color: #77736d;
  font-size: 1.35rem;
  cursor: pointer;
}

.water-goal-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;

  gap: 10px;
}

.water-goal-control input {
  padding: 0 15px;
}

.water-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;

  gap: 10px;

  margin-top: 24px;
}

.water-sheet-actions button {
  min-height: 48px;
  border-radius: 16px;
  background: rgba(75, 74, 70, 0.07);
  color: #68655f;
  cursor: pointer;
}

.water-sheet-actions button.primary {
  background: #607475;
  color: #fff;
}

.water-toast {
  position: fixed;
  z-index: 140;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: max(20px, env(safe-area-inset-left));

  width: fit-content;
  max-width: min(350px, calc(100vw - 40px));

  margin: 0 auto;
  padding: 12px 17px;

  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 16px;

  background: rgba(74, 82, 81, 0.93);
  color: #fff;

  font-size: 0.82rem;
  line-height: 1.45;

  box-shadow: 0 13px 34px rgba(36, 38, 37, 0.16);

  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.water-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.water-toast[data-kind="warning"] {
  background: rgba(102, 92, 83, 0.94);
}

@media (max-width: 374px) {
  .water-shell {
    padding-right: max(15px, env(safe-area-inset-right));
    padding-left: max(15px, env(safe-area-inset-left));
  }

  .water-summary {
    padding-right: 20px;
    padding-left: 20px;
  }

  .water-quick-grid {
    gap: 6px;
  }

  .water-quick-button {
    min-height: 50px;
    font-size: 0.76rem;
  }

  .water-record-item {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    padding-left: 12px;
  }
}

@media (min-width: 768px) {
  .water-shell {
    padding-top: 42px;
  }

  .water-back:hover,
  .water-view-toggle:hover,
  .water-quick-button:hover,
  .water-custom-toggle:hover,
  .water-record-edit:hover,
  .water-record-delete:hover,
  .water-goal-button:hover {
    background-color: rgba(255, 255, 255, 0.88);
  }
}

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