/* Highland Base – base layout. Desktop master-detail, mobile single column. */

/* Locally hosted fonts (no external requests; works under the strict CSP).
   Inter = UI text, Fraunces = warm serif for headings/brand. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/static/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/static/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700;
  font-display: swap; src: url("/static/fonts/inter-700.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 500;
  font-display: swap; src: url("/static/fonts/fraunces-500.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 600;
  font-display: swap; src: url("/static/fonts/fraunces-600.woff2") format("woff2"); }

/* Design tokens – single source of truth (UI-Leitfaden §2).
   Palette "zeitgenössisch-alpin": Papier/Kalkstein, Alpin-Grün, Lärche/Holz.
   The serif display face stays Fraunces (a warm serif, already self-hosted –
   the Leitfaden lists Spectral as a recommendation with serif alternatives). */
:root {
  /* Farben */
  --ink:            #262420;  /* Text, warmes Fast-Schwarz */
  --ink-muted:      #6b665c;  /* Labels, Sekundärtext */
  --paper:          #f3efe6;  /* App-Hintergrund */
  --surface:        #faf8f2;  /* Karten/Panels */
  --surface-sunken: #ece7dc;  /* eingelassene Bereiche, Tabellenkopf */
  --border:         #d9d3c6;  /* Haarlinien-Rahmen */

  --green:          #2f5d50;  /* Leitfarbe: Topbar, Primär-Buttons */
  --green-hover:    #274d43;
  --green-soft:     #e3ece8;  /* aktiver Nav-Hintergrund, weiche Tints */

  --wood:           #a9763f;  /* Lärche/Holz-Akzent – SEHR sparsam */

  --success: #3f7d5f;  --success-soft: #e4efe8;
  --warning: #b5862f;  --warning-soft: #f3ead2;
  --danger:  #9c4a3c;  --danger-soft:  #f1e0db;

  --focus:   #2f5d50;  /* Fokus-Ring */

  /* Abstände (4px-Basis) */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px; --s7:48px; --s8:64px;

  /* Radien */
  --r-sm:4px; --r-md:8px; --r-lg:12px;

  /* Schatten – bewusst dezent */
  --shadow-sm: 0 1px 2px rgba(38,36,32,.05);
  --shadow-md: 0 2px 8px rgba(38,36,32,.06);

  /* Typo */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-display:28px; --fs-h2:20px; --fs-h3:16px;
  --fs-body:15px;    --fs-small:13px;
  --lh-tight:1.25;   --lh-body:1.5;

  /* Kompatibilitäts-Aliase: bestehende Selektoren auf die Tokens umgestellt
     (eine Quelle der Wahrheit; Alt-Namen werden schrittweise abgelöst). */
  --bg:          var(--paper);
  --bg-soft:     var(--surface-sunken);
  --panel:       var(--surface);
  --muted:       var(--ink-muted);
  --line:        var(--border);
  --line-strong: var(--border);
  --accent:      var(--green);
  --accent-ink:  var(--green-hover);
  --accent-soft: var(--green-soft);
  --gold:        var(--wood);
  --error:       var(--danger);
  --radius:      var(--r-md);
  --shadow:      var(--shadow-md);
  --font-ui:     var(--font-body);
  --font-head:   var(--font-display);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  font-family: var(--font-ui);
  font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-wrap: break-word;   /* long words/URLs wrap instead of widening */
}
input[type=file] { max-width: 100%; }
.rt-area, .richtext { overflow-wrap: anywhere; }
/* Nothing wider than the viewport (no horizontal scroll on mobile). */
img { max-width: 100%; }
h1, h2, h3, legend, .brand {
  font-family: var(--font-head); font-weight: 600;
  letter-spacing: .1px; color: var(--ink);
}
h1 { font-size: var(--fs-display); line-height: var(--lh-tight); margin: .2rem 0 .6rem; }
h2 { font-size: var(--fs-h2); margin: 1.4rem 0 .5rem; font-weight: 600; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
button { font: inherit; cursor: pointer; }
button[type="submit"] {
  background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: .55rem 1.05rem; font-weight: 500;
  transition: background .15s ease, transform .02s ease;
}
button[type="submit"]:hover { background: var(--accent-ink); }
button[type="submit"]:active { transform: translateY(1px); }
.link-btn { background: none; border: 0; color: var(--accent); padding: 0;
  text-decoration: none; }
.link-btn:hover { color: var(--accent-ink); }
/* A submit button used as an inline text action: the global button[type=submit]
   rule above has higher specificity, so without this it renders as a filled
   green button whose label vanishes on hover (dark text on the dark hover bg).
   These selectors outrank it and restore the link look. */
button[type="submit"].link-btn {
  background: none; border: 0; border-radius: 0; padding: 0;
  font-weight: 400; color: var(--accent);
}
button[type="submit"].link-btn:hover { background: none; color: var(--accent-ink); }
/* Visible keyboard focus everywhere (accessibility). */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* Login */
body.centered {
  display: grid; place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
}
.login-card {
  background: var(--panel); padding: 2rem 2rem 2.2rem; border: 1px solid var(--line);
  border-radius: 14px; width: min(360px, 92vw); box-shadow: var(--shadow);
}
.login-card form { display: grid; gap: .35rem; }
.login-card label { font-size: .85rem; color: var(--muted); margin-top: .5rem; }
.login-card input { padding: .6rem; border: 1px solid var(--line-strong); border-radius: 8px; }
.login-card button { margin-top: 1.1rem; padding: .6rem; }
.error { color: var(--error); font-size: .9rem; }
.notice { color: var(--accent-ink); background: var(--accent-soft);
  padding: .5rem .7rem; border-radius: 7px; font-size: .9rem; }

/* App shell: desktop master-detail grid */
/* The page itself never scrolls – only the content middle does. This prevents
   any whole-page horizontal/vertical scroll if a child is slightly too wide. */
body.app { background: var(--bg); overflow: hidden; }
.layout {
  display: grid;
  height: 100vh; height: 100dvh;   /* dvh: stable under iOS toolbars/insets */
  grid-template-columns: 220px 360px 1fr;
  grid-template-rows: 52px 1fr;
  grid-template-areas:
    "top top top"
    "side master detail";
}
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 1rem;
  /* Background reaches the top edge; content sits below the Dynamic Island and
     clears the side safe areas (landscape). On desktop the insets are 0. */
  padding:
    env(safe-area-inset-top, 0px)
    max(1.1rem, env(safe-area-inset-right, 0px))
    0
    max(1.1rem, env(safe-area-inset-left, 0px));
  min-height: calc(52px + env(safe-area-inset-top, 0px));
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.topbar .brand { color: #fff; font-size: 1.15rem; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }

/* Consistent form controls across the app. */
input, select, textarea { font: inherit; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=search], input[type=date], input[type=number], select, textarea {
  padding: .5rem .6rem; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--panel);
}
/* Never let a control (esp. a <select> sized to its longest option, or a file
   input) grow wider than its container – the main cause of mobile overflow. */
input, select, textarea { max-width: 100%; min-width: 0; }
input::placeholder { color: var(--muted); }

/* User menu: CSS-only dropdown via <details> */
.usermenu { position: relative; }
.usermenu > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-size: .85rem; color: #fff; opacity: .95;
  padding: .35rem .6rem; border-radius: 6px;
}
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary::after { content: " \25BE"; opacity: .8; }
.usermenu[open] > summary { background: rgba(255,255,255,.15); }
.usermenu .menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 180px; padding: .35rem; display: grid; gap: .1rem;
}
.usermenu .menu a,
.usermenu .menu .link-btn {
  display: block; width: 100%; text-align: left;
  padding: .5rem .6rem; border-radius: 6px;
  text-decoration: none; color: var(--ink); font-size: .9rem; cursor: pointer;
}
.usermenu .menu a:hover,
.usermenu .menu .link-btn:hover { background: var(--bg); }
.usermenu .menu form { margin: 0; }

