/* components.css — meal overlay, form inputs, password field, autocompletes,
   dog profile page, modal, multi-select, and responsive rules. */

/* =====================
   MEAL DETAIL OVERLAY
   ===================== */
.meal-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.ingredients-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.ingredient-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ingredient-row:last-child { border-bottom: none; }

.ingredient-name {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.ingredient-amount {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-align: right;
}

.ing-us-measure {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-secondary);
}

/* =====================
   UNIT TOGGLE (Account preferences)
   ===================== */
/* Soft grouped card that wraps a single preference (matches the Profile card) */
.pref-card {
  background: var(--field-bg);
  border-radius: 14px;
  padding: 16px;
}
.pref-card-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 10px;
}
.pref-card-hint {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 10px 0 0;
}

/* Segmented control: two equal options in one pill-shaped track */
.unit-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 3px;
}

.unit-toggle-option {
  display: block;
  cursor: pointer;
}

.unit-toggle-option input[type="radio"] { display: none; }

.unit-toggle-option span {
  display: block;
  text-align: center;
  padding: 9px 0;
  border-radius: 50px;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
  cursor: pointer;
}

.unit-toggle-option input[type="radio"]:checked + span {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,145,210,0.35);
}

.unit-toggle-option:hover span {
  color: var(--accent);
}

.unit-toggle-option input[type="radio"]:checked + span:hover {
  color: #fff;
}

.prep-steps {
  list-style: none;
  counter-reset: prep;
  padding: 0;
  margin: 0 0 4px;
}

.prep-step {
  counter-increment: prep;
  position: relative;
  padding: 0 0 20px 40px;
  min-height: 26px;
}

.prep-step:last-child { padding-bottom: 0; }

/* Connector line linking each step's number to the next. */
.prep-step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.prep-step::before {
  content: counter(prep);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.prep-step-verb {
  font-weight: 700;
  color: var(--accent);
  display: block;
  font-size: 0.82rem;
  margin-bottom: 2px;
}

.prep-step-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.meal-nutrition-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.meal-nutrition-cell {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mnc-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mnc-lbl {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.btn-danger-outline {
  padding: 8px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-danger-outline:hover { border-color: #c0392b; color: #c0392b; }

/* =====================
   Address Autocomplete Dropdown
   ===================== */
.addr-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(28, 43, 26, 0.1);
  z-index: 300;
  max-height: 200px;
  overflow-y: auto;
}
.addr-dropdown.open { display: block; }
.addr-option {
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  line-height: 1.4;
}
.addr-option:last-child { border-bottom: none; }
.addr-option:hover { background: var(--accent-light); color: var(--accent); }

/* =====================
   Password Input Group + Eye Toggle
   ===================== */
.password-input-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.2s;
}
.password-input-group:focus-within { border-color: var(--accent); }
.password-input-group input {
  flex: 1;
  border: none !important;
  background: none !important;
  border-radius: 0 !important;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
}
.btn-eye {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: color 0.2s;
  flex-shrink: 0;
}
.btn-eye:hover { color: var(--text-primary); }

.forgot-pwd-link {
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
}
.forgot-pwd-link:hover { text-decoration: underline; }

.auth-success {
  color: #1a7f37;
  font-size: 0.85rem;
  margin-bottom: 12px;
  min-height: 18px;
}

/* Hide browser search-input decorations (clear button, etc.) */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration { display: none; }

/* =====================
   Google Places Autocomplete
   ===================== */
.pac-container {
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(28, 43, 26, 0.1);
  margin-top: 2px;
  overflow: hidden;
}
.pac-item {
  padding: 9px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  border-top: 1px solid var(--border);
}
.pac-item:first-child { border-top: none; }
.pac-item:hover, .pac-item-selected { background: var(--accent-light); }
.pac-item-query { font-weight: 500; color: var(--text-primary); }
.pac-matched { font-weight: 600; color: var(--accent); }
.pac-icon { display: none; } /* hide Google pin icon */

/* =====================
   Form Inputs — shared
   ===================== */
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-group select { cursor: pointer; appearance: none; }
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* Custom dropdown: full descriptions in the open list, short label when selected
   (native <select> can't show different open vs. collapsed text). */
.cdrop { position: relative; }
.cdrop-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.cdrop.open .cdrop-trigger,
.cdrop-trigger:focus-visible { border-color: var(--accent); }
.cdrop-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cdrop-value[data-empty="true"] { color: var(--text-secondary); }
.cdrop-chevron {
  flex: 0 0 auto;
  color: var(--text-secondary);
  transition: transform 0.15s;
}
.cdrop.open .cdrop-chevron { transform: rotate(180deg); }
.cdrop-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28, 43, 26, 0.14);
  max-height: 260px;
  overflow-y: auto;
}
.cdrop-opt {
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
}
.cdrop-opt:hover { background: var(--accent-light); }
.cdrop-opt[aria-selected="true"] { color: var(--accent); font-weight: 600; }

/* =====================
   Dog Card — footer & badges
   ===================== */
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 50px;
  background: var(--accent-light);
  color: var(--accent);
  white-space: nowrap;
}
.badge-activity {
  background: #FFFFFF;   /* landing-page light blue */
  color: #143C52;        /* dark blue for readable contrast */
  font-weight: 600;
}
.badge-more {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 4px;
}
.card-edit-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s;
}
.dog-card:hover .card-edit-hint { opacity: 1; }

