/* Anleitung (public/guide.js): Kapitel mit Einfach | Ausführlich, Suche,
   Bereichs-Filter und Inhaltsverzeichnis. Nur Tokens aus styles.css (:root). */

#modal-guide .gd-card {
  max-width: var(--modal-w-xl);
}
/* Desktop: the guide uses the room it gets (wider and taller than other dialogs, fixed height so the
   card does not jump while searching and filtering). */
@media (min-width: 900px) {
  #modal-guide .gd-card {
    max-width: min(1400px, calc(100vw - 4rem));
    height: min(calc(100dvh - 4rem), 1200px);
    max-height: none;
  }
}
/* Handy: lange Texte – das Sheet nimmt die volle verfügbare Höhe, damit es
   beim Suchen nicht mit jeder Trefferzahl auf und ab springt. */
@media (max-width: 540px) {
  #modal-guide .gd-card { height: 100dvh; }
}

#modal-guide .gd-mode { margin: 0.5rem 0 0.5rem; }
#modal-guide .gd-search { margin: 0 0 0.25rem; }

#modal-guide .gd-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
}
@media (max-width: 540px) {
  /* Eine waagerecht scrollende Zeile wie im Benachrichtigungsverlauf. */
  #modal-guide .gd-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--modal-pad-x, 1.25rem));
    padding-inline: var(--modal-pad-x, 1.25rem);
  }
  #modal-guide .gd-filters::-webkit-scrollbar { display: none; }
  #modal-guide .gd-filters .status-pill { flex: 0 0 auto; white-space: nowrap; }
}

/* Inhaltsverzeichnis: Handy aufklappbar über den Kapiteln, ab 900 px links daneben. */
/* Room below the last chapter, so it does not touch the edge of the dialog (and clears the iPhone home bar). */
#modal-guide .gd-body { display: block; padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) {
  #modal-guide .gd-body {
    display: grid;
    grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
  }
}
/* Desktop: the table of contents stays in view while the chapters scroll and is a rounded card of its own (rounded at the bottom too);
   only its content scrolls. --gd-head-h / --gd-view-h are set by guide.js (pinned header, visible height of the dialog). */
@media (min-width: 900px) {
  #modal-guide .gd-toc {
    position: sticky;
    top: calc(var(--gd-head-h, 0px) + 0.5rem);
    max-height: min(calc(var(--gd-view-h, 100dvh) - var(--gd-head-h, 0px) - 1.75rem), var(--gd-toc-room, 100dvh));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-tile);
    background: var(--surface2);
  }
  #modal-guide .gd-toc > .gd-toc-fold {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  #modal-guide .gd-toc > .gd-toc-fold .gd-toc-inner { padding-bottom: 0.6rem; }
  #modal-guide .gd-toc > .gd-toc-fold > .gd-toc-summary { border-radius: 0; }
}
#modal-guide .gd-chapter { scroll-margin-top: calc(var(--gd-head-h, 0px) + 0.5rem); }
#modal-guide .gd-toc-fold {
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface2);
  margin-bottom: 0.75rem;
}
/* The bar ("Inhalt (n Kapitel)") is a button and, like the chapter bars, stays pinned while the list scrolls past. */
#modal-guide .gd-toc-summary {
  appearance: none;
  width: 100%;
  background: var(--surface2);
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  font-size: var(--text-fold);
  font-weight: 700;
  text-align: left;
  min-height: var(--touch-target);
  padding: 0.25rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  position: sticky;
  top: var(--gd-head-h, 0px);
  z-index: var(--z-settings-head);
  border-radius: var(--radius-tile);
}
#modal-guide .gd-toc-fold.is-open > .gd-toc-summary { border-radius: var(--radius-tile) var(--radius-tile) 0 0; border-bottom: 1px solid var(--border); }
#modal-guide .gd-toc-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#modal-guide .gd-toc-summary-chevron { display: inline-flex; color: var(--text-muted); transition: transform var(--transition-fast); }
#modal-guide .gd-toc-summary[aria-expanded="true"] .gd-toc-summary-chevron { transform: rotate(180deg); }
@media (min-width: 900px) {
  /* The sidebar scrolls on its own: the bar sticks inside it. */
  #modal-guide .gd-toc-summary { top: 0; }
}
#modal-guide .gd-toc-body {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.28s var(--ease-standard), visibility 0s linear 0.28s;
}
#modal-guide .gd-toc-body.is-open { grid-template-rows: 1fr; visibility: visible; transition: grid-template-rows 0.28s var(--ease-standard), visibility 0s; }
#modal-guide .gd-toc-body.no-anim, #modal-guide .gd-toc-body.no-anim.is-open { transition: none; }
#modal-guide .gd-toc-inner { min-height: 0; overflow: hidden; padding: 0 0.75rem; }
#modal-guide .gd-toc-body.is-open .gd-toc-inner { padding-bottom: 0.5rem; }
@media (prefers-reduced-motion: reduce) {
  #modal-guide .gd-toc-body { transition: grid-template-rows 0.18s linear, visibility 0s linear 0.18s; }
  #modal-guide .gd-toc-body.is-open { transition: grid-template-rows 0.18s linear, visibility 0s; }
}
#modal-guide .gd-toc-area {
  margin: 0.5rem 0 0.15rem;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#modal-guide .gd-toc-list { list-style: none; margin: 0; padding: 0; }
