/* ============================================================
   MenoWell — Component Styles
   ============================================================ */

/* ---------- Page Header ---------- */
.page-header {
  margin-bottom: 24px;
}
.page-header__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: 6px;
}
.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

@media (max-width: 768px) {
  .page-header__title { font-size: var(--text-2xl); }
}

/* ---------- Card ---------- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  transition: box-shadow 200ms ease, transform 200ms ease;
  margin-bottom: 16px;
}
.card:hover { box-shadow: var(--shadow-md); }

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.card__title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin: 0;
}

.card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.card__actions {
  display: flex;
  gap: 6px;
}

.card__body { color: var(--color-text); }

.card__footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

@media (max-width: 768px) {
  .card { padding: 16px; }
}

/* ---------- Card Variants ---------- */
.card--hero {
  background: var(--color-hero-bg, var(--color-surface-2));
  color: var(--color-text);
}
.card--hero .card__title { color: var(--color-text); }

.card--soft {
  background: var(--color-surface-2);
  border-color: transparent;
}

.card--accent {
  border-left: 3px solid var(--color-primary-dark);
}

/* ---------- Grid System ---------- */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

@media (max-width: 768px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  min-height: 44px;
  text-decoration: none;
  color: var(--color-text);
  transition: filter 150ms, transform 80ms, background 150ms, border-color 150ms;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--color-primary-dark);
  color: #fff;
}
.btn--primary:hover { filter: brightness(0.93); }

.btn--secondary {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
}
.btn--secondary:hover {
  border-color: var(--color-primary-dark);
  background: var(--color-surface-2);
}

.btn--ghost {
  background: none;
  color: var(--color-text-muted);
  padding: 6px 10px;
  min-height: auto;
  text-decoration: underline;
  font-weight: var(--weight-normal);
}
.btn--ghost:hover { color: var(--color-text); }

.btn--danger {
  background: var(--color-danger-dark);
  color: #fff;
}

.btn--success {
  background: var(--color-success-dark);
  color: #fff;
}

.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  min-height: 40px;
  background: transparent;
  color: var(--color-text-muted);
}
.btn--icon:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn--full { width: 100%; }
.btn--sm { padding: 6px 12px; min-height: 36px; font-size: var(--text-xs); }
.btn--lg { padding: 14px 28px; min-height: 52px; font-size: var(--text-base); }

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color 150ms, box-shadow 150ms;
  min-height: 44px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px rgba(216,167,160,0.15);
  outline: none;
}

.textarea {
  min-height: 80px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B817C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ---------- Slider ---------- */
.slider-field { margin-bottom: 16px; }

.slider-field__label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin-bottom: 8px;
}

.slider-field__track {
  position: relative;
  padding: 8px 0 4px;
}

.slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  outline: none;
  margin: 8px 0;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary-dark);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary-dark);
  cursor: pointer;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.slider-field__labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
}

.slider-field__value {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-primary-dark);
  font-weight: var(--weight-medium);
  min-width: 28px;
}

/* ---------- Chips ---------- */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  cursor: pointer;
  transition: all 150ms;
}
.chip:hover { background: var(--color-primary); }
.chip.is-selected {
  background: var(--color-primary);
  border-color: var(--color-primary-dark);
  color: var(--color-text);
}
.chip--readonly { cursor: default; }
.chip--severity-low { background: var(--color-secondary); border-color: var(--color-secondary-dark); }
.chip--severity-mid { background: var(--color-warning); border-color: var(--color-warning-dark); }
.chip--severity-high { background: var(--color-danger); border-color: var(--color-danger-dark); }

.chip__remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  margin-left: 4px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