.sidebar { grid-area: side; background: var(--panel); border-right: 1px solid var(--line); padding: .75rem .6rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.sidebar a { display: flex; align-items: center; justify-content: space-between;
  padding: .5rem .65rem; border-radius: 7px; text-decoration: none; color: var(--ink);
  border-left: 3px solid transparent; }
.sidebar a:hover { background: var(--bg-soft); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 600; border-left-color: var(--accent); }

.master { grid-area: master; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.detail { grid-area: detail; background: var(--bg); display: flex; flex-direction: column; min-height: 0; }
.detail.wide { grid-column: master / detail; }
.master-head, .detail-head {
  flex: 0 0 auto;
  padding: .7rem 1.1rem; border-bottom: 1px solid var(--line);
  font-family: var(--font-head); font-weight: 600; font-size: 1.05rem;
  background: var(--panel);
}
.detail .detail-head { background: transparent; }
/* The content middle is the only scroll container (header/nav stay fixed). */
.master-body, .detail-body {
  flex: 1 1 auto; min-height: 0; min-width: 0; padding: 1.1rem;
  overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.placeholder { color: var(--muted); }

.mobilebar { display: none; }

table.data {
  width: 100%; border-collapse: collapse; margin: .5rem 0 1.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
table.data th, table.data td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); }
table.data thead th {
  font-family: var(--font-body); font-size: var(--fs-small); font-weight: 600;
  color: var(--ink-muted); background: var(--surface-sunken);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-soft); }
tr.inactive { color: var(--muted); }
form.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .35rem; max-width: 380px; }
form.stack label { font-size: .85rem; color: var(--muted); margin-top: .4rem; }
form.stack input, form.stack select, form.stack textarea { width: 100%; padding: .55rem .6rem; border: 1px solid var(--line-strong); border-radius: 7px; }
/* Date/time fields have a natural compact size – don't stretch them full-width. */
form.stack input[type=date], form.stack input[type=time] { width: auto; justify-self: start; }
form.stack button { margin-top: .9rem; justify-self: start; }

