:root {
  --paper: #f6f3ee;
  --ink: #24312f;
  --muted: #6b7471;
  --line: #dad4c8;
  --panel: #fffdf8;
  --mint: #d9ece5;
  --teal: #1d7b75;
  --rose: #b7525d;
  --amber: #a66b16;
  --blue: #3d6794;
  --shadow: 0 18px 42px rgba(49, 55, 50, 0.13);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px 12px;
}

.simple-topbar {
  padding-top: 22px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 7vw, 2.35rem);
  letter-spacing: 0;
  line-height: 1.08;
}

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

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 1.5rem;
  line-height: 1;
}

.status-band {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 18px;
  min-height: 92px;
  background: var(--mint);
  border: 1px solid rgba(29, 123, 117, 0.2);
  border-radius: 8px;
}

.status-band strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  line-height: 1.15;
}

.status-label,
.quiet,
time {
  color: var(--muted);
  font-size: 0.88rem;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 0;
  background: rgba(246, 243, 238, 0.94);
  backdrop-filter: blur(12px);
}

.tab {
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 14px;
}

.panel,
.assessment,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel.compact {
  display: grid;
  gap: 10px;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
  padding: 10px 12px;
  outline: none;
}

.elder-mode label {
  font-size: 1rem;
}

.elder-mode input,
.elder-mode select,
.elder-mode textarea {
  min-height: 56px;
  font-size: 1.12rem;
}

.simple-record {
  gap: 16px;
}

.big-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.big-inputs input {
  min-height: 64px;
  font-size: 1.35rem;
  font-weight: 800;
}

.save-big {
  min-height: 62px;
  font-size: 1.25rem;
}

.optional-note,
.more-tools {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.optional-note summary,
.more-tools > summary {
  color: var(--teal);
  cursor: pointer;
  font-weight: 800;
  min-height: 36px;
  display: flex;
  align-items: center;
}

.optional-note label {
  margin-top: 12px;
}

.more-tools {
  margin-top: 14px;
  background: transparent;
}

.more-tools > summary {
  color: var(--ink);
  font-size: 1.05rem;
}

.more-tools[open] {
  display: grid;
  gap: 14px;
}

.safety-panel {
  margin-top: 14px;
}

.safety-panel p {
  color: var(--muted);
  line-height: 1.55;
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(29, 123, 117, 0.16);
}

.form-row {
  display: grid;
  gap: 10px;
}

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

.actions,
.section-head,
.data-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.primary,
.ghost,
.text-button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  flex: 1;
  background: var(--teal);
  color: #fff;
}

.primary.wide {
  width: 100%;
  margin-top: 12px;
}

.ghost {
  min-width: 86px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.data-actions {
  flex-wrap: wrap;
}

.data-actions .ghost {
  flex: 1;
}

.danger-text {
  color: var(--rose);
}

.text-button {
  background: transparent;
  color: var(--teal);
  padding: 0 4px;
}

.assessment,
.history {
  display: grid;
  gap: 12px;
}

.assessment-list,
.history-list,
.reminder-list,
.summary-grid {
  display: grid;
  gap: 10px;
}

.assessment-item,
.history-item,
.summary-tile,
.reminder-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.assessment-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-left: 5px solid var(--teal);
}

.assessment-item.warn {
  border-left-color: var(--amber);
}

.assessment-item.danger {
  border-left-color: var(--rose);
}

.assessment-item strong {
  font-size: 0.96rem;
}

.assessment-item span,
.history-meta,
.summary-tile span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.history-item {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.history-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.history-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #eef5f3;
  color: var(--ink);
  padding: 4px 10px;
  font-size: 0.86rem;
  font-weight: 800;
}

.delete-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f7e8e8;
  color: var(--rose);
  font-size: 1.1rem;
}

#trendChart {
  width: 100%;
  aspect-ratio: 12 / 7;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-top: 14px;
}

.summary-grid {
  grid-template-columns: repeat(2, 1fr);
}

.summary-tile {
  padding: 14px;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.reminder-item {
  grid-template-columns: 24px 1fr 112px;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.reminder-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  accent-color: var(--teal);
}

.reminder-copy {
  color: var(--ink);
  font-weight: 800;
}

.reminder-time {
  min-height: 40px;
  padding: 8px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-links a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.empty {
  min-height: 86px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

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

  .form-row.two,
  .big-inputs,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .reminder-item {
    grid-template-columns: 24px 1fr;
  }

  .reminder-time {
    grid-column: 2;
  }
}
