:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #111827;
  --card: rgba(255, 255, 255, 0.78);
  --solid-card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(17, 24, 39, 0.1);
  --button: #111827;
  --button-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    background: #111318;
    color: #f9fafb;
    --card: rgba(31, 41, 55, 0.74);
    --solid-card: #1f2937;
    --text: #f9fafb;
    --muted: #a7b0bd;
    --line: rgba(249, 250, 251, 0.12);
    --button: #f9fafb;
    --button-text: #111827;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f4f6f8;
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, var(--gradient-a, #4fca7c), var(--gradient-b, #b6efb6));
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
  background: linear-gradient(135deg, var(--gradient-a), var(--gradient-b));
  overscroll-behavior-x: contain;
}

.screen {
  max-width: 620px;
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  color: var(--text);
  background: var(--card);
}

.icon-button:disabled {
  opacity: 0.28;
}

.page-title {
  text-align: center;
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.hero {
  margin: 22px 0;
}

.hero h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.35;
  font-weight: 650;
}

.stack {
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: var(--card);
  backdrop-filter: blur(18px);
}

.solid-card {
  background: var(--solid-card);
}

.vital-input {
  min-height: 104px;
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  gap: 12px;
}

.label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.vital-title {
  font-size: 18px;
  font-weight: 850;
}

.unit {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.number-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  text-align: right;
  font-size: 48px;
  font-weight: 900;
}

.result {
  padding: 24px;
}

.result-value {
  font-size: 54px;
  line-height: 1;
  font-weight: 950;
}

.result-label {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 850;
}

.button {
  min-height: 54px;
  border: 0;
  border-radius: 22px;
  padding: 0 18px;
  color: var(--button-text);
  background: var(--button);
  font-size: 16px;
  font-weight: 850;
}

.button.secondary {
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
}

.button.danger {
  color: #ffffff;
  background: #b4232f;
}

.button:disabled {
  opacity: 0.45;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-value {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 900;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row.wrap {
  flex-wrap: wrap;
}

.field {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--text);
}

textarea.field {
  min-height: 118px;
  resize: vertical;
}

.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 19px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(120, 120, 128, 0.14);
  font-weight: 800;
}

.segment.active {
  color: var(--button-text);
  background: var(--button);
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.history-value {
  text-align: right;
  font-size: 22px;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
  background: rgba(15, 23, 42, 0.48);
}

.modal {
  max-height: 90vh;
  overflow: auto;
  border-radius: 28px 28px 0 0;
  padding: 20px 18px max(28px, env(safe-area-inset-bottom));
  background: #f4f6f8;
}

@media (prefers-color-scheme: dark) {
  .modal {
    background: #111318;
  }
}

.hidden {
  display: none !important;
}
