:root {
  --bg: #edf2f7;
  --paper: #fff;
  --ink: #162536;
  --muted: #526477;
  --line: #d9e3ec;
  --accent: #125e7c;
  --accent-dark: #0d4d67;
  --accent-light: #e4f2f8;
  --night: #152d42;
  --green: #175846;
  --shadow: 0 10px 32px rgb(16 39 61 / 6%);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .50; }
a { color: var(--accent-dark); }
:focus-visible { outline: 3px solid #0087af; outline-offset: 3px; }
.shell { width: min(1300px, 100% - 64px); margin-inline: auto; }
.main { padding: 32px 0 52px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.12; letter-spacing: -.04em; }
h2 { font-size: 1.165rem; letter-spacing: -.014em; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip:focus { position: absolute; inset: .5rem auto auto .5rem; z-index: 2; padding: .5rem .8rem; background: white; }
.muted { color: var(--muted); }
.message, .muted { font-size: .925rem; }
.message.error { color: #8d262e; }

.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-content { min-height: 69px; display: flex; align-items: center; gap: clamp(1rem, 2vw, 2rem); }
.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); font-weight: 750; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
.brand-mark { display: inline-flex; align-items: flex-end; gap: 3px; padding: 9px; height: 37px; width: 37px; border-radius: 10px; background: var(--night); }
.brand-mark i { height: 7px; width: 4px; border-radius: 1px; background: #77d2e7; }
.brand-mark i:nth-child(2) { height: 12px; }
.brand-mark i:nth-child(3) { height: 18px; }
nav { display: flex; gap: clamp(.7rem, 1.2vw, 1.3rem); align-self: stretch; }
nav a { display: flex; align-items: center; color: var(--muted); border-bottom: 3px solid transparent; padding-top: 3px; font-size: .94rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
nav a:hover, nav a[aria-current="page"] { color: var(--accent-dark); }
nav a[aria-current="page"] { border-color: var(--accent); }
.account { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.local-tag { background: #e8f3ef; color: var(--green); display: inline-block; white-space: nowrap; border-radius: 20px; padding: .25rem .68rem; font-size: .83rem; font-weight: 650; }
#konto-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.text-button { color: var(--accent-dark); border: 0; padding: .25rem 0; background: none; text-align: left; font-size: .9rem; text-decoration: underline; text-underline-offset: .2em; }
.primary, .outline { min-height: 42px; border-radius: 8px; padding: .55rem 1rem; font-weight: 650; border: 1px solid transparent; white-space: nowrap; }
.primary { background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.outline { color: var(--accent-dark); background: #fff; border-color: #b9cddd; }
.outline:hover:not(:disabled) { background: var(--accent-light); }
input, select, textarea { border: 1px solid #b7c7d6; border-radius: 8px; min-width: 0; padding: .62rem .76rem; color: var(--ink); background: white; }
input::placeholder { color: #607286; }

.login { max-width: 680px; margin: 9vh auto; background: white; border: 1px solid var(--line); border-top: 5px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow); padding: clamp(1.5rem, 6vw, 3.2rem); }
.login h1 { margin: 1rem 0; }
.login > p { color: var(--muted); max-width: 34rem; }
.login form { display: grid; max-width: 25rem; gap: .8rem; margin-top: 1.2rem; }
.login form button { justify-self: start; margin-top: .2rem; }
#konto-wechsel { margin-top: .85rem; }
.login .message:not(:empty) { margin-top: .75rem; }

.hero { border-radius: 16px; background: linear-gradient(115deg, #132b40, #173a54); padding: clamp(1.45rem, 3.3vw, 2.8rem); color: white; box-shadow: var(--shadow); }
.hero > p { color: #d2e4ef; margin: .7rem 0 1.45rem; }
.searchline { display: flex; border-radius: 9px; background: white; padding: 5px; gap: .5rem; max-width: 920px; }
.searchline input { flex: 1 1 100px; border: 0; padding: .63rem .8rem; }
.searchline select { max-width: 11rem; }
.searchline .primary { min-width: 108px; }
.fachfilter { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .7fr) minmax(0, 1.4fr) auto; align-items: end; gap: .6rem; margin-top: .75rem; max-width: 920px; }
.fachfilter label { min-width: 0; display: grid; gap: .26rem; color: #e8f7ff; font-size: .86rem; font-weight: 650; }
.fachfilter select { width: 100%; min-height: 40px; padding: .46rem .6rem; font-weight: 450; font-size: .93rem; }
#filter-reset { justify-self: start; min-height: 40px; border: 0; background: none; color: #e8f7ff; padding: .3rem .35rem; font-size: .86rem; text-decoration: underline; text-underline-offset: .2em; }
.fachfilter-status { margin-top: .5rem; color: #ffe0d7; font-size: .875rem; }
.fachfilter-status:empty { display: none; }
.search-controls { display: flex; align-items: flex-start; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .85rem; max-width: 920px; }
.sprachen { display: inline-flex; align-items: center; gap: .45rem; min-height: 30px; color: #e8f7ff; font-size: .87rem; cursor: pointer; }
.sprachen input { width: 1rem; height: 1rem; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; }
.examples { display: flex; gap: .45rem; flex-wrap: wrap; }
.examples button, .filters summary { color: #e8f7ff; background: #21465e; border: 1px solid #517287; border-radius: 7px; padding: .29rem .66rem; font-size: .87rem; }
.examples button:hover, .filters summary:hover { background: #2d5670; }
.filters { margin-left: auto; }
.filters summary { cursor: pointer; width: fit-content; margin-left: auto; }
.filters[open] { flex-basis: 100%; }
.filter-fields { color: var(--ink); background: #f5f9fd; border-radius: 9px; padding: .9rem; margin-top: .55rem; display: grid; grid-template-columns: 1.4fr 1fr .8fr; gap: .75rem; align-items: end; }
.filter-fields label { display: grid; gap: .3rem; font-weight: 650; font-size: .86rem; }
.filter-fields input, .filter-fields select { font-weight: 400; font-size: .92rem; }
.collection-info { display: flex; gap: .5rem 2rem; flex-wrap: wrap; margin: 0; padding: 1rem .15rem; }
.collection-info div { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem; }
.collection-info dt { color: var(--muted); font-size: .875rem; }
.collection-info dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 675; font-size: .93rem; }

.research-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.direkte-fundstelle :is(.hero, .collection-info, .results) { display: none; }
.direkte-fundstelle .research-grid { grid-template-columns: minmax(0, 1fr); }
.direkte-fundstelle #details { position: static; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); min-width: 0; }
.card-heading { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-heading .muted:not(:empty) { margin-top: .25rem; }
.result-list, .files { list-style: none; padding: 0; margin: 0; }
.result-list li + li { border-top: 1px solid var(--line); }
.result-pages { display: flex; justify-content: space-between; gap: .5rem; padding: .8rem 1.25rem; border-top: 1px solid var(--line); }
.result { width: 100%; display: block; text-align: left; padding: .9rem 1.25rem; border: 0; border-left: 4px solid transparent; color: var(--ink); background: transparent; }
.result:hover { background: #f3f8fc; }
.result[aria-pressed="true"] { background: #ebf5fb; border-left-color: #187594; }
.result-meta { display: flex; flex-wrap: wrap; gap: .35rem .6rem; align-items: center; color: var(--muted); font-size: .86rem; }
.badge { border-radius: 5px; background: var(--accent-light); color: var(--accent-dark); font-weight: 675; padding: .16rem .45rem; font-size: .82rem; }
.result-title { display: block; font-weight: 690; line-height: 1.36; margin: .38rem 0 .18rem; overflow-wrap: anywhere; }
.excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted); font-size: .92rem; }
mark { background: #fff0b0; color: var(--ink); border-radius: 2px; }
.details { position: sticky; top: 16px; }
.details-content:not(:empty) { padding: 1.15rem 1.25rem 1.25rem; }
.details-content h3 { font-size: 1.125rem; margin: .55rem 0; line-height: 1.35; overflow-wrap: anywhere; }
.document-label { font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .85rem; margin: 1rem 0 .9rem; }
.doc-actions a { font-weight: 630; font-size: .9rem; }
.doc-actions a.outline { min-height: unset; text-decoration: none; }
.source-text { max-height: 49vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin: 0; background: #f6f9fc; padding: .8rem; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .94rem; }
.source-text:empty { display: none; }
.context-button { margin-top: .7rem; }

.secondary-page { max-width: 970px; margin-inline: auto; }
.page-heading { margin-bottom: 1.35rem; }
.page-heading p { margin-top: .6rem; color: var(--muted); }
.fragen-form, .fragen-ergebnis { padding: clamp(1rem, 4vw, 1.5rem); }
.fragen-form { display: grid; gap: .85rem; }
.fragen-form textarea { width: 100%; resize: vertical; font-weight: 400; }
.fragen-bedienung { display: flex; align-items: end; flex-wrap: wrap; gap: .7rem; }
.fragen-bedienung label { flex: 1 1 14rem; max-width: 28rem; }
#fragen-status:empty { display: none; }
.fragen-ergebnis { margin-top: 1rem; overflow-wrap: anywhere; }
#fragen-bereich { margin-top: .25rem; }
#fragen-antwort p { margin-top: .8rem; white-space: pre-wrap; }
.fragen-beleg { display: inline-block; margin-left: .36em; font-size: .85rem; font-weight: 650; }
#fragen-belege { border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: .85rem; }
#fragen-belege h3 { margin: 0 0 .5rem; font-size: 1rem; }
#fragen-quellen { margin: 0; padding-left: 1.5rem; }
#fragen-quellen li + li { margin-top: .7rem; }
#fragen-quellen .fragen-original { display: inline-block; margin-top: .2rem; font-size: .875rem; }
.upload-card, .connection, .tool-card { padding: clamp(1rem, 3.3vw, 1.6rem); }
.drop { border: 2px dashed #b5cbdc; border-radius: 11px; background: #f6fafd; padding: 1.5rem 1rem; text-align: center; }
.drop.dragging { background: #e6f6fb; border-color: var(--accent); }
.upload-icon { display: block; width: 28px; height: 22px; margin: .25rem auto .85rem; border: 2px solid #347c99; border-radius: 4px; position: relative; }
.upload-icon::before { content: ""; position: absolute; width: 10px; left: 9px; top: -7px; height: 9px; background: #f6fafd; border-left: 2px solid #347c99; border-top: 2px solid #347c99; transform: rotate(45deg); }
.drop p { color: var(--muted); margin: .4rem 0 .85rem; font-size: .92rem; }
.upload-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; margin-top: .9rem; }
.files li { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .3rem .9rem; padding: .8rem .1rem; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.files li:last-child { border-bottom: 0; }
.files strong { overflow-wrap: anywhere; min-width: 0; font-size: .96rem; }
.file-meta { font-size: .87rem; color: var(--muted); }
.intake { margin-top: 1.15rem; }
.intake .files, .empty { margin: 0 1.25rem; }
.empty:not(:empty) { padding: .8rem 0; }
.files .upload-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem 1.1rem; }
.upload-details .file-meta { margin-top: .22rem; }
.upload-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .35rem .65rem; font-size: .875rem; }
.upload-durchsuchbar { background: #e8f3ef; color: var(--green); }
.upload-fehler { background: #faebeb; color: #8d262e; }
.connection > h2 { margin-bottom: .85rem; }
.connection label { display: block; margin-top: .8rem; font-weight: 650; font-size: .94rem; }
.copy-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .35rem 0 .75rem; }
.copy-row input { flex: 1 1 260px; }
.connection .message:not(:empty) { margin-top: .7rem; }
.tools-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1rem; }
.tool-card p { color: var(--muted); margin-top: .36rem; }

.figure-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; max-width: 920px; margin-top: .85rem; }
.figure-filter { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .55rem; font-size: .88rem; color: #e8f7ff; }
.figure-filter input { padding: .37rem .6rem; max-width: 13rem; font-size: .91rem; }
.figure-status { min-height: 2.9rem; padding: .85rem .15rem .7rem; color: var(--muted); }
.figure-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; list-style: none; margin: 0; padding: 0; }
.figure-card { display: flex; flex-direction: column; overflow: hidden; }
.figure-preview { display: block; position: relative; overflow: hidden; aspect-ratio: 1.48; background: #f6f9fc; border-bottom: 1px solid var(--line); }
.figure-preview:hover { background: #eaf3f9; }
.figure-preview:focus-visible { outline-offset: -4px; }
.figure-preview img { position: absolute; inset: .65rem; width: calc(100% - 1.3rem); height: calc(100% - 1.3rem); object-fit: contain; }
.figure-preview img[hidden] { display: none; }
.figure-preview .muted { position: absolute; inset: .65rem; display: grid; place-items: center; text-align: center; }
.figure-info { display: flex; flex-direction: column; flex: 1; padding: .9rem 1rem 1rem; }
.figure-info h2 { margin: .48rem 0 .3rem; font-size: 1.02rem; line-height: 1.34; overflow-wrap: anywhere; }
.figure-document { margin-bottom: .8rem; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.figure-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: auto; }
.figure-open, .figure-actions .merk-knopf { min-height: 38px; padding: .42rem .72rem; font-size: .9rem; text-decoration: none; }

.merk-knopf.gemerkt { opacity: 1; color: var(--accent-dark); background: var(--accent-light); }
.themen-quellen .merk-knopf { margin-top: .6rem; }
.merk-status:empty, .merk-hinweis:empty { display: none; }
.merk-liste { display: grid; gap: .8rem; list-style: none; margin: 0; padding: 0; }
.merk-zeile { display: flex; align-items: flex-start; gap: 1rem; padding: 1.15rem; }
.merk-inhalt { min-width: 0; }
.merk-inhalt h2 { margin: .35rem 0; overflow-wrap: anywhere; }
.merk-auszug { overflow-wrap: anywhere; }
.merk-vorschau { width: clamp(100px, 18vw, 170px); aspect-ratio: 1.4; object-fit: contain; background: #f6f9fc; border: 1px solid var(--line); border-radius: 8px; }
.merk-aktionen { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; margin-top: .9rem; }
.merk-aktionen .outline { text-decoration: none; display: inline-flex; align-items: center; }
.merk-kopierfeld { padding: .85rem 1rem; margin-bottom: .8rem; }
.merk-kopierfeld label { display: block; font-weight: 650; margin-bottom: .35rem; }
.merk-kopierfeld textarea { width: 100%; resize: vertical; }
.merk-projekte { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: .55rem 1rem; padding: .85rem 1rem; margin-bottom: .8rem; }
.merk-projekte > label { flex: 1 1 14rem; max-width: 27rem; }
.merk-projekte summary { width: fit-content; cursor: pointer; font-size: .9rem; }
.merk-projekte details[open] { flex-basis: 100%; }
#merk-projekt-form { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; margin-top: .6rem; }
#merk-projekt-form label { flex: 1 1 12rem; max-width: 26rem; }
.merk-projektliste { margin-top: .55rem; overflow-wrap: anywhere; }
:is(.anmerkung-dialog, .projekt-dialog) { width: min(590px, calc(100% - 32px)); max-height: calc(100% - 32px); border: 1px solid var(--line); border-radius: 13px; padding: 1.2rem; color: var(--ink); box-shadow: var(--shadow); }
:is(.anmerkung-dialog, .projekt-dialog)::backdrop { background: rgb(18 35 52 / 56%); }
:is(.anmerkung-dialog, .projekt-dialog) form { display: grid; gap: .65rem; }
.anmerkung-dialog textarea, .upload-entwurf textarea { width: 100%; resize: vertical; font-weight: 400; }
#anmerkung-dokument { overflow-wrap: anywhere; }
#merk-loeschen-bestaetigung { display: grid; gap: .65rem; }
#merk-projekt-loeschen { color: #8d262e; margin-left: auto; }
#merk-loeschen-bestaetigen { background: #a32e37; }
#merk-loeschen-bestaetigen:hover:not(:disabled) { background: #80232b; }
#merk-bearbeiten-status:not(:empty) { margin-top: .65rem; }
#anmerkung-status:empty, #merk-bearbeiten-status:empty, #merk-bearbeiten-info:empty, #merk-zuordnung-status:empty { display: none; }
#merk-projektauswahl { display: grid; gap: .6rem; }
#merk-zuordnung-quelle { overflow-wrap: anywhere; }
.merk-projektgruppe { min-inline-size: 0; margin: 0; padding: .3rem .8rem .65rem; border: 1px solid var(--line); border-radius: 8px; }
.merk-projektgruppe legend { font-size: .94rem; font-weight: 650; padding: 0 .3rem; }
.merk-projektgruppe label { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; overflow-wrap: anywhere; }
.merk-projektgruppe input { flex: none; accent-color: var(--accent); }
.merk-projektgruppe .muted { margin: .1rem 0 .35rem; }
.anmerkung-aktionen { display: flex; flex-wrap: wrap; gap: .55rem; }
.upload-entwurf { flex-basis: 100%; min-width: 0; }
.upload-entwurf .text-button { margin-top: .35rem; }
.upload-entwurf .file-meta { margin-top: .3rem; }
.merk-hinweis { position: fixed; z-index: 5; right: 1rem; bottom: 1rem; max-width: calc(100% - 2rem); color: var(--ink); background: var(--paper); box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 9px; padding: .6rem .9rem; pointer-events: none; }

@media (max-width: 1000px) {
  .shell { width: calc(100% - 40px); }
  .topbar-content { gap: 1rem; }
  nav { gap: .8rem; }
  .account .local-tag { display: none; }
}

@media (max-width: 930px) { .figure-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 1280px) {
  .topbar-content { flex-wrap: wrap; justify-content: space-between; padding-top: .6rem; gap: .3rem; }
  nav { width: 100%; order: 3; gap: 0 .85rem; flex-wrap: wrap; }
  nav a { min-height: 43px; font-size: .89rem; }
}

@media (max-width: 760px) {
  .shell { width: calc(100% - 28px); }
  .main { padding-top: 18px; }
  .hero { padding: 1.2rem; }
  .hero > p { margin-bottom: 1rem; }
  .searchline .primary { min-width: unset; }
  .research-grid, .tools-grid { grid-template-columns: 1fr; gap: .9rem; }
  .details { position: static; }
  .filter-fields { grid-template-columns: 1fr; }
  .collection-info { gap: .25rem 1rem; }
  .collection-info dt, .collection-info dd { font-size: .83rem; }
}

@media (max-width: 575px) { .figure-grid { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 640px) { .fachfilter { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 500px) {
  #suche .searchline { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  #begriff { grid-column: 1 / -1; }
  #suchformat { max-width: none; }
  .merk-zeile { flex-direction: column; }
  .files .upload-entry { grid-template-columns: minmax(0, 1fr); }
  .upload-actions { justify-content: flex-start; }
}

@media (max-width: 380px) {
  .account .text-button { font-size: .86rem; }
  nav { gap: .68rem; }
}
