/* Schlicht und funktional: wenig Farbe, klare Hierarchie, dichte Formulare. */
:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #667085; --line: #d9dde5; --line-soft: #eceef2;
  --accent: #2459c4; --accent-soft: #e8effc; --ok: #1d7a46; --ok-soft: #e3f4ea; --warn: #9a5b00; --warn-soft: #fdf1dc;
  --err: #b42318; --err-soft: #fdeceb; --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --on-accent: #fff; --focus: var(--accent-soft);
  color-scheme: light;
}
/* Farbmodi: data-theme auf <html> (theme.js); ohne JavaScript folgt die Seite dem System. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14171c; --surface: #1c2027; --text: #e6e8ec; --muted: #98a2b3; --line: #343a46; --line-soft: #272c35;
    --accent: #7aa2f7; --accent-soft: #1f2a40; --ok: #5cc38a; --ok-soft: #173225; --warn: #f0b45a; --warn-soft: #3a2c14;
    --err: #f2877e; --err-soft: #3d1d1b; --on-accent: #10131a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2027; --text: #e6e8ec; --muted: #98a2b3; --line: #343a46; --line-soft: #272c35;
  --accent: #7aa2f7; --accent-soft: #1f2a40; --ok: #5cc38a; --ok-soft: #173225; --warn: #f0b45a; --warn-soft: #3a2c14;
  --err: #f2877e; --err-soft: #3d1d1b; --on-accent: #10131a; color-scheme: dark;
}
:root[data-theme="sepia"] {
  --bg: #f3ecdc; --surface: #fbf7ee; --text: #3a2f24; --muted: #7b6b58; --line: #ddd0b6; --line-soft: #ece3cf;
  --accent: #8a4a17; --accent-soft: #f2e2c9; --ok: #47662b; --ok-soft: #e6ecd3; --warn: #8a5800; --warn-soft: #f6e6c2;
  --err: #9a2f1f; --err-soft: #f6dcd3; --on-accent: #fffaf0; color-scheme: light;
}
:root[data-theme="contrast"] {
  --bg: #fff; --surface: #fff; --text: #000; --muted: #2b2b2b; --line: #000; --line-soft: #6b6b6b;
  --accent: #0030b3; --accent-soft: #dfe6ff; --ok: #00561c; --ok-soft: #d9f2df; --warn: #6a3a00; --warn-soft: #ffe9c2;
  --err: #a30000; --err-soft: #ffdede; --on-accent: #fff; --focus: #000; color-scheme: light;
}
:root[data-theme="contrast"] a { text-decoration: underline; }
:root[data-theme="contrast"] :is(.entries, .sidebar, .cards, .formhead, .topbar) a, :root[data-theme="contrast"] a.button { text-decoration: none; }
:root[data-theme="contrast"] .entries li { border-top-color: var(--line); }
:root[data-theme="contrast"] :focus-visible { outline: 3px solid #000; outline-offset: 2px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .6rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
code { font-size: .9em; background: var(--line-soft); padding: 0 .25em; border-radius: 3px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.pad { padding: 1rem 1.25rem; }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .45rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); }
.crumb { font-weight: 600; }
.usermenu { margin-left: auto; display: flex; gap: .75rem; align-items: center; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; color: var(--muted); }
.menu-panel { position: absolute; right: 0; top: 1.8rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .4rem; display: flex; flex-direction: column; min-width: 13rem; z-index: 20; }
.menu-panel a, .menu-panel .link { padding: .3rem .5rem; text-align: left; }
.langtoggle { display: flex; gap: .25rem; }

/* Seiten */
.page { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
.narrow { max-width: 34rem; }
.page.narrow { margin: 2rem auto; }
.messages { max-width: 1100px; margin: .75rem auto 0; padding: 0 1rem; }
.msg { padding: .5rem .75rem; border-radius: var(--radius); margin: .4rem 0; border: 1px solid transparent; }
.msg ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.msg-success { background: var(--ok-soft); color: var(--ok); }
.msg-error { background: var(--err-soft); color: var(--err); }
.msg-warning { background: var(--warn-soft); color: var(--warn); }
.msg-info { background: var(--accent-soft); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  margin-bottom: 1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .75rem; }
.card { display: flex; flex-direction: column; gap: .3rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem; color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.badge { display: inline-block; font-size: .78em; padding: .05rem .45rem; border-radius: 999px; font-weight: 600;
  background: var(--line-soft); color: var(--muted); width: fit-content; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.count { color: var(--muted); font-size: .85em; }

/* Formularelemente */
input, select, textarea, button, .button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .3rem .45rem; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--accent); }
input:invalid:not(:placeholder-shown) { border-color: var(--err); }
textarea { width: 100%; resize: vertical; }
button, .button { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .3rem .75rem;
  cursor: pointer; display: inline-block; color: var(--text); }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.danger { color: var(--err); }
.danger-link { color: var(--err); }
button.small, .button.small { padding: .15rem .55rem; font-size: .9em; }
button.mini { padding: 0 .4rem; font-size: .85em; line-height: 1.6; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.stack > div { display: flex; flex-direction: column; gap: .2rem; }
.stack label { font-weight: 600; }
.stack .helptext { color: var(--muted); font-size: .85em; }
.stack ul.errorlist, .errorlist { color: var(--err); margin: 0; padding-left: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grow { flex: 1; }
form.inline { display: inline-flex; gap: .25rem; }
.check { display: inline-flex; align-items: center; gap: .3rem; font-weight: normal; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { display: inline-flex; gap: .25rem; align-items: center; border: 1px solid var(--line); border-radius: 999px;
  padding: .05rem .55rem; background: var(--surface); cursor: pointer; font-weight: normal; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chip.small { font-size: .82em; padding: 0 .45rem; }

/* Arbeitsbereich */
body.ws { height: 100vh; display: flex; flex-direction: column; }
body.ws .messages { position: fixed; bottom: 1rem; right: 1rem; z-index: 30; max-width: 28rem; margin: 0; }
.workspace { flex: 1; display: grid; grid-template-columns: 12.5rem 1fr; min-height: 0; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  justify-content: space-between; overflow-y: auto; }
.sidebar nav { display: flex; flex-direction: column; padding: .5rem 0; }
.sidebar nav a { padding: .4rem 1rem; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar nav a:hover { text-decoration: none; background: var(--line-soft); }
.sidebar-foot { display: flex; flex-direction: column; gap: .3rem; padding: .75rem 1rem; border-top: 1px solid var(--line);
  font-size: .9em; }
.main { overflow: auto; min-height: 0; }
.split { display: grid; grid-template-columns: minmax(18rem, 26rem) 1fr; height: 100%; min-height: 0; }
.listpane { border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface); }
.listhead { display: flex; justify-content: space-between; align-items: center; padding: .75rem .75rem .25rem; }
.listhead h1 { margin: 0; }
.filter { margin: .25rem .75rem .5rem; width: calc(100% - 1.5rem); }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; align-items: stretch; border-top: 1px solid var(--line-soft); }
.entries li.current { background: var(--accent-soft); }
.entries li a { flex: 1; display: flex; flex-direction: column; gap: .05rem; padding: .4rem .6rem .45rem 0;
  color: var(--text); }
.entries li a:hover { text-decoration: none; background: var(--line-soft); }
.eid { font-family: ui-monospace, monospace; font-size: .82em; color: var(--muted); }
.etitle { font-weight: 600; }
.emeta, .evis { font-size: .82em; color: var(--muted); }
.entries .eid, .selentry .eid { font-size: .75em; line-height: 1.2; }
.vtag { display: inline-block; font-size: .78em; border: 1px solid var(--line); border-radius: 3px; padding: 0 .25rem;
  margin-right: .15rem; }
.vtag.none { border-style: dashed; }
.handle { cursor: grab; color: var(--muted); padding: .4rem .35rem; user-select: none; }
.detailpane { overflow-y: auto; }
.detailpane.full { height: 100%; }

/* Eintragsformular */
.entryform { padding: .75rem 1.25rem 3rem; max-width: 60rem; }
.formhead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; position: sticky; top: 0;
  background: var(--bg); padding: .5rem 0; z-index: 5; border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.formhead h2 { margin: 0; }
.actions { display: flex; gap: .4rem; }
.formfoot { margin-top: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 .9rem;
  padding: .5rem .9rem .9rem; }
legend { font-weight: 700; padding: 0 .3rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: .75rem 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.flabel { font-weight: 600; font-size: .9em; }
.req { color: var(--err); }
.help { color: var(--muted); font-size: .82em; }
.ferror { color: var(--err); font-size: .85em; }
.lsrow { display: flex; gap: .35rem; align-items: flex-start; }
.lsrow input, .lsrow textarea { flex: 1; }
.langtag { font-family: ui-monospace, monospace; font-size: .75em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 3px; padding: .1rem .25rem; margin-top: .3rem; min-width: 2.1em; text-align: center; }
.langtag.main { color: var(--text); }
.langtag.missing { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.term { display: flex; flex-direction: column; gap: .25rem; }
.term-all input { width: 100%; }
.rows { display: flex; flex-direction: column; gap: .35rem; }
.rowitem { display: flex; gap: .3rem; align-items: flex-start; border: 1px solid var(--line-soft); border-radius: 4px;
  padding: .3rem; background: var(--bg); }
.rowbody { flex: 1; display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.hidein { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.add-row { align-self: flex-start; }
details.sub summary { cursor: pointer; color: var(--muted); font-size: .88em; }

/* Tabellen */
.tablewrap { overflow-x: auto; }
table.grid, table.matrix { border-collapse: collapse; background: var(--surface); }
table.grid { width: 100%; }
table.grid th, table.grid td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.matrix th, table.matrix td { padding: .2rem .45rem; border-bottom: 1px solid var(--line-soft); text-align: center; }
table.matrix tbody th { text-align: left; font-weight: normal; }
table.matrix.big tbody th { min-width: 22rem; }
table.matrix .sep { color: var(--muted); font-size: .8em; }
table.matrix th.rot { font-size: .78em; font-weight: 600; vertical-align: bottom; white-space: nowrap; }
table.matrix tbody tr:hover { background: var(--line-soft); }
.problems { padding-left: 1.2rem; }
.problems li { margin: .2rem 0; }
ul.plain { list-style: none; padding: 0; }

/* Anmeldung (allauth) */
.account form { display: flex; flex-direction: column; gap: .6rem; }
.account form p, .account form div { display: flex; flex-direction: column; gap: .2rem; }
.account input:not([type=checkbox]) { width: 100%; }

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .split { grid-template-columns: 1fr; }
}

/* Export */
.exportpage { display: grid; grid-template-columns: 19rem 1fr; height: 100%; min-height: 0; }
.exportopts { padding: 1rem; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto;
  display: flex; flex-direction: column; gap: .6rem; }
.exportopts label { display: flex; flex-direction: column; gap: .2rem; font-weight: 600; font-size: .9em; }
.downloads { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.downloads .button { text-align: center; }
.button.disabled { pointer-events: none; opacity: .45; }
.previewpane { background: #8a8f99; min-height: 0; }
.previewpane iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Varianten */
.pad-x { padding-left: 1.25rem; padding-right: 1.25rem; }
.variantform .formhead, form > .formhead { margin: 0; }
.selsection { border-top: 1px solid var(--line-soft); padding: .4rem 0; }
.selsection summary { cursor: pointer; }
.selrows { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .2rem; }
.selrows li { align-items: center; }
.selrows li.off { opacity: .6; }
.selrows li:has(input[name=sel]:checked) { opacity: 1; }
.secret { background: var(--surface); border: 1px solid var(--line); padding: .5rem; border-radius: 4px; user-select: all; overflow-x: auto; }
fieldset.choices { display: flex; flex-direction: column; gap: .35rem; }
.stack > .row { flex-direction: row; }
.stack label.check { font-weight: normal; }
.selentry { align-items: flex-start !important; }
.selentry input { margin-top: .2rem; }
.seltext { display: flex; flex-direction: column; gap: .05rem; }
.themepick { font-size: .85em; padding: .1rem .3rem; }
