/* Nest planner: shared shell colors; gender colors retain their meaning. */
.nest-page {
  --male-border: #65b5ff;
  --female-border: #ff8fb2;
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 1160px;
  min-width: 0;
  margin-inline: auto;
  color: var(--shell-text);
}
.nest-page *, .nest-page *::before, .nest-page *::after { box-sizing: border-box; }
.nest-page [hidden] { display: none !important; }
.nest-page :focus-visible { outline: 2px solid var(--shell-accent); outline-offset: 3px; }
.nest-page :is(h1, h2, h3, p, fieldset) { margin: 0; }
.nest-page h2 { font-size: 19px; line-height: 1.35; }
.nest-page h3 { font-size: 15px; line-height: 1.4; }
.nest-page :is(p, strong, small, span, button) { overflow-wrap: anywhere; }
.nest-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
  background: var(--shell-panel);
}
.nest-hero { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.nest-hero .shell-intro-copy { min-width: 0; }
.nest-hero h1 { margin: 6px 0 8px; font-size: clamp(25px, 3vw, 32px); line-height: 1.2; }
.nest-eyebrow { color: var(--shell-accent); font-size: 12px; font-weight: 700; }
.nest-hero .nest-btn { flex-shrink: 0; }
.nest-muted, .nest-note { color: var(--shell-muted); }
.nest-note { font-size: 12px; line-height: 1.65; }
.nest-panel-head, .nest-task-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; min-width: 0; }
.nest-panel-head > .nest-muted { font-size: 12px; }
.nest-settings-grid { display: grid; grid-template-columns: minmax(130px, 180px) minmax(0, 1fr); gap: 14px 22px; }
.nest-field, .nest-fieldset, .nest-target-picker { display: grid; align-content: start; gap: 7px; min-width: 0; }
.nest-field > span, .nest-fieldset > legend { color: var(--shell-muted); font-size: 12px; font-weight: 600; }
.nest-fieldset { padding: 0; border: 0; }
.nest-fieldset > legend { margin-bottom: 7px; padding: 0; }
.nest-page :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--shell-line-strong);
  border-radius: 8px;
  background: var(--shell-field);
  color: var(--shell-text);
  font: inherit;
  font-size: 16px;
}
.nest-page :is(input, select):focus { border-color: var(--shell-accent); }
.nest-page input::placeholder { color: var(--shell-muted); opacity: 1; }
.nest-page select option { background: var(--shell-field); color: var(--shell-text); }
.nest-btn, .nest-segment, .nest-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--shell-line);
  border-radius: 8px;
  background: var(--shell-panel-soft);
  color: var(--shell-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.nest-btn:hover, .nest-segment:hover, .nest-chip:hover { border-color: var(--shell-accent-border); }
.nest-btn.is-primary { border-color: var(--shell-accent); background: var(--shell-accent); color: var(--shell-on-accent); }
.nest-btn.is-primary:hover { border-color: var(--shell-accent-2); background: var(--shell-accent-2); }
.nest-btn.is-subtle { background: transparent; }
.nest-btn.is-danger { border-color: color-mix(in srgb, var(--shell-danger) 35%, var(--shell-line)); background: var(--shell-danger-soft); color: var(--shell-danger); }
.nest-page button:disabled { opacity: .55; cursor: not-allowed; }
.nest-segmented { display: flex; flex-wrap: wrap; gap: 4px; width: fit-content; max-width: 100%; }
.nest-segment { flex: 1 1 auto; }
.nest-segment:is(.is-active, [aria-pressed="true"]) { border-color: var(--shell-accent-border); background: var(--shell-accent-soft); color: var(--shell-accent); }
.nest-input-columns { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; min-width: 0; }
.nest-list, .nest-inventory { display: grid; gap: 8px; min-width: 0; }
.nest-search-results { display: grid; gap: 6px; min-width: 0; max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.nest-search-results:empty { display: none; }
.nest-pet-option, .nest-inventory-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--shell-line);
  border-radius: 9px;
  background: var(--shell-panel-soft);
  color: var(--shell-text);
  font: inherit;
  text-align: left;
}
.nest-pet-option { grid-template-columns: 40px minmax(0, 1fr); }
.nest-pet-option > .nest-stock-controls { grid-column: 1 / -1; }
.nest-pet-option .nest-btn { flex: 1 1 auto; }
.nest-pet-option:hover { border-color: var(--shell-accent-border); background: var(--shell-accent-soft); }
.nest-pet-avatar { width: 40px; height: 40px; max-width: 100%; object-fit: contain; border-radius: 8px; }
.nest-pet-copy { display: grid; gap: 3px; min-width: 0; }
.nest-pet-copy strong { font-size: 14px; line-height: 1.45; }
.nest-pet-copy small { color: var(--shell-muted); font-size: 11px; line-height: 1.5; }
.nest-stock-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; min-width: 0; }
.nest-count-field { display: grid; gap: 4px; width: 74px; min-width: 0; color: var(--shell-muted); font-size: 12px; }
.nest-count-field input { min-height: 38px; padding: 7px 8px; font-variant-numeric: tabular-nums; }
.nest-sex-badge, .nest-badge { display: inline-flex; align-items: center; gap: 4px; width: fit-content; max-width: 100%; padding: 3px 7px; border: 1px solid var(--shell-line); border-radius: 6px; font-size: 11px; line-height: 1.45; }
:is(.nest-sex-badge, .nest-badge, .nest-btn).is-male { border-color: var(--male-border); background: color-mix(in srgb, var(--male-border) 12%, var(--shell-panel)); color: color-mix(in srgb, var(--male-border) 30%, var(--shell-text)); }
:is(.nest-sex-badge, .nest-badge, .nest-btn).is-female { border-color: var(--female-border); background: color-mix(in srgb, var(--female-border) 12%, var(--shell-panel)); color: color-mix(in srgb, var(--female-border) 30%, var(--shell-text)); }
.nest-chips, .nest-action-bar, .nest-task-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.nest-chip { min-height: 34px; padding: 5px 9px; font-size: 12px; }
.nest-storage-status { min-height: 1.6em; color: var(--shell-muted); font-size: 12px; line-height: 1.6; }
.nest-load-error { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--shell-danger) 35%, var(--shell-line)); background: var(--shell-danger-soft); color: var(--shell-danger); }
.nest-load-error > span { flex: 1 1 200px; }
.nest-page :is(.nest-note, .nest-plan-status, .nest-storage-status).is-warning { color: var(--shell-warn); }
.nest-page :is(.nest-note, .nest-plan-status, .nest-storage-status).is-error { color: var(--shell-danger); }
.nest-plan-status { color: var(--shell-muted); font-size: 14px; line-height: 1.6; }
.nest-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: 8px; min-width: 0; }
.nest-summary:empty, .nest-layout:empty { display: none; }
.nest-summary-stat { display: grid; gap: 5px; min-width: 0; padding: 11px 13px; border: 1px solid var(--shell-line); border-radius: 8px; background: var(--shell-panel-soft); }
.nest-summary-stat strong { font-size: 23px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.nest-summary-stat small { color: var(--shell-muted); font-size: 12px; line-height: 1.4; }
/* Each group is a parent relationship tree, never a physical nest map. */
.nest-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); align-items: start; gap: 12px; min-width: 0; }
.nest-layout-group { display: grid; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--shell-line); border-radius: 10px; background: var(--shell-panel-soft); }
.nest-pair-tree {
  --tree-gap: 28px;
  --tree-row-gap: 8px;
  --tree-line: color-mix(in srgb, var(--shell-accent) 42%, var(--shell-line-strong));
  display: grid;
  grid-template-columns: minmax(68px, 84px) minmax(0, 1fr);
  align-items: center;
  column-gap: var(--tree-gap);
  min-width: 0;
}
.nest-tree-father { position: relative; min-width: 0; }
.nest-tree-father::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  width: calc(var(--tree-gap) / 2);
  border-top: 1px solid var(--tree-line);
  pointer-events: none;
}
.nest-tree-mothers { display: grid; gap: var(--tree-row-gap); min-width: 0; }
.nest-slot { position: relative; display: grid; justify-items: center; align-content: start; gap: 5px; min-width: 0; padding: 8px 5px; border: 1px solid var(--shell-line); border-radius: 8px; background: var(--shell-panel); text-align: center; }
.nest-slot.is-male { border-color: color-mix(in srgb, var(--male-border) 55%, var(--shell-line)); }
.nest-slot.is-female { border-color: color-mix(in srgb, var(--female-border) 55%, var(--shell-line)); }
.nest-slot-number { color: var(--shell-muted); font-size: 11px; line-height: 1.4; }
.nest-slot .nest-pet-avatar { width: 36px; height: 36px; }
.nest-slot strong { font-size: 12px; line-height: 1.4; }
.nest-slot small { color: var(--shell-muted); font-size: 11px; line-height: 1.4; }
.nest-tree-mothers > .nest-slot {
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-areas: "number number" "avatar name" "avatar note";
  justify-items: start;
  align-content: center;
  gap: 2px 6px;
  padding: 6px 7px;
  text-align: left;
}
.nest-tree-mothers .nest-slot-number { grid-area: number; }
.nest-tree-mothers .nest-pet-avatar { grid-area: avatar; align-self: center; width: 28px; height: 28px; }
.nest-tree-mothers .nest-slot strong { grid-area: name; }
.nest-tree-mothers .nest-slot small { grid-area: note; }
.nest-tree-mothers > .nest-slot::before,
.nest-tree-mothers > .nest-slot::after {
  content: "";
  position: absolute;
  left: calc(var(--tree-gap) / -2 - 1px);
  pointer-events: none;
}
.nest-tree-mothers > .nest-slot::before { top: 50%; width: calc(var(--tree-gap) / 2); border-top: 1px solid var(--tree-line); }
/* Half-segments meet across the row gap even when names wrap to different heights. */
.nest-tree-mothers > .nest-slot::after {
  top: calc(var(--tree-row-gap) / -2 - 1px);
  bottom: calc(var(--tree-row-gap) / -2 - 1px);
  border-left: 1px solid var(--tree-line);
}
.nest-tree-mothers > .nest-slot:first-child::after { top: 50%; }
.nest-tree-mothers > .nest-slot:last-child::after { bottom: 50%; }
.nest-page .nest-subheading { margin-top: 3px; }
.nest-evolution-section { display: grid; gap: 10px; min-width: 0; }
.nest-task-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 10px; min-width: 0; }
.nest-task-card { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 13px; border: 1px solid var(--shell-line); border-radius: 10px; background: var(--shell-panel-soft); }
.nest-task-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; min-width: 0; }
.nest-pair-parent { display: grid; justify-items: center; align-content: start; gap: 5px; min-width: 0; padding: 8px; border-radius: 8px; background: var(--shell-panel); font-size: 13px; text-align: center; }
.nest-task-actions .nest-btn { flex: 1 1 110px; }
.nest-info-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; min-width: 0; padding: 10px 12px; border: 1px solid var(--shell-line); border-radius: 8px; background: var(--shell-panel-soft); }
.nest-info-row > .nest-pet-copy { flex: 1 1 140px; }
.nest-empty { grid-column: 1 / -1; padding: 13px; border: 1px dashed var(--shell-line); border-radius: 8px; color: var(--shell-muted); font-size: 13px; line-height: 1.65; }
.nest-route-steps { display: grid; gap: 7px; min-width: 0; margin: 0; padding-left: 21px; color: var(--shell-muted); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.nest-fold { min-width: 0; padding-top: 10px; border-top: 1px solid var(--shell-line); }
.nest-fold > summary { width: fit-content; max-width: 100%; padding: 5px 0; color: var(--shell-accent); font-size: 14px; font-weight: 600; line-height: 1.5; cursor: pointer; }
.nest-fold-body { display: grid; gap: 10px; min-width: 0; margin-top: 8px; }
@media (max-width: 1000px) {
  .nest-input-columns { grid-template-columns: minmax(0, 1fr); }
  .nest-search-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .nest-page, .nest-input-columns { gap: 10px; }
  .nest-panel { gap: 11px; padding: 14px; }
  .nest-hero { flex-wrap: wrap; }
  .nest-hero h1 { font-size: 26px; }
  .nest-panel-head { align-items: start; }
  .nest-settings-grid { grid-template-columns: minmax(0, 1fr); }
  .nest-search-results { grid-template-columns: minmax(0, 1fr); max-height: 250px; }
  .nest-inventory-row { grid-template-columns: 40px minmax(0, 1fr); }
  .nest-stock-controls { grid-column: 1 / -1; }
  .nest-count-field { flex: 1 1 70px; width: auto; }
  .nest-btn, .nest-segment, .nest-page input, .nest-page select { min-height: 44px; }
  .nest-segmented, #nest_generate { width: 100%; }
  .nest-layout-group { padding: 10px; }
  .nest-task-card { padding: 11px; }
  .nest-summary-stat { padding: 10px; }
  .nest-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .nest-panel { padding: 12px; }
  .nest-pair-tree { --tree-gap: 22px; grid-template-columns: minmax(62px, 72px) minmax(0, 1fr); }
  .nest-task-actions .nest-btn { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .nest-btn, .nest-segment, .nest-chip { transition: none; }
}
