/* Diary uses the existing pine green palette, with quiet borders and large touch targets. */
.health-fields {
  --health-green: #234c3c;
  --health-mint: #eaf4ec;
  --health-ink: #183d32;
  border-top: 1px solid #dce6dd;
  padding-top: 22px;
  margin-top: 22px;
  min-width: 0;
  color: var(--health-ink);
}
.health-fields h3 {
  font-size: 24px;
  margin: 0 0 14px;
}
.health-fields [hidden],
.diary-history [hidden] {
  display: none !important;
}
.health-step-labels {
  display: flex;
  gap: 6px;
  margin: 0 0 18px;
  flex-wrap: wrap;
}
.health-step-labels span {
  font-size: var(--ui-caption);
  padding: 7px 12px;
  color: var(--ui-muted);
  background: #f4f6f3;
  border-radius: 6px;
}
.health-step-labels .current {
  color: #fff;
  background: var(--health-green);
}
.health-fields button {
  min-height: 44px;
  white-space: normal;
  text-align: left;
  line-height: var(--ui-leading);
}
.health-good {
  width: 100%;
  justify-content: flex-start;
  font-weight: 600;
  margin-bottom: 16px;
  border-color: #aacbb4;
  background: #f7fbf6;
}
.health-fields button.selected,
.health-pick.selected {
  background: var(--health-mint);
  border-color: #3d805f;
  color: #164e3b;
  box-shadow: inset 0 0 0 1px #3d805f;
}
.health-search {
  margin-bottom: 16px;
}
.health-groups {
  border: 1px solid #dce6dd;
  border-radius: 10px;
  overflow: hidden;
}
.health-groups details {
  margin: 0;
  border-bottom: 1px solid #dce6dd;
}
.health-groups details:last-child {
  border: 0;
}
.health-groups summary {
  cursor: pointer;
  padding: 14px;
  background: #f8faf7;
  font-weight: 600;
  min-height: 48px;
}
.health-picks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 10px;
}
.health-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e0e7df;
  border-radius: 7px;
  cursor: pointer;
  background: white;
  font-size: var(--ui-caption);
}
.health-pick input {
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  accent-color: #276647;
}
.health-pick span {
  line-height: var(--ui-leading);
}
.health-fields button:focus-visible,
.health-groups summary:focus-visible {
  outline: 3px solid #8ab39a;
  outline-offset: 2px;
}
.health-pick:focus-within {
  outline: 2px solid #8ab39a;
  outline-offset: 1px;
}
.health-step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e0e7df;
}
.health-step-actions > span {
  font-size: var(--ui-caption);
}
.health-step-actions .primary {
  margin-left: auto;
}
.health-question-head {
  padding: 14px 16px;
  background: #edf5ee;
  border-radius: 9px;
  margin-bottom: 20px;
}
.health-question-head span {
  font-size: var(--ui-caption);
  color: #627a6c;
}
.health-question-head h4 {
  font-size: 23px;
  margin: 5px 0 0;
}
.health-question {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
}
.health-question legend {
  font-weight: 600;
  margin-bottom: 9px;
  padding: 0;
  font-size: var(--ui-caption);
}
.health-answer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.health-answer-options button {
  padding: 9px 13px;
  font-size: var(--ui-caption);
}
.health-question > input {
  max-width: 260px;
}
.health-comment {
  margin-top: 20px;
}
.health-comment textarea {
  min-height: 84px;
}
.health-error {
  color: #9b3434;
  background: #fff3f1;
  border-radius: 7px;
  padding: 12px;
  margin-top: 15px;
}
.health-confirmed,
.health-good-result {
  color: #286341;
}
.health-good-result {
  padding: 15px;
  background: #eaf4ec;
  border-radius: 9px;
}
.health-summary-cards {
  display: grid;
  gap: 10px;
}
.health-summary-card {
  border: 1px solid #dce6dd;
  border-left: 3px solid #6c9c7d;
  border-radius: 7px;
  padding: 14px;
  background: #fff;
}
.health-summary-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}
.health-summary-card h4 {
  font-size: var(--ui-body);
  margin: 0 0 12px;
}
.health-summary-card .small {
  font-size: var(--ui-caption);
  padding: 7px 10px;
  min-height: 36px;
}
.health-summary-card dl,
.history-facts {
  margin: 0;
}
.health-summary-card dl > div,
.history-facts > div {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 1.4fr;
  gap: 12px;
  margin: 7px 0;
  line-height: var(--ui-leading);
  font-size: var(--ui-caption);
}
.health-summary-card dt,
.history-facts dt {
  color: var(--ui-muted);
}
.health-summary-card dd,
.history-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.health-legacy {
  color: var(--ui-muted);
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
}
.health-extra {
  margin-top: 10px;
}
.health-extra summary {
  padding: 10px 0;
}
.health-extra .formgrid {
  margin-top: 15px;
}
.diary-history {
  min-width: 0;
}
.diary-history .pagehead {
  gap: 16px;
}
.diary-history .pagehead h2 {
  font-size: 28px;
}
.diary-history .pagehead p {
  margin: 5px 0 0;
  font-size: var(--ui-caption);
}
.history-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
  background: #fff;
  border: 1px solid #dce6dd;
  border-radius: 12px;
  margin: 18px 0;
}
.history-filters label {
  font-size: var(--ui-caption);
  margin: 0;
  min-width: 0;
}
.history-search {
  grid-column: 1/-1;
}
.history-table-scroll {
  border: 1px solid #dce6dd;
  border-radius: 12px;
  overflow: auto;
  background: white;
}
.diary-history-table {
  width: 100%;
  min-width: 1600px;
  border-collapse: collapse;
  font-size: var(--ui-caption);
  table-layout: fixed;
}
.diary-history-table thead {
  background: #edf3ed;
}
.diary-history-table th {
  font-size: var(--ui-caption);
  font-weight: 500;
  color: #506a5a;
  padding: 13px 10px;
  border-bottom: 1px solid #dce6dd;
  text-align: left;
  white-space: normal;
}
.diary-history-table td {
  padding: 14px 10px;
  border: 0;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.diary-history-table tbody + tbody {
  border-top: 1px solid #e0e7df;
}
.history-overview > td:first-child > * {
  display: block;
  margin-bottom: 6px;
}
.history-overview strong {
  font-size: var(--ui-caption);
}
.history-overview small {
  font-size: var(--ui-caption);
  color: var(--ui-muted);
}
.history-overview .history-rise {
  color: #9b6d22;
}
.history-overview .history-warning {
  color: #a65c3d;
}
.history-basics {
  display: grid;
  gap: 7px;
  font-size: var(--ui-caption);
}
.history-symptoms {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.history-symptoms > span {
  padding: 5px 8px;
  background: #f2f6f2;
  border-radius: 6px;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
}
.history-symptoms small {
  display: block;
}
.history-good {
  color: #286b46;
  font-size: var(--ui-caption);
}
.history-overview .pill {
  font-size: var(--ui-caption);
  white-space: normal;
}
.history-overview button {
  white-space: nowrap;
  min-height: 40px;
  padding: 7px 10px;
}
.history-detail-row > td {
  padding: 20px;
  background: #f7faf6;
  border-top: 1px dashed #d4e2d6;
}
.history-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
.history-detail-grid > section {
  min-width: 0;
}
.history-detail-grid h3 {
  font-size: 21px;
  margin: 0 0 15px;
}
.history-detail-grid h4 {
  margin: 18px 0 9px;
}
.history-detail-grid .health-summary-card h4 {
  margin: 0 0 10px;
  font-size: var(--ui-body);
}
.history-detail-grid .textbody {
  font-size: var(--ui-caption);
}
.history-facts {
  margin: 18px 0;
}
.history-plan {
  margin: 12px 0;
}
.history-plan summary {
  cursor: pointer;
  font-weight: 600;
  padding: 5px 0;
}
.history-plan p {
  font-size: var(--ui-caption);
  margin: 8px 0;
}
.history-reply {
  border-bottom: 1px solid #dce6dd;
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.history-photos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.history-photos img {
  width: 70px;
  height: 80px;
  object-fit: cover;
  border-radius: 7px;
}
.history-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0;
  font-size: var(--ui-caption);
  color: #637c6e;
}
.history-bottom button {
  min-height: 44px;
}
@media (min-width: 700px) {
  .health-picks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .history-filters {
    grid-template-columns: 150px 150px minmax(180px, 1fr) minmax(160px, 0.7fr);
  }
  .history-search {
    grid-column: auto;
  }
  .history-detail-grid {
    grid-template-columns: 1.2fr 1fr 1fr;
  }
}
@media (max-width: 1050px) {
  .history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .diary-history-table {
    font-size: var(--ui-caption);
  }
  .diary-history-table th,
  .diary-history-table td {
    padding: 12px 9px;
  }
  .history-detail-grid {
    grid-template-columns: 1fr 1fr;
  }
  .history-detail-grid > section:last-child {
    grid-column: 1/-1;
  }
}
@media (max-width: 700px) {
  .history-table-scroll {
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .diary-history-table,
  .diary-history-table tbody,
  .diary-history-table tr,
  .diary-history-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .diary-history-table colgroup {
    display: none;
  }
  .diary-history-table .history-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .history-cell-date,
  .history-cell-health,
  .history-cell-reply,
  .history-cell-details {
    grid-column: 1/-1;
  }
  .diary-history-table thead {
    display: none;
  }
  .diary-history-table tbody {
    background: white;
    border: 1px solid #dce6dd !important;
    border-radius: 10px;
    margin: 0 0 13px;
    overflow: hidden;
  }
  .diary-history-table td {
    padding: 9px 14px;
  }
  .history-overview > td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--ui-caption);
    color: var(--ui-muted);
    margin-bottom: 5px;
  }
  .history-overview > td:first-child {
    background: #f2f7f0;
    padding: 13px 14px;
  }
  .history-overview > td:first-child::before {
    display: none;
  }
  .history-overview > td:last-child button {
    width: 100%;
    min-height: 44px;
  }
  .history-detail-row > td {
    padding: 16px;
  }
  .history-detail-grid {
    grid-template-columns: 1fr;
  }
  .history-detail-grid > section:last-child {
    grid-column: auto;
  }
  .history-filters {
    padding: 13px;
  }
  .history-filters .history-search,
  .history-filters label:last-child {
    grid-column: 1/-1;
  }
  .history-bottom {
    align-items: start;
    flex-direction: column;
  }
  .history-bottom button {
    width: 100%;
  }
  .health-step-labels span {
    padding: 7px 9px;
  }
  .health-summary-card dl > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .health-step-actions > button {
    flex: 1;
    justify-content: center;
  }
  .health-extra .formgrid {
    grid-template-columns: 1fr;
  }
  .health-fields .health-pick {
    font-size: var(--ui-caption);
  }
}
/* Keep the date in view while comparing individual measurements across the table. */
@media (min-width: 701px) {
  .history-overview > td + td {
    border-left: 1px solid #edf1eb;
  }
  .diary-history-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #edf3ed;
  }
  .history-overview > .history-cell-date {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    border-right: 1px solid #dce6dd;
  }
}