/* Mobile / PWA: fixed shell (topbar + bottom nav), scrolling middle only.
   Rows are auto/1fr/auto so the safe-area padding expands the bars (Spec §2/§7). */
@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      "top"
      "detail"
      "mobilebar";
  }
  .sidebar, .master { display: none; }
  .detail.wide { grid-column: auto; }
  .master-body, .detail-body {
    overflow-x: hidden;
    padding-left: max(1.1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1.1rem, env(safe-area-inset-right, 0px));
  }
  .mobilebar {
    grid-area: mobilebar; display: flex; align-items: stretch;
    background: var(--panel); border-top: 1px solid var(--line);
    /* Keep clear of the home indicator and side notches. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  .mobilebar a {
    flex: 1; display: grid; place-items: center; gap: 2px;
    min-height: 52px;                /* touch target ≥ 44px */
    text-decoration: none; color: var(--ink); font-size: .8rem;
  }
  .mobilebar a.active {
    color: var(--accent-ink); font-weight: 600;
    box-shadow: inset 0 2px 0 var(--accent);
  }
}

/* --- Phase 2 UI elements --- */
.sidebar a.active { background: var(--bg); font-weight: 600; }
.badge {
  display: inline-block; background: var(--gold); color: #fff;
  border-radius: 999px; padding: .02rem .45rem; font-size: .7rem; font-weight: 600;
  vertical-align: middle;
}
.muted { color: var(--muted); font-size: .85rem; }