/* ---------- Toggle / Switch ---------- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.toggle__input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 100px;
  transition: background 200ms;
}
.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms;
}
.toggle__input:checked + .toggle__track { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.toggle__input:checked + .toggle__track .toggle__thumb { transform: translateX(18px); }

/* ---------- Segmented Control ---------- */
.segmented {
  display: inline-flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.segmented__btn {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  min-height: 36px;
  transition: all 150ms;
}
.segmented__btn.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: var(--weight-medium);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}
.badge--primary { background: var(--color-primary); color: var(--color-text); }
.badge--success { background: var(--color-success); color: var(--color-text); }
.badge--warning { background: var(--color-warning); color: var(--color-text); }
.badge--danger { background: var(--color-danger); color: var(--color-text); }

/* ---------- Progress Bar ---------- */
.progress {
  width: 100%;
  height: 8px;
  background: var(--color-surface-2);
  border-radius: 100px;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: var(--color-primary-dark);
  transition: width 500ms ease-out;
  border-radius: 100px;
}
.progress--lg { height: 14px; }

/* ---------- Metric ---------- */
.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric__value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-normal);
  color: var(--color-text);
  line-height: 1.1;
}
.metric__unit {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31,26,24,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 150ms;
}
.modal-backdrop.is-visible { opacity: 1; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 200ms, opacity 200ms;
}
.modal-backdrop.is-visible .modal {
  transform: scale(1);
  opacity: 1;
}

.modal--lg { max-width: 720px; }
.modal--sm { max-width: 400px; }

.modal__header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
}
.modal__close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__close:hover { background: var(--color-surface-2); }

.modal__body { padding: 20px 24px; }
.modal__footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .toast-root {
    bottom: calc(var(--bottom-nav-height) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary-dark);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  pointer-events: auto;
}
.toast--success { border-left-color: var(--color-success-dark); }
.toast--error { border-left-color: var(--color-danger-dark); }
.toast--info { border-left-color: var(--color-info); }

.toast__icon { flex-shrink: 0; }
.toast__msg { flex: 1; min-width: 0; }
.toast__action {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-height: 36px;
  font: inherit;
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  cursor: pointer;
}
.toast__action:hover { background: var(--color-surface-2); }

/* ---------- Daily check-in (10-second logging) ---------- */
.checkin .card__header { align-items: flex-start; gap: var(--space-sm); }
.checkin__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.checkin__chip { min-height: 40px; }
.checkin__level { font-weight: var(--weight-semibold); }
.checkin__levels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
}
.checkin__levels[hidden] { display: none; }
.checkin__levels .segmented { flex: 1 1 220px; }
.checkin__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-md); }
.checkin__actions .btn.is-active { border-color: var(--color-success-dark); }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-state__illustration {
  width: 64px;
  height: 64px;
  opacity: 0.7;
  margin-bottom: 4px;
}
.empty-state__message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 360px;
  line-height: 1.5;
}

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }

.list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background 150ms, border-color 150ms;
}
.list__item:hover { border-color: var(--color-border); }

.list__item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.list__item-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}
.list__item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.list__item-actions {
  display: flex;
  gap: 4px;
}

/* ---------- Calendar ---------- */
.calendar {
  width: 100%;
}
.calendar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}
.calendar__month {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}
.calendar__nav-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.calendar__nav-btn:hover { background: var(--color-surface-2); }

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar__dow {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
  padding: 4px;
  letter-spacing: 0.04em;
}
.calendar__day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text);
  position: relative;
  transition: all 150ms;
}
.calendar__day:hover { background: var(--color-surface-2); }
.calendar__day.is-today {
  border-color: var(--color-primary-dark);
  font-weight: var(--weight-medium);
}
.calendar__day.is-selected {
  background: var(--color-primary-dark);
  color: #fff;
}
.calendar__day.is-outside { opacity: 0.3; }
.calendar__day.has-period {
  background: var(--color-primary);
}
.calendar__day.has-spotting {
  background: transparent;
  border: 1.5px solid var(--color-primary-dark);
}
.calendar__day-dot {
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-secondary-dark);
}