/* Daily entry: quiet pastel cards, with related questions kept together. */
.diary-entry-form {
  font-family: var(--ui-font);
  font-size: var(--ui-caption);
  color: #263a45;
  min-width: 0;
}
.diary-date-note {
  margin: 0 0 16px;
  color: #687b78;
  font-size: var(--ui-caption);
  line-height: var(--ui-leading);
}
.diary-entry-form .diary-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid #e4e9e6;
  border-radius: 15px;
  box-shadow: 0 3px 14px #293b3210;
  margin-bottom: 18px;
}
.diary-card-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 20px;
  background: var(--diary-tint);
  border-bottom: 1px solid var(--diary-border);
}
.diary-card-heading > svg {
  width: 30px;
  height: 30px;
  flex: none;
  color: var(--diary-accent);
}
.diary-entry-form .diary-card-heading h2 {
  font: 700 19px/var(--ui-leading) var(--ui-font);
  color: #253944;
  margin: 0;
}
.diary-card-heading h2 small {
  font-size: var(--ui-caption);
  font-weight: 400;
  color: var(--ui-muted);
  margin-left: 7px;
}
.diary-card-heading p {
  font-size: var(--ui-caption);
  color: #6b787a;
  margin: 4px 0 0;
  line-height: var(--ui-leading);
}
.diary-card-body {
  padding: 20px;
}
.diary-card-body > fieldset {
  margin: 0;
  min-width: 0;
}
.diary-morning {
  --diary-tint: #fff6e8;
  --diary-accent: #d29a32;
  --diary-border: #f4e9d4;
}
.diary-evening {
  --diary-tint: #f1f4fc;
  --diary-accent: #7d87b4;
  --diary-border: #e5e9f4;
}
.diary-health {
  --diary-tint: #f5effc;
  --diary-accent: #9572af;
  --diary-border: #eadef4;
}
.diary-photos {
  --diary-tint: #edf7fd;
  --diary-accent: #5699ba;
  --diary-border: #deedf5;
}
.diary-measures {
  --diary-tint: #edf7f1;
  --diary-accent: #4d9478;
  --diary-border: #dceee3;
}
.diary-entry-form label,
.diary-entry-form legend {
  font-size: var(--ui-caption);
  color: #37474f;
}
.diary-entry-form input,
.diary-entry-form textarea {
  font-size: var(--ui-caption);
  min-width: 0;
}
.diary-entry-form .formgrid {
  gap: 5px 24px;
}
.diary-entry-form .diary-answer {
  min-width: 0;
  margin-bottom: 16px;
}
.diary-entry-form .checks {
  gap: 12px 24px;
}
.diary-entry-form .check {
  min-height: 30px;
  margin: 0;
}
.diary-entry-form button {
  font-size: var(--ui-caption);
  min-height: 42px;
}
.diary-entry-form fieldset:disabled input {
  background: #f8f9f8;
  color: #687474;
}
.diary-save-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.diary-save-line span {
  font-size: var(--ui-caption);
  color: #557b69;
}
.diary-entry-form .diary-submit {
  padding: 12px 22px;
  margin-bottom: 20px;
  font-weight: 600;
}
.diary-photo-input {
  margin-top: 12px;
}
.diary-photo-input input {
  padding: 10px;
  background: #f9fcfe;
  font-size: var(--ui-caption);
}
.diary-entry-form .health-fields {
  border: 0;
  margin: 0;
  padding: 0;
  color: #37404d;
  --health-green: #73568d;
  --health-mint: #f1eaf8;
  --health-ink: #554467;
}
.diary-entry-form .health-good {
  border-color: #d7e8de;
  background: #f5faf6;
  color: #397358;
  font-size: var(--ui-caption);
}
.diary-entry-form .health-good.selected {
  background: #edf6ef;
  border-color: #6eaa85;
  box-shadow: inset 0 0 0 1px #6eaa85;
}
.diary-entry-form .health-search {
  margin-bottom: 14px;
}
.diary-entry-form .health-groups {
  border-color: #e6ddee;
}
.diary-entry-form .health-groups summary {
  background: #faf7fd;
  font-size: var(--ui-caption);
  min-height: 44px;
  padding: 12px 14px;
  color: #675378;
}
.diary-entry-form .health-picks {
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 10px;
}
.diary-entry-form .health-pick {
  min-height: 44px;
  border-color: #e8e1ed;
  font-size: var(--ui-caption);
}
.diary-entry-form .health-pick.selected,
.diary-entry-form .health-answer-options button.selected {
  background: #f2eafa;
  border-color: #ae90c4;
  box-shadow: inset 0 0 0 1px #ae90c4;
  color: #664c80;
}
.diary-entry-form .health-pick input {
  accent-color: #8a69a7;
  min-height: 0;
}
.health-inline-detail {
  padding: 18px 12px 4px;
  border-left: 2px solid #c5add8;
  margin: 8px 4px 10px 10px;
}
.diary-entry-form .health-question {
  margin-bottom: 18px;
  min-width: 0;
}
.diary-entry-form .health-question legend {
  font-size: var(--ui-caption);
  font-weight: 600;
}
.diary-entry-form .health-answer-options {
  gap: 6px;
}
.diary-entry-form .health-answer-options button {
  padding: 8px 10px;
  min-height: 38px;
  font-size: var(--ui-caption);
  border-color: #e5ddeb;
  color: #63596c;
}
.health-selection {
  font-size: var(--ui-caption);
  color: var(--ui-muted);
  margin: 12px 0 0;
}
.diary-entry-form .health-comment {
  margin-top: 18px;
}
@media (min-width: 1100px) {
  .diary-layout {
    grid-template-columns: minmax(420px, 1.15fr) minmax(300px, 1fr);
    gap: 24px;
  }
}
@media (max-width: 760px) {
  .diary-card-heading {
    padding: 15px 16px;
  }
  .diary-card-body {
    padding: 16px;
  }
  .diary-entry-form .formgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
  }
  .diary-entry-form .checks {
    gap: 12px;
  }
  .diary-entry-form .diary-card-heading h2 {
    font-size: var(--ui-body);
  }
  .diary-entry-form .diary-submit {
    width: 100%;
  }
  .health-inline-detail {
    padding-left: 10px;
    margin-left: 6px;
  }
}
@media (max-width: 360px) {
  .diary-entry-form .formgrid {
    grid-template-columns: 1fr;
  }
}

