/* Resin Health Signals, screen 6 of /app. Built on the tokens in style.css.
   Rules: STYLE_GUIDE.md 2.0.0. App body 16px, labels 15px/600, hints 14px,
   titles 24px/700, section headings 18px/600, 44px touch targets,
   one column at most 640px wide, 16px phone gutters. Since 2.20.0 a soft warm
   gray page (--page), white cards with 24px corners and soft shadows in place
   of borders, pill buttons and tag pills.
   The screen's own width sets the layout, not the window's: on a computer
   /app shows a 375px phone frame inside a wide window. */

.sg-root {
  container-type: inline-size;
  font-size: 16px;
  line-height: 1.5;
  color: var(--stone-800);
  background: var(--page);
  /* A focused field stops below the sticky header. */
  scroll-padding-top: 120px;
}

.sg-root [hidden],
.sg-toast[hidden] { display: none !important; }

.sg-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sg-icon { display: block; flex: none; }

/* ---------------------------------------------------------------- Header */

.sg-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--page);
  box-shadow: 0 1px 0 rgba(41, 37, 36, 0.06);
}

.sg-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  min-height: 60px;
  margin: 0 auto;
  padding: 8px 16px 4px;
}

.sg-brand { font-size: 18px; font-weight: 700; line-height: 1.15; color: var(--stone-900); }

/* On phones the badge sits under the name so the header keeps its 44px targets. */
.sg-brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.sg-brand-block .sg-badge { padding: 0 6px; font-size: 12px; line-height: 1.5; }

@container (min-width: 560px) {
  .sg-brand-block { flex-direction: row; align-items: center; gap: 8px; }
  .sg-brand-block .sg-badge { padding: 2px 10px; font-size: 13px; line-height: 1.6; }
}
.sg-spacer { flex: 1; }

.sg-header-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--stone-800);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.sg-header-btn:hover { box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--stone-300); }
.sg-icon-btn { width: 44px; padding: 0; }
.sg-header-btn[aria-current="page"] { color: var(--amber); box-shadow: var(--shadow-soft), inset 0 0 0 2px var(--amber); }

.sg-demo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.sg-demo-banner p {
  flex: 1 1 220px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--warm-cream);
  color: var(--stone-900);
  font-size: 15px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- Layout */

.sg-main {
  display: block;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  outline: none;
}

.sg-view h1 {
  margin: 4px 0 8px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--stone-900);
}

.sg-view h1:focus { outline: none; }

.sg-view h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--stone-900);
}

.sg-view h3, .sg-view h4, .sg-view h5 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--stone-900);
}

.sg-view p { margin: 0 0 12px; }
.sg-lead { font-size: 17px; color: var(--stone-700); }
.sg-subtitle { margin-top: -4px !important; color: var(--stone-600); }
.sg-hint { font-size: 14px; color: var(--stone-600); }
.sg-empty { padding: 8px 0; color: var(--stone-600); }
.sg-section { margin-top: 28px; }
.sg-device-note { font-weight: 600; color: var(--stone-900); }
.sg-preview-note {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--amber-50);
  font-size: 15px;
  color: var(--stone-800);
}

