/* kartenwerk im Browser: Jost und Blau #427897 wie GUI und Karten. Handy zuerst, ab 900px zweispaltig. */
@font-face { font-family: Jost; src: url(/fonts/Jost-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: Jost; src: url(/fonts/Jost-Medium.ttf); font-weight: 500; font-display: swap; }
@font-face { font-family: Jost; src: url(/fonts/Jost-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  --blau: #427897; --blau-hell: #5a92b2; --blau-dunkel: #2c6483;
  --rot: #b03a2e; --gruen: #3d8a5a; --bernstein: #c08a3e;
  --grund: #f4f1ea; --flaeche: #ffffff; --text: #1f2a30; --schwach: #66727a; --linie: #dcd8cf;
  --wahl: #e3eef4;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #161b1e; --flaeche: #20272b; --text: #e6e9eb; --schwach: #93a0a8; --linie: #354047;
    --wahl: #24394a; --blau-hell: #7fb2d0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.4 Jost, system-ui, sans-serif; color: var(--text); background: var(--grund);
  min-height: 100dvh; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--blau-hell); }
code { font-family: ui-monospace, monospace; font-size: .9em; }
.mono { font-family: ui-monospace, monospace; }
.klein { font-size: 13.5px; color: var(--schwach); margin: 6px 0; }
.fehler { color: var(--rot); margin: 6px 0; }
.ok { color: var(--gruen); }
.warn { color: var(--bernstein); }
.rechts { margin-left: auto; }

input, select, button { font: inherit; color: inherit; }
input[type=search], input:not([type]), select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 8px;
  background: var(--flaeche); min-height: 44px;
}
select { width: auto; min-height: 36px; padding: 4px 8px; font-size: 14px; }
input:focus, select:focus { outline: 2px solid var(--blau); outline-offset: -1px; }

