/* FlarmDB – Oberfläche. Keine externen Schriften oder Bibliotheken. */

:root {
  --bg: #f4f7fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eaf0f7;
  --text: #0e1b2c;
  --text-muted: #556479;
  --border: #d9e2ee;
  --accent: #e8752c;
  --accent-strong: #c95e18;
  --accent-soft: #fdeadc;
  --link: #1f6fd1;
  --ok: #1f9d63;
  --ok-soft: #dcf4e8;
  --fail: #d0423a;
  --fail-soft: #fbe3e1;
  --sky-1: #cfe3fb;
  --sky-2: #f4f7fb;
  --shadow: 0 1px 2px rgb(14 27 44 / 6%), 0 8px 24px rgb(14 27 44 / 6%);
  --shadow-hover: 0 2px 4px rgb(14 27 44 / 8%), 0 16px 40px rgb(14 27 44 / 12%);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07111f;
    --bg-elev: #0e1c2f;
    --bg-sunken: #0a1626;
    --text: #e6edf7;
    --text-muted: #8c9bb1;
    --border: #1d2e46;
    --accent: #ff9147;
    --accent-strong: #ffad73;
    --accent-soft: rgb(255 145 71 / 14%);
    --link: #6cb0ff;
    --ok: #4fd39a;
    --ok-soft: rgb(79 211 154 / 14%);
    --fail: #ff7a72;
    --fail-soft: rgb(255 122 114 / 14%);
    --sky-1: #12305a;
    --sky-2: #07111f;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    --shadow-hover: 0 2px 4px rgb(0 0 0 / 35%), 0 16px 40px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #07111f;
  --bg-elev: #0e1c2f;
  --bg-sunken: #0a1626;
  --text: #e6edf7;
  --text-muted: #8c9bb1;
  --border: #1d2e46;
  --accent: #ff9147;
  --accent-strong: #ffad73;
  --accent-soft: rgb(255 145 71 / 14%);
  --link: #6cb0ff;
  --ok: #4fd39a;
  --ok-soft: rgb(79 211 154 / 14%);
  --fail: #ff7a72;
  --fail-soft: rgb(255 122 114 / 14%);
  --sky-1: #12305a;
  --sky-2: #07111f;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  --shadow-hover: 0 2px 4px rgb(0 0 0 / 35%), 0 16px 40px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { width: min(1160px, 100% - 32px); margin-inline: auto; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Himmel im Hintergrund */
.sky {
  position: absolute;
  inset: 0 0 auto 0;
  height: 640px;
  z-index: -1;
  background:
    radial-gradient(1200px 420px at 80% -10%, var(--accent-soft), transparent 70%),
    linear-gradient(180deg, var(--sky-1), var(--sky-2));
  overflow: hidden;
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgb(128 160 200 / 18%) 1px, transparent 0);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 30%, transparent);
}

/* Kopfzeile */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 20px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand strong { color: var(--accent); }
.brand-mark { width: 30px; height: 30px; color: var(--accent); stroke: none; transform: rotate(-8deg); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--text-muted); padding: 8px 12px; border-radius: 8px; font-size: 15px; }
.nav a:hover { color: var(--text); background: var(--bg-sunken); text-decoration: none; }
.theme-toggle, .icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
}
.theme-toggle:hover, .icon-btn:hover { color: var(--text); }
.theme-toggle { margin-left: 8px; }

