/* Layout and components. Colors and fonts come from theme.css, no fixed color values here. */

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

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: var(--line_height);
  letter-spacing: var(--letter_spacing);
  color: var(--color-text);
  background: var(--color-background);
}

h1, h2, h3 { color: var(--color-text-strong); font-weight: var(--font-weight-heading); line-height: 1.3; letter-spacing: 0.5px; }
h1 { font-size: 1.75rem; margin: 0 0 var(--spacing); }
h2 { font-size: 1.25rem; margin: calc(var(--spacing) * 2.25) 0 calc(var(--spacing) * 0.75); }
h3 { font-size: 1.05rem; margin: var(--spacing) 0 8px; }
h4 { font-size: 0.95rem; color: var(--color-text-strong); margin: calc(var(--spacing) * 1.25) 0 6px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
/* Links and quiet buttons: lighter than the main color in dark mode (see below), otherwise the same */
:root { --color-link: var(--color-primary); }
@media (prefers-color-scheme: dark) {
  :root { --color-link: color-mix(in srgb, var(--color-primary) 60%, var(--color-text-strong)); }
}
a { color: var(--color-link); }
small, .muted { color: var(--color-text-muted); font-size: 0.88em; }
code { font-size: 0.9em; background: var(--color-surface); padding: 1px 5px; border-radius: var(--radius-small); }

/* hidden wins over display rules (buttons are inline-flex) */
[hidden] { display: none !important; }

/* Buttons and forms */
.button, button {
  font: inherit; font-size: 0.95rem; letter-spacing: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: 1px solid var(--color-primary); border-radius: var(--radius);
  background: var(--color-primary); color: var(--color-primary-text);
  cursor: pointer; text-decoration: none; white-space: nowrap; justify-content: center;
}
.button:hover, button:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.button-muted, button.button-muted { background: transparent; color: var(--color-link); }
.button-muted:hover, button.button-muted:hover { background: var(--color-soft); color: var(--color-link); }
/* Third level: secondary actions without a border (order, reset) */
.button-text, button.button-text { background: transparent; border-color: transparent; color: var(--color-link); padding: 4px 8px; font-size: 0.85rem; }
.button-text:hover, button.button-text:hover { background: var(--color-soft); border-color: transparent; color: var(--color-link); }
button.button-text:disabled { opacity: 0.3; cursor: default; }
.button-small, button.button-small { padding: 4px 12px; font-size: 0.85rem; }
.button-danger, button.button-danger { background: transparent; color: var(--color-error); border-color: var(--color-error); }
.button-danger:hover, button.button-danger:hover { background: var(--color-error-surface); color: var(--color-error); }
button:disabled { opacity: 0.5; cursor: wait; }

input, textarea, select {
  font: inherit; font-size: 0.95rem; color: var(--color-text-strong);
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-background);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--color-soft-border); border-color: var(--color-primary); }
input[type=checkbox] { width: auto; }
input[type=file] { padding: 6px; }
input[type=file]::file-selector-button { font: inherit; font-size: 0.85rem; margin-right: 10px; padding: 4px 12px; cursor: pointer;
  border: 1px solid var(--color-primary); border-radius: var(--radius); background: transparent; color: var(--color-link); }