/* "Add a dog" tile — the next open slot in the pack grid. Reuses .dog-card for
   matching size/radius, but renders as a dashed placeholder. */
.dog-add-tile {
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  background: transparent;
  border: 2px dashed var(--border);
  box-shadow: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
}
.dog-add-tile:hover {
  border-color: #143C52;   /* landing-page blue */
  background: #FFFFFF;
  color: #143C52;
  box-shadow: none;
}

/* Dog profile "Dog's info" tile — stat strip + health chips */
.dp-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.dp-stat {
  background: #f4f2ec;
  border-radius: 10px;
  padding: 12px 14px;
}
.dp-stat-label { display: block; font-size: 0.72rem; color: var(--text-secondary); }
.dp-stat-val   { display: block; margin-top: 4px; font-size: 1.05rem; font-weight: 600; color: var(--text-primary); }
.dp-group-label {
  margin: 16px 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.dp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dp-chip {
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 0.82rem;
}
/* Semantic chip colors: green = will eat / already gets, red = avoid. */
.dp-chip-allowed,
.dp-chip-supplement { background: #e8f4e8; color: #2a5c2a; }
.dp-chip-allergen,
.dp-chip-dislike    { background: #fceaea; color: #a32d2d; }
.dp-chip-empty { color: var(--text-secondary); font-size: 0.85rem; }
.dp-notes { margin: 0; font-size: 0.9rem; line-height: 1.6; color: var(--text-primary); }

/* Collapsible detail (health chips + notes) inside the Dog's info tile.
   Rolled up by default so only the 6 stats show; the toggle reveals the rest. */
.dp-more[hidden] { display: none; }
.dp-more-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-end;
  gap: 4px;
  margin-top: 12px;
  padding: 2px 0;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.dp-more-toggle:hover { color: var(--accent-hover); }
.dp-more-chevron { transition: transform 0.2s ease; }
.dp-more-toggle.is-open .dp-more-chevron { transform: rotate(180deg); }
/* The roll-up only earns its keep once the side tiles drop below Dog's info
   (single-column at <=700px). On the wide two-column layout there's room to
   spare, so show everything and hide the toggle — a collapsed card there just
   leaves an odd empty gap next to the stats. */
@media (min-width: 701px) {
  .dp-more[hidden]  { display: block; }
  .dp-more-toggle   { display: none; }
}
/* Collapsed (single-column) mode: don't let the fields box flex-grow or carry
   its extra bottom margin, so the gap below "See more" equals the tile's own
   20px padding — matching the space above the Edit button at the top. */
@media (max-width: 700px) {
  #dogpage-fields { flex: none; margin-bottom: 0; }
  /* Trim the info box vertically so "My plan" rises into view with a little
     grey breathing room below it. Scoped to the info tile + mobile only. */
  .dog-tile-grid > .dog-tile { padding: 16px; }
  #dogpage-fields .dp-stat-strip { gap: 8px; }
  #dogpage-fields .dp-stat { padding: 9px 12px; }
  #dogpage-fields .dp-more-toggle { margin-top: 8px; }
}

/* Body-condition: collapsed summary field in the form */
.bcs-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease;
}
.bcs-summary:hover { border-color: var(--accent); }
.bcs-summary-art {
  width: 46px; height: 40px; object-fit: contain; flex-shrink: 0;
}
.bcs-summary-text { flex: 1; font-size: 0.95rem; color: var(--text-secondary); }
.bcs-summary.is-set .bcs-summary-text { color: var(--text-primary); font-weight: 600; }
.bcs-summary-chevron { color: var(--text-secondary); flex-shrink: 0; }

/* Body-condition picker (inside its own popup) */
#bcs-modal-overlay { z-index: 210; }
.bcs-modal-card { max-width: 620px; }
.bcs-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 4px;
}
.bcs-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 14px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.bcs-card:hover { border-color: var(--accent); }
.bcs-card.is-selected {
  border: 2px solid var(--accent);
  padding: 13px 9px 13px;
  background: var(--accent-light);
}
.bcs-art { width: 100%; height: 128px; object-fit: contain; pointer-events: none; }
.bcs-name { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }
.bcs-desc { font-size: 0.76rem; line-height: 1.35; color: var(--text-secondary); }

.btn-card-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.btn-card-delete:hover {
  background: #fdecea;
  border-color: #f5c6cb;
  color: #c0392b;
}

/* =====================
   Dog Profile Page
   ===================== */
.dog-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;      /* in lockstep with .page-header so both pages' first cards align at every width */
  margin-bottom: 34px;
}
@media (max-width: 768px) {
  .dog-page-header { min-height: 60px; margin-bottom: 28px; }
}
@media (max-width: 480px) {
  .dog-page-header { min-height: 82px; margin-bottom: 24px; }
}
.dog-back-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.dog-back-circle:hover { border-color: var(--accent); color: var(--accent); }
.dog-page-nav { display: flex; gap: 10px; }

