:root {
  color-scheme: light only;

  /* Surfaces */
  --bg: #EAF7F6;
  --bg-soft: #F1FAF9;
  --surface: #FFFFFF;
  --surface-2: #F7FBFB;

  /* Text */
  --text: #1F2937;
  --text-strong: #0F172A;
  --muted: #4B5563;
  --muted-2: #6B7280;
  --muted-3: #9CA3AF;

  /* Brand teal */
  --primary: #0F8B8D;
  --primary-hover: #0B7375;
  --primary-deep: #084E50;
  --primary-soft: #D6ECEA;
  --primary-soft-2: #C1E2DE;
  --primary-tint: #EAF7F6;
  --primary-shadow: rgba(15, 139, 141, 0.30);

  /* Borders */
  --border: #D6ECEA;
  --border-2: #BFDDD8;
  --hairline: rgba(15, 139, 141, 0.12);

  /* Inputs */
  --input-bg: #F3FAF9;
  --input-border: #CFE6E2;

  /* Status */
  --link: #0B7375;
  --error-bg: #FDECEC;
  --error-fg: #B42323;
  --error-border: #F4C9C9;
  --success-bg: #E5F5EA;
  --success-fg: #166344;
  --success-border: #B6DDC4;

  /* Accent palette — pastel bg + saturated foreground */
  --pain-bg: #FCE5E2;
  --pain-fg: #C45D5D;
  --pain-deep: #9B3D3D;

  --flare-bg: #FCEDD5;
  --flare-fg: #B16E1F;
  --flare-deep: #8A5414;

  --urination-bg: #D6ECEA;
  --urination-fg: #0F8B8D;
  --urination-deep: #0B7375;

  --sleep-bg: #ECE6F8;
  --sleep-fg: #6E59C7;
  --sleep-deep: #4D3F94;

  --mood-bg: #FCEFC8;
  --mood-fg: #A57C1B;
  --mood-deep: #7A5C12;

  --energy-bg: #DCEFD8;
  --energy-fg: #4F8C5E;
  --energy-deep: #366841;

  /* Effects */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 16px -8px rgba(15, 67, 70, 0.18), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 36px -20px rgba(15, 67, 70, 0.28), 0 4px 14px -6px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px -10px rgba(15, 67, 70, 0.14);

  /* Brand gradient — restrained teal */
  --grad: linear-gradient(135deg, #14B0B2 0%, #0F8B8D 55%, #0A6F71 100%);
  --grad-soft: linear-gradient(180deg, #F4FAFA 0%, #EAF7F6 100%);
  --grad-page: linear-gradient(180deg, #F2FAF9 0%, #EAF7F6 220px, #EAF7F6 100%);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light only;
    --bg: #EAF7F6;
    --surface: #FFFFFF;
    --text: #1F2937;
    --muted: #4B5563;
    --muted-2: #6B7280;
    --muted-3: #9CA3AF;
    --border: #D6ECEA;
    --input-bg: #F3FAF9;
    --input-border: #CFE6E2;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  forced-color-adjust: none;
  letter-spacing: -0.005em;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 48px 24px 40px;
  padding-top: max(48px, env(safe-area-inset-top));
}

.brand { text-align: center; margin: 0 0 28px; }
.brand__logo {
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--grad);
  box-shadow:
    0 18px 36px -16px rgba(15, 139, 141, 0.55),
    0 4px 10px -4px rgba(15, 67, 70, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand__logo img { width: 64px; height: 64px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.10)); }
.brand__title {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}
.brand__tm {
  font-size: 14px;
  font-weight: 600;
  vertical-align: super;
  margin-left: 2px;
  color: var(--muted-2);
}
.brand__subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
}

/* Buttons */
.btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease, box-shadow 0.18s ease;
  font-family: inherit;
  letter-spacing: -0.005em;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }

.btn--google {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-2);
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
}
.btn--google:hover { background: #fafafa; box-shadow: var(--shadow-sm); }
.google-icon { width: 20px; height: 20px; flex: none; }

.btn--primary {
  background: var(--primary);
  color: #ffffff;
  margin-top: 6px;
  box-shadow: 0 8px 18px -8px var(--primary-shadow), 0 1px 2px rgba(15, 67, 70, 0.10);
}
.btn--primary:hover { background: var(--primary-hover); box-shadow: 0 10px 22px -8px var(--primary-shadow); }

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 22px;
  color: var(--muted-3);
  font-size: 14px;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Form */
.form { display: flex; flex-direction: column; gap: 14px; }
.form__error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.form__success {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.form__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 4px;
}
.form__switch {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  margin: 14px 0 0;
}
.form__resend {
  margin: -6px 0 0;
  font-size: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field > legend { padding: 0; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding-left: 2px;
  letter-spacing: 0.01em;
}
.field__control {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 13px 14px;
  background: var(--input-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.field__control:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}
.field__icon { width: 18px; height: 18px; color: var(--muted-2); flex: none; }
.field input {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  min-width: 0;
  font-family: inherit;
}
.field input::placeholder { color: var(--muted-3); }
.field__toggle {
  background: transparent;
  border: 0;
  padding: 4px;
  color: var(--muted-2);
  cursor: pointer;
  display: inline-flex;
}
.field__toggle svg { width: 20px; height: 20px; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  user-select: none;
}
.checkbox input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted-3);
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  position: relative;
  flex: none;
}
.checkbox input:checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px #ffffff;
}