#modal-guide .gd-toc-link {
  appearance: none;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
html:not(.using-touch) #modal-guide .gd-toc-link:hover,
#modal-guide .gd-toc-link:focus-visible { background: var(--surface); }
/* Where you are (accent bar, bold) and what is open (dot on the right). */
#modal-guide .gd-toc-link { position: relative; padding-right: 1.4rem; border-left: 3px solid transparent; }
#modal-guide .gd-toc-link.is-current {
  border-left-color: var(--accent);
  background: var(--accent-soft, var(--surface));
  font-weight: 700;
}
#modal-guide .gd-toc-link.is-open::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.225rem;
  border-radius: 50%;
  background: var(--accent);
}

/* Kapitel */
#modal-guide .gd-chapters { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
/* Where a new area begins, the list shows a divider with its name (dot in the area colour, count, a line to the right). */
#modal-guide .gd-area-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.9rem 0 0.1rem;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#modal-guide .gd-area-head:first-child { margin-top: 0; }
#modal-guide .gd-area-head::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--gd-area, var(--border));
  flex: 0 0 auto;
}
#modal-guide .gd-area-head::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border-strong); }
#modal-guide .gd-area-head-count { order: 3; font-weight: 400; }
#modal-guide .gd-area-head::after { order: 2; }
#modal-guide .gd-chapter {
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface2);
  scroll-margin-top: 12rem;
}
#modal-guide .gd-ch-head {
  appearance: none;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  padding: 0.75rem 0.9rem;
  min-height: var(--touch-target);
  cursor: pointer;
  border-radius: var(--radius-tile);
}
#modal-guide .gd-ch-titles { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 auto; min-width: 0; }
#modal-guide .gd-ch-title { font-size: var(--text-fold); font-weight: 700; }
#modal-guide .gd-ch-summary { color: var(--text-muted); font-size: var(--text-sm); }
#modal-guide .gd-ch-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; }
#modal-guide .gd-tag {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}
#modal-guide .gd-tag-admin { color: var(--warning); }
#modal-guide .gd-ch-chevron { display: inline-flex; color: var(--text-muted); transition: transform var(--transition-fast); }
#modal-guide .gd-ch-head[aria-expanded="true"] .gd-ch-chevron { transform: rotate(180deg); }
/* No empty tag row (it left a gap under the title and pushed the arrow down). */
#modal-guide .gd-ch-tags:empty { display: none; }
@media (max-width: 540px) {
  /* Title and arrow on one row, centred; tags (when there are any) below, full width. */
  #modal-guide .gd-ch-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 0.6rem; row-gap: 0.35rem; }
  #modal-guide .gd-ch-titles { grid-column: 1; }
  #modal-guide .gd-ch-chevron { grid-column: 2; grid-row: 1; }
  #modal-guide .gd-ch-tags { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
}

/* Opening and closing animate the height (0fr → 1fr); closed content is hidden from the tab order and screen readers via inert. */
#modal-guide .gd-ch-body {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.28s var(--ease-standard), visibility 0s linear 0.28s;
  line-height: 1.55;
}
#modal-guide .gd-ch-body.is-open {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 0.28s var(--ease-standard), visibility 0s;
}
#modal-guide .gd-ch-inner { min-height: 0; overflow: hidden; padding: 0 0.9rem; }
#modal-guide .gd-ch-body.is-open .gd-ch-inner { padding-top: 0.6rem; padding-bottom: 0.9rem; }
@media (prefers-reduced-motion: reduce) {
  #modal-guide .gd-ch-body, #modal-guide .gd-ch-body.is-open { transition: none; }
}
#modal-guide .gd-where { color: var(--text-muted); font-size: var(--text-sm); margin: 0 0 0.6rem; }
#modal-guide .gd-where-label { font-weight: 700; }
#modal-guide .gd-h { margin: 1rem 0 0.35rem; font-size: var(--text-base); font-weight: 700; }
#modal-guide .gd-p { margin: 0 0 0.6rem; }
#modal-guide .gd-steps,
#modal-guide .gd-list { margin: 0 0 0.6rem; padding-left: 1.4rem; }
#modal-guide .gd-steps li,
#modal-guide .gd-list li { margin: 0.2rem 0; }
#modal-guide mark {
  background: color-mix(in srgb, var(--warning) 35%, transparent);
  color: inherit;
  border-radius: var(--radius-xs);
  padding: 0 0.1em;
}