/* A visible top scrollbar stays reachable while reading a long diary. */
.history-horizontal-scroll {
  position: sticky;
  top: 0;
  z-index: 5;
  width: 100%;
  max-width: 100%;
  height: 22px;
  overflow-x: scroll;
  overflow-y: hidden;
  background: #edf3ed;
  border: 1px solid #dce6dd;
  border-radius: 6px;
  margin-bottom: 8px;
  scrollbar-width: auto;
  scrollbar-color: #6e8a7a #edf3ed;
  overscroll-behavior-x: contain;
}
.history-horizontal-scroll > div {
  height: 1px;
}
.history-horizontal-scroll::-webkit-scrollbar {
  height: 16px;
}
.history-horizontal-scroll::-webkit-scrollbar-track {
  background: #edf3ed;
  border-radius: 6px;
}
.history-horizontal-scroll::-webkit-scrollbar-thumb {
  background: #6e8a7a;
  border: 3px solid #edf3ed;
  border-radius: 8px;
}
.history-horizontal-scroll:focus-visible,
.history-table-scroll:focus-visible {
  outline: 2px solid #236f61;
  outline-offset: 2px;
}
.history-table-scroll {
  max-width: 100%;
  min-width: 0;
}

.history-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.diary-history [data-history-column][hidden] {
  display: none !important;
}
.history-review-target > .history-overview {
  outline: 2px solid #d0b36c;
  outline-offset: -2px;
}