/* ---------- Star Rating ---------- */
.stars {
  display: inline-flex;
  gap: 4px;
}
.stars__star {
  cursor: pointer;
  color: var(--color-border);
  transition: color 150ms;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stars__star.is-filled { color: var(--color-warning-dark); }
.stars--readonly .stars__star { cursor: default; }

/* ---------- Counter ---------- */
.counter {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.counter__btn {
  width: 36px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  font-size: var(--text-lg);
  color: var(--color-text);
}
.counter__btn:hover { background: var(--color-primary); }
.counter__value {
  min-width: 50px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  padding: 0 6px;
}

/* ---------- Quick Log Strip ---------- */
.quick-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.quick-strip__btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  min-width: 84px;
  cursor: pointer;
  transition: all 150ms;
}
.quick-strip__btn:hover {
  background: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-strip__icon {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
}

.quick-strip__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

/* Compact variant — fits a half-width card without horizontal scroll */
.quick-strip--compact {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  overflow: visible;
  padding: 2px 0;
}
.quick-strip--compact .quick-strip__btn {
  flex-shrink: 1;
  min-width: 0;
  padding: 10px 6px;
  gap: 4px;
}
.quick-strip--compact .quick-strip__icon {
  width: 28px;
  height: 28px;
}
.quick-strip--compact .quick-strip__icon i {
  width: 16px;
  height: 16px;
}
.quick-strip--compact .quick-strip__label {
  font-size: 11px;
}

/* ---------- Mood Dial ---------- */
.mood-dial {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto;
}

/* ---------- Wellness Hero ---------- */
.wellness-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  border-radius: var(--radius-xl);
  text-align: center;
  margin-bottom: 16px;
}

.wellness-hero__label {
  font-size: var(--text-sm);
  color: var(--color-text);
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wellness-hero__score {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 300;
  color: var(--color-text);
  line-height: 1;
  margin: 8px 0;
}

.wellness-hero__caption {
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: 12px;
}

.wellness-hero__breakdown {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.wellness-hero__mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.wellness-hero__mini-label {
  font-size: 11px;
  color: var(--color-text);
  opacity: 0.8;
}
.wellness-hero__mini-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-base);
}

/* ---------- Charts ---------- */
.chart-container {
  position: relative;
  width: 100%;
  margin-top: 8px;
}
.chart-container canvas {
  width: 100%;
  height: auto;
  max-height: 280px;
  display: block;
}

/* ---------- Date Navigator ---------- */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  margin-bottom: 16px;
}
.date-nav__date {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}
.date-nav__btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.date-nav__btn:hover { background: var(--color-surface-2); }

/* ---------- Misc helpers ---------- */
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }
.mt-0 { margin-top: 0; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.gap-sm { gap: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ---------- Onboarding ---------- */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.onboarding__card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  padding: 32px;
  text-align: center;
}

.onboarding__progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 24px;
}
.onboarding__dot {
  width: 24px;
  height: 4px;
  background: var(--color-surface-2);
  border-radius: 100px;
  transition: background 200ms;
}
.onboarding__dot.is-active { background: var(--color-primary-dark); width: 32px; }
.onboarding__dot.is-complete { background: var(--color-secondary-dark); }

.onboarding__hero {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  margin-bottom: 8px;
  line-height: 1.2;
}
.onboarding__sub {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: 24px;
}
.onboarding__body {
  text-align: left;
  margin-bottom: 24px;
}
.onboarding__footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.theme-swatch {
  flex: 1;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  background: var(--color-surface-2);
  transition: all 150ms;
}
.theme-swatch.is-selected {
  border-color: var(--color-primary-dark);
  background: var(--color-surface);
}
.theme-swatch__chips {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.theme-swatch__chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
}
.theme-swatch__name {
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}

/* ---------- Severity Pill ---------- */
.severity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-medium);
}
.severity-low { background: var(--color-secondary); color: var(--color-text); }
.severity-mid { background: var(--color-warning); color: var(--color-text); }
.severity-high { background: var(--color-danger); color: var(--color-text); }