#modal-guide .gd-callout {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0.6rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border-left: 3px solid var(--info);
}
#modal-guide .gd-callout p { margin: 0; }
#modal-guide .gd-warn { border-left-color: var(--danger); }
#modal-guide .gd-callout-icon { display: inline-flex; color: var(--info); padding-top: 0.15rem; }
#modal-guide .gd-warn .gd-callout-icon { color: var(--danger-text); }

#modal-guide .gd-formula {
  margin: 0.5rem 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
#modal-guide .gd-formula-expr {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
#modal-guide .gd-formula-example { margin: 0.35rem 0 0; color: var(--text-muted); font-size: var(--text-sm); }
#modal-guide .gd-formula-label { font-weight: 700; }

#modal-guide .gd-table-wrap { overflow-x: auto; margin: 0.5rem 0; }
#modal-guide .gd-table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
#modal-guide .gd-table th,
#modal-guide .gd-table td { text-align: left; vertical-align: top; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
#modal-guide .gd-table th { color: var(--text-muted); font-weight: 700; }

#modal-guide .gd-install {
  margin: 0.4rem 0 0.8rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft, var(--surface));
  border: 1px solid var(--border);
}
#modal-guide .gd-install-text { margin: 0; }
#modal-guide .gd-install-btn { margin-top: 0.5rem; }

/* Action row under each chapter: real buttons of one size, wrapping two per row on a phone. */
#modal-guide .gd-actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.5rem; margin-top: 0.9rem; }
/* One size for every button of the row: .btn-primary carries a top margin, 100 % width and no border, .btn-secondary a border – that made
   "Zeig es mir" smaller and lower than its neighbours. Same box (1 px border, transparent on the filled one), no margin, centred label. */
#modal-guide .gd-act {
  flex: 0 1 auto;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  margin: 0;
  min-height: var(--touch-target);
  padding: 0.5rem 0.95rem;
  border-width: 1px;
  border-style: solid;
  font-size: 0.88rem;
  line-height: 1.2;
  text-align: center;
}
#modal-guide .btn-primary.gd-act { border-color: transparent; }
@media (max-width: 480px) {
  #modal-guide .gd-act { flex: 1 1 calc(50% - 0.25rem); }
}
#modal-guide .gd-more-hits { align-self: flex-start; min-height: var(--touch-target); flex: 0 1 auto; padding: 0.5rem 0.95rem; }

#modal-guide .gd-related { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.9rem; }
#modal-guide .gd-related-label { color: var(--text-muted); font-size: 0.82rem; margin-right: 0.15rem; }
/* lange Titel (z. B. „Abos: feste Zahlung monatlich, vierteljährlich oder jährlich“) brechen um, statt über den Rand des Fensters zu laufen */
#modal-guide .gd-related-link { min-height: var(--touch-target); max-width: 100%; white-space: normal; text-align: left; overflow-wrap: anywhere; }

/* "Rechne mit deinen Zahlen" */
#modal-guide .gd-tool {
  margin: 0.8rem 0;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
#modal-guide .gd-tool-title { margin: 0 0 0.3rem; font-weight: 600; }
#modal-guide .gd-tool-hint { margin: 0 0 0.5rem; color: var(--text-muted); font-size: 0.84rem; }
#modal-guide .gd-tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.6rem 0.8rem; }
#modal-guide .gd-tool-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
#modal-guide .gd-tool-label { font-size: 0.82rem; color: var(--text-muted); }
#modal-guide .gd-tool-input { display: flex; align-items: center; gap: 0.4rem; }
#modal-guide .gd-tool-field.form-group { margin: 0; }
#modal-guide .gd-tool-input input,
#modal-guide .gd-tool-input select { flex: 1; min-width: 0; }
#modal-guide .gd-tool-unit { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
#modal-guide .gd-tool-out { margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid var(--border); }
#modal-guide .gd-tool-result { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; margin: 0; }
#modal-guide .gd-tool-result dt { color: var(--text-muted); }
#modal-guide .gd-tool-result dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#modal-guide .gd-tool-strong { font-weight: 700; color: var(--accent); }
#modal-guide .gd-tool-note { margin: 0.6rem 0 0; color: var(--text-muted); font-size: 0.8rem; }
#modal-guide .gd-tool-error { margin: 0; color: var(--warning); }