.health-fields .health-good:not(.selected) {
  background: #fff !important;
  color: #47534d !important;
  border-color: #d8dedb !important;
  box-shadow: none !important;
}
.health-fields .health-good.selected {
  background: #e3f3e8 !important;
  color: #164e3b !important;
  border-color: #3d805f !important;
  box-shadow: inset 0 0 0 1px #3d805f !important;
}

.health-acknowledged-summary small {
  display: block;
  color: #718075;
  font-size: 11px;
  margin-top: 4px;
}
.health-acknowledged-summary .history-symptoms span {
  background: transparent;
  color: #6b756f;
}
.health-reviewed .health-summary-card {
  border-left-color: #d9dfdb;
  background: #fafbfa;
  color: #68746c;
}
.health-acknowledged-note {
  font-size: 12px;
  color: #69786e;
}
.history-detail-grid button.primary {
  background: #315c46;
  color: white;
  border-color: #315c46;
}

.history-brief-item {
  padding: 7px 0;
  border-bottom: 1px solid #e1e7e2;
}
.history-brief-item strong,
.history-brief-item small {
  display: block;
}
.history-brief-item small {
  font-size: 12px;
  color: #69776d;
  margin-top: 3px;
}
.history-brief-links {
  display: flex;
  gap: 10px;
  margin: 7px 0;
  flex-wrap: wrap;
}
.history-detail-grid .history-inline-link {
  background: none;
  border: 0;
  color: #365f47;
  padding: 3px 0;
  font-size: 12px;
  text-decoration: underline;
  min-height: 0;
}
.history-household {
  margin-top: 8px;
}
.history-replacement-brief {
  margin-top: 12px;
  border-top: 1px solid #dde5df;
  padding-top: 8px;
}
.history-replacement-brief article {
  padding: 8px 0;
  border-bottom: 1px solid #e1e7e2;
}
.history-replacement-brief article > strong {
  display: block;
  margin-top: 3px;
}
.history-replacement-brief article p {
  font-size: 13px;
  line-height: var(--ui-leading);
  margin: 4px 0;
}
.history-replacement-brief article > small {
  color: #6d7a71;
  font-size: 11px;
}