.link {
  background: transparent;
  border: 0;
  color: var(--link);
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
  font-size: inherit;
  font-family: inherit;
}
.link:hover { text-decoration: underline; }
.link--forgot {
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 380px) {
  .page { padding: 36px 18px 32px; }
  .brand__title { font-size: 26px; }
}

/* Welcome page */
.welcome-page { max-width: 460px; }
.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-card);
}
.welcome-card__status {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.welcome-card__signout {
  align-self: center;
  font-size: 14px;
  font-weight: 600;
}

/* Tour / walkthrough */
.tour-body { background: var(--bg); }

.tour {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.tour__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.tour__counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.tour__skip {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 6px;
}
.tour__skip:hover { text-decoration: underline; }

.tour__progress {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}
.tour__progress-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transition: background-color 0.2s ease;
}
.tour__progress-dot.is-active { background: var(--primary-soft-2); }
.tour__progress-dot.is-current { background: var(--primary); }

.tour__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 12px;
}
.tour__content.is-entering {
  animation: tour-fade-in 250ms ease both;
}
@keyframes tour-fade-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.tour__icon {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.tour__icon.icon--soft { background: var(--primary-soft); color: var(--primary); }
.tour__icon.icon--primary {
  background: var(--grad);
  color: #ffffff;
  box-shadow: 0 18px 32px -16px var(--primary-shadow), inset 0 1px 0 rgba(255,255,255,0.18);
}
.tour__icon.icon--purple { background: var(--sleep-bg); color: var(--sleep-fg); }
.tour__icon.icon--gray { background: #F1F5F4; color: var(--text); }
.tour__icon.icon--blue { background: var(--urination-bg); color: var(--urination-fg); }

.tour__title {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}
.tour__subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 360px;
}

.tour__bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.tour__bullet {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.tour__bullet-icon {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}
.tour__bullet-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  padding-top: 4px;
}

.tour__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 20px;
}
.tour__back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  padding: 12px 6px;
  font-family: inherit;
}
.tour__back-spacer { width: 80px; display: inline-block; }

.tour__next {
  width: auto;
  margin: 0;
  padding: 14px 28px;
}

/* Profile form */
.profile-page { max-width: 520px; padding-bottom: 64px; }
.brand--compact { margin-bottom: 18px; }
.brand--compact .brand__logo { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 12px; }
.brand--compact .brand__logo img { width: 48px; height: 48px; }
.brand--compact .brand__title { font-size: 24px; }

.profile-form { gap: 18px; }
.profile-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.profile-section__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-row--body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .field-row--body { grid-template-columns: 1fr; }
}

.field select,
.field textarea {
  flex: 1;
  border: 0;
  outline: none;
  font-size: 15px;
  background: transparent;
  color: var(--text);
  min-width: 0;
  font-family: inherit;
  resize: vertical;
}
.field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%234B5563' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 4px center; padding-right: 22px; }

.field__control--unit { gap: 6px; }
.field__unit {
  flex: none;
  width: auto;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border);
  padding-left: 8px;
  color: var(--muted);
  font-size: 14px;
  font-family: inherit;
}

/* Button spinner */
.btn__spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}
.btn__spinner[hidden] { display: none; }
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Height input — imperial mode (feet + inches dropdowns) */
.height-input { display: flex; flex-direction: column; }
.height-input__metric { }
.height-input__imperial {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--input-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.height-input__imperial:focus-within {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}
.height-input__imperial[hidden] { display: none; }
.height-input__select {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 24px 8px 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%234B5563' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  min-height: 40px;
  cursor: pointer;
}
.height-input__select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}
.height-input__toggle {
  flex: none;
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease;
  min-height: 40px;
}
.height-input__toggle:hover { background: var(--primary-soft-2); }

.field--checkboxes { gap: 10px; }
.field--checkboxes legend { padding: 0; }
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 10px -6px var(--primary-shadow);
}

.profile-skip {
  align-self: center;
  margin-top: 4px;
  width: auto;
}

/* Profile: trigger rows with confidence selector */
.trigger-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trigger-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
}
.trigger-row__check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.trigger-row__check input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--muted-3);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex: none;
}
.trigger-row__check input:checked {
  border-color: var(--primary);
  background: var(--primary);
}
.trigger-row__check input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.trigger-row__confidence {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 26px 6px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%234B5563' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}
.trigger-row__confidence:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}

.seg--compact .seg__opt span { padding: 8px 12px; font-size: 13px; }

/* Profile: mobile responsiveness & UX improvements */
@media (max-width: 420px) {
  .profile-page { padding: 28px 14px 56px; max-width: 100%; }
  .profile-section { padding: 14px; gap: 12px; }
  .profile-section__title { font-size: 14px; }
  .profile-form { gap: 14px; }
  .brand--compact { margin-bottom: 14px; }
  .brand--compact .brand__title { font-size: 22px; }
  .brand--compact .brand__logo { width: 60px; height: 60px; border-radius: 16px; margin-bottom: 10px; }
  .brand--compact .brand__logo img { width: 40px; height: 40px; }

  .field__control { padding: 12px; }
  .field__control--unit { padding: 10px 12px; }
  .height-input__imperial { padding: 6px 8px; gap: 4px; }
  .height-input__select { padding: 8px 22px 8px 8px; font-size: 14px; }
  .height-input__toggle { padding: 8px 10px; font-size: 12px; }

  .chip { padding: 8px 12px; font-size: 13px; }
  .seg__opt span { padding: 9px 10px; font-size: 13px; }
  .trigger-row { padding: 8px 10px; gap: 6px; }
  .trigger-row__confidence { padding: 5px 22px 5px 8px; font-size: 12px; }
}