/* "?" next to the close button of other dialogs (injected by guide.js) */
.gd-help {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  margin-left: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.gd-help::after { content: ""; position: absolute; inset: -5px; }
.gd-help:hover { color: var(--text); }
.gd-help:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gd-help + .modal-close { margin-left: 0.5rem; }

/* Link to the chapter inside an info ("i") dialog */
.gd-info-link { margin-top: 0.8rem; min-height: var(--touch-target); }

/* "Zeig es mir": note next to the spotlighted element, with a way back */
.gd-hint {
  position: fixed;
  z-index: calc(var(--z-top) + 3); /* the target can sit in the open menu (header: --z-top + 2) */
  max-width: min(20rem, calc(100vw - 16px));
  width: max-content;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: var(--gd-hint-radius, 16px); /* follows the marked element (guide.js place()) */
  background: var(--surface2);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: center;
  line-height: 1.4;
}
.gd-hint-text { margin: 0; text-wrap: balance; }
/* Pointer towards the marked element: a rotated square that shares the box's fill and border. */
.gd-hint::before {
  content: "";
  position: absolute;
  left: var(--gd-arrow-x, 50%);
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  transform: rotate(45deg);
}
.gd-hint.is-below::before { top: -7px; border-right: 0; border-bottom: 0; border-top-left-radius: 3px; }
.gd-hint.is-above::before { bottom: -7px; border-left: 0; border-top: 0; border-bottom-right-radius: 3px; }
#modal-guide .gd-empty { color: var(--text-muted); padding: 1rem 0; }


/* ===== Übersicht: Werkzeugleiste, „Ich möchte …“, Zuletzt/Gemerkt, Stern, Gliederung, Bereichsfarben ===== */
#modal-guide .gd-main { min-width: 0; display: flex; flex-direction: column; gap: 0.6rem; }
#modal-guide .gd-top { display: flex; flex-direction: column; gap: 0.6rem; }
#modal-guide .gd-top:empty { display: none; }
#modal-guide .gd-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; }
#modal-guide .gd-tb { flex: 0 1 auto; min-height: var(--touch-target); padding: 0.4rem 0.9rem; font-size: 0.85rem; }
#modal-guide .gd-top-title { margin: 0 0 0.4rem; font-size: var(--text-base); font-weight: 700; }
#modal-guide .gd-quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: 0.5rem; }
#modal-guide .gd-quick-card {
  appearance: none;
  min-height: var(--touch-target);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-tile);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
html:not(.using-touch) #modal-guide .gd-quick-card:hover { border-color: var(--accent); }
#modal-guide .gd-quick-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#modal-guide .gd-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
#modal-guide .gd-chips-label { color: var(--text-muted); font-size: var(--text-sm); }
#modal-guide .gd-chips .status-pill { min-height: var(--touch-target); }

/* Chapter bar: title button + star. The bar of an open chapter sticks under the dialog header while its text scrolls. */
#modal-guide .gd-ch-bar { display: flex; align-items: center; border-radius: var(--radius-tile); }
#modal-guide .gd-ch-bar .gd-ch-head { width: auto; flex: 1 1 auto; min-width: 0; }
#modal-guide .gd-chapter.is-expanded > .gd-ch-bar {
  position: sticky;
  top: var(--gd-head-h, 0px);
  z-index: var(--z-settings-head);
  background: var(--surface2);
  border-radius: var(--radius-tile) var(--radius-tile) 0 0;
  border-bottom: 1px solid var(--border);
}
#modal-guide .gd-chapter.is-expanded .gd-ch-summary { display: none; }
#modal-guide .gd-fav {
  appearance: none;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--touch-target);
  height: var(--touch-target);
  margin-right: 0.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
#modal-guide .gd-fav:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }
#modal-guide .gd-fav[aria-pressed="true"] { color: var(--warning); }
#modal-guide .gd-fav[aria-pressed="true"] svg { fill: currentColor; }

