/* AIPLuS v0.02 responsive geometry contract.
   This layer owns only layout invariants for dynamic answer/UI surfaces.
   It must not become a second render, scroll, keyboard, or observer owner. */

.answer-surface,
.answer-surface .result-card,
.answer-surface .candidate-item,
.answer-surface .detail-item,
.answer-surface .background-item,
.answer-surface .review-card,
.answer-surface .question-button,
.answer-surface .major-suggestion,
.answer-surface .query-status-row,
.answer-surface .turn-understanding,
.composer,
.composer-row,
.support-panel,
.history-panel{
  min-width:0;
  max-width:100%;
}

.answer-surface :is(
  .candidate-school,
  .candidate-major,
  .candidate-location,
  .candidate-query-match,
  .query-status-query,
  .query-status-result,
  .major-suggestion > span,
  .major-suggestion-button,
  .major-suggestion-button > span,
  .background-item,
  .background-school-link,
  .background-school-prompt,
  .detail-item,
  .review-author,
  .review-meta,
  .review-excerpt,
  .question-button,
  .turn-understanding,
  .turn-understanding > span
){
  writing-mode:horizontal-tb;
  text-orientation:mixed;
  word-break:normal;
  overflow-wrap:break-word;
}

/* Related-major clarification is a reading row with a bounded action track.
   The action track is deliberately finite so intrinsic button content can never
   squeeze Chinese explanation copy into a one-character column. */
.major-suggestions{min-width:0;max-width:100%}
.major-suggestion{
  display:grid;
  grid-template-columns:minmax(13rem,1fr) minmax(9rem,19rem);
  align-items:center;
  justify-content:stretch;
  gap:12px;
  min-width:0;
  max-width:100%;
}
.major-suggestion > span{
  min-width:0;
  max-width:100%;
  line-height:1.55;
}
.major-suggestion-button{
  display:grid;
  grid-template-columns:minmax(0,1fr);
  align-content:center;
  justify-items:start;
  justify-self:stretch;
  min-width:0;
  max-width:19rem;
  white-space:normal;
  line-height:1.35;
  text-align:left;
}
.major-suggestion-button > strong{display:block;min-width:0;max-width:100%}
.major-suggestion-button > span{
  display:block;
  min-width:0;
  max-width:100%;
  margin-top:2px;
  font-size:11px;
  line-height:1.4;
  color:#6f7b75;
}

/* Batch status rows have two shrink-safe reading columns. */
.query-status-row{
  display:grid;
  grid-template-columns:minmax(9rem,.55fr) minmax(0,1fr);
  align-items:start;
  gap:10px 16px;
  min-width:0;
  max-width:100%;
}
.query-status-query,.query-status-result{min-width:0;max-width:100%}
.query-status-result{justify-self:stretch;text-align:right}

/* Short label + explanatory copy follows the same shrink-safe rule. */
.turn-understanding{
  display:grid;
  grid-template-columns:max-content minmax(0,1fr);
  align-items:baseline;
  gap:7px;
}
.turn-understanding > strong,.turn-understanding > span{min-width:0;max-width:100%}

/* Result history cards and the desktop history drawer intentionally share a
   legacy class name. Isolate result cards at the final geometry layer. */
.answer-surface .history-list .history-item{
  display:block;
  grid-template-columns:none;
  width:100%;
  min-width:0;
  max-width:100%;
}
.answer-surface .history-list .history-item .candidate-head{
  width:100%;
  min-width:0;
  max-width:100%;
}
.answer-surface .candidate-head > *{min-width:0;max-width:100%}

/* Action clusters wrap/stack instead of forcing viewport overflow. */
.background-school-actions,
.system-actions,
.dialog-actions,
.composer-buttons,
.starter-score-row{
  min-width:0;
  max-width:100%;
}
.background-school-actions > *,
.system-actions > *,
.dialog-actions > *,
.composer-buttons > *,
.starter-score-row > *{
  min-width:0;
  max-width:100%;
  white-space:normal;
}
.composer textarea{min-width:0;width:100%;max-width:100%}

/* Ordinary Chinese prose should wrap at natural boundaries, never globally at
   every character merely to satisfy a narrow sibling. */
.answer-surface .result-card,
.aiplus-product-footer{overflow-wrap:break-word;word-break:normal}

@media(max-width:760px){
  .major-suggestion{
    grid-template-columns:minmax(0,1fr);
    align-items:stretch;
    gap:8px;
  }
  .major-suggestion-button{
    justify-self:stretch;
    width:100%;
    max-width:100%;
    min-height:42px;
  }
  .query-status-row{
    grid-template-columns:minmax(0,1fr);
    gap:2px;
  }
  .query-status-result{justify-self:start;text-align:left}
  .turn-understanding{
    grid-template-columns:minmax(0,1fr);
    align-items:start;
    gap:2px;
  }
  .background-school-actions{display:grid;grid-template-columns:minmax(0,1fr);align-items:stretch}
  .background-school-actions > *{width:100%;justify-content:center;text-align:center}
  .dialog-actions{flex-wrap:wrap}
}

@media(max-width:420px){
  .topbar{gap:6px}
  .brand{min-width:0;white-space:nowrap;font-size:15px}
  .top-actions{min-width:0}
  .top-actions a,.top-actions button{white-space:nowrap;padding-inline:7px}
  .composer-buttons{grid-template-columns:minmax(0,auto) minmax(0,1fr);
}
}