@media (max-width: 350px) {
  .profile-page { padding: 24px 12px 48px; }
  .profile-section { padding: 12px; }
  .height-input__imperial { flex-wrap: wrap; }
  .height-input__select { min-width: 0; }
}

/* Onboarding sections: smooth transitions */
.profile-section {
  animation: profile-section-in 0.35s ease both;
}
.profile-section:nth-child(1) { animation-delay: 0ms; }
.profile-section:nth-child(2) { animation-delay: 60ms; }
.profile-section:nth-child(3) { animation-delay: 120ms; }
.profile-section:nth-child(4) { animation-delay: 180ms; }
.profile-section:nth-child(5) { animation-delay: 240ms; }
.profile-section:nth-child(6) { animation-delay: 300ms; }
.profile-section:nth-child(7) { animation-delay: 360ms; }
@keyframes profile-section-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Touch-friendly sizing for mobile */
.btn { min-height: 48px; }
.field__control { min-height: 48px; }
.seg__opt span { min-height: 44px; display: flex; align-items: center; justify-content: center; }
.chip { min-height: 40px; }
.slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--primary-shadow);
}
.slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px var(--primary-shadow);
}

/* Prevent horizontal overflow on all profile forms */
.profile-form,
.profile-section,
.field-row,
.field-row--body,
.field__control,
.chip-group,
.seg,
.trigger-list {
  max-width: 100%;
  overflow-x: hidden;
}
.field input,
.field select,
.field textarea {
  max-width: 100%;
}

/* Home dashboard */
.home-body {
  background: var(--bg);
  background-image: var(--grad-page);
  background-attachment: fixed;
}
.home__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 5;
}
.home__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}
.home__brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.home__menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.home__menu-label { font-weight: 600; }

.home {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 18px 96px;
}

.home__intro { margin: 6px 0 18px; }
.home__date {
  margin: 0;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.home__title {
  margin: 6px 0 14px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-strong);
  line-height: 1.2;
}
.home__welcome {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-strong);
}
.home__tagline {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.15s ease;
  position: relative;
}
.metric-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.metric-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}
.metric-card__icon--pink   { background: var(--pain-bg);      color: var(--pain-fg); }
.metric-card__icon--orange { background: var(--flare-bg);     color: var(--flare-fg); }
.metric-card__icon--blue   { background: var(--urination-bg); color: var(--urination-fg); }
.metric-card__icon--purple { background: var(--sleep-bg);     color: var(--sleep-fg); }
.metric-card__icon--amber  { background: var(--mood-bg);      color: var(--mood-fg); }
.metric-card__icon--green  { background: var(--energy-bg);    color: var(--energy-fg); }

.metric-card__value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-strong);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-feature-settings: "tnum" 1;
}
.metric-card__label {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.metric-card__sub {
  font-size: 12px;
  color: var(--muted-2);
  font-style: normal;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-top: 1px solid var(--hairline);
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 5;
  box-shadow: 0 -8px 28px -18px rgba(15, 67, 70, 0.18);
}
.bottom-nav__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-2);
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.bottom-nav__item:hover { color: var(--muted); }
.bottom-nav__item.is-active { color: var(--primary); font-weight: 700; }
.bottom-nav__item.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: var(--primary);
}
.bottom-nav__item svg { color: currentColor; }

/* App header (shared shell) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 5;
}
.app-header__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}
.app-header__brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.app-header__menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  border-radius: 8px;
  transition: background-color 0.15s ease;
}
.app-header__menu-btn:hover { background: var(--primary-soft); color: var(--primary-deep); }
.app-header__menu-label { font-weight: 600; }

/* Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 67, 70, 0.40);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 18;
}
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 88vw);
  background: var(--surface);
  z-index: 20;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(15, 67, 70, 0.22);
}
.drawer.is-open { transform: translateX(0); }
.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
}
.drawer__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}
.drawer__brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.drawer__close {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 6px;
  cursor: pointer;
  border-radius: 8px;
}
.drawer__close:hover { background: var(--input-bg); color: var(--text); }
.drawer__nav {
  display: flex;
  flex-direction: column;
  padding: 8px 6px;
  flex: 1;
}
.drawer__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: background-color 0.12s ease;
}
.drawer__item:hover { background: var(--input-bg); }
.drawer__item.is-active {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--hairline);
}
.drawer__icon { color: var(--muted-2); display: inline-flex; flex: none; }
.drawer__item:hover .drawer__icon { color: var(--text); }
.drawer__item.is-active .drawer__icon { color: var(--primary); }
.drawer__label { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.drawer__sub { font-size: 12px; font-weight: 400; color: var(--muted-2); }
.drawer__logout {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  margin: 6px 6px max(12px, env(safe-area-inset-bottom));
  background: transparent;
  border: 0;
  color: #B42323;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  border-top: 1px solid var(--border);
  border-radius: 0;
}
.drawer__logout .drawer__icon { color: #B42323; }
.drawer__logout:hover { background: rgba(180, 35, 35, 0.06); }

/* Page content shared layout */
.page-content {
  flex: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 18px 96px;
}
.page-head { margin: 0 0 14px; }
.page-head__title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-strong);
  line-height: 1.2;
}
.page-head__sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  margin: 18px 0 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 18px;
}
.section-title-row .section-title { margin: 0; }
.link-inline {
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}
.link-inline:hover { text-decoration: underline; }
.muted-small { color: var(--muted); font-size: 13px; }

