:root {
  color-scheme: light;
  --bg: #f1f7ff;
  --surface: #ffffff;
  --surface-strong: #f7fbff;
  --ink: #13233a;
  --muted: #5a6c82;
  --teal: #2f80c9;
  --teal-dark: #1d5f9f;
  --mint: #e7f3ff;
  --gold: #7fb2e4;
  --coral: #cc5751;
  --coral-dark: #943b37;
  --blue: #3f74d6;
  --violet: #6f8fe6;
  --border: #d6e5f5;
  --shadow: 0 18px 34px rgba(22, 50, 79, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --shadow-strong: 0 22px 52px rgba(22, 50, 79, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.92);
  --radius: 8px;
  --font-size: 19px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e8f4ff 0%, #f8fbff 48%, var(--bg) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}

body.large-text {
  --font-size: 22px;
}

button,
input,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(1180px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.75rem 0 6rem;
}

.topbar,
.hero,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.95rem;
  position: sticky;
  top: 0;
  z-index: 10;
  border-color: transparent;
  border-bottom-color: rgba(47, 128, 201, 0.14);
  background: rgba(241, 247, 255, 0.9);
  backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 12px 28px rgba(22, 50, 79, 0.08);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.5vw, 1.8rem);
  font-weight: 750;
  line-height: 1.1;
}

h3 {
  margin-bottom: 0.35rem;
  font-size: 1.55rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0;
  padding: 1.25rem;
  background:
    linear-gradient(145deg, #ffffff 0%, #eaf6ff 62%, #f4f9ff 100%);
  border-color: rgba(47, 128, 201, 0.18);
  box-shadow: var(--shadow-strong);
}

.today-date,
.hero-text,
.metric p,
.medicine-meta,
.field span {
  color: var(--muted);
}

.today-date {
  margin-bottom: 0.35rem;
  font-weight: 800;
}

.hero-text {
  max-width: 40rem;
  margin: 0.8rem 0 0;
  line-height: 1.5;
}

.care-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 12rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(47, 128, 201, 0.25);
  border-radius: 999px;
  background: var(--mint);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.94), 0 10px 18px rgba(47, 128, 201, 0.12);
}

.status-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: var(--gold);
}

.status-dot.ok {
  background: var(--teal);
}

.status-dot.help {
  background: var(--coral);
}

.icon-button,
.secondary-button,
.primary-button,
.action-button,
.small-button,
.call-button {
  min-height: 2.75rem;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(22, 50, 79, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.icon-button:active,
.secondary-button:active,
.primary-button:active,
.action-button:active,
.small-button:active,
.call-button:active {
  transform: translateY(1px);
  box-shadow: 0 6px 12px rgba(22, 50, 79, 0.12), inset 0 1px 2px rgba(22, 50, 79, 0.08);
}

.icon-button {
  min-width: 3.2rem;
  color: var(--teal);
  background: linear-gradient(180deg, #f8fcff 0%, #e0f0ff 100%);
}

.primary-button {
  width: 100%;
  padding: 0.8rem 1rem;
  color: white;
  background: linear-gradient(180deg, #64b5f0 0%, var(--teal) 100%);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--teal-dark);
}

.secondary-button,
.small-button {
  padding: 0.65rem 0.8rem;
  color: var(--teal);
  background: linear-gradient(180deg, #f8fcff 0%, #e7f3ff 100%);
}

.small-button.danger {
  color: var(--coral-dark);
  background: #feeceb;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 5.2rem;
  padding: 1rem;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-strong) 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.action-button.urgent {
  color: white;
  background: linear-gradient(180deg, #df716c 0%, var(--coral) 100%);
  border-color: var(--coral);
  box-shadow: 0 18px 30px rgba(204, 87, 81, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.action-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal);
  font-weight: 900;
}

.urgent .action-icon {
  color: var(--coral-dark);
  background: white;
}

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.two-col {
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
}

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

.panel {
  padding: 1rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.checkin-form,
.inline-form,
.brain-card,
.settings-form {
  display: grid;
  gap: 1rem;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) 9rem 6rem;
  align-items: end;
}

fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend,
.field span {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.mood-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.mood-row input {
  position: absolute;
  opacity: 0;
}

.mood-row span {
  display: grid;
  min-height: 3.4rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-strong) 100%);
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 8px 16px rgba(22, 50, 79, 0.08);
}

.mood-row input:checked + span {
  color: white;
  border-color: var(--teal);
  background: linear-gradient(180deg, #64b5f0 0%, var(--teal) 100%);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(10rem, 0.9fr));
  gap: 0.75rem;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  color: var(--ink);
  background: #fbfdff;
  box-shadow: inset 0 2px 6px rgba(22, 50, 79, 0.06);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(47, 128, 201, 0.2);
}

.medicine-list {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  margin: 1rem 0 0;
  list-style: none;
}

.medicine-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 8px 14px rgba(22, 50, 79, 0.07);
}

.medicine-title,
.medicine-meta {
  display: block;
}

.medicine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}

.empty-state {
  display: none;
  padding: 1rem;
  margin-top: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.metric {
  min-height: 9rem;
}

.brain-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 10px 18px rgba(22, 50, 79, 0.08);
}

#brain-prompt {
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.35;
}

.summary-box {
  min-height: 15rem;
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
  font: inherit;
  line-height: 1.45;
}

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 14rem)) minmax(260px, 1fr);
  gap: 0.75rem;
  align-items: end;
}

