:root {
  --ink: #18202c;
  --ink-2: #4a5566;
  --muted: #7a8494;
  --paper: #f6f7f9;
  --card: #ffffff;
  --line: #d8dde5;
  --bravura: #2d55c4;
  --bravura-soft: #e3e9fa;
  --aninok: #e07a2f;
  --aninok-soft: #fcebdc;
  --signal: #d52b1e;
  --ok: #2c8a57;
  --focus: #2d55c4;
  --panel-w: 410px;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Barlow", "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body { font: 16px/1.5 var(--body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: var(--panel-w) 1fr; height: 100%; }
.panel { background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; z-index: 2; }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #e8ecef; }

/* header */
.sheet-head { position: sticky; top: 0; background: var(--card); z-index: 3; border-bottom: 1px solid var(--line); }
.grab { display: none; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-die { font-size: 30px; line-height: 1; }
.brand h1 { font: 700 26px/1 var(--display); margin: 0; letter-spacing: .2px; }
.brand-sub { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.link-btn { background: none; border: 0; padding: 6px 4px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; white-space: nowrap; }

#view { padding: 0 0 40px; }
.section { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.section h2 { font: 600 20px/1.2 var(--display); margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: var(--signal); font-weight: 500; margin: 8px 0 0; }

/* turn board – the one loud element */
.board { background: var(--ink); color: #fff; padding: 22px 22px 20px; }
.board-row { display: grid; grid-template-columns: 8px 1fr; gap: 14px; align-items: stretch; }
.board-row + .board-row { margin-top: 14px; }
.board-bar { border-radius: 4px; }
.board-bar.bravura { background: var(--bravura); }
.board-bar.aninok { background: var(--aninok); }
.board-who { font: 700 44px/0.95 var(--display); letter-spacing: .3px; }
.board-what { font: 500 17px/1.3 var(--body); color: #c9d0db; margin-top: 4px; }
.board-small .board-who { font-size: 26px; }
.board-place { margin-top: 18px; padding-top: 16px; border-top: 1px solid #364152; }
.board-place .station { font: 600 30px/1.05 var(--display); }
.board-place .meta { color: #aeb7c4; font-size: 14px; margin-top: 4px; }
.board .btn { margin-top: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); padding: 10px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 15px; min-height: 44px; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (hover: hover) {
  .btn:hover { border-color: var(--ink-2); }
  .btn.primary:hover { background: #2b3647; }
    .results li button:hover { background: var(--paper); }
}
.btn:active { transform: scale(.98); }
.btn.light { background: #fff; color: var(--ink); border-color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--signal); border-color: #efc4c0; }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; min-height: 44px; }
.field textarea { min-height: 150px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px #2d55c433; }
.hint { font-size: 13.5px; color: var(--muted); margin: 6px 0 0; }

.search { position: relative; }
.results { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 240px; overflow-y: auto; background: #fff; }
.results li button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; }
.results li + li button { border-top: 1px solid #eef1f4; }
.results li button { min-height: 44px; }
.results li button:focus-visible { background: var(--paper); }

.pick { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0 14px; }
.pick.okay { border-color: #9fd2b4; background: #f1faf4; }
.pick.bad { border-color: #f0b3ad; background: #fdf1f0; }
.pick strong { font: 600 20px/1.2 var(--display); display: block; }
.pick p { margin: 4px 0 0; font-size: 14px; }

.counter { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; }
.counter button { min-height: 52px; font: 700 26px/1 var(--display); border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.counter input { text-align: center; font: 700 30px/1 var(--display); min-height: 52px; }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { border-radius: 10px; padding: 12px 14px; }
.stat.bravura { background: var(--bravura-soft); }
.stat.aninok { background: var(--aninok-soft); }
.stat b { font: 700 18px/1.1 var(--display); display: block; }
.stat span { font-size: 14px; color: var(--ink-2); }

/* history list */
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid #eef1f4; }
.item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 11px 4px; cursor: pointer; }
.dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 17px/1 var(--display); border: 2px solid rgba(0,0,0,.25); }
.dot.bravura { background: var(--bravura); }
.dot.aninok { background: var(--aninok); }
.item .name { font-weight: 600; display: block; }
.item .sub { font-size: 13.5px; color: var(--muted); }
.badge { font-size: 12.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: #eef1f4; color: var(--ink-2); white-space: nowrap; }
.badge.open { background: #fff1d6; color: #8a5a00; }

/* detail */
.back { margin: 14px 22px 0; }
.detail-head { padding: 16px 22px 18px; border-bottom: 1px solid var(--line); }
.detail-head .who { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); flex-wrap: wrap; }
.detail-head h2 { font: 700 36px/1 var(--display); margin: 8px 0 6px; }
.detail-head .title { font-size: 18px; margin: 4px 0 0; }
.chip { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; font-weight: 600; padding: 3px 10px 3px 6px; border-radius: 99px; }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.chip.bravura { background: var(--bravura-soft); color: var(--bravura); }
.chip.aninok { background: var(--aninok-soft); color: #b5571a; }
.story { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 65ch; }
.empty { color: var(--muted); font-style: italic; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: #e8ecef; }
.photo button.open { all: unset; cursor: zoom-in; display: block; width: 100%; height: 100%; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(24,32,44,.75); color: #fff; cursor: pointer; font-size: 14px; }
.photo button.open:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.upload { margin-top: 12px; }
.upload input { display: none; }
.progress { height: 6px; background: #eef1f4; border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--ok); width: 0; transition: width .2s; }

/* map bits */
.leaflet-control.toggle { margin-top: 10px; }
.toggle { display: flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 1px 3px rgba(24,32,44,.15); }
.map-hint { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 500; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14.5px; max-width: calc(100% - 32px); text-align: center; }
.num-label { background: none; border: 0; }
.num-label span { display: grid; place-items: center; width: 100%; height: 100%; font: 700 22px/1 var(--display); color: var(--ink); text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; pointer-events: none; }
.leaflet-tooltip.place-tip { font: 600 14px/1.2 var(--body); border-radius: 6px; }
.leaflet-container { font-family: var(--body); }
.leaflet-control-layers { font-size: 14px; }

/* dialog */
.dlg { border: 0; border-radius: 14px; padding: 24px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(24,32,44,.35); }
.dlg::backdrop { background: rgba(24,32,44,.5); }
.dlg h2 { font: 700 28px/1 var(--display); margin: 0 0 8px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(12,16,22,.94); z-index: 2000; display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; padding: 50px 0 20px; height: 100%; justify-content: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 4px; }
.lightbox figcaption { color: #dfe4ea; text-align: center; max-width: 60ch; }
.lb-nav, .lb-close { background: none; border: 0; color: #fff; cursor: pointer; font-size: 44px; height: 64px; }
.lb-close { z-index: 2; position: absolute; top: calc(env(safe-area-inset-top, 0px) + 6px); right: 10px; font-size: 26px; width: 48px; height: 48px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px; z-index: 3000; font-weight: 600; box-shadow: 0 6px 24px rgba(24,32,44,.3); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--signal); }

.gate { padding: 40px 22px; }
.gate h2 { font: 700 30px/1.05 var(--display); margin: 0 0 10px; }

@media (max-width: 860px) {
  :root { padding: 0; }
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app { display: block; height: 100%; }
  .map-wrap { position: fixed; inset: 0; z-index: 0; }
  .leaflet-top { top: env(safe-area-inset-top, 0px); }
  .leaflet-bottom { display: none; } /* liegt sonst unter dem Sheet */

  /* Panel wird zum verschiebbaren Bottom Sheet */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    height: 50vh; height: 50dvh;
    border-right: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 28px rgba(24, 32, 44, .22);
    overscroll-behavior: contain;
    transition: height .3s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .panel.dragging { transition: none; }
  .sheet-head { border-radius: 16px 16px 0 0; touch-action: none; cursor: grab; }
  .grab { display: flex; justify-content: center; padding: 8px 0 2px; }
  .grab span { width: 44px; height: 5px; border-radius: 3px; background: #c4cbd5; }
  .top { padding: 2px 16px 10px; }
  .brand-sub { display: none; }
  .brand h1 { font-size: 22px; }
  .brand-die { font-size: 22px; }
  .link-btn { min-height: 40px; }

  .section { padding: 18px 16px; }
  .board { padding: 16px 16px 18px; }
  .board-who { font-size: 36px; }
  .board-place .station { font-size: 26px; }
  .board .row .btn { flex: 1 1 auto; }
  .back { margin: 12px 16px 0; }
  .detail-head { padding: 12px 16px 16px; }
  .detail-head h2 { font-size: 32px; overflow-wrap: anywhere; }
  .btn.small { min-height: 42px; padding: 8px 14px; }
  .row.end .btn { flex: 1 1 0; }
  .photos { gap: 4px; }
  .photo .del { width: 36px; height: 36px; font-size: 15px; }

  .map-hint { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; left: 12px; right: 140px; transform: none; max-width: none; }
  .toast { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; }
  .toggle { padding: 9px 12px; }

  .lightbox { grid-template-columns: 1fr; }
  .lightbox figure { grid-column: 1; grid-row: 1; height: 100vh; height: 100dvh;
    padding: calc(env(safe-area-inset-top, 0px) + 56px) 6px calc(env(safe-area-inset-bottom, 0px) + 16px); }
  .lightbox img { max-height: calc(100dvh - 150px); }
  .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 72px; font-size: 36px; background: rgba(0, 0, 0, .35); border-radius: 8px; z-index: 1; }
  .lb-nav.prev { left: 6px; }
  .lb-nav.next { right: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
