/* ==========================================================================
   Landingpage – Adminbereich (ergaenzt app.css)
   ========================================================================== */

.muted { color: var(--muted); }
code { font-size: .92em; padding: 1px 5px; border-radius: 5px; background: var(--surface-2); }

/* ---------- Anmeldung ---------- */
.login { margin: 0; max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%);
  display: grid; gap: 14px;
  padding: 32px 28px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 6px 0 -10px; font-size: 30px; letter-spacing: -.03em; }
.login-card p { margin: 0; }
.login-card .back { justify-self: center; color: var(--muted); font-size: 14px; }
.login-card .back:hover { color: var(--text); }
.note { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-weight: 550; }
.button.wide { width: 100%; height: 42px; }

/* ---------- Navigation ---------- */
.admin-nav a svg { width: 19px; height: 19px; margin: 0 2px; }
.admin-nav a.is-active::before { background: var(--accent); }
.rail-foot form { margin: 0; }

/* ---------- Kopf ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 4px 0 24px;
}
.page-head h1 { margin: 0; font-size: clamp(30px, 3.6vw, 42px); line-height: 1.05; font-weight: 760; letter-spacing: -.035em; }
.page-head .meta { margin: 8px 0 0; color: var(--muted); }

/* ---------- Buttons ---------- */
.button svg { width: 18px; height: 18px; }
.button:hover { filter: brightness(1.08); }
.ghost.small { width: auto; min-height: 32px; padding: 4px 10px; font-size: 13.5px; gap: 6px; }
.ghost.small svg { width: 16px; height: 16px; }
.ghost.outline { width: auto; border: 1px solid var(--line); color: var(--text); }
.ghost.danger, .icon-btn.danger:hover { color: var(--danger); }
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Gruppen und Zeilen ---------- */
.group { margin-bottom: 22px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 0 4px 8px; }
.group-head h2 { margin: 0; font-size: 18px; font-weight: 680; letter-spacing: -.015em; flex: 1; min-width: 0; }
.group-head .path { color: var(--muted); font-weight: 450; }
.group-head .dot, .cat-rows .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.cat-rows .dot { margin: 0 9px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 6px; background: var(--surface-2);
  color: var(--muted); font-size: 12px; font-weight: 550;
}
.badge svg { width: 14px; height: 14px; }

.rows {
  list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 52px;
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 8px 7px 4px; border-radius: 10px;
}
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row:hover { background: var(--surface-2); box-shadow: none; }
.row:hover + .row { box-shadow: none; }
.row.is-dragging { opacity: .45; background: var(--surface-2); }
.grip { color: var(--muted); cursor: grab; display: grid; place-items: center; width: 22px; }
.grip svg { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 620; display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-weight: 450; font-size: 14px; }
.row-host { color: var(--muted); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-actions { display: flex; gap: 2px; flex: none; }
.drop-hint { padding: 12px 14px; color: var(--muted); font-size: 14px; }
.cat-rows .row { padding-left: calc(8px + var(--depth, 0) * 26px); }
.cat-rows .indent { display: none; }

.chip.chip-sm { width: 38px; height: 38px; border-radius: 10px; }
.chip.chip-sm .initials { font-size: 14px; }
.chip.chip-xs { width: 28px; height: 28px; border-radius: 8px; }
.chip.chip-xs .initials { font-size: 11px; }
.chip.neutral { background: var(--surface-2); }

/* ---------- Dialog ---------- */
.dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--rail); color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
}
.dialog::backdrop { background: rgba(8, 12, 20, .55); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; }
.dialog-head h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.dialog-body { padding: 8px 22px 16px; overflow-y: auto; display: grid; gap: 14px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px 16px 22px; border-top: 1px solid var(--line); }
.dialog-foot .ghost { width: auto; }
.spacer { flex: 1; }

.preview { padding: 14px; border-radius: var(--radius); background: var(--bg); }
.preview .tile { max-width: 340px; }