.sg-main a:not(.sg-btn):not(.sg-entry-link):not(.sg-action) {
  color: var(--amber);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sg-list { margin: 0 0 12px; padding-left: 22px; }
.sg-list li { margin: 6px 0; }

.sg-flash {
  padding: 12px 14px;
  border-radius: 16px;
  background: #ecf6ef;
  color: var(--forest);
  font-weight: 600;
}

/* --------------------------------------------------------------- Buttons */

.sg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.sg-btn-primary { background: var(--amber); color: #fff; box-shadow: 0 6px 16px -8px rgba(143, 64, 7, 0.6); }
.sg-btn-primary:hover { background: var(--amber-hover); }
.sg-btn-secondary { background: var(--surface); color: var(--stone-800); border-color: var(--stone-300); }
.sg-btn-secondary:hover { border-color: var(--stone-500); }
.sg-btn-danger { background: var(--surface); color: var(--red); border-color: var(--stone-300); }
.sg-btn-danger:hover { border-color: var(--red); }
.sg-btn-small { min-height: 44px; padding: 8px 16px; font-size: 15px; }
.sg-btn:disabled { opacity: 0.6; cursor: default; }

.sg-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.sg-actions-stack { flex-direction: column; }
.sg-actions-stack .sg-btn { width: 100%; }
.sg-delete-row { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--stone-200); }

@container (min-width: 560px) {
  .sg-actions-stack { flex-direction: row; }
  .sg-actions-stack .sg-btn { width: auto; }
}

/* ---------------------------------------------------------------- Badges */

.sg-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.sg-badge-preview { background: var(--amber-50); color: var(--amber); border: 1px solid #f1d6a6; }
.sg-badge-pattern { background: var(--amber-50); color: #8a3f06; border: 1px solid #f1d6a6; }
.sg-badge-neutral { background: var(--stone-100); color: var(--stone-700); }
.sg-badge-context { background: #ecf6ef; color: var(--forest); }
.sg-badge-quiet { background: var(--stone-100); color: var(--stone-600); font-weight: 500; }

/* ----------------------------------------------------------------- Cards */

.sg-card {
  position: relative;
  margin: 16px 0;
  padding: 20px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

/* The mark down the left side of a pattern card (amber) and a lab card (stone).
   A border, not a fill, so it prints; it stops short of the round corners. */
.sg-card-personal::before,
.sg-card-lab::before {
  content: '';
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 0;
  border-left: 4px solid var(--amber);
  border-radius: 0 4px 4px 0;
}

.sg-card-lab::before { border-left-color: var(--stone-400); }

.sg-card-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px !important;
}

/* A tag pill that says what the card is ("From your entries"). */
.sg-kicker-text {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--amber-50);
  color: var(--amber-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.sg-card-title { margin-bottom: 6px !important; }
.sg-card-meta { margin-bottom: 6px !important; font-size: 14px; color: var(--stone-600); }
.sg-card-anchor { font-weight: 600; color: var(--stone-800); }
.sg-card-lead { font-weight: 600; color: var(--stone-900); }
.sg-card-diff { font-weight: 600; }

.sg-groups, .sg-card-notes, .sg-facts { margin: 0 0 12px; padding-left: 20px; }
.sg-groups li, .sg-card-notes li, .sg-facts li { margin: 4px 0; }
.sg-card-notes li { color: var(--stone-700); }

.sg-not-cause {
  margin: 12px 0 0 !important;
  padding-top: 10px;
  border-top: 1px solid var(--stone-200);
  font-size: 15px;
  font-weight: 600;
  color: var(--stone-700);
}

.sg-sourced {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--forest);
  border-radius: 8px;
  background: #f3f8f4;
  font-size: 15px;
}

.sg-sourced p { margin: 0 !important; }
.sg-source { margin-top: 4px !important; font-size: 13px; font-weight: 600; color: var(--forest); }
.sg-flag { margin: 8px 0 12px; }
.sg-flag-text { margin-bottom: 4px !important; font-weight: 600; color: var(--stone-900); }

.sg-details { margin-top: 8px; }

.sg-details summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  color: var(--amber);
  cursor: pointer;
}

.sg-checkin-card .sg-btn { margin-top: 4px; }

/* ------------------------------------------------- Greeting card on Today */

/* The day, and the check-in in a frosted pill, on a warm amber card. White
   text is at least 4.9:1 on every part of the gradient, and the pill darkens
   what is behind it, so its text is higher still. */
.sg-greeting {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 4px 0 24px;
  padding: 22px 20px 20px;
  border-radius: var(--radius-card);
  background: var(--greeting);
  box-shadow: 0 14px 30px -16px rgba(143, 64, 7, 0.7);
  color: #fff;
}

/* A soft ring in the top corner, where the gradient is darkest. */
.sg-greeting::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: -120px;
  right: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.sg-view .sg-greeting h1 { margin: 0; font-size: 28px; color: #fff; }
.sg-view .sg-greeting .sg-subtitle { margin: 2px 0 16px !important; color: #fff; }

.sg-greeting-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(28, 25, 23, 0.22);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.sg-view .sg-greeting-status h2 { margin: 0; font-size: 15px; font-weight: 700; color: #fff; }
.sg-view .sg-greeting-status p { margin: 0; font-size: 15px; color: #fff; }
.sg-greeting .sg-checkin-card .sg-btn { margin-top: 0; }
.sg-greeting .sg-btn-primary { background: #fff; color: var(--amber-dark); box-shadow: 0 8px 18px -10px rgba(28, 25, 23, 0.6); }
.sg-greeting .sg-btn-primary:hover { background: var(--amber-50); }
.sg-greeting .sg-btn-secondary { background: transparent; border-color: rgba(255, 255, 255, 0.8); color: #fff; }
.sg-greeting .sg-btn-secondary:hover { background: rgba(255, 255, 255, 0.12); }
.sg-greeting a:focus-visible { outline-color: #fff; }

/* ------------------------------------------- Well-being questions (WHO-5) */

.sg-wb-card .sg-btn { margin-top: 4px; }
.sg-wb-score { margin: 4px 0 !important; font-size: 18px; font-weight: 700; color: var(--stone-900); }
.sg-wb-instructions { margin: 0 0 8px; color: var(--stone-900); }
.sg-wb-stem { margin: 8px 0 0; font-weight: 600; color: var(--stone-900); }
.sg-wb-item { padding: 12px 0 14px; border-bottom: 1px solid var(--stone-200); }
.sg-wb-item .sg-choice-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.sg-wb-option { display: inline-flex; align-items: baseline; gap: 8px; }
.sg-wb-num { min-width: 1ch; font-weight: 700; font-variant-numeric: tabular-nums; }
.sg-wb-copyright { margin-top: 12px !important; }
.sg-wb-meaning p:not(.sg-source) + p:not(.sg-source) { margin-top: 6px !important; }

@container (min-width: 560px) {
  .sg-wb-item .sg-choice-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------ Today's actions */

.sg-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sg-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  height: 100%;
  padding: 8px 14px 8px 8px;
  background: var(--surface);
  border: 0;
  border-radius: 29px;
  box-shadow: var(--shadow-soft);
  color: var(--stone-900);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.sg-action .sg-icon {
  box-sizing: content-box;
  padding: 8px;
  border-radius: 50%;
  background: var(--amber-50);
  color: var(--amber);
}

.sg-action:hover { box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--amber); }

@container (min-width: 560px) {
  .sg-action-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------ Entry rows */

.sg-entries {
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.sg-entry + .sg-entry { border-top: 1px solid var(--stone-200); }

.sg-entry-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  color: inherit;
  text-decoration: none;
}

.sg-entry-link:hover { background: var(--stone-100); }

.sg-entry-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--amber-50);
  color: var(--amber);
}

.sg-entry-body { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.sg-entry-title { font-weight: 600; color: var(--stone-900); overflow-wrap: anywhere; }
.sg-entry-detail { font-size: 14px; color: var(--stone-600); overflow-wrap: anywhere; }
.sg-entry-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sg-entry-link > .sg-icon:last-child { color: var(--stone-400); }
.sg-entries-compact .sg-entry-link { min-height: 48px; padding: 6px 14px; }

.sg-day { margin: 20px 0; }
.sg-view .sg-day-title { font-size: 16px; color: var(--stone-700); }

/* ----------------------------------------------------------------- Forms */

.sg-form { margin-top: 8px; }
.sg-field { min-width: 0; margin: 0 0 16px; }

.sg-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--stone-900);
}

.sg-field input,
.sg-field select,
.sg-field textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--stone-500);
  border-radius: var(--radius-field);
  background: var(--surface);
  color: var(--stone-900);
  font: inherit;
  font-size: 16px;
}

.sg-field textarea { min-height: 72px; resize: vertical; }
.sg-field [aria-invalid="true"] { border: 2px solid var(--red); }
.sg-field .sg-hint { margin: -2px 0 6px !important; }

.sg-input-row { display: flex; align-items: center; gap: 8px; }
.sg-input-row input { flex: 1; min-width: 0; }
.sg-suffix { flex: none; font-weight: 600; color: var(--stone-700); }

.sg-error { margin: 6px 0 0 !important; font-size: 14px; font-weight: 600; color: var(--red); }

.sg-form-error {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--red-bg);
  color: var(--red);
  font-weight: 600;
}

.sg-fieldset { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }

.sg-fieldset legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--stone-900);
}

.sg-fieldset > .sg-hint { margin: -4px 0 8px !important; }
.sg-when-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.sg-when-row .sg-field { margin-bottom: 0; }
.sg-when-row + * { margin-top: 16px; }
.sg-form > .sg-when-row { margin-bottom: 16px; }

.sg-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sg-check input { flex: none; width: 24px; height: 24px; margin-top: 1px; accent-color: var(--amber); }
.sg-check label { font-weight: 600; color: var(--stone-900); cursor: pointer; }

/* Radio buttons and checkboxes shown as large choices. The real input
   covers its label, so a tap anywhere on the choice selects it. */
.sg-choice-list { display: flex; flex-wrap: wrap; gap: 8px; }
.sg-choice { position: relative; min-width: 0; }

.sg-choice input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.sg-choice label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  height: 100%;
  padding: 10px 14px;
  border: 1px solid var(--stone-500);
  border-radius: 22px;
  background: var(--surface);
  color: var(--stone-900);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
}

.sg-choice label::before {
  content: '';
  flex: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2px solid var(--stone-500);
  border-radius: 50%;
  background: #fff;
}

.sg-choices-checkbox .sg-choice label::before { border-radius: 4px; }

.sg-choice input:checked + label {
  border-color: var(--amber);
  background: var(--amber-50);
  box-shadow: inset 0 0 0 1px var(--amber);
  font-weight: 600;
}

.sg-choice input:checked + label::before {
  border-color: var(--amber);
  background: radial-gradient(circle, #fff 0 3px, var(--amber) 3.5px);
}

.sg-choices-checkbox .sg-choice input:checked + label::before {
  background: var(--amber) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.5l2.2 2.2L9.5 3.8' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.sg-choice input:focus-visible + label { outline: 2px solid var(--amber); outline-offset: 2px; }

.sg-scale { padding: 12px 0 14px; border-bottom: 1px solid var(--stone-200); }
.sg-scale .sg-choice-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sg-scale .sg-choice label { gap: 8px; padding: 8px 10px; font-size: 14px; }

@container (min-width: 560px) {
  .sg-scale .sg-choice-list { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.sg-filter .sg-choice label { min-height: 44px; padding: 8px 12px; font-size: 14px; }

/* ------------------------------------------------------ Supplement finder */

.sg-results { margin: -6px 0 16px; }
.sg-small-heading { margin: 8px 0 6px !important; font-size: 14px; font-weight: 600; color: var(--stone-600); }
.sg-result-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }

.sg-result {
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--stone-900);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.sg-result:hover { box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--amber); }

.sg-chosen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--amber);
  border-radius: 16px;
  background: var(--amber-50);
}

.sg-chosen-text { margin: 0 !important; font-weight: 600; overflow-wrap: anywhere; }

.sg-barcode {
  margin: 8px 0 16px;
  padding: 14px;
  border: 1px dashed var(--stone-400);
  border-radius: 16px;
}

.sg-barcode .sg-actions { margin-top: 0; }
.sg-code-row { display: flex; align-items: flex-end; gap: 8px; }
.sg-code-row .sg-field { flex: 1; margin: 0; }

.sg-reader {
  width: 100%;
  min-height: 240px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--stone-900);
}

/* ------------------------------------------- Food barcode and suggestions */

.sg-barcode > .sg-hint { margin: 0 0 10px !important; }
.sg-product-text { flex: 1 1 200px; min-width: 0; }
.sg-product-source { margin: 4px 0 0 !important; }
.sg-why:empty { display: none; }
.sg-why { margin: -8px 0 16px; }
.sg-why .sg-hint { margin: 0 0 4px !important; }
.sg-why-list { margin: 0 0 8px; padding-left: 20px; font-size: 14px; color: var(--stone-700); overflow-wrap: anywhere; }
.sg-why-list li { margin: 2px 0; }
.sg-food-note { margin: -4px 0 16px; }
.sg-food-note p + p { margin-top: 4px !important; }

/* ------------------------------------------------------ Choosing a condition */

.sg-condition-own { margin: -4px 0 16px; padding: 12px 0 0 14px; border-left: 3px solid var(--stone-200); }
.sg-condition-own .sg-fieldset { margin-bottom: 0; }
.sg-condition-name { font-weight: 600; color: var(--stone-900); }
.sg-kept-questions { margin: 0 0 16px; }
.sg-card-source { margin: 12px 0 0; }

/* ------------------------------------------------ Spacing from the label */

.sg-spacing:empty { display: none; }
.sg-spacing { margin: -4px 0 16px; }
.sg-spacing-note p + p { margin-top: 4px !important; }
.sg-spacing-gap { font-weight: 600; color: var(--stone-900); }

/* ------------------------------------------------------- What ODS says */

/* Lines from the ODS fact sheets that match what the person logged: a white
   card with a forest left border, like "What ODS says" in Facts First. Each
   line keeps its source one tap away. */
.sg-ods:empty { display: none; }
.sg-ods { margin: 0 0 16px; }
.sg-ods-box {
  position: relative;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.sg-ods-box::before {
  content: '';
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  border-left: 4px solid var(--forest);
  border-radius: 0 4px 4px 0;
}
.sg-view .sg-ods-title { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: var(--forest); }
.sg-view .sg-ods-box > .sg-hint { margin: 0 0 8px; }
.sg-view .sg-ods-box > .sg-ods-note { margin: 12px 0 0; }
.sg-ods-box .sg-ods-line { padding: 10px 0 0; border-top: 1px solid var(--stone-200); }
.sg-ods-box .sg-ods-line + .sg-ods-line { margin-top: 10px; }
.sg-ods-box .sg-ods-line + .sg-hint { margin-top: 10px; }
.sg-view .sg-ods-why { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--stone-600); }
.sg-view .sg-ods-text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--stone-800); }
.sg-ods-lead { font-weight: 600; color: var(--forest); }
.sg-ods-source { margin: 4px 0 0; }
.sg-ods-source summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--amber);
  cursor: pointer;
}
.sg-ods-source[open] summary { margin-bottom: 4px; }
.sg-view .sg-ods-from { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--stone-600); }
.sg-ods-passage {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--stone-300);
  border-radius: 4px;
  background: var(--stone-100);
  font-size: 14px;
  line-height: 1.5;
  color: var(--stone-800);
}
.sg-view .sg-ods-passage p { margin: 0 0 6px; }
.sg-view .sg-ods-passage p:last-child { margin: 0; }
.sg-view .sg-ods-source .sg-card-meta { margin: 0 0 2px !important; overflow-wrap: anywhere; }
.sg-ods-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
/* Inside a spacing note or a lab warning, an ODS line sits in the green box
   beside the label's line. */