.entrylist { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.entrylist a { display: block; padding: .4rem .5rem; border-radius: 6px;
  text-decoration: none; color: var(--ink); }
.entrylist a:hover { background: var(--bg); }

/* Status chips – Farbzuordnung gemäß UI-Leitfaden §5. */
.st { display: inline-block; font-size: var(--fs-small); font-weight: 500; padding: .1rem .55rem;
  border-radius: 999px; background: var(--surface-sunken); color: var(--ink);
  border: 1px solid var(--border); white-space: nowrap; }
.st-Neu { background: var(--surface-sunken); color: var(--ink-muted); border-color: var(--border); }
.st-Idee { background: var(--green-soft); color: var(--green-hover); border-color: transparent; }
.st-Vorentscheidung { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.st-Entschieden { background: var(--green); color: #fff; border-color: transparent; }
.st-Beauftragt { background: var(--success-soft); color: var(--success); border-color: transparent; }
.st-Ausgeführt { background: #d7ddd4; color: #5b635a; border-color: transparent; }
.st-Verworfen { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

textarea { width: 100%; padding: .5rem; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; resize: vertical; }
select[multiple] { padding: .25rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: .8rem 0; }
legend { padding: 0 .4rem; color: var(--muted); }
.chk { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }

.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0; }
.row-form input[type=text], .row-form input[type=url], .row-form input[type=email],
.row-form input[type=search], .row-form select {
  padding: .45rem; border: 1px solid var(--line); border-radius: 6px; }
.row-form.inline, form.inline { display: inline-flex; margin: 0; gap: .25rem; }
.filterbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filterbar select { padding: .4rem; border: 1px solid var(--line); border-radius: 6px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem 1rem; margin: .6rem 0; }

.comments, .historie, .attachments { list-style: none; margin: .4rem 0; padding: 0; display: grid; gap: .4rem; }
.comments li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; }
.historie li { font-size: .85rem; }
.attachment.has-thumb { display: flex; align-items: center; gap: .6rem; }
.att-thumb { flex: none; display: block; }
.att-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: var(--r-sm);
  border: 1px solid var(--line); display: block; background: var(--panel); }
.att-meta { min-width: 0; word-break: break-word; }
.att-thumb { cursor: zoom-in; }

/* Image lightbox overlay */
.lightbox { position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center; padding: 2.5rem;
  background: rgba(0, 0, 0, .82); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: var(--r-sm); box-shadow: 0 12px 48px rgba(0, 0, 0, .55);
  cursor: default; }
.lightbox-close { position: absolute; top: .75rem; right: 1.1rem; width: 2.4rem;
  height: 2.4rem; font-size: 1.8rem; line-height: 1; background: none; border: none;
  color: #fff; cursor: pointer; }
body.no-scroll { overflow: hidden; }
.richtext { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }

/* --- Phase 3 UI elements --- */
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--error); }
table.data tfoot .total td { font-weight: 600; background: var(--bg-soft); border-top: 2px solid var(--line-strong); }
tr.overdue td { background: #f6e9e6; }
tr.over td { background: #f6e9e6; }
tr.chosen td { background: var(--accent-soft); }

/* Checklist items – a block <li>: a flex row on top, a full-width edit panel
   below (toggled by the CSS-only .edit-cb / .edit-panel pattern). */
.checkitems { margin: 0; }
.checkitems .checkitem { padding: var(--s3) var(--s2); border-bottom: 1px solid var(--border); }
.checkitems .checkitem:last-child { border-bottom: 0; }
.checkrow { display: flex; align-items: flex-start; gap: var(--s3); }
.checkrow .row-main { flex: 1 1 auto; min-width: 0; }   /* normal word wrap, no clipping */
.check-actions { display: flex; align-items: center; gap: var(--s1); flex: none; }
.checkitem .edit-panel { margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px dashed var(--border); }
.checkitem .checkbox-btn {
  background: none; border: 0; padding: 0; margin: 0; line-height: 1.35;
  font-size: 1.15rem; color: var(--green); cursor: pointer; flex: none;
}
.checkitem .check-toggle { margin: 0; flex: none; }
.checkitem.is-done { background: var(--surface-sunken); }
.checkitem.is-done .ctext { text-decoration: line-through; color: var(--ink-muted); }
.checkitem .ctext { font-weight: 500; }
.checkitem .row-meta { margin-top: var(--s1); }
.checkitem .note { margin-top: var(--s1); }
.pill.pill-link { text-decoration: none; }
.pill.pill-link:hover { background: var(--green-soft); color: var(--green-hover); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: .15rem .35rem; color: var(--ink-muted);
  cursor: pointer; border-radius: var(--r-sm); flex: none; line-height: 1;
}
.btn-icon:hover { background: var(--surface-sunken); color: var(--ink); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }
.card-head .count {
  display: inline-block; margin-left: var(--s2); font-family: var(--font-body);
  font-size: var(--fs-small); font-weight: 600; color: var(--ink-muted);
  background: var(--surface-sunken); border-radius: 999px; padding: .02rem .5rem;
}
details.card > summary .count { margin-left: var(--s2); font-family: var(--font-body);
  font-size: var(--fs-small); font-weight: 600; color: var(--ink-muted);
  background: var(--surface-sunken); border-radius: 999px; padding: .02rem .5rem; }
.crumbs { font-size: var(--fs-small); }

/* Lists & filters (Block H) */
.filterbar { align-items: flex-start; gap: var(--s4); }
.filterbar .field { margin-bottom: 0; }
.filter-actions { display: flex; gap: var(--s2); align-items: center; }
.active-filter {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  margin: var(--s3) 0 var(--s5); padding: var(--s3) var(--s4);
  background: var(--surface-sunken); border-radius: var(--r-md);
}
.save-view { position: relative; }
.save-view > summary { list-style: none; display: inline-flex; }
.save-view > summary::-webkit-details-marker { display: none; }
.save-view[open] > summary { background: var(--surface-sunken); }
.save-view .row-form { margin-top: var(--s3); }

/* Bulk import (Phase 6) */
.bulk-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); align-items: stretch; }
/* Photo upload card: same height as its neighbour; the drop zone grows to fill
   the spare space (bigger, easier-to-hit target). */
.upload-card { display: flex; flex-direction: column; }
.upload-card .file-field { display: grid; grid-template-rows: auto 1fr; flex: 1 1 auto; }
.upload-card .dropzone {
  height: 100%; min-height: 150px;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
/* Opt-in larger drop target (e.g. the Inbox file field) – easier to hit. */
.drop-lg .dropzone {
  min-height: 120px;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
@media (max-width: 900px) { .bulk-grid { grid-template-columns: 1fr; } }
.bulk-grid textarea { width: 100%; font-family: var(--font-body); }
.card.result { border-left: 3px solid var(--border); }
.card.result.ok { border-left-color: var(--green); }
.skiplist { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s1);
  font-size: var(--fs-small); }

/* Linked contacts under Verknüpfungen */
.link-contacts { list-style: none; margin: var(--s2) 0; padding: 0; display: grid; gap: var(--s1); }
.link-contacts li { display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.link-contacts li:last-child { border-bottom: 0; }
.link-contacts form { margin: 0; }

/* Baudoku filter: align Raum / Datum / button on one baseline & height. */
.baudoku-filter { align-items: end; }
.baudoku-filter select,
.baudoku-filter input[type="date"],
.baudoku-filter .btn { height: 2.5rem; }

/* Baudoku inline edit (photo & note) */
.edit-toggle { margin-top: var(--s2); }
.edit-toggle > summary { cursor: pointer; font-size: var(--fs-small); color: var(--green);
  list-style: none; display: inline-block; }
.edit-toggle > summary::-webkit-details-marker { display: none; }
.edit-toggle > summary:hover { color: var(--green-hover); }
.edit-form { margin-top: var(--s3); }
.edit-actions { margin-top: var(--s2); }
.edit-delete { margin-top: var(--s2); }

/* Baudoku unified chronological timeline (photos + notes) */
.timeline { list-style: none; margin: var(--s4) 0 0; padding: 0; }
.tl-day { margin-bottom: var(--s5); }
.tl-date { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h3);
  color: var(--ink); padding-bottom: var(--s2); border-bottom: 1px solid var(--border);
  margin-bottom: var(--s3); }
.tl-items { list-style: none; margin: 0; padding: 0 0 0 var(--s4);
  border-left: 2px solid var(--border); display: grid; gap: var(--s3); }
.tl-item { position: relative; }
.tl-item::before { content: ""; position: absolute; left: calc(-1 * var(--s4) - 5px);
  top: var(--s4); width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); border: 2px solid var(--surface); }
.tl-card { display: flex; gap: var(--s4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); }
.tl-thumb { flex: none; }
.tl-thumb img { width: 120px; height: 90px; object-fit: cover; border-radius: var(--r-sm); display: block; }
.tl-body { flex: 1; min-width: 0; }
.tl-meta { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s1); flex-wrap: wrap; }
.tl-body .richtext { margin: var(--s1) 0; }
@media (max-width: 600px) {
  .tl-card { flex-direction: column; }
  .tl-thumb img { width: 100%; height: 160px; }
}