/* ---------- Inline Forms ---------- */
.inline-form {
  background: var(--color-surface-2);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--color-border);
}
.timeline__item {
  position: relative;
  padding-bottom: 18px;
}
.timeline__dot {
  position: absolute;
  left: -28px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary-dark);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
}
.timeline__date {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.timeline__title {
  font-weight: var(--weight-medium);
  margin-top: 2px;
}
.timeline__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ---------- Drawer (mobile menu) ---------- */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  background: var(--color-surface);
  z-index: 105;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 250ms;
}
.drawer.is-open { transform: translateX(0); }

/* ---------- Heatmap ---------- */
.heatmap {
  display: grid;
  gap: 3px;
  padding: 8px 0;
}

/* ---------- Loading ---------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-surface-2);
  border-top-color: var(--color-primary-dark);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Autosave indicator ---------- */
.autosave {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.autosave.is-saving { color: var(--color-warning-dark); }
.autosave.is-saved { color: var(--color-secondary-dark); }

/* ---------- Chart legend ---------- */
.chart-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin-top: 12px;
}
.chart-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.chart-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.chart-legend__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-legend--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}
.chart-legend--inline .chart-legend__label { flex: none; }
.chart-legend__value {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------- Habit row (Goals page) ---------- */
.habit-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 6px 0;
}
.habit-row__name {
  font-weight: var(--weight-medium);
  align-self: center;
}
.habit-row__days {
  display: flex;
  gap: 6px;
}
.habit-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.habit-day__letter {
  font-size: 10px;
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.habit-day__circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
  padding: 0;
}
.habit-day__circle:hover {
  border-color: var(--color-primary-dark);
}
.habit-day__circle.is-done {
  background: var(--color-secondary-dark);
  border-color: var(--color-secondary-dark);
  color: #fff;
}
.habit-day__circle.is-done i {
  width: 14px;
  height: 14px;
  color: #fff;
}

/* ---------- Sidebar overlay (mobile) ---------- */

/* ---------- Setting row (label + toggle) ---------- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.setting-row:last-child { border-bottom: 0; }

/* ---------- Doctor Visit Pack ---------- */
.visit-pack-preview { margin-bottom: var(--space-xl); }
.visit-pack {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px 32px;
  max-width: 820px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}
