:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --line: #d9dde5;
  --tone: #2f5fb3;
  --proposed: #fff1b8;
  --confirmed: #d3f2d9;
  --noevent: #e7e8ec;
  --uncovered: #ffd6d6;
  --danger: #b42318;
  --hl: #8fb3f5;
  --input-bg: #ffffff;
  --topbar: #1d2a44;
  --row-hl: #eaf1ff;
  --row-edit: #fafbff;
  --warn-bg: #fff4e5;
  --chip: #e6eefc;
  --chip-unsure: #f3eefc;
  --chip-source: #e8f4ea;
  --chip-source-unsure: #f1f4e3;
  --chip-block: #fdf0dc;
  --chip-add-border: #9fb3d9;
  --chip-add-bg: #f4f7fd;
  --chip-add-hover: #e6eefc;
  --proposed-fg: #2f5bb7;
  --flag-border: #c8cfdc;
  --flag-checked: #dbe6fb;
  --focus: #6b8fd6;
  --cmp-different: #ffe2c2;
  --pending-bg: #fff3cd;
  --pending-fg: #7a5a00;
  --maybe-double: #fff7d6;
  --soft-bg: #f6f8fc;
  --notice-fg: #8a5a00;
  --link-alt: #2a5bd7;
  --darkened: #f0f2f6;
  --on-accent: #ffffff;
  color-scheme: light;
}
/* dark: the same switch as the admin (Django's theme.js, data-theme on <html>: auto, light, dark) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --panel: #1b1e23;
    --text: #e3e5e8;
    --muted: #9aa1ab;
    --line: #343941;
    --tone: #7fa8ec;
    --proposed: #4a3f12;
    --confirmed: #1f3d29;
    --noevent: #2c3036;
    --uncovered: #4d2224;
    --danger: #f08b84;
    --hl: #5d83c9;
    --input-bg: #23272d;
    --topbar: #0f1626;
    --row-hl: #22304a;
    --row-edit: #1f232a;
    --warn-bg: #3d2f17;
    --chip: #24324a;
    --chip-unsure: #322a46;
    --chip-source: #22382a;
    --chip-source-unsure: #33381f;
    --chip-block: #3e3220;
    --chip-add-border: #4f6488;
    --chip-add-bg: #1e2533;
    --chip-add-hover: #26324a;
    --proposed-fg: #8fb3f5;
    --flag-border: #454c57;
    --flag-checked: #2c3d5c;
    --focus: #7fa8ec;
    --cmp-different: #4a3220;
    --pending-bg: #3d3417;
    --pending-fg: #e8c76a;
    --maybe-double: #3a3416;
    --soft-bg: #1f242c;
    --notice-fg: #e0b45c;
    --link-alt: #8fb3f5;
    --darkened: #262a31;
    --on-accent: #10141b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121417;
  --panel: #1b1e23;
  --text: #e3e5e8;
  --muted: #9aa1ab;
  --line: #343941;
  --tone: #7fa8ec;
  --proposed: #4a3f12;
  --confirmed: #1f3d29;
  --noevent: #2c3036;
  --uncovered: #4d2224;
  --danger: #f08b84;
  --hl: #5d83c9;
  --input-bg: #23272d;
  --topbar: #0f1626;
  --row-hl: #22304a;
  --row-edit: #1f232a;
  --warn-bg: #3d2f17;
  --chip: #24324a;
  --chip-unsure: #322a46;
  --chip-source: #22382a;
  --chip-source-unsure: #33381f;
  --chip-block: #3e3220;
  --chip-add-border: #4f6488;
  --chip-add-bg: #1e2533;
  --chip-add-hover: #26324a;
  --proposed-fg: #8fb3f5;
  --flag-border: #454c57;
  --flag-checked: #2c3d5c;
  --focus: #7fa8ec;
  --cmp-different: #4a3220;
  --pending-bg: #3d3417;
  --pending-fg: #e8c76a;
  --maybe-double: #3a3416;
  --soft-bg: #1f242c;
  --notice-fg: #e0b45c;
  --link-alt: #8fb3f5;
  --darkened: #262a31;
  --on-accent: #10141b;
  color-scheme: dark;
}

/* the frame of the review pages for readers without the staff flag (login, account): aircraft/frame_public.html;
   for staff the review pages are in the frame of the admin (aircraft/frame_admin.html) */