.sg-sourced .sg-ods-line { margin: 4px 0; }
.sg-sourced .sg-ods-line + p { margin-top: 6px !important; }
.sg-flag > .sg-ods-line {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--forest);
  border-radius: 8px;
  background: #f3f8f4;
  font-size: 15px;
}
.sg-ods-record { font-size: 13px; font-weight: 600; color: var(--forest); }

/* --------------------------------------------------- Repeats from yesterday */

.sg-repeat-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.sg-repeat { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; }
.sg-repeat + .sg-repeat { border-top: 1px solid var(--stone-200); }
.sg-repeat-head { display: flex; flex: 1 1 180px; align-items: center; gap: 12px; min-width: 0; }
.sg-repeat > .sg-btn { flex: none; max-width: 100%; }
.sg-repeat-note { flex: 1 1 100%; min-width: 0; }
.sg-repeat-note:empty { display: none; }
.sg-repeat-note .sg-spacing-note { margin: 0; }

/* ------------------------------------------------------- Report and lists */

.sg-download { margin: 12px 0; }
.sg-download .sg-hint { margin-top: 6px !important; }

.sg-summary {
  margin-top: 28px;
  padding: 20px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.sg-view .sg-summary h3 { margin: 22px 0 8px; }
.sg-summary .sg-card { box-shadow: none; border: 1px solid var(--stone-200); }
.sg-demo-note { padding: 8px 12px; border-radius: 12px; background: var(--warm-cream); font-weight: 600; }

.sg-table {
  width: 100%;
  margin: 0 0 16px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.sg-table th, .sg-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--stone-200);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.sg-table th { font-weight: 600; color: var(--stone-700); }

.sg-sources { margin: 0; padding-left: 20px; }
.sg-sources li { margin: 0 0 14px; }
.sg-sources a { font-weight: 600; overflow-wrap: anywhere; }

/* ------------------------------------------------ Section tabs (in the header) */

.sg-tabbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  width: calc(100% - 32px);
  max-width: 608px;
  margin: 2px auto 10px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sg-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 2px;
  border-radius: var(--radius-pill);
  color: var(--stone-600);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.sg-tab[aria-current="page"] {
  background: var(--amber);
  color: #fff;
}

/* ---------------------------------------------------- Toast and dialog */

/* In .screen-container, so it stays in the phone frame while the screen scrolls. */
.sg-toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--stone-900);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}