/* Filters stay in the existing header row, without additional table fields. */
.diary-history .history-column-trigger {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 5px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  white-space: normal;
  box-shadow: none;
}
.diary-history .history-filter-mark {
  flex-shrink: 0;
  opacity: 0.6;
  font-size: 13px;
  line-height: var(--ui-leading);
}
.diary-history .history-column-trigger.is-filtered {
  color: #236142;
}
.diary-history .history-column-trigger.is-filtered .history-filter-mark {
  opacity: 1;
  background: #d8eadf;
  border-radius: 4px;
  padding: 0 3px;
}
.history-column-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 14px;
  border: 1px solid #cddbd2;
  border-radius: 12px;
  background: #fff;
  color: #263b30;
  box-shadow: 0 8px 32px #142c2426;
  font-family: var(--ui-font, Arial, sans-serif);
  font-size: 14px;
}
.history-column-menu::backdrop {
  background: transparent;
}
.history-column-menu > strong {
  display: block;
  margin-bottom: 10px;
}
.history-filter-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.history-column-menu button {
  font-size: 13px;
  padding: 6px 9px;
  min-height: 32px;
}
.history-filter-values {
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid #e2e9e4;
  border-bottom: 1px solid #e2e9e4;
  padding: 6px 0;
}
.history-filter-values label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 7px 2px;
  line-height: var(--ui-leading);
  overflow-wrap: anywhere;
  font-weight: 400;
}
.history-filter-values input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
}
.history-column-menu .history-filter-done {
  display: block;
  margin-top: 10px;
  margin-left: auto;
}