.contact-card {
  display: grid;
  min-height: 5rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(180deg, #72a8ee 0%, var(--blue) 100%);
  text-decoration: none;
  box-shadow: 0 14px 26px rgba(47, 128, 201, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.contact-card:first-child {
  background: linear-gradient(180deg, #df716c 0%, var(--coral) 100%);
}

.settings-contact-card {
  background: linear-gradient(180deg, #64b5f0 0%, var(--teal) 100%);
}

.contact-card span {
  font-size: 0.9rem;
  opacity: 0.9;
}

.contact-card strong {
  align-self: end;
  font-size: 1.35rem;
}

.safety-list {
  display: grid;
  gap: 0.7rem;
  max-width: 56rem;
}

.safety-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.safety-list p:first-child {
  color: var(--ink);
  font-weight: 800;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

.legal-links a {
  display: inline-grid;
  min-height: 2.7rem;
  place-items: center;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(47, 128, 201, 0.24);
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-strong) 100%);
  font-weight: 800;
  text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 16px rgba(22, 50, 79, 0.07);
}

.settings-links {
  margin-top: 1rem;
}

.legal-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(22, 50, 79, 0.42);
}

.dialog-backdrop[hidden] {
  display: none;
}

.help-dialog {
  width: min(34rem, 100%);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 60px rgba(22, 50, 79, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.notice-dialog {
  display: grid;
  gap: 1rem;
}

.notice-list {
  display: grid;
  gap: 0.55rem;
  color: var(--muted);
  line-height: 1.45;
}

.notice-list p {
  margin: 0;
}

.help-copy {
  margin-bottom: 1rem;
  color: var(--muted);
  line-height: 1.5;
}

.help-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.call-button {
  display: grid;
  place-items: center;
  min-height: 3.4rem;
  padding: 0.8rem 1rem;
  color: white;
  text-align: center;
  text-decoration: none;
}

.emergency-call {
  background: linear-gradient(180deg, #df716c 0%, var(--coral) 100%);
}

.family-call {
  background: linear-gradient(180deg, #72a8ee 0%, var(--blue) 100%);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(24rem, calc(100% - 2rem));
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  color: white;
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(0.5rem);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.tabbar {
  position: fixed;
  right: 50%;
  bottom: 0.75rem;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.15rem;
  width: min(42rem, calc(100% - 1rem));
  padding: 0.45rem;
  border: 1px solid rgba(47, 128, 201, 0.16);
  border-radius: var(--radius);
  background: rgba(248, 251, 255, 0.94);
  box-shadow: 0 14px 34px rgba(22, 50, 79, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(18px);
  transform: translateX(50%);
}

.tabbar a {
  display: grid;
  gap: 0.15rem;
  place-items: center;
  min-height: 3rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.tabbar a:first-child {
  color: var(--teal);
  background: linear-gradient(180deg, #f8fcff 0%, #e7f3ff 100%);
}

.tabbar span {
  font-size: 1rem;
  line-height: 1;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 850px) {
  .hero,
  .two-col,
  .three-col,
  .quick-actions,
  .contacts-grid,
  .inline-form,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .care-status {
    width: 100%;
  }

  .topbar {
    position: static;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 0.5rem, 1180px);
  }

  .hero,
  .panel,
  .topbar {
    padding: 0.85rem;
  }

  .mood-row,
  .form-grid,
  .help-action-grid {
    grid-template-columns: 1fr;
  }
}
