:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64716e;
  --soft: #8a9894;
  --line: #dfe7e4;
  --paper: #f4f7f6;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --mint: #e2f4ef;
  --blue: #2563eb;
  --blue-soft: #edf4ff;
  --amber: #f59e0b;
  --amber-soft: #fff7e6;
  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --green: #16a34a;
  --green-soft: #eefbf2;
  --shadow: 0 10px 28px rgba(26, 45, 41, 0.08);
  --shadow-soft: 0 1px 2px rgba(26, 45, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e8f0ee 0%, var(--paper) 38%, #ffffff 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 660px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.top-band {
  order: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 2px 2px;
}

.profile-panel,
.sync-panel {
  order: 2;
}

.status-band {
  order: 3;
}

.medication-panel {
  order: 4;
}

.entry-panel {
  order: 5;
}

.reminder-panel {
  order: 6;
}

.chart-panel {
  order: 7;
}

.history-panel {
  order: 8;
}

.site-footer {
  order: 9;
}

.top-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow,
.status-label,
label span,
.helper,
.reading-meta {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 420px;
  font-size: clamp(2rem, 8vw, 3.15rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.02rem;
  letter-spacing: 0;
}

.today-pill,
.account-chip {
  border: 1px solid rgba(223, 231, 228, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.today-pill {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 9px 11px;
  color: var(--teal-dark);
  font-weight: 900;
  text-align: center;
}

.account-chip {
  display: grid;
  gap: 3px;
  min-width: 126px;
  max-width: 220px;
  color: var(--ink);
  cursor: pointer;
  padding: 9px 12px;
  text-align: left;
}

.account-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.account-chip strong {
  display: block;
  color: var(--teal-dark);
  font-size: 0.92rem;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-panel,
.sync-panel,
.profile-panel,
.reminder-panel,
.medication-panel,
.chart-panel,
.history-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

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

.section-head h2 {
  font-weight: 900;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 0.8rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.wide {
  grid-column: 1 / -1;
}

.entry-form,
.reminder-grid,
.medication-form,
.profile-grid,
.sync-form {
  display: grid;
  gap: 12px;
}

.entry-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reminder-grid,
.profile-grid,
.medication-form {
  grid-template-columns: 1fr 1fr;
}

.primary-button,
.secondary-button,
.social-button,
.text-button,
.link-button,
.icon-button,
.delete-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 54px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-weight: 900;
  box-shadow: 0 12px 22px rgba(15, 118, 110, 0.18);
}

.primary-button:active,
.secondary-button:active,
.social-button:active,
.icon-button:active,
.text-button:active {
  transform: translateY(1px);
}

.secondary-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #1d4f8f;
  font-weight: 900;
}

.social-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.text-button {
  min-width: 54px;
  min-height: 38px;
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  font-weight: 900;
  padding: 0 12px;
}

.link-button {
  justify-self: center;
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-size: 1.5rem;
  font-weight: 900;
}

.secondary-button:disabled,
.social-button:disabled,
.link-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.status-band {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 10px;
  margin: 0;
}

.status-band > div {
  min-height: 116px;
  border-radius: 8px;
  background: #102321;
  color: white;
  padding: 14px;
  box-shadow: var(--shadow);
}

.last-reading-card.bp-normal,
.week-average-card.bp-normal {
  background: #14532d;
}

.last-reading-card.bp-elevated,
.week-average-card.bp-elevated,
.week-average-card.bp-high {
  background: var(--amber);
  color: #2d1c00;
}

.last-reading-card.bp-high,
.last-reading-card.bp-crisis,
.week-average-card.bp-crisis {
  background: #be123c;
  color: white;
}

.status-label {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.status-band strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.08;
}

.last-reading-card.bp-elevated .status-label,
.last-reading-card.bp-elevated .status-note,
.last-reading-card.bp-elevated .reference-note,
.week-average-card.bp-elevated .status-label,
.week-average-card.bp-elevated .status-note,
.week-average-card.bp-high .status-label,
.week-average-card.bp-high .status-note {
  color: #4a3000;
}

.status-note,
.reference-note {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.35;
}

.reference-note {
  font-size: 0.74rem;
  font-weight: 700;
  opacity: 0.92;
}

.profile-panel {
  padding: 18px;
}

.profile-panel:not(.is-open) {
  display: none;
}

.profile-actions {
  display: flex;
  gap: 8px;
}

.sync-panel.is-signed-in,
.sync-panel:not(.is-open):not(.is-signed-in),
.legacy-sync-panel {
  display: none;
}

.sync-actions,
.social-login {
  display: grid;
  gap: 10px;
}

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

.social-login {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 8px;
  background: #f1f5f4;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.sync-badge.is-online {
  background: var(--mint);
  color: var(--teal-dark);
}

.sync-badge.is-error {
  background: var(--rose-soft);
  color: var(--rose);
}

.helper {
  margin-top: 12px;
  font-size: 0.86rem;
  line-height: 1.42;
}

.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 32px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd8d5;
  transition: 0.2s ease;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: 0.2s ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::before {
  transform: translateX(22px);
}

.medication-panel {
  padding: 0;
  overflow: hidden;
}

.medication-panel .section-head,
.medication-form,
.medication-list,
.medication-report,
.medication-panel > .helper {
  margin-left: 16px;
  margin-right: 16px;
}

.medication-panel .section-head {
  margin-top: 16px;
}

.medication-form {
  grid-template-columns: 1.2fr 0.8fr;
}

.time-checks {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.time-checks legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.time-checks label {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  font-weight: 900;
}

.time-checks input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--teal);
}

.medication-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin-top: 14px;
  margin-bottom: 0;
  list-style: none;
}

.medication-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border: 1px solid #dce8e5;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.medication-name {
  display: block;
  font-size: 1.05rem;
  line-height: 1.2;
}