.knopf {
  border: 1px solid var(--linie); background: var(--flaeche); border-radius: 8px; padding: 10px 16px;
  min-height: 44px; font-weight: 500; cursor: pointer;
}
.knopf.blau { background: var(--blau); border-color: var(--blau); color: #fff; }
.knopf.rot { background: var(--rot); border-color: var(--rot); color: #fff; }
.knopf:disabled { opacity: .45; cursor: default; }
.knopf.breit { width: 100%; }
.klein-knopf { min-height: 32px; padding: 4px 10px; font-size: 14px; }
button.link { background: none; border: 0; color: var(--schwach); text-decoration: underline; cursor: pointer; padding: 8px; }

/* Kopf */
.kopf {
  position: sticky; top: 0; z-index: 5; background: var(--blau); color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}
.marke { font-weight: 700; font-size: 21px; color: #fff; text-decoration: none; }
.marke.gross { font-size: 40px; color: var(--blau); }
.reiter { display: flex; gap: 2px; order: 3; width: 100%; }
.reiter button {
  flex: 1; white-space: nowrap; background: none; border: 0; color: rgba(255,255,255,.7); font-weight: 500; font-size: 16px;
  padding: 8px 6px; border-radius: 6px; cursor: pointer; min-height: 40px;
}
.reiter button.aktiv { background: var(--blau-dunkel); color: #fff; }
.status { display: flex; align-items: center; gap: 4px; font-size: 12px; margin-left: auto; }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--rot); display: inline-block; }
.punkt.an { background: #6fd08f; }
.punkt-name { margin-right: 6px; opacity: .85; }
.anlern {
  background: var(--blau-dunkel); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px;
  min-height: 36px; font-weight: 500; cursor: pointer;
}
.anlern.an { background: #fff; color: var(--blau); }
.anlern:disabled { opacity: .5; }

@media (max-width: 420px) { .reiter button { font-size: 14.5px; padding: 8px 2px; } }
@media (min-width: 900px) {
  .reiter { order: 0; width: auto; }
  .reiter button { flex: none; padding: 6px 14px; }
}

/* Seiten */
.seite { padding: 12px 14px 90px; max-width: 1400px; margin: 0 auto; }
.spalten { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 900px) {
  .spalten { flex-direction: row; align-items: flex-start; }
  .spalte-quellen, .spalte-liste { flex: 1 1 52%; min-width: 0; }
  .spalte-zuordnung, .spalte-detail { flex: 1 1 48%; min-width: 0; position: sticky; top: 70px; }
}
/* Handy: Karte zuerst, dann Ziel wählen */
@media (max-width: 899px) {
  #seite-anlernen .spalten { flex-direction: column-reverse; }
  #ziel-box:empty { display: none; }
}
.schritt { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; margin: 10px 0 8px; }
.schritt .nr {
  width: 26px; height: 26px; border-radius: 50%; background: var(--blau); color: #fff; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.box { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; padding: 12px 14px; }
.box .gross { font-size: 18px; font-weight: 500; }
.scan-uid { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 700; word-break: break-all; }
.scan-leer { font-size: 18px; color: var(--schwach); }
.scan-box-neu { animation: blinken 1.2s ease-out; }
@keyframes blinken { from { box-shadow: 0 0 0 4px var(--blau-hell); } to { box-shadow: 0 0 0 0 transparent; } }
.zeile { display: flex; align-items: center; gap: 10px; }
.radio { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin: 8px 0 2px; }
.radio label { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
.radio input { width: 20px; height: 20px; accent-color: var(--blau); }

.segment { display: flex; border: 1px solid var(--linie); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.segment button { flex: 1; border: 0; background: var(--flaeche); padding: 8px; min-height: 42px; font-weight: 500; cursor: pointer; }
.segment button + button { border-left: 1px solid var(--linie); }
.segment button.aktiv { background: var(--blau); color: #fff; }

.schalter { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 15px; cursor: pointer; }
.schalter input { width: 20px; height: 20px; accent-color: var(--blau); }
.zahl { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #fff; color: var(--blau); font-size: 13px; line-height: 20px; text-align: center; }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 8px; }
@media (min-width: 900px) { .kacheln { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); } }
.kachel { border: 2px solid transparent; border-radius: 8px; padding: 3px; cursor: pointer; min-width: 0; background: none; text-align: left; }
.kachel.gewaehlt { border-color: var(--blau); background: var(--wahl); }
.kachel .bild {
  position: relative; aspect-ratio: 1; border-radius: 5px; background: var(--blau-dunkel); color: #fff; display: flex;
  font-weight: 500; font-size: 15px; overflow: hidden;
}
.kachel .cover { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; }
.kachel .cover:has(img) { padding: 0; }
.kachel .cover img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 5px; }
.kachel .name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.kachel .unter { font-size: 12.5px; color: var(--schwach); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* angelernt: kleines Kartensymbol oben rechts; Druckliste: Knopf unten rechts */
.kachel .karten-symbol {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 18px; border-radius: 3px; background: #fff;
  border: 1.5px solid var(--blau); box-shadow: 0 1px 3px rgba(0,0,0,.4); margin: 0;
}
.kachel .karten-symbol::before { content: ""; position: absolute; left: 4px; top: 4px; width: 6px; height: 7px; border-radius: 1px; background: var(--blau); }
.kachel .karten-symbol::after { content: ""; position: absolute; left: 12px; top: 3px; width: 7px; height: 9px; border: 1.5px solid var(--bernstein); border-left: 0; border-radius: 0 9px 9px 0; }
.kachel .karten-symbol b { position: absolute; left: -9px; bottom: -8px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--gruen); color: #fff; font-size: 10.5px; line-height: 16px; text-align: center; font-weight: 500; }
.kachel .druck-knopf {
  position: absolute; right: 4px; bottom: 4px; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(255,255,255,.9); color: var(--blau); box-shadow: 0 1px 4px rgba(0,0,0,.45); cursor: pointer;
  display: flex; align-items: center; justify-content: center; margin: 0;
}
.kachel .druck-knopf.drauf { background: var(--blau); color: #fff; }
.kachel .druck-knopf svg { width: 18px; height: 18px; }
.kachel:focus-visible { outline: 2px solid var(--blau); }

.motiv { width: 100%; max-width: 480px; aspect-ratio: 89.6 / 58; border-radius: 8px; background: var(--flaeche); border: 1px solid var(--linie); display: block; object-fit: contain; }
.motiv.laedt { background: linear-gradient(90deg, var(--flaeche), var(--linie), var(--flaeche)); background-size: 200% 100%; animation: laden 1.2s linear infinite; }
@keyframes laden { to { background-position: -200% 0; } }

.aktionen { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.aktionen .knopf { min-width: 140px; }
@media (max-width: 899px) {
  #speicher-leiste.bereit {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: var(--flaeche); border-top: 1px solid var(--linie); box-shadow: 0 -4px 14px rgba(0,0,0,.12);
  }
  #speicher-leiste.bereit .knopf { flex: 1; }
}

/* Karten */
.liste { list-style: none; padding: 0; margin: 6px 0 0; }
.liste li {
  padding: 9px 12px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; min-height: 48px;
}
.liste li + li { margin-top: 2px; }
.liste li:hover { border-color: var(--linie); }
.liste li.gewaehlt { background: var(--blau); color: #fff; }
.liste .titel { font-weight: 500; }
.liste .unter { font-family: ui-monospace, monospace; font-size: 12px; opacity: .75; }
.zurueck { display: none; }
@media (max-width: 899px) {
  .spalte-detail.offen {
    position: fixed; inset: 0; z-index: 7; background: var(--grund); overflow-y: auto;
    padding: calc(12px + env(safe-area-inset-top)) 14px 40px;
  }
  .spalte-detail:not(.offen) { display: none; }
  .spalte-detail.offen .zurueck { display: inline-block; margin-bottom: 8px; }
}
.detail-titel { font-size: 22px; font-weight: 700; margin: 4px 0 8px; }
.felder { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 15px; }
.felder dt { color: var(--schwach); font-size: 13.5px; }
.felder dd { margin: 0; word-break: break-all; }
details { margin-top: 22px; }
summary { font-weight: 700; font-size: 18px; cursor: pointer; min-height: 40px; }
.verlauf-zeile { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--linie); }
.verlauf-zeile .wann { font-size: 12.5px; color: var(--schwach); }

/* Drucken */
.liste.druck li { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center; cursor: default; border-color: var(--linie); background: var(--flaeche); }
.liste.druck .nr { color: var(--schwach); font-size: 13px; min-width: 22px; text-align: right; }
.liste.druck .druck-status { grid-column: 2; font-size: 13px; }
.liste.druck .druck-status.schwach { color: var(--schwach); }
.liste.druck button { grid-row: 1 / span 2; grid-column: 3; }
@media (min-width: 900px) {
  #seite-drucken .spalte-quellen { position: static; }
  .spalte-quellen-platz { flex: 1 1 52%; min-width: 0; }
  .spalte-druckliste { flex: 1 1 48%; min-width: 0; position: sticky; top: 70px; }
}
@media (max-width: 899px) {
  #seite-drucken .spalten { flex-direction: column-reverse; }
}

/* Übernehmen */
.aenderung { display: grid; grid-template-columns: 80px auto 1fr; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--linie); align-items: baseline; }
@media (max-width: 600px) { .aenderung { grid-template-columns: 80px 1fr; } .aenderung .beschr { grid-column: 1 / -1; } }
.aenderung .art { font-weight: 500; }

/* Fuß, Meldungen, Dialog */
.fuss { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 14px 24px; font-size: 14px; }
.meldungen { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20; width: min(560px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.meldung { background: var(--text); color: var(--grund); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: 15px; pointer-events: auto; }
.meldung.ok { border-left: 5px solid var(--gruen); }
.meldung.warn { border-left: 5px solid var(--bernstein); }
.meldung.fehler { border-left: 5px solid var(--rot); }
dialog { border: 0; border-radius: 12px; padding: 18px; width: min(520px, calc(100% - 24px)); background: var(--flaeche); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog p { white-space: pre-line; }
dialog .aktionen { justify-content: flex-end; }

/* Koppeln */
.koppeln { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.koppeln-karte { width: min(420px, 100%); text-align: center; }
.koppeln form { text-align: left; margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }
.koppeln label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
#koppel-code { font-size: 24px; letter-spacing: 6px; text-align: center; font-family: ui-monospace, monospace; }
.koppeln .unten { margin-top: 28px; }

/* Downloads-Seite */
body.downloads main { max-width: 720px; margin: 0 auto; padding: 16px; }
.dl { list-style: none; padding: 0; }
.dl li { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 2px; }
.dl a { font-weight: 500; font-size: 17px; word-break: break-all; }
.dl small { color: var(--schwach); }

/* 0.3.0: Kartenart, Sprachwahl, Druckstatus */
.kartenart { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.kartenart .klein { margin: 0 4px 0 0; }
.art-knopf { border: 1px solid var(--linie); background: var(--flaeche); border-radius: 16px; padding: 4px 12px; min-height: 32px; font-size: 14px; cursor: pointer; }
.art-knopf.aktiv { background: var(--blau); border-color: var(--blau); color: #fff; }
.art-knopf:disabled { opacity: .5; cursor: default; }
.sprachwahl { display: inline-flex; align-items: center; gap: 6px; }
.sprachwahl select { min-height: 32px; }
.koppeln .sprachwahl { margin-top: 18px; justify-content: center; width: 100%; font-size: 14px; color: var(--schwach); }
.startfeld { gap: 8px; margin-top: 6px; }
.startfeld select { min-height: 36px; }
.klein-schritt { font-size: 16px; margin-top: 14px; }
.liste.druck .knoepfe { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
#gedruckt { margin-top: 16px; }
#gedruckt summary { font-size: 16px; }
#gedruckt .liste.druck li { opacity: .85; }
#gedruckte-entfernen { margin-top: 8px; }