.card-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow-card);
}
.card-section--center { text-align: center; }
.big-number {
  font-size: 56px;
  font-weight: 800;
  margin: 6px 0 0;
  color: var(--text-strong);
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum" 1;
}

.card-form { display: flex; flex-direction: column; gap: 14px; }
.card-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-fieldset__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 0;
}
.card-fieldset__hint { margin: -2px 0 4px; color: var(--muted); font-size: 12px; }

.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type="range"] { flex: 1; }
.slider-value {
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  font-feature-settings: "tnum" 1;
}

.checkbox--row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--input-bg);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.btn--secondary {
  background: var(--primary-soft);
  color: var(--primary-deep);
  margin-right: 8px;
  border: 1px solid var(--hairline);
}
.btn--secondary:hover { background: var(--primary-soft-2); }
.btn--danger {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
}
.btn--danger:hover { background: #FCDCDC; }
.btn--inline { width: auto; display: inline-flex; padding: 10px 18px; }

.success-msg {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}

.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.entry-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.entry-card__when { font-size: 13px; font-weight: 600; color: var(--muted); }
.entry-card__metrics { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-card__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-card__notes {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}

.metric-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--input-bg);
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--border);
}
.metric-pill strong { color: var(--primary-deep); margin-right: 2px; }

.tag {
  font-size: 12px;
  background: var(--primary-soft);
  color: var(--primary-deep);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: capitalize;
}
.tag--trigger { background: var(--flare-bg); color: var(--flare-deep); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge--flare { background: var(--pain-bg); color: var(--pain-deep); }

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted-2);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--input-bg); color: var(--text); }

.empty-text { color: var(--muted); font-size: 14px; margin: 8px 0; }
.empty-card {
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.empty-card .btn { margin-top: 12px; }

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 14px;
}
.select-inline {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 28px 8px 12px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%234B5563' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  box-shadow: var(--shadow-xs);
}

.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-item { display: grid; grid-template-columns: 110px 1fr 32px; align-items: center; gap: 10px; }
.bar-item__name { font-size: 13px; font-weight: 600; color: var(--text); text-transform: capitalize; }
.bar-item__track { background: var(--input-bg); height: 8px; border-radius: 999px; overflow: hidden; }
.bar-item__fill {
  background: linear-gradient(90deg, var(--primary), #14B0B2);
  height: 100%;
  border-radius: 999px;
}
.bar-item__count { font-size: 12px; color: var(--muted); text-align: right; font-weight: 700; }

.row-form { display: flex; gap: 8px; margin-top: 10px; }
.row-form input[type="text"] {
  flex: 1;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.row-form input[type="text"]:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16); }

.helper-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.helper-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Quick actions */
.quick-actions { margin-top: 22px; }
.quick-actions__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  letter-spacing: -0.01em;
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}
.quick-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-2);
}
.quick-action__icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}
.quick-action--green { color: var(--text-strong); }
.quick-action--green .quick-action__icon { background: var(--primary-soft); color: var(--primary); }
.quick-action--purple .quick-action__icon { background: var(--sleep-bg); color: var(--sleep-fg); }
.quick-action--orange .quick-action__icon { background: var(--flare-bg); color: var(--flare-fg); }
.quick-action--blue .quick-action__icon { background: var(--urination-bg); color: var(--urination-fg); }

/* Upcoming */
.upcoming__list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.appt-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.18s ease;
}
.appt-row:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.appt-row__date {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--primary-soft);
  color: var(--primary-deep);
  border-radius: var(--radius);
  padding: 6px 4px;
  text-align: center;
  border: 1px solid var(--hairline);
}
.appt-row__date strong { font-size: 18px; line-height: 1; font-weight: 800; }
.appt-row__date span { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.appt-row__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.appt-row__title { font-weight: 700; font-size: 14px; color: var(--text-strong); }
.appt-row__sub { font-size: 12px; color: var(--muted); }
.appt-row__loc { font-size: 12px; color: var(--muted-2); }
.appt-row__chev { color: var(--muted-3); font-size: 22px; }

/* Journal */
.journal-title { margin: 0; font-size: 16px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.015em; }
.journal-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }

/* Help */
.faq { padding: 10px 0; border-bottom: 1px solid var(--border); }
.faq:last-of-type { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 700; padding: 4px 0; color: var(--text-strong); }
.faq p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* About / Resource lists */
.bullets { margin: 0; padding-left: 18px; }
.bullets li { margin: 6px 0; line-height: 1.6; font-size: 14px; }
.resource-list { list-style: none; padding: 0; margin: 0; }
.resource-list li { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.resource-list li:last-child { border-bottom: 0; }
.resource-list a { font-weight: 700; color: var(--primary); text-decoration: none; }
.resource-list a:hover { text-decoration: underline; }
.resource-list span { font-size: 13px; color: var(--muted); }

/* Recent / chart */
.chart { padding: 8px 0; }
.chart__bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.chart__bar { width: 80%; background: linear-gradient(180deg, var(--primary), #5BB8B9); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart__lbl { font-size: 10px; color: var(--muted); }
.chart__empty { padding: 24px 0; text-align: center; }
.summary-row { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-pill {
  flex: 1;
  min-width: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.summary-pill strong { font-size: 22px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.025em; font-feature-settings: "tnum" 1; }
.summary-pill span { font-size: 12px; color: var(--muted); }

@media (min-width: 460px) {
  .page-content { padding: 22px 22px 110px; }
}

/* ===== Log page (tabs, collapsible sections, segmented control) ===== */
.log-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  margin: 0 0 14px;
  box-shadow: var(--shadow-sm);
}
.log-tab {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.18s ease;
  letter-spacing: -0.005em;
}
.log-tab:hover { color: var(--text); }
.log-tab.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px -8px var(--primary-shadow);
}

.bathroom-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 88% 10%, rgba(255, 244, 202, 0.88), transparent 24%),
    linear-gradient(145deg, #FFFFFF 0%, #EEF9F8 100%);
  border: 1px solid rgba(15, 139, 141, 0.24);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: 0 18px 40px -26px rgba(15, 67, 70, 0.48), var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: bathroomRise 0.34s ease both;
}
.bathroom-card__top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bathroom-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px rgba(15, 139, 141, 0.12);
}
.bathroom-card__title {
  margin: 0;
  color: var(--text-strong);
  font-size: 19px;
  line-height: 1.15;
  letter-spacing: 0;
}
.bathroom-card__sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.bathroom-card__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.bathroom-card__stats span {
  min-height: 48px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(15, 139, 141, 0.14);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-xs);
}
.bathroom-card__stats strong {
  color: var(--primary-deep);
  font-size: 22px;
  line-height: 1;
  font-feature-settings: "tnum" 1;
}
#bathroom-last-logged {
  font-weight: 600;
  line-height: 1.25;
}
.bathroom-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.bathroom-tap {
  appearance: none;
  -webkit-appearance: none;
  min-height: 92px;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 14px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 14px 26px -18px var(--primary-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.bathroom-tap:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 28px -18px var(--primary-shadow);
}
.bathroom-tap:active {
  transform: scale(0.985);
  filter: saturate(0.94);
}
.bathroom-tap--night {
  background: linear-gradient(145deg, #5667AA 0%, #36477E 100%);
}
.bathroom-tap__icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
}
.bathroom-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
}
.bathroom-undo {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(15, 139, 141, 0.24);
  background: rgba(255, 255, 255, 0.78);
  color: var(--primary-deep);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}
.bathroom-undo:disabled {
  cursor: not-allowed;
  color: var(--muted-3);
  border-color: var(--border);
}
.bathroom-card__saved {
  color: var(--success-fg);
  font-size: 12px;
  font-weight: 800;
}
.manual-backup {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 0;
}
.manual-backup summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--primary-deep);
  font-size: 14px;
  font-weight: 800;
}
.manual-backup__body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@keyframes bathroomRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.log-section + .log-section { margin-top: 0; }
.log-section__head {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  user-select: none;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}
.log-section__head::-webkit-details-marker { display: none; }
.log-section__icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.03);
}
.log-section__title { flex: 1; min-width: 0; }
.log-section__chev {
  color: var(--muted-2);
  transition: transform 0.2s ease;
  display: inline-flex;
}
.log-section[open] .log-section__chev { transform: rotate(180deg); }
.log-section__body {
  padding: 4px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.metric-head .card-fieldset__title {
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}
.metric-head .slider-value {
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 700;
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 4px 10px -2px var(--primary-shadow), 0 0 0 1px var(--hairline);
}
.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  box-shadow: 0 4px 10px -2px var(--primary-shadow);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg__opt {
  position: relative;
  flex: 1 0 auto;
}
.seg__opt input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.seg__opt span {
  display: block;
  text-align: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  background: var(--surface);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.seg__opt input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-weight: 700;
}

.field--inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field--inline .field__label {
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.field__control--compact {
  width: 90px;
  flex: none;
  padding: 8px 10px;
  text-align: center;
}
.field__control--compact input {
  text-align: center;
}

.btn--save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 18px;
  font-size: 16px;
  border-radius: 14px;
  margin-top: 6px;
}
.btn-check { display: inline-flex; }

.chip-group--single .chip:has(input[type="radio"]:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* ===== Log panels: ensure hidden truly hides (overrides .card-form display) ===== */
.log-panel[hidden] { display: none !important; }

/* ===== Food Log ===== */
.food-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: var(--shadow-card);
}
.food-card__title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-strong);
  margin-bottom: 12px;
  letter-spacing: -0.015em;
}
.food-card__sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.food-add {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.food-add__input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}
.food-add__input::placeholder { color: var(--muted-3); }
.food-add__input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}
.food-add__btn {
  flex: none;
  width: 52px;
  border-radius: 12px;
  border: 0;
  background: var(--primary);
  color: #fff;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 14px -8px var(--primary-shadow);
}
.food-add__btn:hover { background: var(--primary-hover); }
.food-add__btn:active { transform: scale(0.97); }