#modal-guide .gd-outline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0 0 0.8rem; }
#modal-guide .gd-outline-label { color: var(--text-muted); font-size: var(--text-sm); }
#modal-guide .gd-outline-link { min-height: var(--touch-target); max-width: 100%; white-space: normal; text-align: left; overflow-wrap: anywhere; }
#modal-guide .gd-h { scroll-margin-top: calc(var(--gd-head-h, 0px) + 3.5rem); }

/* Area colours: a coloured edge on the chapter cards and a dot at the area in the table of contents. */
#modal-guide [data-area="start"]    { --gd-area: var(--accent); }
#modal-guide [data-area="debts"]    { --gd-area: var(--info); }
#modal-guide [data-area="plans"]    { --gd-area: color-mix(in srgb, var(--info) 55%, var(--accent)); }
#modal-guide [data-area="pay"]      { --gd-area: var(--warning); }
#modal-guide [data-area="taxi"]     { --gd-area: color-mix(in srgb, var(--warning) 60%, var(--accent)); }
#modal-guide [data-area="saldo"]    { --gd-area: color-mix(in srgb, var(--info) 60%, var(--danger)); }
#modal-guide [data-area="insights"] { --gd-area: color-mix(in srgb, var(--accent) 60%, var(--text)); }
#modal-guide [data-area="account"]  { --gd-area: color-mix(in srgb, var(--info) 50%, var(--text)); }
#modal-guide [data-area="faq"]      { --gd-area: color-mix(in srgb, var(--warning) 55%, var(--danger)); }
#modal-guide [data-area="glossary"] { --gd-area: color-mix(in srgb, var(--text-muted) 70%, var(--accent)); }
#modal-guide [data-area="admin"]    { --gd-area: var(--danger); }
#modal-guide .gd-chapter { border-left: 3px solid var(--gd-area, var(--border)); }

/* Table of contents: areas fold (name, number of chapters, arrow). */
#modal-guide .gd-toc-group { margin: 0.15rem 0; }
#modal-guide .gd-toc-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.15rem;
  cursor: pointer;
  list-style: none;
}
#modal-guide .gd-toc-area::-webkit-details-marker { display: none; }
#modal-guide .gd-toc-area::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--gd-area, var(--border));
  flex: 0 0 auto;
}
#modal-guide .gd-toc-area-name { flex: 1 1 auto; }
#modal-guide .gd-toc-area-count { color: var(--text-muted); font-weight: 400; }
#modal-guide .gd-toc-area::after {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform var(--transition-fast);
}
#modal-guide .gd-toc-group[open] > .gd-toc-area::after { transform: rotate(45deg); }
#modal-guide .gd-toc-area:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }

/* Phone: the filter row must not be squeezed by the flex column (it collapsed to about 11 px). */
#modal-guide .gd-filters { flex: 0 0 auto; }

/* Opening animates even with "reduce motion": a short height reveal, no rotation (the OS setting is often on in VMs and remote desktops). */
@media (prefers-reduced-motion: reduce) {
  #modal-guide .gd-ch-body { transition: grid-template-rows 0.18s linear, visibility 0s linear 0.18s; }
  #modal-guide .gd-ch-body.is-open { transition: grid-template-rows 0.18s linear, visibility 0s; }
  #modal-guide .gd-ch-chevron { transition: none; }
}

/* Print sheet (built by guide.js printGuide): invisible on screen, the only thing printed. Black on white, no controls. */
#gd-print-sheet { display: none; }
@media print {
  /* The app is dark; the sheet is not. export.css hides everything else while a sheet exists (`body > *:not(#gd-print-sheet)`). */
  html, body { background: white !important; }
  #gd-print-sheet.is-ready { display: block !important; position: static !important; color: black; background: white; font-size: 11pt; line-height: 1.45; }
  #gd-print-sheet, #gd-print-sheet * { color: black !important; background: transparent !important; box-shadow: none !important; text-shadow: none !important; opacity: 1 !important; }
  #gd-print-sheet :is(.gd-actions, .gd-related, .gd-outline, .gd-tool, .gd-install-btn, .gd-info-link) { display: none !important; }
  #gd-print-sheet .gd-ps-title { font-size: 18pt; margin: 0 0 0.8rem; }
  #gd-print-sheet .gd-ps-chapter { padding: 0.5rem 0 0.8rem; border-top: 1px solid black; }
  #gd-print-sheet .gd-ps-chapter-title { font-size: 14pt; margin: 0 0 0.4rem; break-after: avoid; }
  #gd-print-sheet .gd-h { font-size: 11.5pt; margin: 0.8rem 0 0.25rem; break-after: avoid; }
  #gd-print-sheet .gd-p, #gd-print-sheet li { margin: 0 0 0.4rem; }
  #gd-print-sheet :is(.gd-formula, .gd-callout, .gd-table-wrap) { border: 1px solid black; border-radius: 0; padding: 0.3rem 0.5rem; margin: 0.4rem 0; break-inside: avoid; }
  #gd-print-sheet table { border-collapse: collapse; width: 100%; }
  #gd-print-sheet :is(th, td) { border: 1px solid black; padding: 0.2rem 0.4rem; text-align: left; vertical-align: top; }
  #gd-print-sheet .gd-callout-icon { display: none; }
}