.medication-dose {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.medication-times {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.taken-check {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal-dark);
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 900;
  text-align: center;
}

.taken-check input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--green);
}

.taken-check.is-taken {
  border-color: #b7ddd2;
  background: var(--green-soft);
  color: #166534;
}

.taken-check.is-taken span {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.medication-report {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  background: #f8fbfa;
  padding: 14px 16px;
}

.medication-report:empty {
  display: none;
}

.medication-report span,
.medication-report small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.medication-report strong {
  display: block;
  margin-top: 3px;
  color: var(--teal-dark);
  font-size: 1.45rem;
}

.medication-report-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.medication-report-days span {
  min-height: 38px;
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
  color: var(--ink);
  font-size: 0.7rem;
}

.medication-report-days .is-complete {
  background: #dcfce7;
  color: #166534;
}

.medication-report-days .is-partial {
  background: #fef3c7;
  color: #92400e;
}

.medication-report-days .is-missed {
  background: #ffe4e6;
  color: #be123c;
}

.medication-panel > .helper {
  margin-top: 12px;
  margin-bottom: 16px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 148px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef6f4;
  padding: 3px;
}

.segment {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.segment.is-active {
  background: var(--panel);
  color: var(--teal-dark);
  box-shadow: 0 2px 8px rgba(12, 54, 48, 0.12);
}

.chart-legend,
.history-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chart-legend span,
.history-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.history-legend span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 4px 8px;
}

.chart-legend i {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.history-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-systolic,
.legend-high {
  background: var(--rose);
}

.legend-diastolic {
  background: var(--teal);
}

.legend-medications,
.legend-normal {
  background: var(--green);
}

.legend-elevated {
  background: var(--amber);
}

.chart-frame {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7faf9 100%);
}

.pressure-chart {
  display: block;
  width: 100%;
  min-height: 240px;
}

.chart-grid {
  stroke: #dce8e5;
  stroke-width: 1;
}

.chart-axis {
  stroke: #9eb2ad;
  stroke-width: 1.5;
}

.chart-label {
  fill: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.chart-line-systolic,
.chart-line-diastolic {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-line-systolic {
  stroke: var(--rose);
}

.chart-line-diastolic {
  stroke: var(--teal);
}

.chart-dot-systolic,
.chart-dot-diastolic,
.chart-medication-dot {
  stroke: white;
  stroke-width: 3;
}

.chart-dot-systolic {
  fill: var(--rose);
}

.chart-dot-diastolic {
  fill: var(--teal);
}

.chart-medication-dot.is-complete {
  fill: var(--green);
}

.chart-medication-dot.is-partial {
  fill: var(--amber);
}

.chart-medication-dot.is-missed {
  fill: var(--rose);
}

.chart-medication-label {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.chart-empty {
  fill: var(--muted);
  font-size: 20px;
  font-weight: 800;
}

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

.reading-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.reading-item.bp-normal,
.medication-history-item.is-complete {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.reading-item.bp-elevated,
.medication-history-item.is-partial {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.reading-item.bp-high,
.reading-item.bp-crisis,
.medication-history-item.is-missed {
  border-left-color: var(--rose);
  background: var(--rose-soft);
}

.reading-value {
  display: block;
  font-size: 1.08rem;
}

.reading-meta {
  display: block;
  margin-top: 4px;
  font-size: 0.84rem;
  line-height: 1.35;
}

.reading-item.bp-normal .reading-value {
  color: #166534;
}

.reading-item.bp-elevated .reading-value {
  color: #92400e;
}

.reading-item.bp-high .reading-value,
.reading-item.bp-crisis .reading-value {
  color: var(--rose);
}

.delete-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--rose-soft);
  color: var(--rose);
  font-size: 1.45rem;
  line-height: 1;
}

.empty-state {
  color: var(--muted);
  padding: 4px 0 2px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 8px 4px 2px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.site-footer a,
.legal-panel a {
  color: var(--teal-dark);
}

.legal-page {
  max-width: 820px;
}

.legal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.legal-panel h1 {
  max-width: none;
  margin-bottom: 14px;
  font-size: clamp(2rem, 7vw, 3rem);
}

.legal-panel h2 {
  margin-top: 24px;
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.legal-panel p {
  color: var(--ink);
  line-height: 1.55;
}

.legal-panel .helper {
  color: var(--muted);
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  font-weight: 900;
}

@media (max-width: 480px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .top-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .account-chip {
    flex: 1;
    max-width: none;
  }

  .today-pill {
    min-width: 86px;
  }

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

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

  .entry-form label:nth-child(3),
  .profile-grid,
  .reminder-grid,
  .medication-form,
  .sync-actions,
  .social-login {
    grid-template-columns: 1fr;
  }

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

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