/* Keep the compact navigation's grid tracks aligned with its tablet width. */
@media (min-width: 681px) and (max-width: 1160px) {
  .app-shell.console-single.no-detail { grid-template-columns: 208px minmax(0, 1fr); }
  .app-shell.console-list.no-detail { grid-template-columns: 208px 260px minmax(0, 1fr); }
}
@media (min-width: 681px) and (max-width: 1000px) {
  .app-shell.console-single.no-detail { grid-template-columns: 64px minmax(0, 1fr); }
  .app-shell.console-list.no-detail { grid-template-columns: 64px minmax(245px, 280px) minmax(0, 1fr); }
}

@media (max-width: 680px) {
  /* Phone navigation is above the page; the memory drawer uses the space below it. */
  .app-shell .detail-pane.is-open { top: 52px; bottom: 0; width: 100%; z-index: 16; }
  /* Dialog errors stay visible while the dialog remains available for correction. */
  .app-shell > .toast.visible { z-index: 40; }
}

/* Scroll controls occupy their own space beside the phone's section links. */
.ch-nav-scroll { display: none; }
@media (max-width: 680px) {
  .rail.ch-nav-discovery { gap: 4px; }
  .rail.ch-nav-discovery .rail-nav { flex: 1 1 auto; min-width: 0; width: auto; }
  .rail.ch-nav-discovery .ch-nav-scroll:not([hidden]) { display: grid; place-items: center; flex: 0 0 32px; align-self: center; height: 40px; padding: 0; border: 1px solid #e5e5e1; border-radius: 8px; background: #f8f8f6; color: #55554f; font: 400 25px/1 var(--font); cursor: pointer; }
  .rail.ch-nav-discovery .ch-nav-scroll[aria-disabled="true"] { color: #b0b0a9; cursor: default; }
  @media (hover: hover) and (pointer: fine){.rail.ch-nav-discovery .ch-nav-scroll:not([aria-disabled="true"]):hover { border-color: #cecec7; background: #eeeee9; }}
  .ch-nav-scroll:focus-visible { outline: 2px solid #45453b; outline-offset: 1px; }
}

/* Explain a selected record outside the retained list without changing matches. */
.ch-selection-outside { flex: 0 0 auto; margin: 0 18px 10px; padding: 9px 11px; border: 1px solid #e5e5e1; border-radius: 10px; background: #fafaf8; color: #61615b; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ch-selection-outside[hidden] { display: none; }
.ch-selection-outside p { margin: 0; }
.ch-selection-outside strong { color: #31312d; font-weight: 600; }
.ch-selection-outside .ch-selection-source { display: block; margin-top: 3px; font-size: 11px; }
.ch-selection-outside button { min-height: 32px; margin: 4px 12px 0 0; }

.ir-impact { margin: 14px 0; padding: 12px 14px; border: 1px solid #dddcd5; border-radius: 10px; background: #fafaf7; overflow-wrap: anywhere; }
.ir-impact h4 { margin: 0 0 6px; color: #292924; font-size: 13px; line-height: 1.5; }
.ir-impact-summary, .ir-impact-note, .ir-impact-unavailable { margin: 10px 0; color: #55554f; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.ir-impact .ir-impact-summary { margin: 0; }
.ir-impact .ir-impact-note:last-child { margin-bottom: 0; }
.ir-impact-people { margin-top: 8px; font-size: 12px; }
.ir-impact-people summary { display: list-item; min-height: 32px; padding: 6px 0; cursor: pointer; }
.ir-impact-people ul { margin: 0; padding: 0; list-style: none; }
.ir-impact-person { padding: 8px 0; border-top: 1px solid #e5e5df; }
.ir-impact-person p { margin: 4px 0; line-height: 1.6; }
.ir-impact-person small { display: block; color: #66665f; line-height: 1.6; }
.ir-impact-unavailable { color: #684a10; }

/* A fixed skip link stays out of the shell's grid until a keyboard user needs it. */
.ch-skip-link { position: fixed; top: 8px; left: 8px; z-index: 70; padding: 9px 13px; border: 1px solid #171717; border-radius: 8px; background: #fff; color: #171717; font: 500 13px/1.4 var(--font); text-decoration: none; transform: translateY(calc(-100% - 16px)); }
.ch-skip-link:focus { transform: translateY(0); outline: 2px solid #171717; outline-offset: 2px; }
.rail-action { text-decoration: none; }
.modal .field-hint { margin: 7px 0 0; color: #666; font-size: 11px; line-height: 1.5; }
.message-row:focus-visible { outline: 2px solid #496d9f; outline-offset: 3px; border-radius: 8px; }
.ch-recovery-notice { position: fixed; right: 16px; bottom: 16px; z-index: 65; display: flex; align-items: center; gap: 16px; max-width: 620px; padding: 16px; border: 1px solid #c7b493; border-radius: 12px; background: #fffaf0; box-shadow: 0 6px 26px #00000016; color: #35312b; font-size: 13px; }
.ch-recovery-notice p { margin: 5px 0 0; line-height: 1.5; }
.ch-recovery-notice .button { flex-shrink: 0; }
@media (max-width: 680px) { .ch-recovery-notice { left: 12px; right: 12px; bottom: 12px; display: block; } .ch-recovery-notice .button { margin-top: 10px; } }
.ch-backup-origin-review { margin: 16px 0; padding: 14px; border: 1px solid #deded9; border-radius: 10px; background: #f8f8f5; overflow-wrap: anywhere; }
.ch-backup-origin-review > strong { font-size: 13px; }
.ch-backup-origin-review p, .ch-backup-origin-review li { font-size: 12px; line-height: 1.5; }
.ch-backup-origin-review p { margin: 7px 0; }
.ch-backup-origin-review summary { cursor: pointer; font-size: 12px; }
.ch-backup-origin-review li { margin: 9px 0; }
.ch-backup-origin-review li strong, .ch-backup-origin-review li span { display: block; }

.import-diagnostics.import-source-error { border-color: #dbc9b9; background: #fbf5ee; color: #76513f; font-size: 12px; overflow-wrap: anywhere; }

.ch-person-date-details { margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid #e9e9e4; }
.ch-person-date-details > summary { padding: 6px 0; font-size: 12px; color: #686861; }
.ch-person-date-facts { display: grid; gap: 5px; padding: 7px 0; color: #686861; font-size: 12px; line-height: 1.45; }
.ch-person-header .main-person { flex: 1; }
.wb-open-link { padding: 8px 10px; border: 1px solid #deded9; border-radius: 8px; background: #fff; font: inherit; font-size: 12px; white-space: nowrap; }
@media (max-width: 700px) { .ch-person-header { flex-wrap: wrap; gap: 8px; padding: 12px 14px; } .ch-person-header .main-person { flex-basis: 100%; } .ch-person-header .main-header-actions { margin-left: auto; } }
.ch-person-date-facts > span { min-width: 0; overflow-wrap: anywhere; }
.ch-source-date-conflict { margin-top: 12px; padding: 12px; border: 1px solid #dcd4c8; border-radius: 10px; background: #faf8f4; overflow-wrap: anywhere; }
.ch-source-date-conflict summary { font-weight: 600; }
.ch-source-date-conflict p { margin: 10px 0; }
.ch-source-date-conflict ul { margin: 0; padding-left: 18px; }
.ch-source-date-conflict li + li { margin-top: 10px; }
.ch-source-date-conflict li > :is(strong, span) { display: block; font-size: 12px; line-height: 1.5; }

.ch-draft-conflicts { flex: 0 0 auto; margin: 12px 14px; padding: 12px 14px; max-height: min(34vh, 320px); overflow: auto; border: 1px solid #ddd4c5; border-radius: 12px; background: #fcfaf4; color: #4e493f; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ch-draft-conflicts summary { font-size: 13px; font-weight: 600; }
.ch-draft-conflicts p { margin: 8px 0; }
.ch-draft-conflicts section + section { border-top: 1px solid #e6e0d4; margin-top: 12px; padding-top: 12px; }
.ch-draft-conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.ch-draft-conflict-actions button { padding: 7px 10px; border: 1px solid #d8d2c5; border-radius: 8px; background: #fff; color: inherit; font: inherit; cursor: pointer; }
.ch-draft-review-error { color: #78513d; }
.modal[data-modal-kind="draft-review"] textarea { resize: vertical; min-height: 90px; overflow: auto; white-space: pre-wrap; }
.checkin-workbench:has(> .ch-draft-conflicts) { grid-template-rows: auto minmax(0, 1fr); }
.checkin-workbench > .ch-draft-conflicts { grid-column: 1 / -1; max-height: min(25vh, 220px); }
@media (max-width: 600px) {
  .settings-row.ch-older-drafts-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .ch-older-drafts-row > .button { align-self: flex-start; min-height: 40px; }
}

/* Search stays beside the saved words and preserves the live input/editor. */
.people-pane > .search-wrap { margin-bottom: 7px; }
.people-search-help { margin: 0 16px 12px; color: #73736d; font-size: 11px; line-height: 1.45; }
.people-search-clear { position: absolute; right: 6px; top: 4px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: #56564f; cursor: pointer; }
@media (hover: hover) and (pointer: fine){.people-search-clear:hover { background: #efefeb; }}
.people-search-clear[hidden], #people-search-shortcut[hidden] { display: none; }
#people-search-count { text-align: right; }
.ps-match-preview { display: grid; min-width: 0; gap: 3px; margin-top: 5px; }
.ps-match-label { color: #66665f; font: 500 10px/1.35 var(--mono); }
.ps-match-excerpt { min-width: 0; color: #55554f; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.person-item .ps-match-excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ps-match-preview mark, .people-search-matches mark { padding: 0; border-radius: 2px; background: #eae7d7; color: #25251e; }
.people-search-matches { min-width: 0; margin: 0 0 18px; padding: 16px; border: 1px solid #e3e3dc; border-radius: 14px; background: #fbfbf8; background-image: linear-gradient(90deg, transparent calc(100% - 25px), #78786a06 calc(100% - 25px), #78786a06 calc(100% - 24px), transparent calc(100% - 24px)); }
.ps-matches-heading h3 { margin: 0; font-size: 15px; font-weight: 600; }
.ps-match-count { margin: 6px 0 12px; color: #6e6e65; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ps-match-count > span { color: #42423a; }
.ps-match-list { display: grid; gap: 8px; }
.ps-match { min-width: 0; border: 1px solid #e3e3dc; border-radius: 10px; background: #fff; }
.ps-match > summary { padding: 11px 12px; cursor: pointer; overflow-wrap: anywhere; }
.ps-match > summary > strong { margin-right: 8px; color: #65655c; font: 500 10px/1.5 var(--mono); }
.ps-match > summary > .ps-match-excerpt { display: block; margin: 5px 0 0 13px; }
.ps-match-body { padding: 0 12px 12px; }
.ps-match-text { max-height: min(34vh, 260px); overflow: auto; overscroll-behavior: contain; padding: 10px; border: 1px solid #ededE7; border-radius: 8px; color: #34342d; font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.ps-match-source-note { margin: 9px 0 0; color: #75756b; font-size: 11px; line-height: 1.5; }
.ps-match-source { margin-top: 10px; padding: 7px 10px; border: 1px solid #deded5; border-radius: 8px; background: #fff; color: #44443c; font: inherit; font-size: 12px; cursor: pointer; }
.ps-match-more { margin-top: 12px; }
.people-search-clear:focus-visible, .ps-match > summary:focus-visible, .ps-match-text:focus-visible, .ps-match-source:focus-visible { outline: 2px solid #45453b; outline-offset: 2px; }
@media (max-width: 680px) { .people-search-matches { padding: 12px; } .ps-match-source { min-height: 40px; } }

/* Literal retained words keep their own line and list boundaries. */
.ch-retained-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Retained context makes same-day manual updates distinguishable. */
.source-row .ch-source-summary { min-width: 0; flex: 1; }
.source-row .ch-source-summary > strong, .source-row small { overflow-wrap: anywhere; }
.ch-source-people { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.ch-source-people li { min-width: 0; }
.ch-source-people li > strong { font-size: 11px; overflow-wrap: anywhere; }
.ch-source-excerpt { white-space: pre-wrap; overflow-wrap: anywhere; font: 400 12px/1.55 var(--font); color: #50504e; margin: 4px 0; }
.ch-source-unlinked, .ch-source-other { color: #666662; font: 400 11px/1.5 var(--font); margin: 4px 0; }
.ch-source-removal-context { padding: 12px; margin: 14px 0; border: 1px solid #e6e6e2; border-radius: 12px; background: #fafaf8; }
.ch-source-removal-context .ch-source-people { margin: 0; }
.ch-source-excerpt { max-height: 8em; overflow-y: auto; }
.ch-source-saved-date { color: #60605b; font-size: 12px; }
.source-row .ch-remove-source { border-radius: 8px; min-height: 32px; color: #555551; }
@media (max-width: 480px) { .source-row { flex-wrap: wrap; align-items: flex-start; gap: 8px; }
  .source-row .ch-source-summary { flex-basis: calc(100% - 42px); }
  .source-row .ch-remove-source { margin-left: 39px; min-height: 40px; }
}

/* Preserve a current copy without leaving the incoming-backup review. */
.ch-backup-current { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 16px 0; padding: 12px; border: 1px solid #e4e4e0; border-radius: 12px; background: #fafaf8; }
.ch-backup-current > button { flex: 0 0 auto; min-height: 40px; }
.ch-backup-current > p { flex: 1 1 180px; margin: 0; color: #555551; font: 400 12px/1.55 var(--font); overflow-wrap: anywhere; }
@media (max-width: 480px) { .ch-backup-current { align-items: stretch; gap: 9px; }.ch-backup-current > button { justify-content: center; }.ch-backup-current > p { flex-basis: 100%; } }

/* Keep recovery scope and its two deliberate actions readable in narrow views. */
.ch-recovery-notice { align-items: flex-start; max-width: 720px; max-height: min(48dvh, 430px); overflow-y: auto; }
.ch-recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; max-width: 180px; }
.ch-recovery-actions .button { min-height: 40px; white-space: normal; text-align: left; }
@media (max-width: 680px) {
  .ch-recovery-actions { max-width: none; margin-top: 10px; }
  .ch-recovery-actions .button { margin-top: 0; }
}
.modal[data-modal-kind="discard-recovery-copy"] .modal-body > p { color: #555551; }

.tp-citation-impact { margin: -4px 0 16px; color: #555551; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.tp-citation-impact[hidden] { display: none; }

.tp-source-chat-time { color: #555551; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }

/* Unfinished fields stay discoverable without covering the current task. */
.ch-person-form-notice { flex: 0 0 auto; min-width: 0; margin: 12px 14px; padding: 12px 14px; max-height: min(32dvh, 300px); overflow: auto; border: 1px solid #deded8; border-radius: 12px; background: #fafaf8; color: #4b4b45; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.ch-person-form-notice summary { font-size: 13px; font-weight: 600; cursor: pointer; }
.ch-person-form-notice p { margin: 7px 0; }
.ch-person-form-notice section + section { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e5e5df; }
.ch-person-form-notice .ch-draft-conflict-actions { margin: 7px 0 9px; }
.ch-person-form-notice .ch-draft-conflict-actions button { min-height: 36px; border-color: #d8d8d1; }
.checkin-workbench:has(> .ch-workbench-notices) { grid-template-rows: auto minmax(0, 1fr); }
.checkin-workbench > .ch-workbench-notices { grid-column: 1 / -1; min-width: 0; max-height: min(30dvh, 280px); overflow: auto; }
.ch-workbench-notices > :is(.ch-draft-conflicts, .ch-person-form-notice) { max-height: none; }
.ch-person-form-reset-warning { margin: 16px 0; padding: 12px; border: 1px solid #deded8; border-radius: 12px; background: #fafaf8; overflow-wrap: anywhere; }
.ch-person-form-reset-warning h3 { margin: 0 0 7px; font-size: 14px; font-weight: 600; }
.ch-person-form-reset-warning p { margin: 0 0 10px; font-size: 12px; line-height: 1.6; }
.modal[data-modal-kind="person-form-recovery"] textarea { min-height: 80px; resize: vertical; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-authored-retention { min-width: 0; overflow-wrap: anywhere; }
.ch-authored-retention > p { color: #55554f; font-size: 12px; line-height: 1.6; }
.ch-retention-records { display: grid; gap: 10px; }
.ch-retention-record { min-width: 0; padding: 12px; border: 1px solid #deded8; border-radius: 12px; background: #fafaf8; }
.ch-retention-record h3 { margin: 0 0 6px; font-size: 14px; line-height: 1.45; }
.ch-retention-record strong, .ch-retention-record p, .ch-retention-record summary { font-size: 12px; line-height: 1.5; }
.ch-retention-date { color: #66665f; }
.ch-retention-words, .ch-retention-json { max-height: 160px; overflow: auto; overscroll-behavior: contain; margin: 5px 0 12px; padding: 8px; border: 1px solid #e4e4de; border-radius: 8px; background: #fff; color: #35352f; font: 400 12px/1.6 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-retention-json { font-family: var(--mono); font-size: 11px; }
.ch-retention-record summary { min-height: 44px; padding: 12px 0; cursor: pointer; }
.ch-retention-pages { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0; font-size: 12px; }
.ch-retention-pages button, .ch-retention-actions button { min-height: 44px; white-space: normal; }
.ch-retention-actions { flex-wrap: wrap; gap: 8px; }
.ch-retention-words:focus-visible, .ch-retention-json:focus-visible, .ch-retention-record summary:focus-visible { outline: 2px solid #45453b; outline-offset: 2px; }
@media (max-width: 600px) {
  .ch-retention-actions { position: sticky; bottom: 0; z-index: 1; align-items: stretch; padding: 12px 0 0; background: #fff; }
  .ch-retention-actions button { width: 100%; justify-content: center; }
  .ch-retention-record { padding: 10px; }
}
.ch-person-form-status { margin: 0 0 8px; color: #60605a; font-size: 12px; line-height: 1.5; }
@media (max-width: 600px) {
  .ch-person-form-notice { margin: 10px; padding: 10px 12px; max-height: 30dvh; }
  .ch-person-form-notice .ch-draft-conflict-actions button { min-height: 40px; }
  .modal[data-modal-kind="person-form-recovery"] .ch-draft-conflict-actions button { min-height: 40px; }
}
