/* Focus and sizing shared by all views. */
:where(a, button, input, select, textarea, [tabindex="0"]):focus-visible {
  outline: 2px solid var(--accent, #992e26);
  outline-offset: 3px;
}

main:focus { outline: none; }
.reveal:focus-within { opacity: 1; transform: none; }
.site-nav-toggle { display: none; }
.nav-links { display: flex; align-items: center; gap: 4px; min-width: 0; }
.chart-grid > *, .herb-grid > *, .form-grid > *, .filter-bar > * { min-width: 0; }
.chat-input input { min-width: 0; }
.msg .bubble, .article-content, .detail-section { overflow-wrap: anywhere; }

.table-wrap, .result-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.table-wrap .data { min-width: 34rem; }
.result-table-wrap .data { min-width: max-content; }
.modal { overscroll-behavior: contain; }
html:has(.modal-mask) { overflow: hidden; }

@media (max-width: 880px) {
  .nav-inner { flex-wrap: wrap; }
  .site-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line, #cdc9bf);
    background: var(--paper, #f5f3ec);
    color: var(--ink, #21392c);
    font: inherit;
    cursor: pointer;
  }
  .nav-inner .spacer { display: none; }
  .nav-links {
    display: none;
    width: 100%;
    order: 3;
    padding: 8px 0 4px;
    border-top: 1px solid var(--line, #cdc9bf);
  }
  .nav-links.is-open {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .nav-links .nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding-inline: 4px;
    text-align: center;
  }
  .account-link { margin: 0; }
}

@media (max-width: 640px) {
  .auth-layout {
    --auth-image-band: clamp(146px, 42vw, 196px);
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    margin: 6px auto 8px;
    padding: var(--auth-image-band) 11px 11px;
    border-radius: 22px;
  }
  .auth-visual img { object-position: 77% center; }
  .auth-visual figcaption {
    top: calc(var(--auth-image-band) - 42px);
    right: 12px;
    bottom: auto;
  }
  .auth-panel { padding: 20px 15px 19px; border-radius: 16px; }
  .account-details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .herb-picture { max-height: 205px; }
  .herb-detail-photo img { max-height: min(280px, 44vh); }
  .chart-grid, .herb-grid, .form-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-box { height: 260px; }
  .filter-bar input { flex-basis: 100%; width: 100%; }
  .filter-bar select { max-width: 100%; }
  :where(input, select, textarea):not([type="checkbox"], [type="radio"]) { font-size: 16px; }
  .chat-input { flex-wrap: wrap; }
  .chat-input input { flex-basis: 100%; }
  .msg .bubble { max-width: 97%; }
  .pager, .form-actions { flex-wrap: wrap; }
  .pager .info { text-align: center; }
  .modal-mask { padding: 12px; }
  .modal {
    width: 100%;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
  .modal .close { min-width: 40px; min-height: 40px; }
  .toast { width: max-content; max-width: calc(100% - 24px); text-align: center; }
}

@media (hover: none) and (pointer: coarse) {
  .btn, .tab, .tree-counties button, .herb-efficacy-options > label { min-height: 44px; }
  .nav-item, button { touch-action: manipulation; }
}