.visit-pack h3 {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #444;
  margin: 0 0 6px;
}
.vp__title { font-family: var(--font-display); font-size: 22px; margin: 0 0 4px; color: #1f1f1f; }
.vp__meta { color: #555; margin: 0; font-size: 12px; }
.vp__head { border-bottom: 2px solid #1f1f1f; padding-bottom: 10px; margin-bottom: 14px; }
.vp__section { margin-bottom: 14px; }
.vp__section p { margin: 0 0 4px; }
.vp__section ol, .vp__section ul { margin: 0; padding-left: 20px; }
.vp__section--first { background: #f4f4f4; border-radius: 8px; padding: 10px 14px; }
.vp__section--first li { font-weight: var(--weight-semibold); }
.vp__flags { border-left: 4px solid #8a4b3f; padding-left: 12px; }
.vp__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.vp__table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.vp__table th, .vp__table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #ddd; }
.vp__table th { font-weight: var(--weight-semibold); color: #444; font-size: 11.5px; }
.vp__small { font-size: 11.5px; color: #555; margin-top: 4px; }
.vp__foot { border-top: 1px solid #ccc; padding-top: 8px; margin-top: 12px; font-size: 11px; color: #555; }
@media (max-width: 640px) {
  .visit-pack { padding: 18px 16px; }
  .vp__cols { grid-template-columns: 1fr; }
  .vp__table { font-size: 11.5px; }
  .vp__table th:nth-child(4), .vp__table td:nth-child(4) { display: none; }
}

/* ---------- HRT Change Check ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cc-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.cc-table th, .cc-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); }
.cc-table th { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: var(--weight-semibold); }
.cc-table td:nth-child(2), .cc-table td:nth-child(3) { font-family: var(--font-mono); white-space: nowrap; }
.cc-word { font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.cc-word--good { color: var(--color-success-dark); }
.cc-word--watch { color: var(--color-danger-dark); }

/* ---------- Bleeding view ---------- */
.segmented--wrap { flex-wrap: wrap; }
.segmented--wrap .segmented__btn { flex: 1 0 auto; text-transform: capitalize; }
.cycle-stats { margin-bottom: var(--space-lg); }
.cycle-stats .metric__value { font-size: var(--text-2xl); }
@media (max-width: 768px) {
  .cycle-stats { grid-template-columns: 1fr 1fr; }
}
.talk-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: var(--text-sm); }
.talk-list li.is-hit::marker { color: var(--color-danger-dark); }

/* ---------- Pattern Finder ---------- */
.pattern-card .card__title { font-size: var(--text-lg); }
.pattern-bars { display: grid; gap: 6px; margin-top: var(--space-sm); }
.pattern-bars__row { display: grid; grid-template-columns: 64px 1fr 52px; align-items: center; gap: 8px; font-size: var(--text-xs); }
.pattern-bars__track { height: 10px; background: var(--color-surface-2); border-radius: 99px; overflow: hidden; }
.pattern-bars__fill { display: block; height: 100%; border-radius: 99px; }
.pattern-bars__value { font-family: var(--font-mono); text-align: right; }

/* ---------- Backup nudge, inline selects, time inputs ---------- */
.backup-nudge { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-md); }
.backup-nudge__text { display: grid; gap: 2px; flex: 1 1 260px; }
.select--inline { width: auto; max-width: 100%; }
.input--time { width: auto; min-width: 110px; flex: none; }

/* ============================================================
   Theme component rules (Luna planner palettes)
   Pastel fill + deep same-hue text everywhere; colour stays in
   small things. These come last so they win over older rules.
   ============================================================ */
body { background: var(--bg); color: var(--text); }
a { color: var(--link); }
*:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.card { background: var(--surface); border-color: var(--border); }
.card--soft { background: var(--surface-alt); border-color: var(--divider); }
.card--hero, .card--accent { background: var(--callout-bg); border: 1.5px solid var(--callout-border); }
.page-header__title, .card__title { color: var(--heading); }

/* Buttons */
.btn--primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); font-weight: var(--weight-semibold); }
.btn--primary:hover { background: var(--btn-primary-hover); filter: none; }
.btn--secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); border: 1.5px solid transparent; }
.btn--secondary:hover { background: var(--btn-secondary-hover); border-color: transparent; }
.btn--ghost { color: var(--btn-ghost-text); }
.btn--ghost:hover { color: var(--text); }
.btn--danger { background: var(--danger-bg); color: var(--danger-text); }
.btn--success { background: var(--success-bg); color: var(--success-text); }
.btn:disabled, .btn[disabled] { opacity: 1; background: transparent; border: 1px solid var(--btn-ghost-border); color: var(--text-muted); }
.btn--icon { color: var(--text-muted); }
.checkin__actions .btn.is-active { background: var(--success-bg); color: var(--success-text); border-color: var(--success-text); }

/* Chips, badges, sliders, toggles, progress */
.chip { background: var(--surface); border-color: var(--border); color: var(--text); }
.chip:hover { background: var(--chip-1-bg); }
.chip.is-selected { background: var(--chip-1-bg); color: var(--chip-1-text); border-color: var(--accent-1-deep); font-weight: var(--weight-semibold); }
.chip--severity-low, .severity-low { background: var(--chip-2-bg); color: var(--chip-2-text); border-color: transparent; }
.chip--severity-mid { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }
.chip--severity-high { background: var(--danger-bg); color: var(--danger-text); border-color: transparent; }
.badge { background: var(--surface-alt); color: var(--text-muted); }
.badge--primary { background: var(--chip-1-bg); color: var(--chip-1-text); }
.badge--success { background: var(--success-bg); color: var(--success-text); }
.badge--warning { background: var(--warning-bg); color: var(--warning-text); }
.badge--danger { background: var(--danger-bg); color: var(--danger-text); }
.slider::-webkit-slider-thumb { background: var(--accent-1-deep); }
.slider::-moz-range-thumb { background: var(--accent-1-deep); }
.slider-field__value { color: var(--chip-1-text); background: var(--chip-1-bg); border-radius: var(--radius-sm); padding: 0 8px; }
.toggle__input:checked + .toggle__track { background: var(--accent-2-deep); border-color: var(--accent-2-deep); }
.progress { background: var(--progress-track); }
.progress__fill { background: var(--progress-fill); }
.segmented { background: var(--surface-alt); }
.segmented__btn { color: var(--text-muted); }
.segmented__btn.is-active { background: var(--surface); color: var(--heading); box-shadow: inset 0 -2px 0 var(--accent-1-deep), var(--shadow-sm); }

/* Menu bar: a light band from the theme, deep same-hue text, near-white active pill */
.sidebar { background: var(--nav-bg); border-right-color: transparent; }
.sidebar::before { content: ''; display: block; height: 6px; flex-shrink: 0; background: var(--brand-stripe); }
.sidebar__header, .sidebar__footer { border-color: rgba(0,0,0,0.06); }
.sidebar__brand { color: var(--nav-active-text); }
.sidebar__group-label { color: var(--nav-text); opacity: 0.85; }
.sidebar__link { color: var(--nav-text); border-left: 0; border-radius: var(--radius-md); margin: 1px 10px; padding: 9px 12px; }
.sidebar__link i, .sidebar__link svg { color: var(--nav-icon); }
.sidebar__link:hover { background: var(--nav-hover-bg); }
.sidebar__link.is-active { background: var(--nav-active-bg); color: var(--nav-active-text); box-shadow: inset 3px 0 0 var(--accent-1-deep); font-weight: var(--weight-semibold); }
.sidebar__link.is-active i, .sidebar__link.is-active svg { color: var(--accent-1-deep); }
.sidebar__footer { color: var(--nav-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+2) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+2) svg { color: var(--chip-1-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+3) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+3) svg { color: var(--chip-2-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+4) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+4) svg { color: var(--chip-3-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+5) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+5) svg { color: var(--chip-4-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+6) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+6) svg { color: var(--chip-5-text); }
[data-theme="rainbow"] .sidebar__link:nth-child(6n+1) i, [data-theme="rainbow"] .sidebar__link:nth-child(6n+1) svg { color: var(--chip-6-text); }

/* Phone top bar and bottom bar carry the theme too */
.topbar { background: var(--nav-bg); border-bottom-color: transparent; color: var(--nav-text); background-image: var(--brand-stripe); background-size: 100% 4px; background-repeat: no-repeat; }
.topbar__brand-mark { color: var(--nav-active-text); }
.topbar button { color: var(--nav-text); }
.bottom-nav { background: var(--surface); border-top-color: var(--border); }
.bottom-nav__item { color: var(--text-muted); }
.bottom-nav__item.is-active { color: var(--nav-active-text); background: var(--nav-bg); font-weight: var(--weight-semibold); }

/* Calendar */
.calendar__day.is-today { border-color: var(--accent-2-deep); }
.calendar__day.is-selected { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.calendar__day.has-period { background: var(--chip-1-bg); color: var(--chip-1-text); }
.calendar__day.has-heavy { background: var(--chip-1-text); color: var(--chip-1-bg); }
.calendar__day.has-spotting { border-color: var(--accent-1-deep); }

/* Banners, toasts, skip link */
.skip-link { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
#update-banner { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
#update-banner button { border-color: var(--btn-primary-text); color: var(--btn-primary-text); }
#update-banner button:hover { background: rgba(255,255,255,0.25); }
.toast { background: var(--surface); color: var(--text); border-color: var(--border); }
.toast--success { border-left-color: var(--success-text); }
.toast--error { border-left-color: var(--danger-text); }
.toast--info { border-left-color: var(--info-text); }
.install-banner__icon { background: var(--chip-1-bg); color: var(--chip-1-text); }

/* Theme picker */
.theme-swatch { background: var(--surface); color: var(--text); }
.theme-swatch.is-selected { border-color: var(--accent-1-deep); box-shadow: 0 0 0 2px var(--accent-1); }
.theme-swatch__preview { display: block; background: transparent; }
.theme-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }

/* ---------- Dashboard welcome panel ----------
   Greeting, a line about today and the illustration (components/hero-art.js).
   Colours are the --hero-* and --art-* tokens in each theme. Laid out by the
   panel's own width (container query): phones keep the picture small beside
   the greeting so the daily check-in stays on the first screen; wider panels
   give it the right-hand column. */
.mw-hero {
  container-type: inline-size;
  position: relative; overflow: hidden;
  background: var(--hero-bg, var(--surface));
  border: 1px solid var(--hero-border, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
}
.mw-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: var(--space-sm) var(--space-md);
  align-items: center;
  padding: var(--space-md);
}
.mw-hero__text { min-width: 0; }
.mw-hero__art { line-height: 0; }
.mw-hero__art svg { width: 100%; height: auto; display: block; }
.mw-hero__eyebrow {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--hero-eyebrow-bg, var(--surface-alt));
  color: var(--hero-eyebrow-text, var(--text));
  font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: 0.02em;
}
.mw-hero__title {
  margin-top: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--text-2xl); line-height: 1.15;
  color: var(--heading);
  overflow-wrap: anywhere;
}
.mw-hero__line { margin-top: var(--space-xs); font-size: var(--text-sm); color: var(--text); line-height: 1.45; }
@container (min-width: 560px) {
  .mw-hero__grid { grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); padding: var(--space-lg) var(--space-xl); gap: var(--space-md) var(--space-xl); }
  .mw-hero__title { font-size: var(--text-4xl); }
  .mw-hero__line { font-size: var(--text-base); }
}