/* PWA companion (Phase 8): Erfassen tiles, contact list */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s3); }
.tile { display: flex; flex-direction: column; gap: var(--s1); min-height: 88px;
  justify-content: center; padding: var(--s4); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); text-decoration: none; color: var(--ink); }
.tile:hover { background: var(--green-soft); border-color: var(--green); }
.tile-k { font-size: var(--fs-small); color: var(--ink-muted); }
.tile-t { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h3); color: var(--ink); }
.contact-list .row-main { text-decoration: none; color: var(--ink);
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.contact-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s4) 0; }

/* Start-page attention summary (Phase 9 D) */
.attention .row-main { text-decoration: none; color: var(--ink); font-weight: 500; }
.attention .row-main:hover { color: var(--green-hover); }
.count-pill { min-width: 1.9rem; justify-content: center; font-variant-numeric: tabular-nums; }

/* Inbox review mode (Phase 9 A) */
.review-card h2 { margin-top: 0; }
.review-actions { margin-top: var(--s4); }
.review-foot { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.review-foot form { margin: 0; }
.kbd { display: inline-block; min-width: 1.2em; padding: 0 .35em; border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--surface);
  font-size: var(--fs-small); color: var(--ink-muted); }
.btn .kbd { margin-left: .4em; border-color: rgba(255,255,255,.45); color: inherit; background: transparent; }
.kbd-hint { margin-top: var(--s4); }

/* KI-Assist in review (Phase 10) */
.ki-bar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin: var(--s3) 0; }
.ki-bar form { margin: 0; }
.ki-vorschlag { border-left: 3px solid var(--green); margin-top: var(--s3); }

/* "abwählen" control added by app.js to native multi-selects */
.select-clear { background: none; border: 0; padding: .1rem 0; margin-top: var(--s1);
  color: var(--ink-muted); font-size: var(--fs-small); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; }
.select-clear:hover { color: var(--green-hover); }