.btn-back-pack {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px 5px 9px;
  margin: 0 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-back-pack:hover { border-color: var(--accent); color: var(--accent); }

.dog-page-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dog-page-avatar-btn {
  position: relative;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  width: 52px;
  height: 52px;
}

.dog-page-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  overflow: hidden;
}

.dog-page-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.dog-page-avatar-btn:hover .dog-page-avatar-overlay { opacity: 1; }
.dog-page-name {
  font-family: var(--font-body);
  font-size: 1.6rem;
  color: var(--text-primary);
  margin: 0;
}
.dog-page-sub {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 2px 0 0;
}
/* Keep breed and the sex/neuter meta each intact so they don't split mid-phrase. */
.dog-page-sub .dp-sub-breed,
.dog-page-sub .dp-sub-meta,
.plan-dog-sub .dp-sub-breed,
.plan-dog-sub .dp-sub-meta { white-space: nowrap; }
/* On phones the meta drops to its own line under the breed; the joining "·"
   is hidden so "Female" aligns with the breed instead of starting with a dot.
   Applied to both the dog page and the plan page so the two headers match. */
@media (max-width: 480px) {
  .dog-page-sub .dp-sub-sep,
  .plan-dog-sub .dp-sub-sep  { display: none; }
  .dog-page-sub .dp-sub-meta,
  .plan-dog-sub .dp-sub-meta { display: block; }
}

.dog-tile-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.dog-tile-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Plan + AI split the side column so together they match the info card height. */
.dog-tile-side > .dog-tile {
  flex: 1;
}
@media (max-width: 700px) {
  .dog-tile-grid { grid-template-columns: 1fr; }
}

.dog-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.dog-tile-soon { opacity: 0.65; }

.dog-tile-icon {
  color: var(--text-secondary);
  margin-bottom: 10px;
  min-height: 34px;            /* match the Dog's-info header (icon + Edit button) */
  display: flex;
  align-items: center;
}
.dog-tile-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}
.dog-tile-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 12px;
}
.dog-tile-badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 3px 10px;
  margin-top: auto;
  align-self: flex-start;
}