/* ===== Handy: kompakter Kopf, Übersicht in zwei Spalten ===== */
@media (max-width: 540px) {
  #modal-guide .modal-kicker { display: none; }
  #modal-guide .gd-mode { margin: 0.25rem 0 0.5rem; }
  #modal-guide .gd-main > .gd-search { margin: 0 0 0.25rem; }
  #modal-guide .gd-toolbar { flex-wrap: nowrap; gap: 0.4rem; }
  #modal-guide .gd-tb { flex: 1 1 0; min-width: 0; padding: 0.35rem 0.4rem; text-align: center; }
  #modal-guide .gd-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #modal-guide .gd-quick-card { padding: 0.5rem 0.6rem; font-size: 0.88rem; }
  #modal-guide .gd-chips .status-pill { max-width: 100%; white-space: normal; text-align: left; }
}

/* Single buttons: no stray margin from .btn-primary, same box as the neighbours. */
#modal-guide .gd-install-btn, #modal-guide .gd-info-link { box-sizing: border-box; min-height: var(--touch-target); }
.gd-info-link { margin-top: 0.5rem; }

/* Toolbar buttons: lit when their state holds ("Alle aufklappen" with every chapter open, "Alle zuklappen" with none), a pressed feel, a busy pulse while printing. */
#modal-guide .gd-tb { transition: border-color var(--motion-base) var(--ease-standard), background var(--motion-base) var(--ease-standard), color var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-standard); }
#modal-guide .gd-tb:active { transform: scale(0.97); }
#modal-guide .gd-tb.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
#modal-guide .gd-tb.is-busy { animation: gdBusy 0.9s var(--ease-standard) infinite; }
@keyframes gdBusy { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  #modal-guide .gd-tb:active { transform: none; }
  #modal-guide .gd-tb.is-busy { animation: none; }
}

/* ===== One button language for the whole guide =====
   Action buttons (row under a chapter, toolbar, "weitere Themen", install, info dialog, "Zeig es mir" note) share size, type, radius, border and
   motion; cards, bars, pills and icon buttons share hover, press and focus feedback. (Audit: sizes ranged from 12 to 16 px, radii and transitions varied.) */
#modal-guide :is(.gd-act, .gd-tb, .gd-more-hits, .gd-install-btn),
#modal-confirm .gd-info-link {
  box-sizing: border-box;
  min-height: var(--touch-target);
  border-width: 1px;
  border-style: solid;
  border-radius: var(--radius-btn);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  touch-action: manipulation;
  transition: border-color var(--motion-base) var(--ease-standard), background var(--motion-base) var(--ease-standard), color var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-standard), opacity var(--motion-fast) linear;
}
#modal-guide .btn-primary:is(.gd-act, .gd-install-btn) { border-color: transparent; }
#modal-guide :is(.gd-act, .gd-tb, .gd-more-hits, .gd-install-btn, .gd-quick-card):active,
.gd-return-back:active,
#modal-confirm .gd-info-link:active { transform: scale(0.98); }