/* Inbox bulk actions (Phase 9 B) */
.review-link { margin-left: var(--s2); font-size: var(--fs-small); }
.entrylist.checks { margin: 0; }
.entrylist.checks .chk { display: flex; align-items: center; gap: var(--s2); padding: .25rem .35rem; }
.entrylist.checks .chk input[type="checkbox"] { flex: none; width: 1rem; height: 1rem; margin: 0; }
.entrylist.checks .chk a { text-decoration: none; color: var(--ink); }
.entrylist.checks .chk:hover { background: var(--bg-soft); border-radius: var(--r-sm); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center;
  margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--border); }
.bulk-bar select, .bulk-bar input { min-width: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; }
.gallery figure { margin: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; }
.gallery img { width: 100%; height: 140px; object-fit: cover; display: block; }
.gallery figcaption { padding: .4rem .5rem; font-size: .82rem; }

h3 { font-family: var(--font-head); font-weight: 500; font-size: 1rem; margin: 1rem 0 .4rem; }

/* Richtext editor (B/I/U) */
.rt-toolbar { display: flex; gap: .3rem; margin-bottom: .35rem; }
.rt-btn { width: 2.1rem; height: 2rem; padding: 0; line-height: 1;
  border: 1px solid var(--line-strong); background: var(--panel);
  border-radius: 6px; color: var(--ink); }
.rt-btn:hover { background: var(--bg-soft); }
.rt-area { min-height: 6rem; padding: .55rem .65rem; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--panel); line-height: 1.5; }
.rt-area:focus { outline: none; border-color: var(--accent); }
.rt-area p { margin: 0 0 .5rem; }
.rt-area a { cursor: pointer; }
.rt-hint { margin-top: .35rem; font-size: .85rem; color: var(--muted); }

/* Drag & drop file upload zones */
.dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  border: 1.5px dashed var(--line-strong); border-radius: 8px;
  padding: .55rem .7rem; background: var(--panel); transition: background .12s, border-color .12s; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-hint { color: var(--muted); font-size: .85rem; }
.dz-file { font-size: .85rem; color: var(--accent-ink); font-weight: 500; }

/* ============================================================
   PHASE 5 – Basis-Komponenten (UI-Leitfaden §5).
   Wiederverwendbare Klassen; pro Screen nutzen statt kopieren.
   ============================================================ */

/* Buttons – primär / sekundär / ghost / destruktiv. Einheitliche Höhe. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: inherit; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer;
  padding: .55rem 1.05rem; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--ink);
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .02s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-sunken); }
.btn-ghost { background: transparent; color: var(--green); }
.btn-ghost:hover { background: var(--green-soft); color: var(--green-hover); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* Formularfeld – Label oben (klein, gedämpft), Input darunter; klarer Fehler. */
.field { display: grid; gap: var(--s1); margin-bottom: var(--s3); }
.field > label, .field-label { font-size: var(--fs-small); color: var(--ink-muted); }
.field .hint { font-size: var(--fs-small); color: var(--ink-muted); }
.field .field-error { font-size: var(--fs-small); color: var(--danger); }
.field input[aria-invalid="true"], .field .invalid,
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }

/* Zweispaltiges Feldraster (bricht unter ~720px auf eine Spalte). */
.fieldgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3) var(--s5); }
.fieldgrid .span2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .fieldgrid { grid-template-columns: 1fr; } }

/* Sektion / Karte – Grundelement; optional einklappbar via <details class="card">. */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s5); margin: 0 0 var(--s4);
}
.card > h2:first-child, .card > h3:first-child, .card-head { margin-top: 0; }
.card-head { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h3); }
details.card { padding: 0; }
details.card > summary {
  list-style: none; cursor: pointer; user-select: none;
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h3);
  display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s5);
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "\25B8"; color: var(--ink-muted); }
details.card[open] > summary::before { content: "\25BE"; }
details.card > .card-body { padding: 0 var(--s5) var(--s5); }

/* Pill / Badge – Status, Bewertung, Raum/Gewerk, Frist. Dezente Tints. */
.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: var(--fs-small); font-weight: 500; line-height: 1.4;
  padding: .1rem .55rem; border-radius: 999px;
  background: var(--surface-sunken); color: var(--ink); border: 1px solid var(--border);
  white-space: nowrap;
}
.pill-green   { background: var(--green-soft);   color: var(--green-hover); border-color: transparent; }
.pill-success { background: var(--success-soft); color: var(--success);     border-color: transparent; }
.pill-warning { background: var(--warning-soft); color: var(--warning);     border-color: transparent; }
.pill-danger  { background: var(--danger-soft);  color: var(--danger);      border-color: transparent; }