.sg-dialog {
  width: 100%;
  max-width: min(420px, calc(100% - 32px));
  margin: auto;
  padding: 24px;
  border: 0;
  border-radius: 28px;
  background: var(--surface);
  color: var(--stone-800);
  box-shadow: var(--shadow-raised);
}

.sg-dialog::backdrop { background: rgba(28, 25, 23, 0.5); }
.sg-dialog h2 { margin-bottom: 8px; font-size: 20px; font-weight: 700; color: var(--stone-900); }
.sg-dialog p { margin-bottom: 16px; }
.sg-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; }

/* ---------------------------------------------------------- Trends chart */

.sg-trends {
  margin: 12px 0 16px;
  padding: 16px;
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.sg-summary .sg-trends { box-shadow: none; border: 1px solid var(--stone-200); }

.sg-trends-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--stone-600);
}

.sg-trends-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sg-trends-legend svg { flex: none; }

.sg-trends-caption { margin: 4px 0 !important; font-size: 13px; color: var(--stone-600); }
.sg-trends-dates { margin: 0 0 8px !important; font-size: 14px; font-weight: 600; color: var(--stone-800); }

/* Tall enough for a full day on a phone, so the chart stays still under a finger. */
.sg-trends-readout {
  min-height: calc(4.5em + 16px);
  margin: 8px 0 !important;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--stone-100);
  font-size: 14px;
  color: var(--stone-800);
}
.sg-trends-readout strong { color: var(--stone-900); }