/* Cards, bars and list entries: same motion as the buttons, a quiet hover and the same focus ring. */
#modal-guide .gd-quick-card { transition: border-color var(--motion-base) var(--ease-standard), background var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-standard); touch-action: manipulation; }
#modal-guide .gd-ch-head, #modal-guide .gd-toc-link, #modal-guide .gd-toc-summary, #modal-guide .gd-fav, #modal-guide .gd-toc-area { transition: background var(--motion-base) var(--ease-standard), color var(--motion-base) var(--ease-standard); touch-action: manipulation; }
html:not(.using-touch) #modal-guide .gd-ch-head:hover,
html:not(.using-touch) #modal-guide .gd-toc-summary:hover,
html:not(.using-touch) #modal-guide .gd-quick-card:hover { background: var(--surface); }
html:not(.using-touch) #modal-guide .gd-fav:hover { color: var(--warning); }
/* (The search field is left out: its bar already carries the app's own focus ring – a second one inside it looked like a double frame.) */
#modal-guide :is(button, summary, select, input:not(.loan-search-input)):focus-visible,
.gd-return-back:focus-visible,
#modal-confirm .gd-info-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#modal-guide :is(.gd-ch-head, .gd-toc-summary, .gd-fav):focus-visible { outline-offset: -2px; }
@media (pointer: coarse) {
  #modal-guide .gd-toc-link { min-height: var(--touch-target); }
}
@media (prefers-reduced-motion: reduce) {
  #modal-guide :is(.gd-act, .gd-tb, .gd-more-hits, .gd-install-btn, .gd-quick-card):active,
  .gd-return-back:active, #modal-confirm .gd-info-link:active { transform: none; }
}

/* Empty table of contents (search without hits): a quiet note instead of an empty box. */
#modal-guide .gd-toc-empty { margin: 0; padding: 0.6rem 0.25rem; color: var(--text-muted); font-size: var(--text-sm); }