/* Illustration fills (classes, not fill attributes — see hero-art.js) */
.mw-glow { fill: var(--art-glow); }
.mw-shadow { fill: var(--art-shadow); opacity: 0.08; }
.mw-spark { fill: var(--art-spark); } .mw-spark--soft { opacity: 0.55; }
.mw-moon { fill: var(--art-moon); }
.mw-fan1 { fill: var(--art-fan1); } .mw-fan2 { fill: var(--art-fan2); }
.mw-fan-edge { fill: none; stroke: var(--art-ink); stroke-width: 1.4; opacity: 0.16; }
.mw-fan-handle { fill: var(--art-fan-handle); }
.mw-cover { fill: var(--art-cover); }
.mw-page { fill: var(--art-page); }
.mw-spine { fill: var(--art-ink); opacity: 0.07; }
.mw-line { fill: var(--art-ink); opacity: 0.16; }
.mw-grid { fill: var(--art-ink); opacity: 0.08; }
.mw-chip1 { fill: var(--art-chip1); } .mw-chip2 { fill: var(--art-chip2); } .mw-chip3 { fill: var(--art-chip3); }
.mw-chip-off { fill: var(--art-chip-off); }
.mw-heart { fill: var(--art-heart); }
.mw-trend { fill: none; stroke: var(--art-trend); stroke-width: 2.4; stroke-linecap: round; }
.mw-dot { fill: var(--art-dot); }
.mw-mug { fill: var(--art-mug); }
.mw-mug-band { fill: var(--art-page); opacity: 0.55; }
.mw-handle { fill: none; stroke: var(--art-mug); stroke-width: 6; }
.mw-steam path {
  fill: none; stroke: var(--art-steam); stroke-width: 3; stroke-linecap: round; opacity: 0.45;
  animation: mwSteam 3.6s ease-in-out infinite;
}
.mw-steam path + path { animation-delay: 1.8s; }
.mw-leaf { fill: var(--art-leaf); } .mw-leaf2 { fill: var(--art-leaf2); }
.mw-pot { fill: var(--art-pot); }
.mw-pot-rim { fill: var(--art-pot); }
.mw-pot-rim-shade { fill: var(--art-ink); opacity: 0.08; }
@keyframes mwSteam {
  0% { transform: translateY(5px); opacity: 0; }
  40% { opacity: 0.45; }
  100% { transform: translateY(-7px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mw-steam path { animation: none; } }
@media print {
  .mw-hero { background: #fff; border-color: #ccc; }
  .mw-hero__art { display: none; }
  .mw-hero__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Luna Sync card ---------- */
.sync-code { font-family: var(--font-mono); font-size: 2.25rem; font-weight: var(--weight-semibold); letter-spacing: 0.12em; text-align: center; margin: var(--space-md) 0; color: var(--heading); }
.sync-code-input { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: 0.12em; text-align: center; }
.sync-pics { display: flex; justify-content: center; gap: var(--space-lg); margin: var(--space-md) 0; flex-wrap: wrap; }
.sync-pics__item { display: grid; justify-items: center; gap: 4px; }
.sync-pic { font-size: 2.5rem; line-height: 1; }
.sync-key { display: block; width: 100%; font-family: var(--font-mono); font-size: var(--text-sm); word-break: break-all; text-align: left; padding: var(--space-sm) var(--space-md); background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text); }
.sync-key--hidden { filter: blur(6px); cursor: pointer; }

/* ---------- Free demo (only when demo-shim.js has run) ---------- */
html.is-demo .demo-hide { display: none !important; }
.demo-bar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 16px;
  padding: 8px 16px; font-size: var(--text-sm);
  background: var(--callout-bg); color: var(--text); border-bottom: 1px solid var(--callout-border);
  position: relative; z-index: 95;
}
.demo-card { border: 1.5px solid var(--border-accent); background: var(--callout-bg); }
@media print { .demo-bar { display: none !important; } }

/* ---------- Narrow-screen safety (audit: 320px with a pasted link) ----------
   Long unbroken text (a pasted URL) may break anywhere instead of pushing the
   page sideways; grid and list children may shrink below their content; form
   fields never outgrow their box; option rows and habit rows wrap. */
.main-content { overflow-wrap: anywhere; }
.grid > *, .list__item-main { min-width: 0; }
.input, .select, .textarea { min-width: 0; max-width: 100%; }
.segmented { flex-wrap: wrap; }
.habit-row { flex-wrap: wrap; row-gap: 8px; }

/* ---------- iPhone / iPad safety (audit #26, #28, #29, #30, #32) ----------
   Fixed in code; needs checking on a real iPhone/iPad. */
[hidden] { display: none !important; }
/* iOS draws date/time boxes at its own width and ignores width:100% */
.input[type="date"], .input[type="time"], .input[type="datetime-local"], .input[type="month"] {
  -webkit-appearance: none; appearance: none; min-width: 0; width: 100%; max-width: 100%; display: block;
}
.input[type="date"]::-webkit-date-and-time-value, .input[type="time"]::-webkit-date-and-time-value { text-align: left; }
.input--time[type="time"] { width: auto; display: inline-block; }
/* iOS zooms into any field under 16px */
@media (pointer: coarse) { input, select, textarea { font-size: max(16px, 1rem); } }
/* Pop-ups fit between Safari's bars */
.modal { max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - 8px); overscroll-behavior: contain; }
/* Bottom bar clears the iPhone home indicator */
.bottom-nav { height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
@media (max-width: 1023px) {
  .main-content { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 24px); }
  .toast-root { bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px); left: 12px; right: 12px; max-width: none; }
}
/* Ghost buttons on tinted cards: the ghost green measures 3.9:1 on Blush's callout pink */
.card--hero .btn--ghost, .card--accent .btn--ghost, .card--soft .btn--ghost, .demo-card .btn--ghost { color: var(--heading); }