.sg-trends-plot { width: 100%; border-radius: 8px; cursor: crosshair; touch-action: pan-y; }
.sg-trends-plot:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.sg-trends-plot svg, .sg-trends-print svg { display: block; width: 100%; height: auto; overflow: visible; }

.sg-trends-print { display: none; }

.sg-trends text { font-family: inherit; font-size: 12px; fill: var(--stone-600); }
.sg-trends .sg-trends-tick { font-variant-numeric: tabular-nums; }

.sg-trends .sg-trends-title, .sg-trends .sg-trends-value {
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.sg-trends .sg-trends-title { font-size: 13px; font-weight: 600; fill: var(--stone-800); }
.sg-trends .sg-trends-value { font-weight: 600; fill: var(--stone-800); font-variant-numeric: tabular-nums; }

.sg-trends-grid { stroke: var(--stone-200); stroke-width: 1; }
.sg-trends-flare { fill: var(--stone-200); opacity: 0.7; }
/* Period days and life stages (2.19.0): dark bars and mid-gray bars, each in its own row. */
.sg-trends-period { fill: var(--stone-800); }
.sg-trends-stage { fill: var(--stone-500); }
.sg-trends .sg-trends-stage-label { font-size: 11px; font-weight: 600; fill: #fff; }
.sg-trends-range { fill: var(--warm-cream); }
.sg-trends-change { stroke: var(--stone-500); stroke-width: 1; }
.sg-trends-mark { fill: var(--stone-800); stroke: #fff; stroke-width: 2; }
.sg-trends-daily { fill: var(--stone-500); }
.sg-trends-line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sg-trends-lab { fill: var(--amber); stroke: #fff; stroke-width: 2; }
.sg-trends-cursor { stroke: var(--stone-900); stroke-width: 1; }

.sg-trends .sg-table th:first-child { width: 21%; }
.sg-trends .sg-table th:nth-child(2):not(:last-child) { width: 33%; }

/* ----------------------------------------------------------------- Print */

/* -------------------------------------------------------- Planned change */

.sg-plan-card h2, .sg-plan h1 { overflow-wrap: anywhere; }
.sg-plan-kicker { margin: 0 0 2px !important; font-size: 13px; font-weight: 600; color: var(--stone-600); }
.sg-plan-day { margin: 0 0 12px !important; font-weight: 600; color: var(--stone-700); }
.sg-plan-question { margin: 0 0 8px !important; }

.sg-plan-answers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.sg-plan-answers .sg-btn { min-width: 0; padding: 8px 4px; }

.sg-plan-status { font-weight: 600; }
.sg-plan-parts section { margin-top: 24px; }
.sg-plan-next { margin-top: 8px !important; }
.sg-print-only { display: none; }
#sg-plan-labs .sg-table th:first-child { width: 30%; }
#sg-plan-else .sg-table th:first-child { width: 46%; }

@media print {
  .sg-header, .sg-tabbar, .sg-toast, .sg-noprint, .skip-nav, .sg-details, .sg-ods-source, #sg-demo { display: none !important; }
  /* Without containment the summary can break across pages. */
  .sg-root { container-type: normal; background: #fff; }
  .sg-main { max-width: none; padding: 0 !important; }
  .sg-summary { margin: 0; padding: 0; border: 0; }
  .sg-card { break-inside: avoid; box-shadow: none; }
  .sg-summary h3 { break-after: avoid; }
  .sg-trends { break-inside: avoid; padding: 0; border: 0; }
  .sg-trends-screen { display: none; }
  .sg-trends-print { display: block; }
  html, body, #screen-signals { background: #fff !important; }
  .sg-print-only { display: block; }
  .sg-plan { font-size: 11.5px; line-height: 1.3; }
  .sg-plan h1 { margin: 0 0 2px; font-size: 18px; }
  .sg-plan h2 { margin: 0 0 2px; font-size: 13px; }
  .sg-plan p, .sg-plan li { margin: 0 !important; font-size: 11.5px; }
  .sg-plan .sg-trends { margin: 4px 0; box-shadow: none; }
  .sg-plan .sg-trends-legend { margin: 0; font-size: 11px; }
  .sg-plan .sg-demo-note { padding: 2px 6px; font-size: 11.5px; }
  .sg-plan-parts {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "left right" "sources sources"; gap: 0 16px;
  }
  .sg-plan-left { grid-area: left; }
  .sg-plan-right { grid-area: right; }
  #sg-plan-labsources { grid-area: sources; }
  .sg-plan-parts section { margin: 0 0 6px; }
  .sg-plan .sg-list, .sg-plan .sg-groups, .sg-plan .sg-card-notes { margin: 0; padding-left: 14px; }
  .sg-plan .sg-table { margin: 2px 0; font-size: 11px; }
  .sg-plan .sg-table th, .sg-plan .sg-table td { padding: 1px 4px; }
  .sg-plan .sg-not-cause { margin: 4px 0 0 !important; padding-top: 4px; font-size: 11.5px; }
  .sg-plan .sg-ods-line { margin: 2px 0 0; }
  .sg-plan .sg-ods-line .sg-ods-text { font-size: 11.5px; line-height: 1.3; }
  .sg-plan .sg-ods-line .sg-ods-record { font-size: 11.5px; }
}

/* ---------------------------------------------------------- Session mode */

/* A session phone shows Signals alone: no page header, no app tabs and no
   language button, so a participant stays inside the session. */
html.sg-session .app-header,
html.sg-session .tab-bar,
html.sg-session #sg-lang { display: none !important; }

/* The task above the app. It scrolls with the page, so a long prompt never
   covers a small screen. */
.sg-session-bar {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.sg-session-task {
  padding: 14px 16px;
  border: 1px solid #f1d6a6;
  border-radius: 20px;
  background: var(--amber-50);
}

.sg-session-kicker { margin: 0 0 2px; font-size: 14px; font-weight: 600; color: #8a3f06; }
.sg-session-prompt { margin: 0 0 4px; font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--stone-900); }
.sg-session-question { margin: 8px 0; font-weight: 600; color: var(--stone-900); }

.sg-session-answers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 4px;
}

.sg-session-answers .sg-btn { min-width: 0; padding: 8px 4px; }

.sg-session-answers .sg-btn[aria-pressed="true"],
.sg-session-choice[aria-pressed="true"],
.sg-session-option[aria-pressed="true"] {
  border: 2px solid var(--amber);
  background: #fff3df;
  color: #8a3f06;
}

/* For the team member, at the end of the task. Quiet, so a participant reads past it. */
.sg-session-team {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--stone-700);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.sg-session-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 16px;
  margin: 12px 0 16px;
  padding: 14px 16px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sg-session-facts dt { font-size: 15px; color: var(--stone-600); }
.sg-session-facts dd { margin: 0; font-weight: 600; color: var(--stone-900); overflow-wrap: anywhere; }

.sg-session-label { margin: 16px 0 8px !important; font-size: 15px; font-weight: 600; color: var(--stone-800); }

.sg-session-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sg-session-row .sg-btn { min-width: 0; padding: 8px 6px; }

.sg-session-rule { margin: 24px 0 8px; border: 0; border-top: 1px solid var(--stone-200); }

.sg-session-options { display: grid; gap: 8px; margin: 16px 0 8px; }
.sg-session-option { justify-content: flex-start; width: 100%; text-align: left; }

/* The 7-point scale: one row on most phones, a column where 7 buttons of
   44px would not fit side by side. */
.sg-session-scale {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin: 0 0 8px;
}

.sg-session-point { min-width: 0; padding: 0; font-size: 18px; }

@container (max-width: 351px) {
  .sg-session-scale { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  /* 1 is at the top of the column, so its label comes first. */
  .sg-session-ends { flex-direction: column; }
}

.sg-session-ends {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 12px 0 8px !important;
  font-size: 14px;
  color: var(--stone-600);
}

.sg-session-text {
  display: block;
  width: 100%;
  min-height: 96px;
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--stone-300);
  border-radius: 16px;
  background: var(--surface);
  color: var(--stone-900);
  font: inherit;
  font-size: 16px;
  box-sizing: border-box;
}

.sg-field .sg-session-text { margin: 0; }

.sg-session-link {
  display: flex;
  align-items: center;
  width: fit-content;
  min-width: 44px;
  min-height: 44px;
  margin: 4px 0;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--amber);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.sg-session-link:disabled { color: var(--stone-500); text-decoration: none; cursor: default; }

/* Stopping is always there, a little apart from the answers. */
.sg-session-stop { margin-top: 24px; color: var(--stone-700); }

.sg-session-confirm {
  margin: 12px 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sg-session-confirm p { font-weight: 600; color: var(--stone-900); }
.sg-session-confirm .sg-actions { margin: 8px 0 0; }

.sg-session-copy { margin: 0 0 12px; }

.sg-session-copy textarea {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--stone-300);
  border-radius: 12px;
  background: var(--surface);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  box-sizing: border-box;
}

.sg-session-saw .sg-list { margin-bottom: 0; }

/* ------------------------------------------- What changed because of feedback */

.sg-change h2 { margin-bottom: 2px; }
.sg-change-parts { margin: 0; }
.sg-change-parts dt { margin-top: 10px; font-size: 15px; font-weight: 600; color: var(--stone-900); }
.sg-change-parts dd { margin: 2px 0 0; }
.sg-change-contact { margin-top: 16px !important; }
.sg-change-contact a { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }

@media print {
  .sg-session-bar { display: none !important; }
}