body.review-frame * { box-sizing: border-box; }
body.review-frame { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body.review-frame main { padding: 16px; max-width: 1500px; margin: 0 auto; }
body.review-frame h1 { font-size: 1.35rem; margin: 0 0 4px; }
.topbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--topbar); color: #fff; }
.topbar a, .topbar .link { color: #fff; text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.topbar-left { display: flex; gap: 12px; align-items: center; }
.brand { font-weight: 600; }
/* the switch light / dark / automatic: the symbol of the current setting */
.topbar .theme-toggle { background: none; border: 1px solid rgba(255, 255, 255, 0.4); color: #fff; border-radius: 6px; padding: 0 8px;
                font-size: 1rem; line-height: 1.6; }
.topbar .theme-toggle span { display: none; }
:root:not([data-theme]) .topbar .theme-toggle .when-auto, :root[data-theme="auto"] .topbar .theme-toggle .when-auto,
:root[data-theme="light"] .topbar .theme-toggle .when-light, :root[data-theme="dark"] .topbar .theme-toggle .when-dark { display: inline; }

/* in the frame of the admin the review pages take its colours: the same page as the admin around them */
body.review-pages {
  --bg: var(--body-bg); --panel: var(--body-bg); --text: var(--body-fg); --muted: var(--body-quiet-color);
  --line: var(--hairline-color); --tone: var(--link-fg); --input-bg: var(--body-bg); --darkened: var(--darkened-bg);
  --on-accent: var(--button-fg);
}
/* the main button like the admin's ("Speichern") */
body.review-pages .review-content button.primary { background: var(--button-bg); border-color: var(--button-bg); color: var(--button-fg); }
body.review-pages .review-content button.primary:hover { background: var(--button-hover-bg); }

@keyframes blink { 50% { opacity: 0.2; } }
body.review-frame {
  --border-color: var(--line);
  --body-bg: var(--input-bg);
  --body-fg: var(--text);
  --body-quiet-color: var(--muted);
  --darkened-bg: var(--darkened);
  --selected-bg: var(--flag-checked);
  --selected-row: var(--row-hl);
  --hairline-color: var(--line);
  --link-fg: var(--tone);
  --primary: var(--tone);
  --primary-fg: var(--on-accent);
  --error-fg: var(--danger);
}
/* search fields of the admin (select2): its colours come from variables of the admin stylesheet, which is not
   loaded here; same frame as the other inputs */
.select2-container--admin-autocomplete .select2-selection--single {
  height: auto; min-height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg);
}
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
  line-height: 30px; padding-left: 6px;
}
.select2-container--admin-autocomplete .select2-selection--single .select2-selection__arrow { height: 30px; }
.select2-container--admin-autocomplete.select2-container--focus .select2-selection,
.select2-container--admin-autocomplete.select2-container--open .select2-selection { border-color: var(--focus); }
.select2-container--admin-autocomplete .select2-dropdown { border-color: var(--line); }
/* the content of the review pages */
.review-content {
  &, & *, & *::before, & *::after { box-sizing: border-box; }
  h2 { font-size: 1rem; margin: 0 0 8px; }
  a { color: var(--tone); }


  .muted { color: var(--muted); }
  .small { font-size: 0.85em; }
  .nowrap { white-space: nowrap; }
  .num { text-align: right; }
  .warn { color: var(--danger); }
  .inline { display: inline; }
  .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
  .stack { display: flex; flex-direction: column; gap: 8px; }

  button, .button { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
  button:hover, .button:hover { border-color: var(--tone); }
  button.primary { background: var(--tone); border-color: var(--tone); color: var(--on-accent); font-weight: 600; }
  button.danger { color: var(--danger); }
  button.small, .button.small { padding: 1px 7px; font-size: 0.85em; }
  button.link { background: none; border: none; padding: 0; }
  input, select, textarea { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 100%;
                            background: var(--input-bg); color: var(--text); }
  textarea { width: 100%; }

  .message { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
  .message.error { background: var(--uncovered); color: var(--danger); }
  .message.info { background: var(--confirmed); }
  .warn-box { background: var(--warn-bg); }

  .cards { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 20px; }
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; min-width: 130px; }
  .card-value { font-size: 1.5rem; font-weight: 600; }
  .card-label { color: var(--muted); font-size: 0.85em; }
  section { margin-bottom: 20px; }
  .search { display: flex; flex-wrap: wrap; gap: 8px; max-width: 600px; }
  /* "+ Quelle": the data quality of the chosen source */
  .source-hint { flex-basis: 100%; }
  .source-hint:empty { display: none; }
  /* the hint on the placeholders * and ?, while the search field has the focus */
  .wildcard-hint { display: none; flex-basis: 100%; font-size: 0.8125rem; color: var(--muted); }
  form:focus-within > .wildcard-hint { display: block; }
  .search input { flex: 1; }

  table { border-collapse: collapse; width: 100%; background: var(--panel); }
  th, td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
  th { font-size: 0.85em; color: var(--muted); font-weight: 600; }
  .list { max-width: 1100px; }

  .editor-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: start; }
  .editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
  @media (max-width: 1000px) { .editor-grid { grid-template-columns: minmax(0, 1fr); } }
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 16px; overflow-x: auto; }
  .panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; }
  .legend { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8em; }
  .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }

  /* the legacy text, segments coloured by the event status */
  .oldtext { white-space: pre-wrap; word-break: break-word; font: 15px/1.9 ui-monospace, Consolas, monospace; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
  .seg { border-radius: 3px; padding: 1px 0; }
  .seg-proposed { background: var(--proposed); }
  .seg-confirmed { background: var(--confirmed); }
  .seg-noevent { background: var(--noevent); color: var(--muted); text-decoration: line-through; }
  .seg-uncovered { background: var(--uncovered); text-decoration: underline wavy var(--danger); }
  .seg.hl { outline: 2px solid var(--hl); }
  .oldtext { cursor: text; }
  /* the legacy text on the airplane page, only to read */
  .old-text-box summary { cursor: pointer; }
  .old-text-read { white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, Consolas, monospace; margin: 6px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; max-height: 24em; overflow-y: auto; }
  .split-marker { display: inline-block; width: 2px; height: 1.3em; margin: 0 -1px; vertical-align: text-bottom; background: var(--danger); animation: blink 1s step-end infinite; }
  #selection-info { margin-top: 6px; font-family: ui-monospace, Consolas, monospace; }

  .events td.actions { white-space: nowrap; }
  .events tr.hl td { background: var(--row-hl); }
  .events tr.status-2 td { color: var(--muted); }
  .events tr.editing td { background: var(--row-edit); }
  .badge { display: inline-block; padding: 0 6px; border-radius: 10px; font-size: 0.8em; white-space: nowrap; }
  .badge-0 { background: var(--proposed); }
  .badge-1 { background: var(--confirmed); }
  .badge-2 { background: var(--noevent); }

  .form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; margin-top: 6px; }
  .form-grid label { display: block; font-size: 0.85em; color: var(--muted); }
  .form-grid .field-info, .form-grid .field-source_detail { grid-column: 1 / -1; }
  .form-grid input, .form-grid select { width: 100%; }
  .form-grid .field-head { display: flex; justify-content: space-between; align-items: end; gap: 6px; }
  /* event form: the parts besides kind, date and status, opened by their chip, "×" empties and closes them */
  .event-section { position: relative; margin: 8px 0 0; padding: 2px 34px 8px 10px; border: 1px solid var(--line);
                   border-radius: 8px; background: var(--panel); }
  .event-section legend { padding: 0 4px; font-size: 0.85em; font-weight: 600; color: var(--muted); }
  .event-section .form-grid { margin-top: 0; }
  /* the parts side by side: a part of several fields takes two columns, the info the whole row */
  .event-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 12px; }
  .event-section.section-info { grid-column: 1 / -1; }
  @media (min-width: 900px) { .event-section:not(.single) { grid-column: span 2; } }
  /* the legend names a part of one field; the help of a field in a part is its tooltip */
  .event-section.single .field:first-child .field-head > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .event-section.single .field:first-child .field-head { justify-content: flex-end; }
  .event-section .field > .muted.small { display: none; }
  .proposed { color: var(--proposed-fg); }
  .proposal-hint { display: inline-block; margin: 2px 6px 2px 0; }
  .photo-source input { padding: 1px 6px; font-size: 0.85em; }
  .section-close { position: absolute; top: 4px; right: 4px; padding: 0 7px; border: 0; background: none; color: var(--muted);
                   font-size: 1.1em; line-height: 1.4; }
  .section-close:hover { color: var(--danger); }
  .section-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
  .chip-add[hidden], .event-section[hidden] { display: none; }
  .chip-add { padding: 1px 10px; border: 1px dashed var(--chip-add-border); border-radius: 12px; background: var(--chip-add-bg); color: var(--proposed-fg);
              font-size: 0.85em; }
  .chip-add:hover { border-style: solid; background: var(--chip-add-hover); }

  /* flag switch (sicher | ? | w) in the head of a field */
  .flags > div { display: inline-flex; }
  .flags > div > div { display: contents; }
  .flags label { display: inline-block; padding: 0 6px; border: 1px solid var(--flag-border); margin-left: -1px; cursor: pointer;
                 font-size: 0.8em; line-height: 1.5; color: var(--muted); background: var(--input-bg); }
  .flags > div > div:first-child label { border-radius: 8px 0 0 8px; margin-left: 0; }
  .flags > div > div:last-child label { border-radius: 0 8px 8px 0; }
  .flags input { position: absolute; opacity: 0; width: 0; height: 0; }
  .flags label:has(input:checked) { background: var(--flag-checked); color: inherit; font-weight: 600; }
  .flags label:has(input:focus-visible) { outline: 2px solid var(--focus); }
  .error { color: var(--danger); }

  .facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 0; }
  .facts dt { color: var(--muted); }
  .facts dd { margin: 0; }
  ul.plain { list-style: none; padding: 0; margin: 0; }
  ul.plain li { margin-bottom: 6px; }

  /* event details */
  .details { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 4px; }
  .chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 2px 0 8px; border-radius: 10px; background: var(--chip); font-size: 0.85em; }
  .chip-unsure { background: var(--chip-unsure); }
  .chip-source { background: var(--chip-source); }
  .chip-source.chip-unsure { background: var(--chip-source-unsure); }
  .chip-type { color: var(--muted); }
  .chip-remove { border: none; background: none; padding: 0 4px; color: var(--muted); }
  .chip-remove:hover { color: var(--danger); }
  button.suggestion { padding: 0 8px; border-style: dashed; border-radius: 10px; font-size: 0.85em; color: var(--tone); }
  .add-detail summary { cursor: pointer; font-size: 0.85em; color: var(--tone); }
  .add-detail .row { margin-top: 4px; }

  /* duplicates */
  .filters label { display: flex; flex-direction: column; font-size: 0.85em; color: var(--muted); }
  .list.wide { max-width: none; }
  .dup-0 { background: var(--proposed); }
  .dup-1 { background: var(--confirmed); }
  .dup-2 { background: var(--noevent); }
  .compare { max-width: 900px; }
  .compare td:first-child { width: 120px; }
  .cmp-same td, span.cmp-same { background: var(--confirmed); }
  .cmp-different td, span.cmp-different { background: var(--cmp-different); }
  .cmp-one td, span.cmp-one { background: var(--noevent); }
  .legend span { padding: 0 6px; border-radius: 3px; }
  .side-by-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  @media (max-width: 1000px) { .side-by-side { grid-template-columns: minmax(0, 1fr); } }
  .events.compact td { padding: 3px 6px; font-size: 0.9em; }
  .panel.merged { border-color: var(--tone); }
  .place-kind { margin-bottom: 4px; }
  /* "Flugzeug erfassen": the form, beside it the possible hits */
  .capture { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
  @media (max-width: 900px) { .capture { grid-template-columns: 1fr; } }
  .capture-hits h2 { margin-top: 0; font-size: 1.05em; }
  .capture-hits .hits { list-style: none; margin: 0; padding: 0; }
  .capture-hits .hit { list-style: none; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .capture-hits .hit:last-child { border-bottom: 0; }
  .capture-hits .reasons { margin: 2px 0 6px; }
  .capture-evidence { margin-top: 12px; padding-right: 10px; }
  .capture-photo { margin: 12px 0; }
  .capture-photo .inline-check { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
  .capture-photo [data-photo-fields][hidden] { display: none; }
  .capture-preview { display: block; max-width: 100%; max-height: 360px; margin: 0 auto 12px; border-radius: 6px; }
  .capture-preview[hidden] { display: none; }
  /* the date: "am / ab / bis / von–bis" before it */
  .form-grid .date-input { display: flex; gap: 4px; }
  .form-grid .date-input select { width: auto; flex: none; }
  .form-grid .date-input input { flex: 1; min-width: 0; }
  .place-suggestion { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--flag-border); background: var(--soft-bg); }
  .place-suggestion .notice { color: var(--notice-fg); }
  .similar-places li { margin: 2px 0; }
  .similar-places button.link { color: var(--link-alt); margin-left: 6px; cursor: pointer; }

  .login { max-width: 360px; margin: 40px auto; }
  .changes ul.plain { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
  .changes li.change { margin: 3px 0 3px 8px; }
  .changes li.reverted { text-decoration: line-through; opacity: 0.6; }
  .changes button.link { color: var(--tone); cursor: pointer; }
  .changes a.pending { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: var(--pending-bg); color: var(--pending-fg); font-size: 0.85em; text-decoration: none; }
  .approval-batch { border-top: 1px solid var(--line); padding: 8px 0; }
  .approval-batch .panel-head { margin-bottom: 4px; }
  .badge-link { font-weight: 600; }
  .move { white-space: nowrap; }
  .image-strip { display: flex; flex-wrap: wrap; gap: 12px; }
  .image-strip figure { margin: 0; max-width: 220px; }
  .image-strip img { max-width: 220px; max-height: 160px; border: 1px solid var(--line); border-radius: 4px; }
  .master-form .field { margin-bottom: 6px; }
  .master-form input[type=text], .master-form input[type=number] { width: 100%; }
  .new-airplane { max-width: 900px; }

  /* Werknummernblock from the text of an event */
  .chip-block { background: var(--chip-block); padding-right: 8px; }
  .block-form { display: grid; grid-template-columns: max-content minmax(0, 28em); gap: 4px 8px; align-items: center; margin-top: 4px; font-size: 0.9em; }
  .block-form > label { color: var(--muted); }
  .block-form textarea { width: 100%; box-sizing: border-box; }
  .inline-check { display: inline-flex; align-items: center; gap: 4px; }

  /* panels of the side column: open and close by the heading */
  .panel-toggle { cursor: pointer; user-select: none; }
  .panel-toggle::before { content: '▾'; display: inline-block; width: 1em; color: var(--muted); }
  .panel.closed .panel-toggle::before { content: '▸'; }
  .panel.closed > :not(h2):not(.panel-head) { display: none; }
  .panel.closed .panel-head > :not(h2) { display: none; }
  .panel.closed h2 { margin-bottom: 0; }

  /* merging the events of the records of one airplane: possible doubles */
  .merge-events tr.maybe-double td { background: var(--maybe-double); }
  .page-head .row { flex-wrap: wrap; gap: 6px; }

  /* sortable tables: the headings sort */
  table.sortable th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
  table.sortable th[data-sort]::after { content: ' ↕'; color: var(--muted); font-size: 0.8em; }
  table.sortable th[aria-sort='ascending']::after { content: ' ▲'; color: inherit; }
  table.sortable th[aria-sort='descending']::after { content: ' ▼'; color: inherit; }

  /* the parts of an event one by one (_event_parts.html): value, ✎ and ×; empty parts as chips */
  .parts .part:empty { display: none; }
  .parts .part { margin: 1px 0; }
  .part-label { display: inline-block; min-width: 5.5em; color: var(--muted); font-size: 0.85em; }
  .part-controls { white-space: nowrap; }
  .part-controls button { padding: 0 4px; border: none; background: none; color: var(--muted); cursor: pointer; }
  .part-controls button.part-clear:hover { color: var(--danger); }
  .part-controls button.part-edit:hover { color: var(--tone); }
  .part-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
  .part-form { min-width: 300px; margin: 4px 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--row-edit); }
  .part-form-head { margin-bottom: 2px; font-size: 0.9em; }
  .part-chips .chip-add, td > .chip-add, td > form > button.suggestion, .parts form > button.suggestion { white-space: nowrap; }
}
