:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #14181f;
  --muted: #5b6677;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --border: #c9d2de;
  --ok: #138a47;
  --err: #c0392b;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  /* respect the iPhone notch / home indicator */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1 { font-size: 1.7rem; margin: 0.2em 0 0.4em; }
h2 { font-size: 1.25rem; margin: 0 0 0.5em; font-weight: 600; }
.lead { font-size: 1.15rem; color: var(--muted); }

/* --- Passcode screen --- */
#passcode-view { padding-top: 12vh; text-align: center; }
#passcode-input {
  width: 100%;
  font-size: 1.6rem;
  text-align: center;
  padding: 16px;
  margin: 12px 0;
  border: 2px solid var(--border);
  border-radius: 12px;
}

/* --- Date row --- */
.date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.date-row label { font-weight: 600; }
#date {
  font-size: 1.15rem;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  min-height: 48px;
  flex: 1 1 auto;
}
.status { color: var(--muted); font-size: 0.95rem; width: 100%; }

/* --- Blocks --- */
.block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0;
}
/* Live readout of the chosen value, e.g. "7 — Severe" */
.readout {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--muted);
  min-height: 1.4em;
}
.readout.chosen { color: hsl(var(--h) 60% 34%); }
.readout.skipped { color: var(--muted); font-style: italic; }

/* --- 0-10 rating scale --- */
/* Wraps to 6 + 5 on a phone, but a green->red wash + end labels + the readout
   make the two rows read as one continuous scale. Numbers + words carry the
   meaning too, so it stays clear without relying on colour. */
.scale {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.scale button {
  min-height: 58px;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  background: hsl(var(--h) 70% 90%);
  border: 2px solid hsl(var(--h) 45% 78%);
  border-radius: 12px;
  cursor: pointer;
  transition: transform .05s ease;
  -webkit-tap-highlight-color: transparent;
}
.scale button.selected {
  background: hsl(var(--h) 58% 42%);
  border-color: hsl(var(--h) 58% 30%);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

/* True end labels, spanning the full width below the whole control */
.ends {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

/* Skip control */
.skip {
  display: block;
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.skip.active {
  color: var(--ink);
  background: #eef2f7;
  border-style: solid;
}

/* --- Note --- */
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1.1rem;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  resize: vertical;
}

/* --- Buttons & messages --- */
.primary {
  display: block;
  width: 100%;
  min-height: 60px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.primary:disabled { background: #aebfd6; cursor: default; }

.saved { color: var(--ok); font-weight: 700; text-align: center; font-size: 1.2rem; }
.error { color: var(--err); font-weight: 600; }