.food-items-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.food-insight {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: var(--primary-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.food-insight__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.food-insight__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  flex: none;
}
.food-insight__label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.3;
}
.food-insight__hint {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
  color: var(--text);
  opacity: 0.85;
  line-height: 1.5;
}
.food-insight__disclaimer {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
}
.food-cat-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.food-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 14px;
  border: 1px solid var(--hairline);
}
.food-item-chip__label { line-height: 1.2; }
.food-item-chip__remove {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 0;
  background: rgba(15, 67, 70, 0.08);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.food-item-chip__remove:hover { background: rgba(15, 67, 70, 0.14); color: var(--text); }

/* ===== Water Log ===== */
.log-tabs--3 { grid-template-columns: 1fr 1fr 1fr; }

.water-card { gap: 18px; }

.water-search {
  position: relative;
  margin-top: 6px;
}
.water-suggestions {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
}
.water-suggestion {
  display: grid;
  grid-template-columns: 1fr auto 10px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.water-suggestion:hover,
.water-suggestion.is-active { background: var(--primary-soft); }
.water-suggestion__name { font-weight: 600; }
.water-suggestion__type {
  font-size: 12px;
  color: var(--muted);
}
.water-suggestion__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: none;
}

.water-result {
  margin-top: 14px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--hairline);
  background: var(--primary-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.water-result__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.water-result__title-wrap { flex: 1; min-width: 0; }
.water-result__title {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-strong);
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.water-result__sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.water-result__badge {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  align-self: flex-start;
}
.water-result__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 14px;
  margin: 0;
}
.water-result__meta > div { display: flex; flex-direction: column; gap: 2px; }
.water-result__meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}
.water-result__meta dd {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.water-result__explanation {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.water-result__personal {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--flare-bg);
  border: 1px solid #F0D6A8;
  font-size: 13px;
  color: var(--flare-deep);
  font-weight: 600;
  line-height: 1.45;
}
.water-result__log {
  align-self: flex-start;
  margin-top: 4px;
}

.water-brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.water-brand-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 12px 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.18s ease, transform 0.05s ease;
  border-left: 3px solid var(--rating, var(--border));
  box-shadow: var(--shadow-sm);
}
.water-brand-card:hover {
  border-color: var(--rating, var(--primary));
  box-shadow: var(--shadow-md);
}
.water-brand-card:active { transform: scale(0.98); }
.water-brand-card__name { font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--text-strong); }
.water-brand-card__type {
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}
.water-brand-card__badge {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.water-disclaimer {
  margin: 6px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  font-style: italic;
}

.tag-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tag-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.tag-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.tag-chip span {
  display: block;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.tag-chip input:checked + span {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-deep);
  font-weight: 600;
}

.water-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.water-icon { display: inline-flex; }
.water-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* Insights — long-term food-trigger pattern detection */
.insights-disclaimer {
  margin: 8px 0 16px;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}
.medical-disclaimer-banner {
  margin: 0 0 20px;
  padding: 14px 16px;
  background: #FFF8E1;
  border: 1px solid #FFD54F;
  border-left: 4px solid #F9A825;
  border-radius: 10px;
  color: #5D4037;
  font-size: 13px;
  line-height: 1.55;
}
.insights-subtitle {
  margin: 18px 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.insights-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.insight-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.insight-card--compact { padding: 10px 12px; }
.insight-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.insight-card__name {
  font-weight: 700;
  color: var(--text-strong);
  text-transform: capitalize;
  letter-spacing: -0.005em;
}
.insight-card__msg {
  margin: 4px 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.insight-card__meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.confidence-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.confidence-badge--low {
  background: var(--mood-bg);
  color: var(--mood-deep);
  border-color: #F1DFA2;
}
.confidence-badge--medium {
  background: var(--flare-bg);
  color: var(--flare-deep);
  border-color: #F3C896;
}
.confidence-badge--high {
  background: var(--pain-bg);
  color: var(--pain-deep);
  border-color: #EFB1B1;
}

/* Terms / disclaimer */
.terms-body { background: var(--bg); }

.terms {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100dvh;
}

.terms__header {
  text-align: center;
  margin: 4px 0 4px;
}
.terms__title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-strong);
}
.terms__subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.terms__scroll {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  box-shadow: var(--shadow-sm), inset 0 -10px 12px -10px rgba(15, 67, 70, 0.06);
}
.terms__scroll:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.terms__scroll p { margin: 0 0 12px; }
.terms__scroll p:last-child { margin-bottom: 0; }

.terms__heading {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.015em;
}

.terms__list {
  margin: 0 0 12px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.terms__list li { line-height: 1.5; }

.terms__end { height: 1px; }

.terms__hint {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.terms__actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}
.terms__actions .btn { margin: 0; }
.terms__decline { flex: 1; margin-right: 0 !important; }
.terms__agree { flex: 1; }

@media (max-width: 390px) {
  .bathroom-card__actions,
  .bathroom-card__stats {
    grid-template-columns: 1fr;
  }
  .bathroom-tap {
    min-height: 78px;
  }
}

/* ========================================================================
   Triggers & Helpers — Premium Insight Dashboard
   ======================================================================== */

/* --- Enhanced Trigger/Insight Cards --- */
.tri-card {
  position: relative;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 67, 70, 0.06), 0 4px 14px -6px rgba(15, 67, 70, 0.10);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.tri-card--compact { padding: 14px 16px; }
.tri-card:hover {
  box-shadow: 0 2px 6px rgba(15, 67, 70, 0.10), 0 8px 20px -8px rgba(15, 67, 70, 0.14);
}

.tri-card.tri-conf--high { border-left: 3px solid var(--pain-fg); }
.tri-card.tri-conf--med { border-left: 3px solid var(--flare-fg); }
.tri-card.tri-conf--low { border-left: 3px solid var(--mood-fg); }
.tri-card--safe { border-left: 3px solid var(--energy-fg); }

.tri-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tri-card__identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tri-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}
.tri-card__icon--safe {
  background: var(--energy-bg);
  color: var(--energy-fg);
}
.tri-card__name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-strong);
  text-transform: capitalize;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tri-card__bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.tri-card__pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
  font-feature-settings: "tnum" 1;
}
.tri-card__msg {
  margin: 4px 0 6px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
}
.tri-card__meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.45;
}

