* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --background: #f7f4f8;
  --surface: #ffffff;
  --text: #242126;
  --muted: #767077;
  --border: #e6e0e7;
  --accent: #8d5f88;
  --accent-dark: #6f486a;
  --popup: #242126;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button {
  font: inherit;
}

.page {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 36px 18px calc(120px + env(safe-area-inset-bottom));
}

.page-header {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.instructions {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.summary-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.label,
.latest-time {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.latest-value {
  margin: 5px 0;
  font-size: 30px;
  font-weight: 750;
}

.clear-button {
  min-width: 68px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.clear-button:active {
  transform: scale(0.97);
}

.history-section {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item,
.empty-state {
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.history-amount {
  font-weight: 700;
}

.history-time,
.empty-state {
  color: var(--muted);
  font-size: 14px;
}

.milk-button {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 22px rgba(36, 33, 38, 0.24);
  font-size: 28px;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

.milk-button.is-active {
  background: var(--accent-dark);
  transform: scale(0.93);
}

.amount-popup {
  position: fixed;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 138px;
  padding: 15px;
  border-radius: 18px;
  background: var(--popup);
  color: white;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.92);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
  pointer-events: none;
}

.amount-popup.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.amount-number {
  font-size: 30px;
  font-weight: 760;
}

.amount-popup p {
  margin: 9px 0 0;
  color: #d9d5da;
  font-size: 12px;
}

.amount-scale {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  background: #555057;
  border-radius: 999px;
}

.amount-scale-fill {
  width: 0;
  height: 100%;
  background: #d7b4d2;
  border-radius: inherit;
}

.save-message {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 10;
  padding: 10px 15px;
  border-radius: 999px;
  background: var(--popup);
  color: white;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 14px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  pointer-events: none;
  white-space: nowrap;
}

.save-message.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