/* Listen-Zeile – Icon · Haupttext · kleine Badges · optional Thumbnail. */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s2); border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .row-main { flex: 1; min-width: 0; }
.list-row .row-meta { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.list-row .row-thumb { width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover; flex: none; }

/* Leerzustand – freundlich, handlungsleitend (kein bloßes „leer"). */
.empty { color: var(--ink-muted); text-align: center; padding: var(--s7) var(--s4); }
.empty strong {
  display: block; color: var(--ink); font-family: var(--font-display);
  font-size: var(--fs-h3); font-weight: 600; margin-bottom: var(--s2);
}

/* Tag-Input – entfernbare Chips + Combobox (Verhalten in app.js, Block D). */
.taginput {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  padding: var(--s2); border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface);
}
.taginput:focus-within { border-color: var(--focus); }
.taginput input { border: 0; outline: none; background: transparent; padding: .2rem; flex: 1; min-width: 8rem; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: var(--fs-small); padding: .15rem .25rem .15rem .55rem;
  border-radius: 999px; background: var(--green-soft); color: var(--green-hover);
}
.chip button {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  line-height: 1; padding: 0 .3rem; font-size: 1rem; border-radius: 999px;
}
.chip button:hover { background: rgba(38,36,32,.1); }

/* Toast / Inline-Bestätigung – dezentes Speicher-Feedback. */
.toast-region { position: fixed; bottom: var(--s5); right: var(--s5); z-index: 50;
  display: grid; gap: var(--s2); }
.toast {
  background: var(--ink); color: var(--surface); padding: var(--s3) var(--s4);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); font-size: var(--fs-small);
  animation: toast-in .18s ease;
}
.toast.ok { background: var(--green); color: #fff; }
.inline-ok { color: var(--success); font-size: var(--fs-small); }

/* Detail footer – primary action always same place, destructive at the end. */
.detail-foot {
  display: flex; align-items: center; gap: var(--s4);
  margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--border);
}
.detail-foot .spacer { flex: 1; }
.detail-foot form { margin: 0; }

/* Control bar (status / quick selects) above the detail content. */
.control-bar {
  display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3);
  margin: 0 0 var(--s4);
}
.control-bar form { display: flex; align-items: end; gap: var(--s2); margin: 0; }
/* Drop the field's bottom margin so Status, Grund and the button share one
   baseline (the label sits above the row). */
.control-bar .field { margin-bottom: 0; }
/* Unify all three controls on one height (the Status dropdown's). box-sizing
   is border-box globally, so the explicit height is identical for select,
   input and button regardless of their differing line-heights/paddings. */
.control-bar select,
.control-bar input[type="text"],
.control-bar .btn { height: 2.5rem; line-height: 1.2; }