.dog-tile-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 16px;
  flex: 1;
}
.dog-tile-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 12px;
}
.dog-tile-field:last-child { border-bottom: none; }
.dog-tile-field-label { color: var(--text-secondary); flex-shrink: 0; }
.dog-tile-field-val {
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
}

/* Header row for the Dog's info tile: icon left, Edit button right */
.dog-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 34px;
}
.dog-tile-head .dog-tile-icon { margin-bottom: 0; min-height: 0; }

.btn-tile-edit {
  align-self: flex-end;
  padding: 6px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  margin-top: auto;
}
/* In the header row it sits inline with the icon, not pushed to the bottom */
.dog-tile-head .btn-tile-edit { align-self: center; margin-top: 0; }
.btn-tile-edit:hover { border-color: var(--accent); color: var(--accent); }

/* =====================
   Modal
   ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 26, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

/* The account-section popup is a container modal: modals opened from inside it
   (Edit profile, the photo editor) must stack above it. */
#section-modal-overlay { z-index: 190; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(28, 43, 26, 0.22);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.22s ease both;
}

/* Recipe & day-detail modals: standard responsive modal behavior, just a wider
   desktop cap. Placed AFTER .modal-card so the larger max-width wins on desktop;
   the mobile block below still overrides these to full-screen at ≤640. */
.plan-meal-card { max-width: 680px; }
.plan-day-modal { max-width: 680px; }
.freq-modal    { max-width: 550px; }
.shopping-modal { max-width: 520px; }   /* desktop cap; the mobile block below overrides to full-screen */

/* Regenerate confirm dialog: no divider lines, a bit wider, and text sized so
   the title and body each sit on one line (down to phones). */
.modal-card.regen-modal { max-width: 580px; }
.regen-modal .modal-header { border-bottom: none; padding-bottom: 4px; }
.regen-modal .modal-footer { border-top: none; padding-top: 10px; }
.regen-modal .modal-header h2 { font-size: 1.2rem; }
.regen-modal .modal-body { padding-top: 4px; padding-bottom: 8px; font-size: 0.95rem; }
.alert-modal   { max-width: 380px; }

/* Nutritionist coming-soon dialog: no divider lines. */
#nutritionist-overlay .modal-header { border-bottom: none; }
#nutritionist-overlay .modal-footer { border-top: none; }
#plan-supplements-overlay .modal-header { border-bottom: none; }
#dog-hub-overlay .modal-header { border-bottom: none; }
#dog-hub-overlay .modal-footer { border-top: none; }

/* Non-blocking toast (used for 'coming soon' notices, etc.). */
.kb-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(420px, 92vw);
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 24px rgba(28, 43, 26, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}
.kb-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: var(--font-body);
  font-size: 1.35rem;
  color: var(--text-primary);
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--bg); color: var(--text-primary); }

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;   /* forms should never scroll sideways (mobile drag) */
  flex: 1;
}
.modal-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 14px;
  margin-top: 24px;
}
.modal-section-label:first-child { margin-top: 0; }

.modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.btn-secondary {
  padding: 10px 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.modal-save-btn { width: auto; }
/* Two-factor authentication modal */
.twofa-desc { font-size: 0.9rem; color: var(--text-secondary, #6b7280); line-height: 1.5; margin: 0 0 14px; }
.twofa-desc .ti { color: var(--accent); vertical-align: -2px; }
.twofa-qr-wrap { display: flex; justify-content: center; padding: 14px; background: #fff; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; margin-bottom: 14px; }
.twofa-secret { display: block; font-family: var(--font-mono, ui-monospace, monospace); font-size: 0.95rem; letter-spacing: 1px; background: var(--surface-alt, #f3f3f0); padding: 9px 12px; border-radius: 8px; text-align: center; word-break: break-all; }
#twofa-code, #mfa-challenge-code { text-align: center; letter-spacing: 6px; font-size: 1.2rem; }
.twofa-lost { font-size: 0.8rem; color: var(--text-secondary, #6b7280); margin-top: 12px; line-height: 1.4; }
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { opacity: 0.8; }
/* Match the header/navbar blue instead of the app's green accent */
#forgot-submit-btn { background: #143C52; }
#forgot-submit-btn:hover { background: #1E4E6E; }
.required { color: #c0392b; }

/* ----- Dog photo reposition editor ----- */
.photo-editor-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin: 0;
}
.photo-editor-stage {
  position: relative;
  width: 280px;
  height: 280px;
  max-width: 70vw;
  max-height: 70vw;
  border-radius: 50%;
  overflow: hidden;
  background: var(--avatar-bg);
  touch-action: none;
}
.photo-editor-frame {
  position: absolute;
  inset: 0;
  cursor: grab;
  overflow: hidden;
}
.photo-editor-frame:active { cursor: grabbing; }
.photo-editor-frame img {
  position: absolute;
  top: 0;
  left: 0;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
/* Subtle ring so the crop circle is obvious; doesn't capture clicks */
.photo-editor-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(255,255,255,0.001), inset 0 0 0 2px rgba(255,255,255,0.85);
  pointer-events: none;
}
.photo-editor-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 280px;
  max-width: 70vw;
  color: var(--text-secondary);
}
.photo-editor-zoom input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}
.photo-editor-zoom-icon { flex-shrink: 0; }

/* =====================
   Form Row (2-col grid)
   ===================== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* =====================
   Age Input Group
   ===================== */
.age-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.age-input-group input {
  width: 52px;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
.age-input-group input:focus { border-color: var(--accent); }
.age-unit {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* =====================
   Weight Input Group
   ===================== */
.weight-input-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color 0.2s;
}
.weight-input-group:focus-within { border-color: var(--accent); }
.weight-input-group input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
}
.weight-input-group select {
  border: none;
  border-left: 1px solid var(--border);
  background: var(--bg);
  padding: 10px 10px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  appearance: none;
  width: 56px;
  text-align: center;
}

/* =====================
   Multi-Select Component
   ===================== */
.multi-select { position: relative; }

.ms-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  min-height: 44px;
  cursor: text;
  transition: border-color 0.2s;
}
.ms-tags:focus-within { border-color: var(--accent); }

.ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 50px;
  white-space: nowrap;
}
.ms-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  padding: 0 1px;
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.ms-remove:hover { opacity: 1; }

.ms-search {
  border: none;
  background: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  min-width: 80px;
  flex: 1;
  padding: 2px 0;
}

.ms-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(28, 43, 26, 0.1);
  z-index: 50;
  max-height: 190px;
  overflow-y: auto;
}
.ms-dropdown.open { display: block; }
.ms-option {
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.12s;
}
.ms-option:hover { background: var(--accent-light); color: var(--accent); }
.ms-empty {
  padding: 10px 14px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 640px) {
  /* nav-inner padding intentionally removed — the .navbar already supplies the
     side padding. Re-adding it here double-padded the header below 640px,
     making the logo/buttons jump inward as the window narrowed. */
  .nav-inner    { padding: 0; }
  /* Icon-only nav on mobile so the links never overflow the viewport (which
     pushed the whole page sideways and left a refresh off-center). */
  .nav-label    { display: none; }
  .nav-link     { padding: 8px; gap: 0; }
  .nav-links    { gap: 4px; }
  .nav-auth-inline { display: none; }
  .nav-auth-menu   { display: block; }
  .main-content { padding: 32px 20px; }
  .plan-content { padding: 32px 20px; }   /* match .main-content so the header + first block line up when switching pages */
  .page-title   { font-size: 1.9rem; }
  .form-row     { grid-template-columns: 1fr; }

  /* Full-screen modals on mobile: iOS Safari's vh includes the address bar, so
     a centered vh-capped card overflows the visible area — the top clips and
     the body's scroll region falls off-screen. Filling the dynamic viewport
     (dvh) keeps the header pinned at the very top, the footer at the bottom,
     and the body scrolling between them. */
  .modal-overlay { align-items: flex-start; padding: 0; }
  .modal-card {
    max-width: 100%;
    height: 100vh;              /* fallback */
    height: 100dvh;             /* excludes the dynamic toolbar on iOS 15.4+ */
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .modal-body {
    padding: 20px;
    -webkit-overflow-scrolling: touch;
  }
  .modal-header,
  .modal-footer { padding-left: 20px; padding-right: 20px; }

  /* Small alert-style dialog (e.g. Coming soon) stays a centered compact card. */
  #nutritionist-overlay,
  #regen-confirm-overlay { align-items: center; padding: 16px; }
  .alert-modal {
    height: auto;
    max-height: 90dvh;
    max-width: min(380px, 92vw);
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
  }
  .modal-card.regen-modal {
    max-width: 94vw;
  }
  /* Readable text on mobile; the body simply wraps to a second line. */
  .regen-modal .modal-header h2 { font-size: 1.1rem; }
  .regen-modal .modal-body { font-size: 0.95rem; }
}

/* First-plan transition banner (plan page) */
.plan-transition {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.plan-transition-title { font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.plan-transition-steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .plan-transition-steps { grid-template-columns: repeat(4, 1fr); } }
.plan-transition-step {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface-alt, #f6f7f8); border-radius: 8px; padding: 8px 10px;
}
.pts-days { font-size: 0.78rem; color: var(--text-secondary, #6b7280); }
.pts-mix  { font-weight: 600; font-size: 0.9rem; }
.plan-transition-note { margin: 10px 0 0; font-size: 0.85rem; color: var(--text-secondary, #6b7280); }

/* Check-in modal */
.checkin-intro { color: var(--text-secondary, #6b7280); font-size: 0.9rem; margin: 0 0 16px; }
.checkin-result {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-alt, #f0f7f0); border: 1px solid var(--border, #e5e7eb);
}
.checkin-result p { margin: 0 0 8px; font-size: 0.9rem; line-height: 1.45; }
.checkin-result p:last-child { margin-bottom: 0; }

/* Transition banner: inline owner controls (mark complete / restart) */
.plan-transition-link {
  background: none; border: none; padding: 0; margin: 6px 0 0; display: block;
  color: var(--accent, #143C52); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.plan-transition-link:hover { opacity: 0.8; }

/* Add-dog wizard (stepped add flow; edit stays flat) */
.wiz-progress { height: 6px; background: var(--surface-alt, #eee); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.wiz-progress-bar { height: 100%; background: var(--accent, #e07a5f); width: 16%; transition: width .25s ease; }
.wiz-step-label { font-weight: 600; font-size: 0.9rem; color: var(--text-secondary, #6b7280); margin: 0 0 16px; }
#wiz-back-btn { margin-right: auto; }

/* Center the wizard primary button label (Continue / Create dog) */
#wiz-next-btn { justify-content: center; text-align: center; }

/* Edit hub: section cards */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.hub-card {
  text-align: left; background: var(--surface, #fff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; transition: border-color .15s;
}
.hub-card:hover { border-color: var(--accent, #143C52); }
.hub-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.hub-card-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; color: var(--text-primary, #1a1a1a); }
.hub-card-title .ti { color: var(--accent, #143C52); font-size: 1.05rem; }
.hub-card-edit { color: var(--text-secondary, #9ca3af); font-size: 0.95rem; }
.hub-card-summary { margin: 0; font-size: 0.85rem; color: var(--text-secondary, #6b7280); line-height: 1.5; }

/* Plan header: meals-vs-treats reconciliation note */
.plan-kcal-note {
  margin: 8px 0 0; font-size: 0.85rem; color: var(--text-secondary, #6b7280);
  display: flex; align-items: center; gap: 6px; line-height: 1.5;
}
.plan-kcal-note .ti { color: var(--accent, #143C52); }

/* Dog page: single labeled back pill (replaces the two chevron circles) */
.dog-back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;  /* keep "Your pack" on one line on narrow screens */
  flex-shrink: 0;
}
.dog-back-pill:hover { border-color: var(--accent); color: var(--accent); }

/* Account card footer: "Member since" left, Log Out bottom-right */
.account-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.account-footer .account-since { margin: 0; }

/* Account page: back link (top-left) + full-width neutral log out (bottom) */
.account-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0; margin-bottom: 16px;
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: color 0.15s;
}
.account-back:hover { color: var(--accent); }
.btn-logout-full {
  width: 100%; margin-top: 20px; padding: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-btn);
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
}
.btn-logout-full:hover { border-color: var(--accent); color: var(--accent); }
.account-since-center { text-align: center; margin: 12px 0 0; }
