:root {
  color-scheme: light;
  --navy: #17324d;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --green: #15703d;
  --green-light: #effcf3;
  --amber-light: #fff8df;
  --red: #b42318;
  --red-light: #fff0ef;
  --ink: #172033;
  --muted: #66758a;
  --line: #dce4ee;
  --page: #f4f7fa;
  --white: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

header {
  align-items: center;
  background: linear-gradient(145deg, #10283e, #285574);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  padding: calc(20px + env(safe-area-inset-top)) 18px 24px;
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 2rem; margin-bottom: 2px; }
h2 { font-size: 1.15rem; margin-bottom: 7px; }

.kicker, .label {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .09em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.kicker { opacity: .72; }
.label { color: var(--muted); }
.subtitle { margin: 0; opacity: .82; }

main {
  margin: 0 auto;
  max-width: 720px;
  padding: 14px 13px calc(30px + env(safe-area-inset-bottom));
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: 0 5px 18px rgba(23, 50, 77, .06);
  margin-bottom: 13px;
  overflow: hidden;
}

.card-pad, .next-card { padding: 17px; }
.next-card { background: linear-gradient(145deg, #fff, var(--blue-light)); }
#next-time { font-size: 1.8rem; margin-bottom: 5px; }
.next-meds { font-weight: 750; margin-bottom: 5px; }
.countdown { color: var(--blue); font-weight: 800; margin: 0; }

.warning {
  align-items: center;
  background: var(--amber-light);
  border: 1px solid #f1cf6f;
  border-radius: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 13px;
  padding: 11px 13px;
}

.danger-warning { background: var(--red-light); border-color: #f1aaa3; color: #7d1c14; }

.tabs {
  background: #e9eef5;
  border-radius: 13px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 13px;
  padding: 4px;
  position: sticky;
  top: 6px;
  z-index: 5;
}

button, select, .file-button {
  border: 1px solid #bcc8d6;
  border-radius: 11px;
  font: inherit;
  min-height: 44px;
}

button, .file-button {
  align-items: center;
  background: var(--blue);
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  padding: 9px 13px;
}

.file-button input { display: none; }
.tab { background: transparent; border: 0; color: var(--navy); }
.tab.active { background: var(--white); box-shadow: 0 2px 7px rgba(23, 50, 77, .12); }
.header-button { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.35); }
.secondary, .secondary-file { background: var(--white); color: var(--navy); }
.danger-button { background: var(--white); border-color: #f1a7a1; color: var(--red); }
.small-button { margin-left: auto; min-height: 36px; padding: 6px 9px; }
.button-stack { display: flex; flex-wrap: wrap; gap: 9px; }

dialog {
  border: 0;
  border-radius: 17px;
  box-shadow: 0 18px 55px rgba(10, 28, 46, .28);
  color: var(--ink);
  max-width: min(92vw, 480px);
  padding: 18px;
}

dialog::backdrop { background: rgba(8, 21, 35, .55); }
.dialog-head { align-items: center; display: flex; justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.icon-button {
  background: transparent;
  border: 0;
  color: var(--navy);
  font-size: 1.8rem;
  min-height: 36px;
  padding: 0 6px;
}

#install-instructions { margin-top: 14px; }
#install-instructions ol { padding-left: 22px; }

.slot-head {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 13px 16px;
}

.slot-date { color: var(--muted); font-size: .82rem; margin-bottom: 0; }
.slot-time { font-size: 1.35rem; margin: 0; }
.slot-state { color: var(--muted); font-size: .8rem; font-weight: 750; }

.med-row {
  align-items: center;
  border-bottom: 1px solid #edf1f6;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr auto;
  padding: 14px 16px;
}

.med-row:last-child { border-bottom: 0; }
.med-row.given { background: var(--green-light); }
.med-row.given .med-name { opacity: .62; text-decoration: line-through; }
.med-name { display: block; font-size: 1.02rem; }
.med-note { color: #8a5b00; display: block; font-size: .77rem; font-weight: 700; margin-top: 2px; }

.dose-label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: .8rem;
  gap: 7px;
  margin-top: 8px;
}

select { background: var(--white); padding: 7px 9px; }
.given-button.done { background: var(--green); }
.section-head { align-items: center; display: flex; justify-content: space-between; }
.history-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.history-item:last-child { border: 0; }
.history-time { color: var(--muted); font-size: .78rem; }
.muted { color: var(--muted); }

@media (max-width: 390px) {
  .med-row { align-items: stretch; grid-template-columns: 1fr; }
  .given-button, .file-button { width: 100%; }
  .small-button { margin-left: 0; width: auto; }
}