/* Einstieg */
.hero { padding: 72px 0 32px; }
.eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-size: clamp(38px, 6.4vw, 68px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.accent {
  background: linear-gradient(90deg, var(--accent), #f5b13d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { max-width: 640px; margin: 20px 0 0; font-size: 18px; color: var(--text-muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 40px 0 0;
}
.stat {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  backdrop-filter: blur(6px);
}
.stat dt { font-size: 13px; color: var(--text-muted); }
.stat dd {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Abschnitte */
.section { padding: 48px 0 8px; }
.section-head { margin-bottom: 20px; }
h2 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.section-head p { margin: 6px 0 0; color: var(--text-muted); max-width: 720px; }

/* Downloads */
.downloads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dl-card {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.dl-card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.dl-icon {
  flex: none;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 26px;
}
.dl-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dl-title { font-size: 19px; font-weight: 700; }
.dl-text { font-size: 14px; color: var(--text-muted); }
.dl-file {
  align-self: flex-start;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-sunken);
  font: 13px var(--mono);
  color: var(--text-muted);
}
.dl-action {
  flex: none;
  margin-left: auto;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  transition: background 0.18s ease;
}
.dl-card:hover .dl-action { background: var(--accent-strong); }

/* Suche */
.search { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.search-field {
  flex: 1 1 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  font-size: 20px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.search-field input::placeholder { color: var(--text-muted); opacity: 0.7; }
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
kbd {
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  font: 12px var(--mono);
  color: var(--text-muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

.results-meta { min-height: 24px; margin: 4px 2px 10px; font-size: 14px; color: var(--text-muted); }

.table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.results { width: 100%; border-collapse: collapse; font-size: 15px; }
.results th {
  position: sticky;
  top: 0;
  padding: 12px 16px;
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.results td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.results tbody tr { cursor: pointer; transition: background 0.12s ease; }
.results tbody tr:hover, .results tbody tr:focus-visible { background: var(--bg-sunken); outline: none; }
.results .id { font-family: var(--mono); font-weight: 600; color: var(--accent-strong); letter-spacing: 0.02em; }
.results .cs { font-weight: 700; }
.results .muted { color: var(--text-muted); }
.results tbody.loading { opacity: 0.45; transition: opacity 0.2s ease; }
.dash { color: var(--border); }

.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-sunken);
  color: var(--text-muted);
  white-space: nowrap;
}
.tag-flarmnet { background: rgb(31 111 209 / 12%); color: var(--link); }
.tag-ogn { background: var(--ok-soft); color: var(--ok); }
.tag-weglide { background: var(--accent-soft); color: var(--accent-strong); }

.empty { padding: 48px 24px; text-align: center; color: var(--text-muted); }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 17px; }

.skeleton td::after {
  content: "";
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-sunken), var(--border), var(--bg-sunken));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.pager-info { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.btn {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-strong); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* Konflikte */
.chip-count { margin-left: 6px; font-variant-numeric: tabular-nums; opacity: 0.7; }
.conflicts { margin: 0; padding: 0; list-style: none; }
.conflicts.loading { opacity: 0.45; transition: opacity 0.2s ease; }
.conflict { padding: 16px 20px; border-top: 1px solid var(--border); border-left: 3px solid var(--border); }
.conflict:first-child { border-top: 0; }
.conflict-duplicate_id, .conflict-mismatch { border-left-color: var(--fail); }
.conflict-duplicate_registration, .conflict-mismatch-plane_type { border-left-color: var(--accent); }
.conflict-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.id-main { font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--accent-strong); letter-spacing: 0.02em; }
.conflict-title { font-weight: 600; }
.conflict-since { margin-left: auto; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.conflict-entries { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.conflict-entry { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 15px; }
.conflict-entry .tags { min-width: 76px; }
.conflict-value { font-weight: 600; overflow-wrap: anywhere; }
.conflict-hint { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }
.tag-export { background: var(--ok-soft); color: var(--ok); }
.id-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font: 600 14px var(--mono);
  cursor: pointer;
}
.id-link:hover { text-decoration: underline; }
.id-link.id-main { color: var(--accent-strong); font-size: 16px; font-weight: 700; }

/* Quellen */
.sources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.source-card {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.source-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.source-card h3 { margin: 0; font-size: 18px; }
.source-card p { margin: 8px 0 0; font-size: 14px; color: var(--text-muted); }
.source-count strong { color: var(--text); font-size: 22px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.source-error { color: var(--fail) !important; overflow-wrap: anywhere; }
.source-url { display: block; margin-top: 12px; font: 12px var(--mono); overflow-wrap: anywhere; }
.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-sunken); color: var(--text-muted); }
.badge-success { background: var(--ok-soft); color: var(--ok); }
.badge-failed { background: var(--fail-soft); color: var(--fail); }
.badge-running { background: var(--accent-soft); color: var(--accent-strong); }

/* Detailansicht */
.detail {
  width: min(720px, 100% - 32px);
  max-height: min(860px, 100% - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 30px 80px rgb(0 0 0 / 35%);
}
.detail[open] { animation: pop 0.2s ease; }
.detail::backdrop { background: rgb(7 17 31 / 55%); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.detail-close-form { position: absolute; top: 16px; right: 16px; margin: 0; }
.detail-body { padding: 28px; }
.detail-head { display: flex; gap: 18px; align-items: center; padding-right: 48px; }
.avatar {
  flex: none;
  width: 64px; height: 64px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 40px;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar svg { stroke: none; }
.detail-head h2 { font-size: 26px; }
.detail-sub { margin: 2px 0 0; color: var(--text-muted); font-family: var(--mono); }
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 24px 0 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
  overflow: hidden;
}
.facts div { padding: 12px 16px; background: var(--bg-elev); }
.facts dt { font-size: 12px; color: var(--text-muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.detail h3 { margin: 28px 0 10px; font-size: 15px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.raw { width: 100%; border-collapse: collapse; font-size: 14px; }
.raw-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.raw th, .raw td { padding: 9px 12px; text-align: left; border-top: 1px solid var(--border); white-space: nowrap; }
.raw thead th { border-top: 0; background: var(--bg-sunken); font-size: 12px; color: var(--text-muted); }
.raw tbody th { font-weight: 500; color: var(--text-muted); }
.detail-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.detail-links a { display: inline-flex; align-items: center; gap: 6px; }
.detail-conflicts {
  margin-top: 22px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--fail-soft);
  font-size: 14px;
}
.detail-conflicts strong { color: var(--fail); }
.detail-conflicts ul { margin: 4px 0 0; padding-left: 18px; }
.raw tr.conflict th, .raw tr.conflict td { background: var(--fail-soft); }
.raw tr.conflict th { color: var(--fail); font-weight: 600; }
.detail-meta { margin-top: 18px; font-size: 13px; color: var(--text-muted); }

/* XCSoar-Repository */
.repo-card {
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.repo-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.repo-row { display: flex; gap: 12px; align-items: center; }
.repo-url {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-sunken);
  font: 15px var(--mono);
  overflow-wrap: anywhere;
  user-select: all;
}
.repo-copy { flex: none; }

.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0 0;
  padding: 0;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding: 20px 22px 20px 70px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 22px;
  top: 18px;
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}
.steps h3 { margin: 4px 0 6px; font-size: 17px; }
.steps p { margin: 0; font-size: 14px; color: var(--text-muted); }
.steps strong { color: var(--text); }
.steps code { padding: 1px 6px; border-radius: 5px; background: var(--bg-sunken); font: 13px var(--mono); color: var(--text); }

/* Fußzeile */
.footer { margin-top: 72px; border-top: 1px solid var(--border); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 0 32px; font-size: 14px; color: var(--text-muted); }

/* Kleine Bildschirme */
@media (max-width: 900px) {
  .downloads, .sources, .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .nav a { display: none; }
  .hero { padding-top: 44px; }
  .stat dd { font-size: 21px; }
  kbd { display: none; }
  .facts { grid-template-columns: 1fr; }
  .conflict { padding: 14px 16px; }
  .conflict-since { margin-left: 0; width: 100%; }
  .detail-body { padding: 22px; }
  .repo-row { flex-direction: column; align-items: stretch; }
  .steps li { padding-left: 62px; }
  .steps li::before { left: 16px; }

  /* Tabelle wird zu Karten */
  .results thead { display: none; }
  .results, .results tbody, .results tr, .results td { display: block; }
  .results tr { padding: 12px 16px; border-top: 1px solid var(--border); }
  .results tbody tr:first-child { border-top: 0; }
  .results td { padding: 2px 0; border: 0; }
  .results td:empty, .results td.blank { display: none; }
  .results td[data-label]::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 96px;
    color: var(--text-muted);
    font-size: 13px;
  }
  .results td.id::before { display: none; }
  .results td.id { font-size: 17px; margin-bottom: 4px; }
  .results td .tags { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