input[type=file]::file-selector-button:hover { background: var(--color-soft); }
label { display: block; font-size: 0.9rem; color: var(--color-text-muted); margin: 12px 0 4px; }
textarea.large { min-height: 360px; font-family: ui-monospace, Menlo, monospace; font-size: 0.88rem; line-height: 1.5; }
.form-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-row > * { flex: 1 1 140px; }
.form-row > button, .form-row > .button { flex: 0 0 auto; }
.form-row > form:not(:has(input:not([type=hidden]), select, textarea)) { flex: 0 0 auto; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-row form { margin: 0; }
.title-row { display: flex; flex-wrap: wrap; gap: 8px var(--spacing); align-items: center; justify-content: space-between; margin-bottom: var(--spacing); }
.title-row h1 { margin: 0; }
.spacing-left { margin-left: 8px; }
details.help-text { margin: 0 0 var(--spacing); font-size: 0.9rem; color: var(--color-text-muted); }
details.help-text > summary { cursor: pointer; display: inline-block; color: var(--color-link); }
details.help-text > p { margin: 6px 0 0; }

.selection { position: relative; }
.inline { display: inline; }
.no-wrap { white-space: nowrap; }
input.field-amount { width: 9em; }
input.field-slug { width: 14em; }
.right { text-align: right; }

/* Messages */
.message { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 10px; font-size: 0.95rem; }
.message-ok { background: var(--color-ok-surface); color: var(--color-ok); }
.message-error { background: var(--color-error-surface); color: var(--color-error); }
.message-warning { background: var(--color-warning-surface); color: var(--color-warning); }
.autosave-status { margin: 6px 0 0; font-size: 0.88em; color: var(--color-text-muted); }
.autosave-status:empty { display: none; }
.autosave-status.message { padding: 6px 10px; }
form[data-autosave] { position: relative; }
form[data-autosave] > .autosave-status:not(.message) { position: absolute; top: 0; right: 0; z-index: 2; margin: 0; padding: 2px 10px;
  border-radius: 99px; background: var(--color-ok-surface); color: var(--color-ok); pointer-events: none; }
form[data-autosave] > .autosave-status:not(.message):has(a) { pointer-events: auto; }
form.card[data-autosave] > .autosave-status:not(.message) { top: 10px; right: 14px; }
.rename > .autosave-status:not(.message) { position: static; }
td .autosave-status { display: inline-block; margin: 0 0 0 6px; }
td .autosave-status:empty { display: none; }

/* Cards and tables */
.card { background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-large); padding: calc(var(--spacing) * 1.25); margin-bottom: var(--spacing); box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--spacing); margin-bottom: var(--spacing); }
.tile { background: var(--color-soft); border-radius: var(--radius-large); padding: var(--spacing); }
.tile b { display: block; font-size: 1.5rem; color: var(--color-text-strong); }
a.tile { display: block; color: inherit; text-decoration: none; }
a.tile:hover { outline: 2px solid var(--color-soft-border); }
.tile-warning { background: var(--color-warning-surface); }
.progress { height: 6px; margin: 8px 0 var(--spacing); border-radius: 3px; background: var(--color-border); overflow: hidden; }
.progress div { height: 100%; background: var(--color-ok); }
.steps li.done a, .steps li.done span:not(.badge) { color: var(--color-text-muted); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: calc(var(--spacing) * 0.75); }
.steps li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.steps li .muted { flex-basis: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { color: var(--color-text-muted); font-weight: normal; font-size: 0.85rem; }
.table-scroll { overflow-x: auto;
  background: linear-gradient(to right, var(--color-background) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--color-background) 30%, transparent) right center / 40px 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--color-text-strong) 16%, transparent), transparent) left center / 12px 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--color-text-strong) 16%, transparent), transparent) right center / 12px 100% no-repeat scroll,
    var(--color-background); }
.badge { display: inline-block; font-size: 0.75rem; padding: 1px 8px; border-radius: 99px; background: var(--color-soft); color: var(--color-primary); text-transform: uppercase; letter-spacing: 0.6px; font-weight: bold; }
.badge-off { background: var(--color-surface); color: var(--color-text-muted); }
.badge-ok { background: var(--color-ok-surface); color: var(--color-ok); }
.badge-warning { background: var(--color-warning-surface); color: var(--color-warning); }
.badge-error { background: var(--color-error-surface); color: var(--color-error); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: var(--spacing); background: var(--color-soft); }
.login .card { width: 100%; max-width: 420px; }