/* ===== Way back: "Zurück zur Hilfe" bar (after "Zeig es mir", "In der App öffnen", the tour) and "Zurück zu …" chip (jumps inside the help) ===== */
.gd-return {
  position: fixed;
  z-index: calc(var(--z-top) + 3); /* above the open menu (header: --z-top + 2) */
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  max-width: calc(100vw - 1.5rem);
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  background: var(--surface2);
  box-shadow: var(--shadow);
  overflow: hidden;
}
html.has-tabbar .gd-return { bottom: calc(var(--app-tabbar-h) + 0.75rem); }
.gd-return.is-top, html.has-tabbar .gd-return.is-top { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 0.75rem); }
.gd-return-back, .gd-return-close {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch-target);
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--motion-base) var(--ease-standard);
}
.gd-return-back { padding: 0.4rem 0.9rem 0.4rem 0.75rem; }
.gd-return-close { width: var(--touch-target); border-left: 1px solid var(--border); color: var(--text-muted); }
.gd-return-arrow { display: inline-flex; transform: rotate(90deg); color: var(--accent-text); }
html:not(.using-touch) :is(.gd-return-back, .gd-return-close):hover { background: var(--surface); }
:is(.gd-return-back, .gd-return-close):focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.gd-return { animation: gdReturnIn 0.22s var(--ease-standard); }
@keyframes gdReturnIn { from { opacity: 0; transform: translate(-50%, 0.6rem); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .gd-return { animation: none; } }

#modal-guide .gd-backchip {
  position: sticky;
  bottom: 0.75rem;
  align-self: flex-start;
  z-index: var(--z-settings-head);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  border-color: var(--accent);
  background: var(--surface2);
  box-shadow: var(--shadow);
  animation: gdReturnInStatic 0.2s var(--ease-standard);
}
#modal-guide .gd-backchip-arrow { display: inline-flex; transform: rotate(90deg); color: var(--accent-text); flex: 0 0 auto; }
@keyframes gdReturnInStatic { from { opacity: 0; transform: translateY(0.4rem); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { #modal-guide .gd-backchip { animation: none; } }

/* ===== Terms (tap a word), "Neu" tag, rating, admin evaluation, tour, hint for newcomers ===== */
/* The help keeps its own place (keepPlace / pin in guide.js); the browser's automatic scroll anchoring would fight that. */
#modal-guide .modal-card { position: relative; overflow-anchor: none; }
#modal-guide .gd-term {
  appearance: none;
  display: inline;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  border-bottom: 1px dashed var(--accent);
  border-radius: 0;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: color var(--motion-base) var(--ease-standard), border-color var(--motion-base) var(--ease-standard);
}
html:not(.using-touch) #modal-guide .gd-term:hover, #modal-guide .gd-term[aria-expanded="true"] { color: var(--accent-text); border-bottom-style: solid; }
#modal-guide .gd-term:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }
#modal-guide .gd-term-pop {
  position: absolute;
  z-index: var(--z-dropdown-over-sticky);
  width: min(20rem, calc(100% - 1rem));
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  box-shadow: var(--shadow);
  animation: gdReturnInStatic 0.18s var(--ease-standard);
}
#modal-guide .gd-term-pop-title { margin: 0 0 0.2rem; font-weight: 700; }
#modal-guide .gd-term-pop-text { margin: 0 0 0.6rem; color: var(--text); font-size: var(--text-sm); line-height: 1.45; }
#modal-guide .gd-term-more { width: 100%; min-height: var(--touch-target); font-size: 0.88rem; }
@media (prefers-reduced-motion: reduce) { #modal-guide .gd-term-pop { animation: none; } }

#modal-guide .gd-tag-new { background: var(--accent-soft); color: var(--accent-text); }

#modal-guide .gd-vote { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.9rem; padding-top: 0.7rem; border-top: 1px solid var(--border); }
#modal-guide .gd-vote-label { color: var(--text-muted); font-size: var(--text-sm); margin-right: 0.25rem; }
#modal-guide .gd-vote-btn { flex: 0 1 auto; min-height: var(--touch-target); padding: 0.4rem 0.9rem; font-size: 0.88rem; }
#modal-guide .gd-vote-btn.is-current { border-color: var(--accent); color: var(--accent); }

#modal-guide .gd-stats-note { margin: 0 0 0.5rem; color: var(--text-muted); font-size: var(--text-sm); }
#modal-guide .gd-stats .gd-act { margin-top: 0.8rem; }

#modal-guide .gd-quick-tour { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.gd-tourbar {
  position: fixed;
  z-index: calc(var(--z-top) + 3);
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.9rem;
  max-width: calc(100vw - 1.5rem);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  background: var(--surface2);
  box-shadow: var(--shadow);
  text-align: center;
}
html.has-tabbar .gd-tourbar { bottom: calc(var(--app-tabbar-h) + 0.75rem); }
/* Ziel in der unteren Bildhälfte (Tab-Leiste der installierten App): die Leiste wandert nach oben, damit die Notiz am Ziel nicht dahinter verschwindet. */
.gd-tourbar.is-top, html.has-tabbar .gd-tourbar.is-top { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 0.75rem); }
.gd-tourbar-step { color: var(--text-muted); font-size: var(--text-sm); }
.gd-tourbar-btns { display: flex; gap: 0.4rem; }
.gd-tour-btn { flex: 0 1 auto; min-height: var(--touch-target); padding: 0.4rem 0.9rem; font-size: 0.88rem; font-weight: 600; border-radius: var(--radius-btn); }
.gd-tour-btn.is-primary { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.gd-tour-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.gd-newcomer {
  position: fixed;
  z-index: var(--z-sidebar-open); /* above the page, below dialogs */
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  width: min(24rem, calc(100vw - 1.5rem));
  max-height: 34dvh;
  overflow-y: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-card);
  background: var(--surface2);
  box-shadow: var(--shadow);
  animation: gdReturnInStatic 0.25s var(--ease-standard);
}
html.has-tabbar .gd-newcomer { right: 0.75rem; left: 0.75rem; width: auto; bottom: calc(var(--app-tabbar-h) + 0.75rem); }
@media (prefers-reduced-motion: reduce) { .gd-newcomer { animation: none; } }
.gd-newcomer-text { margin: 0; }
.gd-newcomer-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
/* Große Systemschrift (200 %, html.text-big): Text und Knöpfe in rem füllten die Karte höher, als max-height (34 dvh) erlaubt – die Knöpfe waren abgeschnitten, die Karte scrollte in sich.
   Der Hinweis ist nur ein Wink: Schrift und Abstände auf höchstens 20 px gedeckelt, die Knöpfe untereinander über die Breite. Bleibt er trotzdem zu hoch, entfernt ihn maybeShowNewcomer (guide.js). */
html.text-big .gd-newcomer { padding: min(0.8rem, 12px) min(0.95rem, 14px); gap: min(0.6rem, 8px); font-size: min(1rem, 20px); }
html.text-big .gd-newcomer-btns { flex-direction: column; align-items: stretch; gap: min(0.5rem, 8px); }
html.text-big .gd-nc-btn { width: 100%; font-size: min(0.88rem, 18px); padding: 0.4rem min(0.95rem, 14px); white-space: normal; }
.gd-nc-btn { flex: 0 1 auto; width: auto; margin: 0; min-height: var(--touch-target); padding: 0.4rem 0.95rem; font-size: 0.88rem; font-weight: 600; border-radius: var(--radius-btn); border: 1px solid var(--border); }
.gd-nc-btn.btn-primary { border-color: transparent; }

@media print {
  #gd-print-sheet :is(.gd-vote, .gd-term-pop) { display: none !important; }
  #gd-print-sheet .gd-term { border: 0; color: inherit; }
}