/* --- Confidence Bar --- */
.tri-conf-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--input-bg);
  overflow: hidden;
}
.tri-conf-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.tri-conf-fill.tri-conf--high {
  background: linear-gradient(90deg, #e88a8a 0%, var(--pain-fg) 100%);
}
.tri-conf-fill.tri-conf--med {
  background: linear-gradient(90deg, #f0b96e 0%, var(--flare-fg) 100%);
}
.tri-conf-fill.tri-conf--low {
  background: linear-gradient(90deg, #f0d778 0%, var(--mood-fg) 100%);
}

/* --- Status Pills --- */
.tri-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.tri-pill.tri-conf--high {
  background: var(--pain-bg);
  color: var(--pain-deep);
}
.tri-pill.tri-conf--med {
  background: var(--flare-bg);
  color: var(--flare-deep);
}
.tri-pill.tri-conf--low {
  background: var(--mood-bg);
  color: var(--mood-deep);
}
.tri-pill--safe {
  background: var(--energy-bg);
  color: var(--energy-deep);
}

/* --- Sparkline --- */
.tri-sparkline {
  display: block;
  opacity: 0.7;
}

/* --- Section Headers --- */
.tri-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

/* --- "Why am I seeing this?" --- */
.tri-explain-btn {
  background: none;
  border: none;
  color: var(--link);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.tri-explain-btn:hover { color: var(--primary-deep); }
.tri-explain-panel {
  margin: 8px 0 12px;
  padding: 14px 16px;
  background: var(--primary-soft);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}
.tri-explain-panel p { margin: 0 0 8px; }
.tri-explain-panel p:last-child { margin-bottom: 0; }

/* --- Well-Tolerated Section Label --- */
.tri-well-tolerated-title {
  color: var(--energy-deep) !important;
}

/* --- Empty States --- */
.tri-empty {
  padding: 18px 16px;
  background: var(--bg-soft);
  border-radius: 12px;
  border: 1px dashed var(--border-2);
  text-align: center;
}
.tri-empty--inline {
  list-style: none;
  text-align: left;
  padding: 14px;
}
.tri-empty__text {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

/* --- Wellness Wins --- */
.tri-wellness-card {
  background: linear-gradient(135deg, #E5F5EA 0%, #D6ECEA 100%);
  border-color: var(--success-border);
}
.tri-wellness-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tri-wellness-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255,255,255,0.6);
}
.tri-wellness-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tri-win {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.55);
  border-radius: 10px;
  border: 1px solid rgba(22, 99, 68, 0.08);
}
.tri-win__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--success-bg);
  color: var(--success-fg);
  flex-shrink: 0;
}
.tri-win__text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
  padding-top: 3px;
}

/* --- Helpers Section --- */
.tri-helpers-card {
  border-color: var(--primary-soft-2);
}
.tri-helpers-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
}
.tri-helper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--primary-soft-2);
  border-radius: 12px;
  background: linear-gradient(135deg, #F7FDFB 0%, #EFF9F7 100%);
  transition: box-shadow 0.15s ease;
}
.tri-helper:hover {
  box-shadow: 0 2px 8px rgba(15, 139, 141, 0.08);
}
.tri-helper__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--primary-soft);
  flex-shrink: 0;
}
.tri-helper__text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* --- Floating Action Button (base — enhanced at end of file) --- */

/* --- Bathroom Quick-Log Sheet --- */
.tri-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.25);
  opacity: 1;
  transition: opacity 0.2s ease;
}
.tri-sheet-backdrop[hidden] { display: none; }
.tri-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.12);
  transition: transform 0.25s ease;
}
.tri-sheet[hidden] { display: none; }
.tri-sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--muted-3);
  margin: 0 auto 14px;
  opacity: 0.5;
}
.tri-sheet__title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-strong);
}
.tri-sheet__sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.tri-sheet__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tri-sheet__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.tri-sheet__btn:hover {
  background: var(--primary-soft);
  box-shadow: 0 2px 8px rgba(15, 139, 141, 0.12);
}
.tri-sheet__btn:active { transform: scale(0.97); }
.tri-sheet__btn--night {
  color: var(--sleep-fg);
}
.tri-sheet__btn--night:hover {
  background: var(--sleep-bg);
  box-shadow: 0 2px 8px rgba(110, 89, 199, 0.12);
}
.tri-sheet__confirm {
  text-align: center;
  margin: 14px 0 2px;
  padding: 10px;
  background: var(--success-bg);
  border-radius: 10px;
  color: var(--success-fg);
  font-size: 13.5px;
  font-weight: 700;
}
.tri-sheet__confirm[hidden] { display: none; }

/* --- Premium Triggers Page Enhancements --- */

/* Section icon headers */
.tri-section-elevated {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 67, 70, 0.05), 0 6px 20px -10px rgba(15, 67, 70, 0.10);
}
.tri-section-icon-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.tri-section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}
.tri-section-icon--food {
  background: var(--flare-bg);
  color: var(--flare-fg);
}
.tri-section-icon--flare {
  background: var(--pain-bg);
  color: var(--pain-fg);
}
.tri-section-icon--helped {
  background: var(--success-bg);
  color: var(--success-fg);
}
.tri-section-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted-2);
  line-height: 1.4;
}

/* Explain row */
.tri-explain-row {
  margin-bottom: 12px;
}

/* Disclaimer (soft) */
.tri-disclaimer-soft {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tri-disclaimer-soft p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted-2);
  line-height: 1.5;
}
.tri-disclaimer-icon {
  flex-shrink: 0;
  color: var(--muted-3);
  margin-top: 1px;
}

/* Bottom disclaimer */
.tri-bottom-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 67, 70, 0.04);
}
.tri-bottom-disclaimer p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted-2);
  line-height: 1.5;
}