@media (max-width: 700px) {
  .diary-history .history-table-scroll {
    border: 1px solid #dce6dd;
    border-radius: 10px;
    background: #fff;
    overflow: auto;
  }
  .diary-history .diary-history-table {
    display: table;
  }
  .diary-history .diary-history-table colgroup {
    display: table-column-group;
  }
  .diary-history .diary-history-table thead {
    display: table-header-group;
  }
  .diary-history .diary-history-table tbody {
    display: table-row-group;
    border: 0 !important;
    border-radius: 0;
    margin: 0;
    overflow: visible;
  }
  .diary-history .diary-history-table tr,
  .diary-history .diary-history-table .history-overview {
    display: table-row;
  }
  .diary-history .diary-history-table td {
    display: table-cell;
    width: auto;
    padding: 10px;
    min-width: 0;
  }
  .diary-history .history-overview > td[data-label]::before {
    display: none;
  }
  .diary-history .history-overview > td:first-child {
    background: transparent;
    padding: 10px;
  }
}

/* Aligned history cells and complete filter labels at every viewport width. */
.diary-history .diary-history-table th,
.diary-history .diary-history-table .history-overview > td {
  box-sizing: border-box;
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
}
.diary-history .diary-history-table th + th,
.diary-history .diary-history-table .history-overview > td + td {
  border-left: 1px solid #dce6dd;
}
.diary-history .history-column-trigger {
  min-width: 0;
  min-height: 0;
  line-height: var(--ui-leading);
  align-items: flex-start;
  overflow: visible;
}
.diary-history .history-column-trigger > span:first-child {
  min-width: 0;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}
.diary-history .history-filter-mark {
  flex: 0 0 auto;
}

/* Compact proportional columns fill the available history viewport. */
.diary-history .diary-history-table th,
.diary-history .diary-history-table .history-overview > td {
  padding: 8px 5px;
  line-height: var(--ui-leading);
}
.diary-history .history-column-trigger {
  gap: 2px;
}
.diary-history .history-overview button {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 100%;
  padding: 6px 3px;
  min-width: 0;
}
.diary-history .history-overview > td:first-child > * {
  margin-bottom: 0;
}

.diary-history .diary-history-table th {
  position: relative;
  padding-right: 10px;
}
.diary-history .history-resize-handle {
  position: absolute;
  right: -4px;
  top: 0;
  bottom: 0;
  width: 9px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
  z-index: 4;
  box-shadow: none;
}
.diary-history .history-resize-handle:hover,
.diary-history .history-resize-handle:focus-visible {
  background: #23785b55;
  outline: 2px solid #23785b;
  outline-offset: -2px;
}

.diary-history .history-meal-item {
  padding: 6px 0;
  border-bottom: 1px solid #e1e7df;
  overflow-wrap: anywhere;
}
.diary-history .history-meal-item:last-child {
  border-bottom: 0;
}
.diary-history .history-meal-item p {
  margin: 2px 0;
}
.diary-history .history-meal-item.has-issue {
  color: #924b17;
}
.diary-history .history-meal-comment {
  white-space: pre-wrap;
}

/* Keep expanded diary answers within the phone viewport while the overview remains scrollable. */
@media (max-width: 700px) {
  .diary-history .history-detail-viewport {
    position: sticky;
    left: 10px;
    width: var(--history-detail-width, calc(100vw - 46px));
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .diary-history .history-detail-viewport .history-detail-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .diary-history .history-detail-viewport .history-facts > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    margin: 10px 0;
  }
  .diary-history .history-detail-viewport .history-facts dd {
    margin: 0;
    font-weight: 500;
  }
}
