/* ============================================
   RESET
   ============================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: #12212B;
  background: #E8ECEF;
  -webkit-font-smoothing: antialiased;
}

fieldset { border: 0; margin: 0 0 22px; padding: 0; }

legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #5D7080;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #0F6E64;
  outline-offset: 2px;
}


/* ============================================
   LAYOUT
   ============================================ */

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 16px 140px;
}

.sheet-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #E8ECEF;
  border-bottom: 1px solid #D3DBE1;
}

.sheet-header h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.link {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: #0F6E64;
  min-height: 52px;
  padding: 10px 4px;
  cursor: pointer;
}


/* ============================================
   SHARED
   ============================================ */

.card {
  background: #fff;
  border: 1px solid #D3DBE1;
  border-radius: 14px;
  padding: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 15px;
  font-weight: 600;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * { flex: 1; }

.hint {
  margin: 2px 0 0;
  font-size: 14px;
  color: #5D7080;
}
/* Replace your existing .entry rules with these.
   The row is now a flex container so the pencil and cross
   sit beside the text rather than under it. */

.entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #D3DBE1;
  border-radius: 12px;
  padding: 12px;
}

.entry-text { flex: 1; min-width: 0; }

.entry-when { font-size: 14px; color: #5D7080; }

.entry-what { font-weight: 600; }

.entry-sym { font-size: 14px; color: #A8382A; margin-top: 4px; }

/* Highlights the row currently loaded into the form. */
.entry.editing {
  border-color: #0F6E64;
  background: #E2EFED;
}
.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #8A9BA6;
}


/* ============================================
   INPUTS
   ============================================ */

input, select, textarea {
  min-height: 52px;
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #D3DBE1;
  border-radius: 11px;
  background: #fff;
  font: inherit;
  font-size: 16px;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}


/* ============================================
   MEAL BUTTONS
   ============================================ */

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.choice {
  min-height: 52px;
  border: 1.5px solid #D3DBE1;
  border-radius: 14px;
  background: #fff;
  font: inherit;
  font-weight: 550;
  color: inherit;
  cursor: pointer;
}

.choice[aria-pressed="true"] {
  border-color: #0F6E64;
  background: #E2EFED;
  color: #0F6E64;
  font-weight: 700;
}


/* ============================================
   CHIPS
   ============================================ */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 0 15px;
  border: 1.5px solid #D3DBE1;
  border-radius: 99px;
  background: #fff;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: #0F6E64;
  background: #E2EFED;
  color: #0F6E64;
  font-weight: 650;
}

.chip.add {
  border-style: dashed;
  color: #5D7080;
}

.chip .thumb {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #DDE5E9;
  flex: none;
  display: grid;
  place-items: center;
}

.btn-secondary {
  flex: 0 0 84px;
  min-height: 52px;
  border: 1.5px solid #D3DBE1;
  border-radius: 11px;
  background: #fff;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}


/* ============================================
   SELECTED FOODS
   ============================================ */

.selected-foods {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.food-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #E2EFED;
  border-radius: 10px;
  padding: 9px 10px;
}

.food-row .name {
  flex: 1;
  font-weight: 600;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  font: inherit;
  color: #5D7080;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(0, 0, 0, 0.06); }


/* ============================================
   SEVERITY
   ============================================ */

.sev {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.sev button {
  min-height: 60px;
  border: 1.5px solid #D3DBE1;
  border-radius: 14px;
  background: #fff;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}

.sev button[aria-pressed="true"] {
  color: #fff;
  border-color: transparent;
}

.sev button[data-sev="mild"][aria-pressed="true"]     { background: #4A7C59; }
.sev button[data-sev="moderate"][aria-pressed="true"] { background: #B4720C; }
.sev button[data-sev="severe"][aria-pressed="true"]   { background: #A8382A; }


/* ============================================
   TOGGLE
   ============================================ */

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 14px;
  background: #fff;
  border: 1px solid #D3DBE1;
  border-radius: 14px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.toggle .q { font-weight: 600; }

.switch {
  position: relative;
  width: 56px;
  height: 32px;
  border-radius: 99px;
  background: #C9D3D9;
  flex: none;
  transition: background 0.18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}

.toggle[aria-pressed="true"] .switch { background: #0F6E64; }

.toggle[aria-pressed="true"] .switch::after { transform: translateX(24px); }

#symBlock { margin-top: 12px; }


/* ============================================
   TIME SPINE
   ============================================ */

.spine {
  display: grid;
  grid-template-columns: 76px 1fr;
  column-gap: 14px;
  margin-top: 14px;
  padding: 16px 14px;
  background: #F6F8F9;
  border: 1px solid #D3DBE1;
  border-radius: 14px;
}


/* ============================================
   FOOTER
   ============================================ */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, #E8ECEF 72%, rgba(232, 236, 239, 0));
}

.save {
  display: block;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: #0F6E64;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.save:disabled {
  background: #A9B7BF;
  cursor: not-allowed;
}


.spine-time {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  padding-bottom: 16px;
}

.spine-label {
  padding-left: 16px;
  padding-bottom: 16px;
  border-left: 2px solid #D3DBE1;
  position: relative;
}

.spine-label::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #F6F8F9;
  border: 2.5px solid #0F6E64;
}

.spine-label.warn {
  color: #A8382A;
  font-weight: 600;
}

.entries { display: flex; flex-direction: column; gap: 8px; }
.entry { background: #fff; border: 1px solid #D3DBE1; border-radius: 12px; padding: 12px; }
.entry-when { font-size: 14px; color: #5D7080; }
.entry-what { font-weight: 600; }
.entry-sym { font-size: 14px; color: #A8382A; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}