/* Flare card refinements */
.tri-card--flare {
  padding: 16px 18px;
}
.tri-card--supportive {
  border-left-color: var(--mood-fg) !important;
  opacity: 0.88;
}
.tri-card__icon--neutral {
  background: var(--mood-bg);
  color: var(--mood-fg);
}
.tri-card__clarify {
  margin: 6px 0 2px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.5;
  background: var(--bg-soft);
  border-radius: 8px;
  border-left: 2px solid var(--mood-fg);
  font-style: italic;
}
.tri-card__name-group {
  min-width: 0;
}

/* Percentage badge (circular feel) */
.tri-card__pct-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  font-feature-settings: "tnum" 1;
  flex-shrink: 0;
}
.tri-card__pct-badge.tri-conf--high {
  background: var(--pain-bg);
  color: var(--pain-deep);
}
.tri-card__pct-badge.tri-conf--med {
  background: var(--flare-bg);
  color: var(--flare-deep);
}
.tri-card__pct-badge.tri-conf--low {
  background: var(--mood-bg);
  color: var(--mood-deep);
}
.tri-card__pct-badge.tri-conf--helped {
  background: var(--success-bg);
  color: var(--success-fg);
}

/* Small pill variant */
.tri-pill--sm {
  padding: 2px 8px;
  font-size: 10px;
}

/* Helped section styling */
.tri-helped-section {
  border-color: var(--success-border) !important;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FDFB 100%);
}
.tri-card--helped {
  border-left: 3px solid var(--success-fg);
  background: linear-gradient(135deg, #FAFFFE 0%, #F2FBF7 100%);
}
.tri-card--helped:hover {
  box-shadow: 0 2px 8px rgba(22, 99, 68, 0.10), 0 6px 16px -8px rgba(22, 99, 68, 0.12);
}
.tri-card__icon--helped {
  background: var(--success-bg);
  color: var(--success-fg);
}
.tri-conf-fill.tri-conf--helped {
  background: linear-gradient(90deg, #8CC5A0 0%, var(--success-fg) 100%);
}
.tri-pill--helped {
  background: var(--success-bg);
  color: var(--success-fg);
}

/* Helped user section */
.tri-helped-user-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.tri-helped-user-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
}

/* Enhanced empty states */
.tri-empty {
  padding: 24px 20px;
  background: var(--bg-soft);
  border-radius: 14px;
  border: 1px dashed var(--border-2);
  text-align: center;
}
.tri-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted-3);
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(15, 67, 70, 0.06);
}
.tri-empty--helped {
  background: linear-gradient(135deg, #F0FBF5 0%, #E8F8EE 100%);
  border-color: var(--success-border);
}
.tri-empty--helped .tri-empty__icon {
  color: var(--success-fg);
  background: var(--success-bg);
}
.tri-empty--helped .tri-empty__text {
  color: var(--success-fg);
}

/* Improved FAB */
.tri-fab {
  position: fixed;
  bottom: max(84px, calc(76px + env(safe-area-inset-bottom)));
  right: 18px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px 11px 14px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px -4px rgba(15, 139, 141, 0.45), 0 2px 8px rgba(0,0,0,0.06);
  opacity: 0.95;
  transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.tri-fab:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 6px 22px -4px rgba(15, 139, 141, 0.50), 0 3px 10px rgba(0,0,0,0.08);
}
.tri-fab:active { transform: scale(0.97); }
.tri-fab__label { letter-spacing: 0.02em; }

/* ============ Date Picker Bar ============ */
.date-picker-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 0 0 12px;
  box-shadow: var(--shadow-xs);
}
.date-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.date-nav-btn:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.date-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.date-display {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-strong);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 140px;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.date-display:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.date-display__icon {
  color: var(--primary);
  flex-shrink: 0;
}
.date-hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
}
.date-today-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-tint);
  border: 1px solid var(--primary-soft-2);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.date-today-btn:hover {
  background: var(--primary-soft);
}
.date-picker-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--primary-deep);
  background: var(--primary-tint);
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  margin: -4px 0 12px;
}

/* ============ Slider Labels & Helpers ============ */
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--muted-2);
  padding: 0 2px;
  margin-bottom: 2px;
  letter-spacing: 0.01em;
}
.slider-helper {
  font-size: 0.76rem;
  color: var(--muted-3);
  margin: 4px 0 0;
  text-align: center;
  font-style: italic;
}

/* ============ View History Button ============ */
.btn--view-history {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
  font-size: 0.88rem;
}

/* ============ History Filter Date ============ */
.filter-date-label {
  display: inline-flex;
}
.filter-date-label input[type="date"] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.82rem;
  background: var(--surface);
  color: var(--text);
}

/* ============ Entry Card Editable ============ */
.entry-card--editable {
  cursor: default;
  transition: box-shadow 0.15s;
}
.entry-card--editable:hover {
  box-shadow: var(--shadow-md);
}
.icon-btn.edit-entry {
  color: var(--primary);
  margin-right: 2px;
}
.icon-btn.edit-entry:hover {
  color: var(--primary-hover);
}

/* ============ Edit Modal ============ */
.edit-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
@media (min-width: 500px) {
  .edit-modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}
.edit-modal {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: editSlideUp 0.25s ease-out;
}
@media (min-width: 500px) {
  .edit-modal {
    border-radius: var(--radius-lg);
  }
}
@keyframes editSlideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.edit-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.edit-modal__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0;
}
.edit-modal__close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}
.edit-modal__body {
  padding: 20px;
}
.edit-modal__date {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 16px;
}
.edit-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.edit-modal__actions .btn {
  flex: 1;
  text-align: center;
}
