/* Anlehnung an die Wikimedia-Oberflaeche des Wikidata Query Service */
:root {
  --blue: #3366cc; --blue-dark: #2a4b8d; --ink: #202122; --muted: #54595d;
  --line: #a2a9b1; --line-soft: #eaecf0; --bg: #f8f9fa; --panel: #fff;
  --warn: #8a5a00; --warn-bg: #fef6e7; --err: #b32424; --err-bg: #fee7e6;
  --ok: #14866d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.55 var(--sans); color: var(--ink); background: var(--bg);
       display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- Kopfleiste */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px;
          padding: 0 16px; height: 52px; background: var(--panel);
          border-bottom: 1px solid var(--line); flex: none; }
.wordmark { display: flex; align-items: center; gap: 10px; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 3px;
        background: var(--blue); color: #fff; font-weight: 700; font-size: 13px; }
.title { font-size: 17px; color: var(--ink); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 3px 9px; border-radius: 2px; background: #eaf3ff;
         color: var(--blue-dark); border: 1px solid #c8dcff; cursor: help; white-space: nowrap; }
.dataset { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------- Aufbau */
.layout { display: flex; flex: 1; min-height: 0; }
.rail { width: 62px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
        display: flex; flex-direction: column; padding-top: 6px; }
.rail-btn { border: 0; background: none; cursor: pointer; padding: 9px 2px; color: var(--muted);
            display: flex; flex-direction: column; align-items: center; gap: 3px; font: inherit;
            font-size: 10.5px; }
.rail-btn svg { width: 20px; height: 20px; fill: currentColor; }
.rail-btn:hover, .rail-btn.active { background: var(--line-soft); color: var(--blue); }

.panel { width: 320px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
         display: flex; flex-direction: column; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between;
              padding: 9px 12px; border-bottom: 1px solid var(--line-soft); font-weight: 600;
              font-size: 13px; }
.icon-btn { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer;
            color: var(--muted); padding: 0 4px; }
.panel-body { overflow: auto; padding: 8px; font-size: 13px; }
.panel-body button.example { display: block; width: 100%; text-align: left; border: 0;
      background: none; padding: 8px 9px; border-radius: 2px; cursor: pointer; color: var(--blue);
      font: inherit; }
.panel-body button.example:hover { background: var(--line-soft); }
.panel-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
                 color: var(--muted); margin: 14px 8px 6px; }
.panel-body p { margin: 0 8px 10px; color: #3d4247; }
.panel-body code, code { font-family: var(--mono); font-size: 12.5px; background: var(--line-soft);
                         padding: 1px 4px; border-radius: 2px; }
.panel-body table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.panel-body td { padding: 2px 8px; vertical-align: top; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ------------------------------------------------------------------- Editor */
.editor-area { display: flex; align-items: flex-start; gap: 12px; padding: 12px;
               background: var(--bg); flex: none; }
.run-btn { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0;
           background: var(--blue); color: #fff; cursor: pointer; display: grid;
           place-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.run-btn:hover { background: var(--blue-dark); }
.run-btn svg { width: 24px; height: 24px; fill: currentColor; }
.run-btn.busy { background: var(--muted); }
.editor-wrap { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 2px;
               background: #fff; overflow: hidden; }
.CodeMirror { height: auto; min-height: 190px; max-height: 46vh; font-family: var(--mono);
              font-size: 13px; line-height: 1.5; }
.CodeMirror-scroll { min-height: 190px; }

/* -------------------------------------------------------------- Werkzeugleiste */
.resultbar { display: flex; align-items: center; gap: 8px; padding: 6px 12px;
             border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
             background: var(--panel); flex: none; flex-wrap: wrap; }
.view-btn, .tool-btn { font: inherit; font-size: 13px; padding: 5px 11px; cursor: pointer;
        background: #fff; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); }
.view-btn:hover, .tool-btn:hover { background: var(--line-soft); }
.tool-btn:disabled { opacity: .5; cursor: default; }
.viewpicker, .menu-wrap { position: relative; }
.menu { position: absolute; z-index: 900; top: 100%; left: 0; margin: 2px 0 0; padding: 4px 0;
        list-style: none; background: #fff; border: 1px solid var(--line);
        box-shadow: 0 2px 6px rgba(0,0,0,.18); min-width: 178px; border-radius: 2px; }
.menu li { padding: 6px 14px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.menu li:hover { background: var(--line-soft); }
.menu li.disabled { color: var(--line); cursor: default; }
.menu li.disabled:hover { background: none; }
.check { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.spacer { flex: 1; }
.resultinfo { font-size: 12.5px; color: var(--muted); }

/* ----------------------------------------------------------------- Meldungen */
#messages:empty { display: none; }
.msg { margin: 10px 12px 0; padding: 9px 12px; border-radius: 2px; font-size: 13px; }
.msg.err { background: var(--err-bg); color: var(--err); border: 1px solid #f0b8b6; }
.msg.info { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0dfb8; }
.msg pre { margin: 8px 0 0; font: 12px/1.5 var(--mono); white-space: pre-wrap;
           max-height: 240px; overflow: auto; background: rgba(0,0,0,.04); padding: 8px; }
.msg summary { cursor: pointer; margin-top: 6px; }

/* ---------------------------------------------------------------- Ergebnisse */
#results { flex: 1; min-height: 0; overflow: auto; background: var(--panel); }
#results:empty { display: none; }
table.results { border-collapse: collapse; width: 100%; font-size: 13px; }
table.results th, table.results td { text-align: left; padding: 6px 11px;
      border-bottom: 1px solid var(--line-soft); vertical-align: top; max-width: 480px;
      overflow-wrap: anywhere; }
table.results th { position: sticky; top: 0; background: var(--line-soft); z-index: 2;
      font-size: 12px; font-weight: 700; color: #3d4247; border-bottom: 1px solid var(--line); }
table.results tr:hover td { background: #f6fbff; }
table.results a { color: var(--blue); text-decoration: none; }
table.results a:hover { text-decoration: underline; }
.lang { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.date { font-family: var(--mono); }
.cal { color: var(--warn); cursor: help; }
.redir { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 8px;
         font-size: 11px; background: var(--warn-bg); color: var(--warn);
         border: 1px solid #f0dfb8; }
.empty { padding: 20px; color: var(--muted); }

#map { width: 100%; height: 100%; min-height: 420px; }
.leaflet-popup-content { font: 13px/1.5 var(--sans); max-height: 260px; overflow: auto; }
.leaflet-popup-content table { border-collapse: collapse; }
.leaflet-popup-content td { padding: 1px 6px 1px 0; vertical-align: top; }
.leaflet-popup-content td.k { color: var(--muted); font-size: 12px; }

.imagegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
             gap: 12px; padding: 12px; }
.imagegrid figure { margin: 0; border: 1px solid var(--line-soft); border-radius: 2px;
                    overflow: hidden; background: #fff; }
.imagegrid img { width: 100%; height: 160px; object-fit: cover; display: block; background: #eee; }
.imagegrid figcaption { padding: 6px 8px; font-size: 12px; }
.chart { padding: 12px; }
.chart svg { max-width: 100%; height: auto; font: 11px var(--sans); }
.chart .bar { fill: var(--blue); }
.chart .dot { fill: var(--blue); fill-opacity: .65; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); }