/* ---------- Formularfelder ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .picker input[type=search] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none;
}
.field input:focus, .field select:focus, .picker input:focus { border-color: var(--accent); }
.field input:user-invalid:not(:focus) { border-color: var(--danger); }
.hint { color: var(--muted); font-size: 12.5px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.cols.end { align-items: end; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=color] { width: 46px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.color-row .hex { width: 130px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.swatch { width: 24px; height: 24px; border-radius: 7px; border: 2px solid transparent; background: var(--c); cursor: pointer; padding: 0; }
.swatch:hover { border-color: var(--text); }

/* ---------- Symbolauswahl ---------- */
.picker { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 8px; }
.picker.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.picker-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.picker-bar input { height: 34px !important; }
.picker-bar .ghost { flex: none; border: 1px solid var(--line); }
.picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 4px;
  max-height: 196px; overflow-y: auto;
}
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px 6px; border: 2px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; min-width: 0;
}
.pick:hover { background: var(--surface-2); }
.pick.is-on { border-color: var(--accent); background: var(--surface-2); }
.pick-name { font-size: 11.5px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Symbolbibliothek ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 30px 20px; margin-bottom: 22px;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; color: var(--muted);
}
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone strong { color: var(--text); font-size: 17px; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
input.sr:focus-visible + .dropzone, input.sr:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.icon-card {
  position: relative; margin: 0; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.icon-previews { display: flex; gap: 8px; margin-bottom: 12px; }
.icon-card figcaption { display: grid; gap: 2px; min-width: 0; }
.icon-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-meta { color: var(--muted); font-size: 12.5px; }
.icon-card .icon-btn { position: absolute; top: 8px; right: 8px; }

/* ---------- Einstellungen ---------- */
.cards { display: grid; gap: 16px; max-width: 760px; }
.card { display: grid; gap: 14px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.card p { margin: 0; }
.card .picker { background: var(--bg); }
.card-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
label.ghost { cursor: pointer; }

/* ---------- Meldungen ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 11px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  transition: opacity .3s, transform .3s;
}
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-out { opacity: 0; transform: translateY(6px); }

.tile.static { pointer-events: none; }

@media (max-width: 640px) {
  .cols { grid-template-columns: 1fr; }
  .row-actions .icon-btn { width: 30px; }
  .grip { display: none; }
  .dialog-body { padding: 8px 16px 16px; }
}

/* ---------- Schnellzugriff ---------- */
.dev-rows .dev { border: 0; background: none; box-shadow: none; height: auto; padding: 0 4px; }
.row-status { color: var(--muted); font-size: 13px; text-align: right; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-rows .row:has(.dev[data-state="online"]) .row-status { color: var(--ok); }
.dev-rows .row:has(.dev[data-state="offline"]) .row-status { color: var(--danger); }
.note-below { margin: 12px 4px 0; font-size: 14px; }
.test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.test-row .ghost.small { flex: none; }
.test-result { margin: 0; font-size: 14px; color: var(--muted); }
.test-result[data-state="online"] { color: var(--ok); }
.test-result[data-state="offline"] { color: var(--danger); }
.field[hidden] { display: none; }
@media (max-width: 640px) { .row-status { display: none; } }

.alert {
  display: grid; gap: 4px; margin: 0 0 20px; padding: 14px 16px;
  border: 1px solid var(--danger); border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}
.alert strong { color: var(--danger); }
.alert span { color: var(--text); font-size: 14px; }

.alert-warn { border-color: #e0a526; background: color-mix(in srgb, #e0a526 12%, var(--surface)); grid-template-columns: 1fr auto; align-items: center; column-gap: 16px; }
.alert-warn strong { color: #e0a526; grid-column: 1; }
.alert-warn span { grid-column: 1; }
.alert-warn .small-btn { grid-column: 2; grid-row: 1 / span 2; height: 36px; font-size: 14px; }
@media (max-width: 640px) { .alert-warn { grid-template-columns: 1fr; } .alert-warn .small-btn { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 6px; } }
.ghost.outline.danger { color: var(--danger); }
.card-foot .ghost.outline.danger { margin-right: auto; }

/* ---------- Link-Editor in Startseiten-Ansicht ---------- */
.editor-bar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.cat-tab, .preview-page .subs a {
  --c: var(--accent);
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-weight: 550; font-size: 14px;
  transition: transform .12s ease, border-color .12s ease, background-color .12s ease;
}
.cat-tab:hover { color: var(--text); border-color: var(--c); }
.cat-tab.is-active { color: var(--text); border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.cat-tab .dot, .preview-page .subs .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.cat-tab .sub-mark { color: var(--muted); margin-right: -4px; }
.cat-tab.is-drop, .preview-page .subs a.is-drop {
  border-color: var(--c); border-style: dashed; color: var(--text);
  background: color-mix(in srgb, var(--c) 22%, var(--surface)); transform: scale(1.06);
}
.editor-hint { margin: 0 0 4px; color: var(--muted); font-size: 13.5px; }
.preview-page { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 4px; }
.preview-page .subs a { color: var(--text); }
.h1-badge { vertical-align: middle; margin-left: 12px; font-size: 13px; letter-spacing: 0; }

.edit-tile { position: relative; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .12s ease, border-color .15s ease, background-color .15s ease, opacity .15s ease; }
.edit-tile img { pointer-events: none; }
.edit-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.edit-tile.is-pressing { transform: scale(.97); }
.edit-tile.is-placeholder { opacity: .3; border-style: dashed; border-color: var(--accent); }
.tile-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 2px;
  padding: 2px; border-radius: 10px; background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  opacity: 0; transition: opacity .12s ease;
}
.tile-actions .icon-btn { width: 30px; height: 30px; }
.tile-actions .icon-btn svg { width: 16px; height: 16px; }
.edit-tile:hover .tile-actions, .edit-tile:focus-within .tile-actions { opacity: 1; }
@media (hover: none) { .tile-actions { opacity: 1; } }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 200; margin: 0;
  pointer-events: none; opacity: .96;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  border-color: var(--c);
}
.drag-ghost .tile-actions { display: none; }
body.is-dragging-tile, body.is-dragging-tile * { cursor: grabbing !important; user-select: none; }

.add-tile {
  border-style: dashed; background: transparent; box-shadow: none;
  color: var(--muted); cursor: pointer; text-align: left; font: inherit;
}
.add-tile .chip { background: var(--surface-2); color: var(--muted); }
.add-tile .chip svg { width: 24px; height: 24px; }
.add-tile .title { color: var(--text); }
.add-tile:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
@media (prefers-reduced-motion: reduce) { .edit-tile, .cat-tab { transition: none; } }
@media (hover: none) {
  .edit-tile .body { padding-right: 72px; }
  .tile-actions { top: 50%; transform: translateY(-50%); }
}
@media (max-width: 640px) {
  .editor-bar { flex-direction: column; align-items: stretch; }
  .cat-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
  .cat-tabs::-webkit-scrollbar { display: none; }
  .cat-tab { flex: none; }
}

/* ---------- Aussehen ---------- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); justify-self: start; }
.seg button {
  height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: none;
  color: var(--muted); font-weight: 550; font-size: 14px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.seg-lg button { height: 40px; padding: 0 18px; font-size: 15px; }
.theme-switch { display: flex; }
.bg-fields { display: grid; gap: 14px; }
.bg-fields > .muted { margin: 0; font-size: 14px; }
.range-field output { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; }
.range-field input[type=range] { width: 100%; max-width: 360px; height: auto; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.field select { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.sticky-foot { position: sticky; bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--rail) 92%, transparent); backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }

/* ---------- Freie Anordnung im Raster ---------- */
.editor-grid { position: relative; }
.editor-grid .slot {
  grid-column: var(--x); grid-row: var(--y);
  min-height: 84px; border: 1.5px dashed color-mix(in srgb, var(--line) 80%, transparent); border-radius: var(--radius);
  background: transparent; color: transparent; cursor: pointer;
  display: grid; place-items: center; transition: border-color .12s, background-color .12s, color .12s;
}
.editor-grid .slot svg { width: 22px; height: 22px; }
.editor-grid .slot:hover, .editor-grid .slot:focus-visible { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.editor-grid .slot.is-drop { border-color: var(--accent); border-style: solid; background: color-mix(in srgb, var(--accent) 16%, transparent); }
.editor-grid .edit-tile { z-index: 1; }
.editor-grid .edit-tile.is-drop { box-shadow: 0 0 0 2px var(--accent); }
body.is-dragging-tile .editor-grid .slot { border-color: var(--line); }
@media (max-width: 899px) {
  /* Auf schmalen Bildschirmen bleibt das Raster erhalten, die Kacheln werden kompakt */
  .editor-grid.grid.placed { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; grid-auto-rows: minmax(64px, auto); }
  .editor-grid.grid.placed > .tile, .editor-grid .slot { grid-column: var(--x); grid-row: var(--y); }
  .editor-grid .slot { min-height: 64px; }
  .editor-grid .edit-tile { flex-direction: column; justify-content: center; gap: 6px; padding: 8px 4px; min-height: 64px; text-align: center; }
  .editor-grid .edit-tile .chip { width: 34px; height: 34px; border-radius: 9px; }
  .editor-grid .edit-tile .body { align-items: center; max-width: 100%; }
  .editor-grid .edit-tile .title { font-size: 12px; justify-content: center; }
  .editor-grid .edit-tile .tag, .editor-grid .edit-tile .sub, .editor-grid .edit-tile .host, .editor-grid .tile-actions { display: none; }
  .editor-grid .edit-tile .body { padding-right: 0; }
}
