:root {
  font: 17px/1.5 system-ui, sans-serif;
  color: #212d30;
  background: #faf8f2;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3 { font-family: Georgia, serif; font-weight: normal; line-height: 1.18; }
p { margin: .4em 0 .85em; }
a { color: #065852; text-underline-offset: .2em; }
summary { color: #194844; font-weight: 650; }
summary + p { margin-top: 12px; }
:focus-visible { outline: 3px solid #977020; outline-offset: 3px; }

/* Das eigenständige Briefregister verwendet dasselbe Basisstylesheet. */
body:not(.briefanalyse) :is(header, main) { max-width: 1450px; margin: auto; padding: 25px clamp(20px,5vw,76px); }
body:not(.briefanalyse) header { border-bottom: 1px solid #cdcfc5; }
body:not(.briefanalyse) h1 { font-size: clamp(36px,4.2vw,62px); margin: 2px 0 16px; }
body:not(.briefanalyse) nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
body:not(.briefanalyse) nav a { margin-left: 5px; }
@media (max-width: 820px) {
  body:not(.briefanalyse) :is(header, main) { padding: 18px; }
}

.briefanalyse {
  --wine: #63283b;
  --deep: #44202e;
  --ink: #2e2927;
  --muted: #645d56;
  --line: #d5cdc2;
  --paper: #fffcf6;
  --ground: #f4f0e8;
  color: var(--ink);
  background: var(--ground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}
.briefanalyse [hidden] { display: none !important; }
.briefanalyse .frame { max-width: 1460px; margin-inline: auto; padding-inline: clamp(20px,3.8vw,64px); }
.briefanalyse button {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 14px;
  background: var(--paper);
  line-height: 1.3;
  min-height: 42px;
}
.briefanalyse button:hover:enabled { background: #efe6dc; border-color: #9a817b; }
.briefanalyse button:disabled { color: #79716b; background: transparent; }
.briefanalyse :focus-visible { outline-color: #9b551a; }
.briefanalyse a { color: var(--wine); }
.briefanalyse summary { color: var(--wine); }

.masthead { color: #fff8ee; background: var(--deep); }
.masthead .frame { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.mast-title { position: relative; min-width: 245px; padding: 13px 0 12px; }
.mark { color: #eedac9; font-size: 16px; font-weight: 600; letter-spacing: .025em; }
.mast-title h1 { text-wrap: balance; font-size: clamp(38px,3.9vw,54px); line-height: 1; margin: 2px 0 0; letter-spacing: -.045em; }
.postal { transform: scale(.72); transform-origin: left center; pointer-events: none; position: absolute; left: calc(100% + 16px); top: 20px; width: 95px; height: 62px; color: #d9ad99; opacity: .85; }
.envelope {
  position: absolute; inset: 4px 2px auto auto; width: 88px; height: 54px;
  border: 1px solid currentColor; transform: rotate(-9deg); overflow: hidden;
  background: linear-gradient(145deg,#773f4a,#61313e);
}
.envelope::before { content: ""; position: absolute; left: 10px; bottom: 12px; width: 34px; height: 10px; border-block: 1px solid currentColor; }
.stamp { position: absolute; right: 10px; top: 5px; width: 25px; height: 29px; color: #653344; background: #e0bda2; border: 2px dotted #773f4a; transform: rotate(-9deg); }
.stamp::before { content: "SR"; position: absolute; inset: 1px; display: grid; place-items: center; font: italic 12px Georgia,serif; }
.postmark { position: absolute; right: 27px; top: 11px; width: 27px; height: 27px; border: 2px double currentColor; border-radius: 50%; transform: rotate(-9deg); }
.postmark::before { content: ""; position: absolute; top: 5px; right: 23px; width: 38px; height: 11px; background: repeating-linear-gradient(to bottom,currentColor 0 1px,transparent 1px 4px); }
.masthead nav, .tabs, .related { display: flex; align-items: center; }
.masthead nav { gap: clamp(15px,2.2vw,32px); flex-wrap: wrap; justify-content: flex-end; }
.tabs { gap: 4px; align-self: end; }
.masthead .tabs button { border: 0; color: #f1ded3; border-radius: 6px 6px 0 0; padding: 10px 16px; background: #623646; font-weight: 600; }
.masthead .tabs button:hover { background: #754958; }
.masthead .tabs button[aria-pressed="true"] { color: var(--wine); background: var(--ground); }
.masthead .tabs .kartentab { display: inline-flex; align-items: center; align-self: stretch; padding: 10px 16px; border-radius: 6px 6px 0 0; color: #f1ded3; background: #623646; font-weight: 600; text-decoration: none; }
.masthead .tabs .kartentab:hover { background: #754958; }
.related { gap: 18px; padding-bottom: 10px; }
.related a { color: #fff4e6; text-decoration-color: #bb958b; white-space: nowrap; }
.masthead :focus-visible { outline-color: #efbb72; outline-offset: -3px; }

#suchform {
  display: grid;
  grid-template-columns: minmax(240px,1.5fr) minmax(250px,1fr) minmax(165px,.7fr) auto;
  align-items: end;
  gap: 14px;
  padding: 17px 0 20px;
  border-bottom: 1px solid var(--line);
}
#suchform label { display: grid; min-width: 0; gap: 4px; font-size: 16px; font-weight: 650; }
#suchform :is(input,select,button) { width: 100%; min-width: 0; height: 46px; border-radius: 5px; }
#suchform :is(input,select) { border: 1px solid #afa499; background-color: var(--paper); padding: 0 12px; font-weight: 400; font-size: 17px; }
#suchform select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg,transparent 50%,#645d56 50%),linear-gradient(135deg,#645d56 50%,transparent 50%); background-position: calc(100% - 17px) 52%,calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
#suchform input::placeholder { color: #766d65; opacity: 1; }
#suchform .go { width: auto; padding-inline: 21px; color: #fff; background: var(--wine); border-color: var(--wine); font-weight: 650; }
#suchform .go:hover { background: var(--deep); }

.layout { margin: 22px 0 36px; }
.layout.has-selection {
  display: grid;
  grid-template-columns: minmax(0,.86fr) minmax(0,1.34fr);
  align-items: start;
  gap: clamp(24px,3vw,44px);
}
.results { max-width: 960px; min-width: 0; }
.layout.has-selection .results { max-width: none; }
.list-head { display: flex; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 11px; }
.list-head h2 { font-size: clamp(27px,2vw,32px); margin: 0; }
#anzahl, .meta, .signature { color: var(--muted); }
#anzahl { font-size: 16px; margin: 0; font-variant-numeric: tabular-nums; }
#treffer { border-top: 1px solid var(--line); }
#treffer .hit {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 8px 22px;
  width: 100%;
  min-height: 62px;
  text-align: left;
  padding: 11px 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
#treffer .hit:hover { background: #eae3da; }
#treffer .hit[aria-pressed="true"] { box-shadow: inset 3px 0 var(--wine); background: #ecdee0; }
.hit-title { font-weight: 650; line-height: 1.38; overflow-wrap: break-word; }
.hit .meta { font-size: 16px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.layout.has-selection .hit { grid-template-columns: minmax(0,1fr) !important; gap: 3px !important; }
.empty-action { margin-top: 16px; }
.pager { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 15px; }

#detail {
  min-width: 0;
  padding: clamp(24px,3vw,42px);
  border: 1px solid var(--line);
  border-top: 3px solid var(--wine);
  background: var(--paper);
  overflow-wrap: break-word;
  scroll-margin-top: 16px;
}
#detail:focus:not(:focus-visible) { outline: 0; }
#detail h2 { margin: 0 0 .32em; font-size: clamp(29px,2.6vw,40px); letter-spacing: -.03em; }
#detail h3 { font-size: 1.4rem; margin: 24px 0 10px; }
#detail p { max-width: 65ch; }
.pair-title {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  gap: 12px;
  align-items: start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.party { display: grid; gap: 4px; min-width: 0; }
.role { font: 650 16px/1.35 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; color: var(--muted); letter-spacing: 0; }
.person-name { font: normal clamp(26px,2.25vw,34px)/1.15 Georgia,serif; letter-spacing: -.025em; }
.pair-arrow { color: var(--wine); font: normal 25px/1 Georgia,serif; margin-top: 27px; }
.selection-context { margin: 13px 0 9px; font-size: 16px; color: var(--muted); }
.self-note { padding-left: 12px; border-left: 2px solid var(--wine); font-size: 16px; }
.periods { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.period-item { display: grid; gap: 2px; }
.period-label { color: var(--muted); font-size: 16px; }
.period-item strong { font-size: 21px; line-height: 1.3; font-weight: 650; font-variant-numeric: tabular-nums; }
.other-dates, .outside-date { font-size: 16px; margin: 13px 0 0; }
.outside-date { padding-left: 12px; border-left: 2px solid var(--wine); }
.outside-date button { border: 0; padding: 0; min-height: 0; background: none; color: var(--wine); text-decoration: underline; text-underline-offset: .18em; }
.outside-date button:hover { background: none; }

.source-table { width: 100%; margin-top: 23px; border-collapse: collapse; border-spacing: 0; table-layout: auto; }
.source-table caption { text-align: left; margin-bottom: 9px; font: normal 1.4rem/1.2 Georgia,serif; }
.source-table th { text-align: left; color: var(--muted); font-size: 16px; font-weight: 650; padding: 8px 10px 9px 0; border-bottom: 1px solid var(--line); }
.source-table td { vertical-align: top; padding: 11px 10px 11px 0; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.4; }
.source-table td:first-child { font-variant-numeric: tabular-nums; }
.source-table td:last-child, .source-table th:last-child { padding-right: 0; }
.source-link { border: 0 !important; padding: 0 !important; min-height: 0 !important; background: none !important; color: var(--wine) !important; text-decoration: underline; text-align: left; text-underline-offset: .18em; overflow-wrap: anywhere; }
.source-link:hover { color: var(--deep) !important; }
.cell-note { display: block; color: var(--muted); font-size: 16px; margin-top: 2px; white-space: normal; }
.table-note { color: var(--muted); font-size: 16px; margin-top: 12px; }
.more-sources { margin-top: 16px; }

.folio { margin: 0 0 12px; font-weight: 650; color: var(--wine); }
.signature { margin: 0; }
.people { display: grid; grid-template-columns: max-content minmax(0,1fr); gap: 10px 20px; margin: 24px 0 0; padding: 20px 0; border-block: 1px solid var(--line); }
.people dt { font-weight: 650; }
.people dd { margin: 0; }
.note { color: var(--muted); }
.provenance { border-top: 1px solid var(--line); margin: 22px 0 0; padding-top: 13px; }
.briefanalyse details[open] summary { margin-bottom: 10px; }
.list-links { list-style: none; margin: 0; padding: 0; }
.list-links li { padding: 12px 0; border-top: 1px solid var(--line); }
.back { margin-bottom: 16px; }
#methode { border-top: 1px solid var(--line); padding: 16px 0 28px; }
#methode p { max-width: 80ch; }
.mobile-back { display: none; }

@media (max-width: 1520px) {
  .postal { display: none; }
}
@media (max-width: 1260px) {
  .masthead .frame { display: block; }
  .mast-title { padding-bottom: 7px; }
  .masthead nav { justify-content: space-between; }
  .related { padding-bottom: 8px; }
}
@media (max-width: 1100px) {
  #suchform { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; grid-template-areas: "query query go" "scope holding ."; gap: 10px 12px; padding: 14px 0 17px; }
  .query-field { grid-area: query; }
  .scope-field { grid-area: scope; }
  .holding-field { grid-area: holding; }
  #suchform .go { grid-area: go; }
  .layout.has-selection { display: block; }
  .layout.has-selection .results { display: none; }
  .layout.has-selection .mobile-back { display: inline-block; margin-bottom: 16px; }
  main:has(.layout.has-selection) #suchform { display: none; }
}
@media (max-width: 660px) {
  .briefanalyse .frame { padding-inline: 17px; }
  .mast-title h1 { font-size: 40px; }
  .masthead nav { gap: 0; }
  .related { width: 100%; padding: 9px 0; gap: 16px; }
  .masthead .tabs button, .masthead .tabs .kartentab { border-radius: 5px 5px 0 0; padding: 9px 13px; }
  #suchform { grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "query go" "scope scope" "holding holding"; }
  #suchform .go { padding-inline: 15px; }
  .list-head { display: block; }
  #anzahl { margin-top: 3px; }
  #treffer .hit { grid-template-columns: minmax(0,1fr); gap: 3px; }
  #detail { padding: 21px; }
  .pair-title { grid-template-columns: minmax(0,1fr); gap: 5px; }
  .pair-arrow { transform: rotate(90deg); justify-self: start; margin-top: 0; }
  .periods { gap: 10px; }
  .period-item strong { font-size: 19px; }
  .source-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .source-table tbody tr { display: block; padding: 10px 0; border-top: 1px solid var(--line); }
  .source-table td { display: block; padding: 2px 0; border: 0; white-space: normal !important; }
  .source-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 650; }
  .source-table td:last-child { padding-right: 0; }
  .people { grid-template-columns: minmax(0,1fr); gap: 0; }
  .people dd + dt { margin-top: 12px; }
}
@media (max-width: 520px) {
  .tabs { flex-wrap: wrap; }
  #suchform { grid-template-columns: minmax(0,1fr); grid-template-areas: "query" "scope" "holding" "go"; }
  #suchform .go { width: 100%; }
}
@media (max-width: 380px) {
  .mast-title h1 { font-size: 36px; }
  .periods { grid-template-columns: minmax(0,1fr); }
}
@media (forced-colors: active) {
  #treffer button[aria-pressed="true"], .tabs button[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -3px; }
}
.tabs .kartentab { align-self:stretch; display:flex; align-items:center; padding:8px 16px; background:#623646; color:#fff8ef; font-weight:600; text-decoration:none; border-radius:7px 7px 0 0; }
.tabs .kartentab:hover { background:#754958; text-decoration:underline; }
@media(max-width:560px) { .masthead .tabs {flex-wrap:wrap;} .masthead .tabs .kartentab {padding:8px 10px;border-radius:5px;} }

.catalog-filter-toggle { display: none; }
.catalog-mode .results { max-width: none; }
.catalog-mode #treffer .hit {
  grid-template-columns: minmax(0,1fr) minmax(12ch,auto) minmax(14ch,21%);
  gap: 10px 28px;
  padding: 14px 12px;
}
.catalog-mode .hit-title { font-size: 19px; }
.hit-date, .hit-signature { color: var(--muted); font-size: 17px; overflow-wrap: anywhere; }
.hit-date { font-variant-numeric: tabular-nums; }
.catalog-mode .layout.has-selection { display: block; }
.catalog-mode .layout.has-selection .results,
.catalog-mode:has(.layout.has-selection) :is(#suchform,#methode) { display: none; }
.catalog-mode #detail {
  max-width: 850px;
  margin-inline: auto;
  padding: clamp(22px,4vw,54px);
}
.catalog-mode #detail .mobile-back { display: inline-flex; align-items: center; margin-bottom: 24px; }
.catalog-mode #detail h2 { font-size: clamp(31px,4vw,48px); }
.catalog-mode #detail .folio { margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.catalog-mode #detail .people { margin: 21px 0; padding-block: 16px; }
.catalog-mode #detail .list-links li { border: 0; padding: 0 0 8px; }
.original-link { display: inline-flex; align-items: center; min-height: 44px; }
.catalog-mode #detail .original-link {
  padding: 9px 17px;
  color: #fff;
  background: var(--wine);
  border-radius: 5px;
  font-weight: 650;
  text-decoration: none;
}
.catalog-mode #detail .original-link:hover { background: var(--deep); text-decoration: underline; }
@media (max-width: 660px) {
  .catalog-mode #suchform {
    grid-template-columns: minmax(0,1fr) auto;
    grid-template-areas: "query go" "filters filters";
    gap: 8px;
  }
  .catalog-mode #suchform.show-catalog-filters { grid-template-areas: "query go" "filters filters" "scope scope" "holding holding"; }
  .catalog-mode #suchform .catalog-filter-toggle {
    display: inline-flex;
    grid-area: filters;
    align-items: center;
    justify-self: start;
    width: auto;
    color: var(--wine);
    border: 0;
    background: none;
    padding: 0 4px;
    font-weight: 600;
  }
  .catalog-filter-toggle::after { content: "▾"; margin-left: 8px; }
  .catalog-filter-toggle[aria-expanded="true"]::after { content: "▴"; }
  .catalog-mode #suchform:not(.show-catalog-filters) :is(.scope-field,.holding-field) { display: none; }
  .catalog-mode #treffer .hit { grid-template-columns: auto minmax(0,1fr); gap: 4px 16px; padding: 13px 4px; }
  .catalog-mode .hit-title { grid-column: 1 / -1; }
  .catalog-mode #detail { padding: 20px; }
}