/* Read-only definition rows (architect view). */
.def { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: var(--s2) var(--s4); margin: var(--s4) 0 0; }
.def dt { color: var(--ink-muted); font-size: var(--fs-small); }
.def dd { margin: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Link collection (/links). */
.linklist .list-row { display: block; }
/* Name row: title + tags on the left, "Bearbeiten" toggle right-aligned. */
.link-head { display: flex; align-items: baseline; gap: .5rem; }
.link-head-main { display: flex; flex-wrap: wrap; align-items: baseline;
  gap: .25rem .5rem; min-width: 0; flex: 1; }
.edit-toggle { flex: none; white-space: nowrap; cursor: pointer;
  color: var(--accent); font-size: .85rem; }
.edit-toggle:hover { color: var(--accent-ink); }
.link-title { font-weight: 600; color: var(--accent); text-decoration: none; }
.link-title:hover { text-decoration: underline; }
/* Category tags: small pills with light spacing, right of the link. */
.tag {
  font-size: var(--fs-small); line-height: 1.4;
  padding: .05rem .5rem; border-radius: 999px;
  background: var(--green-soft); color: var(--green-hover); white-space: nowrap;
}
.linklist .url-line { font-size: .8rem; word-break: break-all; margin-top: .15rem; }
/* Multi-line description, capped at 80% of the row width. */
.linklist .note { margin-top: .2rem; white-space: pre-wrap; max-width: 80%; }
/* CSS-only edit panel toggled by the hidden checkbox in the name row. */
.edit-panel { display: none; margin-top: .5rem; }
.edit-cb:checked ~ .edit-panel { display: block; }
.edit-delete { margin-top: .4rem; }

/* Category filter bar (chips as links). */
.kat-filter { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; }
.kat-filter .chip {
  padding: .15rem .65rem; text-decoration: none; cursor: pointer;
  background: var(--surface-sunken); color: var(--ink-muted);
}
.kat-filter .chip:hover { background: var(--green-soft); color: var(--green-hover); }
.kat-filter .chip.is-active { background: var(--green); color: #fff; }

/* "Daten per KI anreichern" checkbox in the add/bulk forms. The auto margin
   pushes the submit button to the right within the existing flex .detail-foot. */
.check-inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem;
  color: var(--ink-muted); margin-right: auto; }

/* KI per-task system prompt editor (Einstellungen). */
.prompt-edit { margin-top: var(--s3); }
.prompt-edit > summary { cursor: pointer; color: var(--accent); font-size: .9rem; width: max-content; }
.prompt-edit textarea { width: 100%; margin-top: var(--s3); font-family: ui-monospace, "SFMono-Regular",
  Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.5; }
.prompt-edit .reset-prompt { margin-top: .4rem; }

/* ============================================================
   PHASE 12 – UI consolidation (layout system, UI-Leitfaden §1).
   Content width cap, field-width scale, control height, nav group.
   No new design – only consistent layout.
   ============================================================ */

/* Sidebar: collapsible group (e.g. Admin), styled like a nav link. */
.sidebar .navgroup > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: var(--s2);
  padding: .5rem .65rem; border-radius: 7px; color: var(--ink);
  border-left: 3px solid transparent;
}
.sidebar .navgroup > summary::-webkit-details-marker { display: none; }
.sidebar .navgroup > summary::after {
  content: "\25B8"; margin-left: auto; color: var(--ink-muted); font-size: .8em;
}
.sidebar .navgroup[open] > summary::after { content: "\25BE"; }
.sidebar .navgroup > summary:hover { background: var(--bg-soft); }
.sidebar .navgroup > ul { margin: .1rem 0; padding: 0; display: grid; gap: .1rem; }
.sidebar .navgroup > ul a { padding-left: 1.1rem; }

/* 1.1 Content width: cap and CENTER form/detail columns (no left-aligned mobile
   look on wide screens). Lists, tables, galleries and the cost dashboard stay
   full width (they don't use these wrappers).
   - .form-col  ~720px  simple forms (e.g. Inbox capture)
   - .read-col  ~820px  reading / documentation content (architect detail view)
   - .detail-cols ~1280px two-column entry detail (main + sidebar) */
.form-col { max-width: 720px; margin-inline: auto; }
.read-col { max-width: 820px; margin-inline: auto; }

/* Centered within the main area (right of the fixed nav); any free space is
   split symmetrically here, not dumped as a strip beside the nav. */
.detail-cols {
  max-width: 1440px; margin-inline: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  gap: var(--s5); align-items: start;
}
.detail-cols .col-side { display: flex; flex-direction: column; gap: 0; min-width: 0; }
/* Sidebar is narrow: stack its form controls full-width so nothing is clipped
   ("Grund", the Verknüpfung/Kontakt selects, the new-contact inputs). */
.col-side .control-bar,
.col-side .control-bar form,
.col-side .row-form { flex-direction: column; align-items: stretch; gap: var(--s2); }
.col-side .control-bar .field { width: 100%; }
.col-side .control-bar select,
.col-side .control-bar input[type="text"],
.col-side .control-bar .btn,
.col-side .row-form select,
.col-side .row-form input,
.col-side .row-form .btn { width: 100%; max-width: none; }
/* Collapse to one column when the detail area gets too narrow for two. */
@media (max-width: 1100px) { .detail-cols { grid-template-columns: 1fr; } }

/* 1.2 Field-width scale – width follows the expected content. Applied to the
   control inside a .field cell (or a bare control); left-aligned in its cell. */
.w-s { max-width: 200px; }
.w-m { max-width: 340px; }
.w-l { max-width: 520px; }

/* 1.4 Multi-select: 6–8 visible rows, not 3. */
select[multiple] { min-height: 180px; }

/* 1.6 Uniform control height (~40px) for inputs, selects and buttons.
   Textareas and multi-selects keep their own (taller) height. */
.field input:not([type=checkbox]):not([type=file]),
.field select:not([multiple]),
form.stack input:not([type=checkbox]):not([type=file]),
form.stack select:not([multiple]),
.btn, .control-bar select, .control-bar input[type=text] { min-height: 40px; }

/* 1.7 Checkbox row: box + label inline, vertically centred; label wraps clean. */
.chk { align-items: center; }
.chk input[type=checkbox] { flex: none; width: 1rem; height: 1rem; margin: 0; }
