.document-shelf { margin: 0 0 18px; border: 1px solid #dedbd5; border-radius: 14px; background: #fffefa; color: #252a28; overflow: hidden; scroll-margin-top: 80px; }
#site-header .document-shelf { margin: 18px 0 0; }
.document-shelf [hidden], .document-dialog [hidden] { display: none !important; }
.document-summary { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 16px; font-weight: 700; cursor: pointer; list-style: none; }
.document-summary::-webkit-details-marker { display: none; }
.document-summary::before { content: "›"; font-size: 22px; width: 12px; line-height: 1; }
.document-details[open] > .document-summary::before { transform: rotate(90deg); }
.document-count { font-size: 12px; font-weight: 600; border-radius: 12px; padding: 3px 8px; background: #f0ede7; }
.document-content { padding: 0 16px 12px; border-top: 1px solid #ede9e1; }
.document-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; }
.document-help, .document-meta { margin: 5px 0; font-size: 13px; line-height: 1.5; color: #626860; overflow-wrap: anywhere; }
.document-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid #ede9e1; }
.document-copy { min-width: 0; flex: 1; }
.document-title { color: #252a28; font-size: 15px; font-weight: 650; line-height: 1.5; overflow-wrap: anywhere; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.document-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px 10px; max-width: 48%; }
.document-button, .document-link { font: inherit; font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 40px; padding: 9px 12px; border-radius: 9px; }
.document-button { border: 1px solid #d8d4cd; background: #fffefa; color: #3b413c; cursor: pointer; white-space: normal; }
.document-button:hover { background: #f5f1e9; }
.document-button:disabled { opacity: .55; cursor: wait; }
.document-link { display: inline-flex; align-items: center; color: #9c3041; text-decoration: underline; text-underline-offset: 3px; }
.document-primary, .document-primary:hover { background: #ad3547; color: white; border-color: #ad3547; }
.document-button:focus-visible, .document-link:focus-visible, .document-summary:focus-visible, .document-title:focus-visible, .document-scope-link:focus-visible { outline: 3px solid #356da4; outline-offset: 3px; }
.document-scope-link { display: inline-flex; align-items: center; min-height: 40px; color: #9c3041; font-size: 14px; font-weight: 700; line-height: 1.4; text-decoration: underline; text-underline-offset: 3px; }
.document-card-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
.document-card-links .document-link { padding-left: 0; }
.document-archives { margin-top: 12px; }
.document-archives > summary { padding: 12px 0; cursor: pointer; font-size: 13px; color: #626860; }
.document-notice { margin: 0; padding: 12px 16px; color: #286247; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.document-retry { margin: 0 16px 12px; }
.document-error { color: #a22a3e !important; }
.document-dialog { box-sizing: border-box; width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 1px solid #d8d4cd; border-radius: 18px; background: #fffefa; color: #252a28; box-shadow: 0 20px 80px #18201840; overflow: auto; overscroll-behavior: contain; }
.document-dialog::backdrop { background: #18201866; }
.document-dialog *, .document-shelf * { box-sizing: border-box; }
.document-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px 12px; }
.document-dialog-head h2 { margin: 4px 0 0; font-size: 21px; line-height: 1.25; overflow-wrap: anywhere; }
.document-close { flex-shrink: 0; }
.document-form { padding: 0 20px 18px; }
.document-field { display: grid; gap: 7px; margin: 16px 0; font-size: 14px; font-weight: 600; }
.document-field input { width: 100%; min-width: 0; min-height: 44px; padding: 10px; border: 1px solid #b9bdb6; border-radius: 8px; background: white; color: #252a28; font: inherit; font-size: 16px; }
.document-field input:focus { outline: 2px solid #356da4; outline-offset: 1px; }
.document-field input[type=file] { font-size: 13px; }
.document-field input::file-selector-button { border: 0; border-radius: 5px; padding: 6px; margin-right: 8px; }
.document-source-tabs { display: flex; gap: 8px; margin: 16px 0; }
.document-source-tabs .document-button { flex: 1; }
.document-source-tabs [aria-pressed=true] { color: #9c3041; border-color: #b53c50; background: #fdf0f0; }
.document-checkbox { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; font-size: 14px; line-height: 1.5; }
.document-checkbox input { width: 19px; height: 19px; margin: 1px 0 0; flex: 0 0 auto; }
.document-dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 0 max(0px, env(safe-area-inset-bottom)); }
.document-dialog-actions .document-button { min-height: 44px; }
.document-form-status { min-height: 1em; margin: 10px 0 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.document-storage { margin-top: 18px; font-size: 12px; }
.document-history-list .document-link { flex-shrink: 0; }
.document-project-shelf > .document-details > .document-summary::before { content: none; }
.document-project-shelf > .document-details > .document-summary { gap: 8px; font-size: 14px; }
.document-project-shelf > .document-details > .document-summary > .document-count { margin-left: auto; background: none; color: #73766e; font-weight: 500; padding: 0; }
.document-summary-chevron { width: 20px; height: 20px; color: #73766e; flex: 0 0 auto; }
.document-details[open] > .document-summary > .document-summary-chevron { transform: rotate(180deg); }
.document-row.document-project-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 8px; padding: 10px 0; }
.document-project-row:first-child { border-top: 0; }
.document-open-row { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 52px; color: inherit; text-decoration: none; border-radius: 8px; }
.document-project-row:has(> .document-open-row:last-child) > .document-open-row { grid-column: 1 / -1; }
.document-open-row:hover .document-title { text-decoration: underline; }
.document-open-row .document-title { display: block; font-size: 15px; font-weight: 600; line-height: 1.45; }
.document-open-row .document-meta { margin: 4px 0 0; font-size: 12px; line-height: 1.4; color: #74786e; }
.document-type-icon { display: grid; place-items: center; width: 32px; height: 38px; border-radius: 7px; background: #f5f3ef; color: #777a71; flex: 0 0 auto; }
.document-icon { width: 20px; height: 20px; }
.document-open-arrow { width: 17px; height: 17px; margin-left: auto; color: #92958c; flex: 0 0 auto; }
.document-download { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 9px; color: #777a71; }
.document-download:hover { background: #f5f3ef; color: #9c3041; }
.document-open-row:focus-visible, .document-download:focus-visible { outline: 3px solid #356da4; outline-offset: 3px; }
.document-project-row > .document-actions { grid-column: 1 / -1; justify-content: flex-start; max-width: none; margin-left: 44px; padding-bottom: 3px; }
#site-header .document-project-shelf { border: 0; border-top: 1px solid #e9e7e1; border-radius: 0; background: transparent; overflow: visible; }
#site-header .document-project-shelf > .document-details > .document-summary { padding: 12px 0; }
#site-header .document-project-shelf > .document-details > .document-content { padding: 0; border-top: 0; }
@media print { .document-shelf, .document-dialog { display: none !important; } }
@media (max-width: 600px) {
  .document-row { flex-direction: column; gap: 4px; }
  .document-actions { max-width: none; justify-content: flex-start; }
  .document-toolbar { align-items: flex-start; }
  .document-toolbar > .document-button { flex-shrink: 0; max-width: 48%; }
  .document-dialog-head { padding: 16px 16px 10px; }
  .document-form { padding: 0 16px 14px; }
  .document-dialog-actions { justify-content: stretch; }
  .document-dialog-actions > * { flex: 1; }
}

/* Preserve the underlying list and give the reader its own scroll area. */
html.document-viewer-open { overflow: hidden; }
.document-viewer {
  position: fixed; inset: 0; box-sizing: border-box; margin: 0; padding: 0;
  width: 100%; max-width: none; height: 100vh; height: 100dvh; max-height: none;
  border: 0; border-radius: 0; color: #262522; background: #f5f3ee; overflow: hidden;
}
.document-viewer[open] { display: flex; flex-direction: column; }
.document-viewer::backdrop { background: #f5f3ee; }
.document-viewer-header {
  flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: #fff; border-bottom: 1px solid #dfdbd4;
}
.document-viewer-back, .document-viewer-control, .document-viewer-external-link {
  box-sizing: border-box; min-height: 44px; border: 1px solid #d8d2ca; border-radius: 9px;
  padding: 10px 14px; background: #fff; color: #a72539; font: inherit; font-weight: 700;
  cursor: pointer; text-align: center; text-decoration: none;
}
.document-viewer-back { background: #c83c4d; border-color: #c83c4d; color: #fff; }
.document-viewer-title { min-width: 0; margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.document-viewer-download { color: #a72539; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.document-viewer-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; background: #fff; border-bottom: 1px solid #dfdbd4; }
.document-viewer-control:disabled { color: #797570; cursor: default; background: #f2efea; }
.document-viewer-page-number { padding: 0 4px; font-size: 14px; }
.document-viewer-status { flex: none; margin: 12px 16px; line-height: 1.5; }
.document-viewer-status:empty { display: none; }
.document-viewer > .document-viewer-control { align-self: flex-start; margin: 0 16px 12px; }
.document-viewer-viewport { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px 12px max(16px, env(safe-area-inset-bottom)); }
.document-viewer-canvas { display: block; margin: 0 auto; background: #fff; box-shadow: 0 2px 10px #0002; max-width: none; }
.document-viewer-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.document-viewer-external { align-self: center; width: min(100%, 620px); box-sizing: border-box; padding: 24px; line-height: 1.6; }
.document-viewer-source { font-weight: 700; overflow-wrap: anywhere; }
.document-viewer-external-link { display: inline-flex; align-items: center; }
.document-viewer :focus-visible { outline: 3px solid #a72539; outline-offset: 3px; }
.document-viewer [hidden] { display: none !important; }
@media (max-width: 600px) {
  .document-viewer-header { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .document-viewer-back { justify-self: start; }
  .document-viewer-title { grid-column: 1 / -1; grid-row: 2; font-size: 16px; max-height: 3.9em; overflow: auto; }
  .document-viewer-toolbar { gap: 6px; }
  .document-viewer-control { padding: 8px 10px; font-size: 13px; }
}
@media print { .document-viewer { display: none !important; } }