/* App frame: sidebar + content */
.frame { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { background: var(--color-surface); border-right: 1px solid var(--color-border); display: flex; flex-direction: column; padding: var(--spacing); gap: 10px; overflow-y: auto; }
.color-field { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 3px; border: 1px solid var(--color-border, #ccc); vertical-align: middle; }
.brand-logo { display: block; max-width: 180px; max-height: 64px; width: auto; height: auto; object-fit: contain; }
.login .brand-logo { margin: 0 auto var(--spacing); }
.sidebar .brand-logo { margin-bottom: 6px; }
.color-choice { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.color-choice input[type=color] { width: 44px; height: 38px; padding: 2px; flex: none; }
.color-choice input:not([type=color]) { width: 9em; flex: none; }
.appearance-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--spacing); }
.appearance-mode { border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--spacing); margin: 0 0 var(--spacing); }
.sidebar .brand-name { font-weight: bold; color: var(--color-primary); font-size: 1.1rem; margin-bottom: 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--color-text); text-decoration: none; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav a:hover { background: var(--color-soft); }
.sidebar nav a.active { background: var(--color-soft); color: var(--color-primary); font-weight: bold; }
.sidebar .menu-title { margin: 14px 0 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; opacity: 0.7; }
.sidebar nav a.menu-back { font-size: 0.88rem; opacity: 0.85; }
.sidebar .menu-area { margin: 10px 0 0; padding: 0 12px; font-weight: bold; font-size: 1rem; }
.counter { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 99px; font-size: 0.75rem; text-align: center; background: var(--color-primary); color: var(--color-primary-text); }
.read-aloud-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sidebar .bottom a.bar-link { color: inherit; }
.sidebar .bottom { margin-top: auto; font-size: 0.88rem; display: flex; flex-direction: column; gap: 8px; }
.content { overflow-y: auto; }
.content-inner { max-width: var(--content-max); margin: 0 auto; padding: calc(var(--spacing) * 2) var(--spacing); }
.admin .sidebar { background: var(--color-secondary); border-color: var(--color-secondary); }
.admin .sidebar, .admin .sidebar nav a { color: #e8ecf3; }
.admin .sidebar nav a:hover, .admin .sidebar nav a.active { background: rgba(255,255,255,0.12); color: #ffffff; }
.admin .sidebar :focus-visible { outline: 2px solid var(--color-primary-text); outline-offset: 2px; }
.admin .sidebar .brand-name { color: #ffffff; }
.admin .sidebar .button-muted, .admin .sidebar button.button-muted { color: #ffffff; border-color: rgba(255,255,255,0.4); }
.admin .sidebar .button-muted:hover { background: rgba(255,255,255,0.12); }
.admin .content-inner { max-width: 1040px; }
/* Pages with wide lists (outbox, analytics, events, customers) may take more space */
.admin .content-inner:has(.list-wide) { max-width: 1320px; }
/* Calmer rounding in the admin than on the chat bubbles */
.admin .card, .admin .tile, .admin .stage-card { border-radius: min(var(--radius-large), 14px); }
@media (prefers-color-scheme: dark) { .admin .sidebar { border-right-color: var(--color-border); } }

/* Balance display */
.balance { background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; font-size: 0.88rem; }
.balance b { color: var(--color-text-strong); }

/* Chat */
.chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.chat-header { padding: 12px var(--spacing); border-bottom: 1px solid var(--color-border); display: flex; gap: 10px; align-items: center; }
.chat-header h1 { font-size: 1.1rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title { flex: 1; min-width: 0; line-height: 1.3; }
.chat-title:has(h1[hidden]) { display: none; }
.chat-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header { position: relative; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.header-actions form { margin: 0; }
.header-actions .delete-header { margin-left: 12px; }
.header-more { display: none; }
.rename { display: flex; gap: 8px; flex: 1; align-items: center; }
.rename input { flex: 1; min-width: 0; }
.top-up-offers { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.only-reader { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.history { flex: 1; overflow-y: auto; padding: var(--spacing); }
.history-inner { max-width: var(--content-max); margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 85%; padding: 12px 18px; border-radius: var(--radius-large); white-space: pre-wrap; word-wrap: break-word; }
.bubble-user { align-self: flex-end; background: var(--color-soft); color: var(--color-text-strong); border-bottom-right-radius: var(--radius-small); }
.bubble-assistant { align-self: flex-start; background: var(--color-surface); border-bottom-left-radius: var(--radius-small); }
.bubble-error { align-self: center; background: var(--color-error-surface); color: var(--color-error); font-size: 0.92rem; }
/* Markdown in replies */
.bubble.md { white-space: normal; }
.bubble.md > :first-child { margin-top: 0; }
.bubble.md > :last-child { margin-bottom: 0; }
.bubble.md p, .bubble.md ul, .bubble.md ol, .bubble.md blockquote { margin: 0 0 0.7em; }
.bubble.md ul, .bubble.md ol { padding-left: 1.4em; }
.bubble.md h3, .bubble.md h4, .bubble.md h5, .bubble.md h6 { margin: 0.9em 0 0.4em; font-size: 1.02em; }
.bubble.md blockquote { padding: 6px 12px; border-left: 3px solid var(--color-soft-border); background: var(--color-background); border-radius: var(--radius-small); }
.bubble.md hr { border: 0; border-top: 1px solid var(--color-border); margin: 0.9em 0; }
/* Tables wrap inside the cells instead of scrolling sideways. A bubble with a table may use the
   whole history width. Sideways scrolling only happens when there is no other way. */
.bubble:has(.md-table) { max-width: 100%; }
.md-table { overflow-x: auto; margin: 0 0 0.7em; }
.md-table table { width: 100%; border-collapse: collapse; font-size: 0.88em; background: var(--color-background); }
.md-table th, .md-table td { border: 1px solid var(--color-border); padding: 6px 8px; text-align: left; vertical-align: top;
  overflow-wrap: break-word; }
.md-table th { background: var(--color-soft); }
/* Reply buttons and forms ([auswahl] blocks, see markdown.js) */
form.selection { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 0.5em 0 0.2em; }
.selection-buttons, .selection-options { display: flex; flex-wrap: wrap; gap: 6px; }
form.selection button { white-space: normal; text-align: left; }
.selection-button { background: var(--color-background); color: var(--color-primary); padding: 6px 14px; }
.selection-button:hover { background: var(--color-soft); color: var(--color-primary); }
.selection-button.selected { background: var(--color-primary); color: var(--color-primary-text); opacity: 1; }
.selection-option { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 12px; font-size: 0.92rem;
  background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer; }
.selection-option:has(input:checked) { border-color: var(--color-primary); background: var(--color-soft); color: var(--color-text-strong); }
.selection-option input { width: auto; margin: 0; accent-color: var(--color-primary); }
.selection-row { display: grid; grid-template-columns: minmax(7em, max-content) 1fr; gap: 6px 12px; align-items: center; width: 100%; }
.selection-label { font-weight: var(--font-weight-heading); }
/* Pairwise comparison ([sortieren] blocks, see sortieren.js) */
.sort { border: 1px solid var(--color-border); border-radius: var(--radius-large); padding: calc(var(--spacing) * 1.25);
  width: min(480px, calc(100vw - 32px)); background: var(--color-background); color: var(--color-text); box-shadow: var(--shadow);
  text-align: center; }
.sort::backdrop { background: rgba(0, 0, 0, 0.35); }
.sort button:disabled { cursor: default; }
.sort-number { font-size: 0.85rem; color: var(--color-text-muted); }
.sort-bar { height: 4px; margin: 8px 0 var(--spacing); border-radius: 2px; background: var(--color-border); overflow: hidden; }
.sort-bar div { height: 100%; background: var(--color-primary); }
.sort-question { margin: 0 0 var(--spacing); color: var(--color-text-strong); font-weight: var(--font-weight-heading); }
.sort-pair { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.sort-muted { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: var(--spacing); }
.sort-muted .button-muted { border-color: transparent; font-size: 0.9rem; padding: 6px 10px; }
.sort-notice { margin: 0 0 8px; font-size: 0.85rem; color: var(--color-text-muted); }
.sort-list { margin: 0; padding: 0 0 0 1.6em; text-align: left; }
.sort-list li { padding: 4px 0; border-bottom: 1px solid var(--color-border); }
.sort-list li:last-child { border-bottom: none; }
.sort-list li > * { vertical-align: middle; }
.sort-term { display: inline-block; width: calc(100% - 5.5em); overflow-wrap: anywhere; }
.sort-arrows { display: inline-flex; gap: 2px; }
.sort-arrows button { padding: 4px 9px; border-color: transparent; }

/* Export link ([export], see markdown.js) */
.bubble .export { margin: 10px 0 0; }
.bubble .export .button { text-decoration: none; }
.send-selection { padding: 8px 18px; }
form.selection.done { opacity: 0.6; }
form.selection.done button:disabled, form.selection.done .selection-option { cursor: default; }
@media (max-width: 600px) { .selection-row { grid-template-columns: 1fr; } }
.bubble .meta { display: block; margin-top: 8px; font-size: 0.78rem; color: var(--color-text-muted); white-space: normal; }
.bubble .copy, .bubble .again { display: block; margin-top: 8px; }
.enters::after { content: "▍"; animation: blinken 1s steps(1) infinite; color: var(--color-primary); }
@keyframes blinken { 50% { opacity: 0; } }
.chat-input { border-top: 1px solid var(--color-border); padding: 12px var(--spacing); }
.chat-input form { max-width: var(--content-max); margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea { resize: none; min-height: 48px; max-height: 220px; }
.input-row { max-width: var(--content-max); margin: 0 auto; }
.ai-notice { max-width: var(--content-max); margin: 6px auto 0; font-size: 0.78rem; color: var(--color-text-muted); text-align: center; }
.empty { margin: auto; text-align: center; max-width: 760px; padding: calc(var(--spacing) * 3) var(--spacing); }
.lock { max-width: var(--content-max); margin: 0 auto; text-align: center; padding: var(--spacing); background: var(--color-soft); border-radius: var(--radius-large); }

/* Admin test chat */
.test-grid { display: grid; grid-template-columns: 1fr 260px; gap: var(--spacing); }
/* The test chat uses the full window width so wide replies (tables) have room */
.admin .content-inner:has(.test-grid) { max-width: none; }
.test-history > .meta { margin-top: -8px; font-size: 0.78rem; color: var(--color-text-muted); }
/* The left card is as tall as the right column, the history fills it, the form sits at the bottom.
   test.js sets the grid's minimum height so the form stays at the bottom of the window even with a short right column. */
.test-grid > .card { display: flex; flex-direction: column; }
.test-grid > .card > form { flex: 0 0 auto; }
.test-history { flex: 1 1 320px; min-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px; }

/* Customers & balance */
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: var(--spacing); }
.user-filter { margin-bottom: var(--spacing); }
.user-filter > div { flex: 0 1 200px; }
td.number, th.number { text-align: right; white-space: nowrap; }
.warning, .tile b.warning { color: var(--color-warning); }
.assistants-selection { margin-top: .75rem; }
.assistants-header { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-weight: 600; }
.assistants-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }
.assistants-grid label { display: flex; gap: 6px; align-items: baseline; font-weight: normal; }

/* Visible keyboard focus */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Mobile */
.menu-button { display: none; }
@media (max-width: 860px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  /* invisible when closed so Tab does not jump into the shifted sidebar */
  .sidebar { position: fixed; inset: 0 25% 0 0; z-index: 20; transform: translateX(-105%); visibility: hidden;
    transition: transform 0.2s, visibility 0.2s; }
  .sidebar.pending { transform: none; visibility: visible; }
  .menu-button { display: inline-flex; }
  body.bar-pending::before { content: ""; position: fixed; inset: 0; z-index: 19; background: var(--dim-color); }
  .header-more { display: inline-flex; }
  .header-actions { display: none; position: absolute; right: var(--spacing); top: 100%; z-index: 10; flex-direction: column;
    align-items: stretch; background: var(--color-background); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
  .header-actions.pending { display: flex; }
  .header-actions .delete-header { margin-left: 0; }
  .ai-notice { font-size: 0.68rem; line-height: 1.3; margin-top: 4px; }
  .chat-input { padding: 8px 12px; }
  .test-grid { grid-template-columns: 1fr; }
  .bubble { max-width: 95%; }
}

/* Two-factor: QR code and emergency codes */
.qr { text-align: center; margin: var(--spacing) 0; }
.qr svg { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto; }
.backup-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.backup-code { font-family: monospace; font-size: 1.05em; padding: 6px 10px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-small); text-align: center; }
#secret { overflow-wrap: anywhere; }
.sidebar nav a small { display: block; font-weight: normal; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 320px)); justify-content: center; gap: var(--spacing); text-align: left; margin-top: var(--spacing); }
.cards .card { display: flex; flex-direction: column; gap: 8px; padding: var(--spacing); background: var(--color-soft); border-radius: var(--radius-large); }
.cards .card h3 { margin: 0; }
.cards .card p { margin: 0; flex: 1; }

/* Comparison: columns side by side, stacked below 700 px */
.admin .content-inner:has(.v-grid) { max-width: none; }
.v-grid { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: var(--spacing); align-items: start; }
.v-grid .card { margin-bottom: 0; }
.v-step { grid-column: 1 / -1; padding: 8px 12px; background: var(--color-soft); border-radius: var(--radius-small); font-weight: 600; }
.v-cell { background: var(--color-surface); border-radius: var(--radius-large); padding: 12px 16px; min-width: 0; }
.v-cell .v-label { display: none; font-size: 0.78rem; }
.v-cell .v-text.md { white-space: normal; }
.v-cell .v-text:not(.md) { white-space: pre-wrap; word-wrap: break-word; }
.v-cell .meta { margin-top: 8px; font-size: 0.78rem; color: var(--color-text-muted); }
.v-cell.error { background: var(--color-error-surface); color: var(--color-error); }
.v-total { font-size: 0.88rem; }
@media (max-width: 700px) {
  .v-grid { grid-template-columns: 1fr; }
  .v-cell .v-label { display: block; }
}

/* Confirmation before deleting (replaces confirm()) */
.confirm-prompt { border: 1px solid var(--color-border); border-radius: var(--radius-large); padding: calc(var(--spacing) * 1.25);
  max-width: min(420px, calc(100vw - 32px)); background: var(--color-background); color: var(--color-text); box-shadow: var(--shadow); }
.confirm-prompt::backdrop { background: rgba(0, 0, 0, 0.35); }
.confirm-prompt p { margin: 0 0 var(--spacing); color: var(--color-text-strong); }
.confirm-prompt-buttons { display: flex; justify-content: flex-end; gap: 8px; }

/* View knowledge file (admin/wissen.html) */
.knowledge-file-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem; line-height: 1.5; max-height: 75vh; overflow-y: auto; }

/* Footer with legal texts, legal pages, confirmation, offers on the lock screen */
.footer { padding: 12px var(--spacing); text-align: center; font-size: 0.85rem; }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; }
.sidebar .legal-links { justify-content: flex-start; font-size: 0.8rem; }
.legal-links a { color: var(--color-text-muted); }
.platform-notice { color: var(--color-text-muted); }
.legal-text { margin-bottom: calc(var(--spacing) * 2); }
/* contact details as SVG outlines (app/contact_svg.py): sits on the text baseline, colour of the text */
.contact-svg { display: inline-block; vertical-align: -0.24em; max-width: 100%; }
.contact-svg-lines { vertical-align: text-top; }  /* address on its own lines: first line next to the text line */
.login .card-wide { max-width: 720px; }
.confirm-text { max-height: 50vh; overflow-y: auto; padding: var(--spacing); background: var(--color-surface); border-radius: var(--radius-large); }
.offers { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.offers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.banner { padding: 10px var(--spacing); background: var(--color-warning-surface); color: var(--color-text-strong); border-radius: var(--radius); margin-bottom: var(--spacing); }

/* Recovery code */
.code-large { font-size: 1.3rem; letter-spacing: .08em; text-align: center; padding: var(--spacing); background: var(--color-soft); border-radius: var(--radius); }
@media print { .sidebar, button, form { display: none !important; } }

/* Tabs within an admin page (settings: General, Address) */
.tab { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 0 0 1.25rem; border-bottom: 1px solid var(--color-border); }
.tab a { padding: 8px 14px; margin-bottom: -1px; color: var(--color-text); text-decoration: none; font-size: 0.95rem;
  border-bottom: 3px solid transparent; border-radius: var(--radius-small) var(--radius-small) 0 0; }
.tab a:hover { background: var(--color-soft); }
.tab a.active { font-weight: 600; color: var(--color-link); border-bottom-color: var(--color-primary); }
.tab .counter { margin-left: 4px; }
/* Narrow screens: one row to swipe instead of wrapping */
@media (max-width: 720px) { .tab { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .tab a { white-space: nowrap; flex: 0 0 auto; } }
/* Tabs within a page (tab.js): stay visible while scrolling */
.tab[data-tab] { position: sticky; top: 0; z-index: 3; background: var(--color-background); padding-top: 6px; }

/* Voice input (diktat.js) */
button.dictation-button { background: transparent; color: var(--color-primary); border-color: var(--color-border);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; }
button.dictation-button:hover { background: var(--color-soft); color: var(--color-primary); }
button.dictation-button.records { color: var(--color-error); border-color: var(--color-error); font-variant-numeric: tabular-nums; }
.dictation-point { width: 10px; height: 10px; border-radius: 50%; background: var(--color-error); animation: diktat-puls 1.2s infinite; }
.load-dictation { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--color-border);
  border-top-color: var(--color-primary); animation: diktat-dreh 0.8s linear infinite; }
.dictation-message { color: var(--color-text-muted); font-size: 0.88em; margin: 4px 0 0; }
.dictation-message:empty { display: none; }
@keyframes diktat-puls { 50% { opacity: 0.3; } }
@keyframes diktat-dreh { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dictation-point, .load-dictation { animation: none; } }

.product-card summary { cursor: pointer; }
.product-card form { margin-top: 12px; }
.button-bar-sticky:not(:has(button:not([hidden]))):has(.autosave-status:empty),
.button-bar-sticky:not(:has(button:not([hidden]))):not(:has(.autosave-status)) { display: none; }
.button-bar-sticky { position: sticky; bottom: 0; z-index: 1; margin: var(--spacing) calc(var(--spacing) * -1.25) calc(var(--spacing) * -1.25); padding: 10px calc(var(--spacing) * 1.25); background: var(--color-background); border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-large) var(--radius-large); }

/* Package 8: earlier versions of the instructions */
details.version { border-top: 1px solid var(--color-border); padding: calc(var(--spacing) / 2) 0; }
details.version:first-child { border-top: 0; }
details.version > summary { cursor: pointer; }

/* Package 8: sections of the assistant page; the note for promotion chats only appears when checked */
fieldset.section { border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--spacing); margin: 0 0 var(--spacing); min-width: 0; }
fieldset.section > legend { font-weight: var(--font-weight-heading); padding: 0 calc(var(--spacing) / 3); }
.promotion:not(:has(input[name="chats_viewable"]:checked)) .only-promotion { display: none; }

/* Package 8: legal texts with large fields and a "Seite ansehen" link */
.field-header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--spacing); }
textarea.legal-text { min-height: 24rem; }
tr.total th, tr.total td { border-top: 2px solid var(--color-border); }

/* Stages: vertical chain (admin) */
.stages-chain { list-style: none; padding: 0; margin: 0 0 var(--spacing); }
.stage-card { display: flex; align-items: center; gap: var(--spacing); flex-wrap: wrap; position: relative;
  background: var(--color-background); border: 1px solid var(--color-border); border-radius: var(--radius-large);
  padding: calc(var(--spacing) * 0.75) var(--spacing); margin-bottom: calc(var(--spacing) * 0.75); }
.stage-card + .stage-card::before { content: ""; position: absolute; left: 1.6rem; top: calc(var(--spacing) * -0.75);
  height: calc(var(--spacing) * 0.75); border-left: 2px solid var(--color-border); }
.stage-nr { font-weight: var(--font-weight-heading); min-width: 1.6rem; text-align: center; }
.stage-info { flex: 1 1 14rem; display: flex; flex-direction: column; }

/* Stages in the chat */
.stage-progress { font-size: 0.9rem; padding: 8px var(--spacing); border-bottom: 1px solid var(--color-border); }
.stage-progress-inner { max-width: var(--content-max); margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.stage-progress-inner b { color: var(--color-text-strong); }
.stage-bar { flex: 1 1 120px; height: 6px; border-radius: 3px; background: var(--color-border); overflow: hidden; }
.stage-bar div { height: 100%; background: var(--color-primary); }
.stage-separator { align-self: stretch; text-align: center; font-size: 0.85rem; font-weight: var(--font-weight-heading);
  color: var(--color-link); margin: var(--spacing) 0 4px; border-top: 2px solid var(--color-soft-border); padding-top: 8px; }
#stage-next { margin: 8px 0; }

/* Providers as collapsible cards */
details.provider > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
details.provider > summary::before { content: "▸"; color: var(--color-text-muted); }
details.provider[open] > summary::before { content: "▾"; }
details.provider > summary { list-style: none; }
details.provider > summary::-webkit-details-marker { display: none; }
details.provider > summary h3 { margin: 0; }

/* Compliance-API: JSON input and output of the test run */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
