/* Kommunikationsdossiers – modernes Stylesheet */

:root {
    /* Farbpalette */
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-surface-2: #f8f9fb;
    --color-fg: #15212b;
    --color-fg-soft: #2b3947;
    --color-muted: #5a6573;
    --color-muted-2: #8a96a3;
    --color-border: #e3e6eb;
    --color-border-strong: #d2d7df;
    --color-accent: #b40c1e;        /* CH-Rot */
    --color-accent-soft: #fce7ea;
    --color-accent-strong: #8c0918;
    --color-focus: rgba(180, 12, 30, 0.28);

    --color-info: #1864ab;
    --color-info-bg: #e7f0fa;
    --color-success: #2b6e3a;
    --color-success-bg: #e6f5ea;
    --color-warning: #a85800;
    --color-warning-bg: #fff3e2;
    --color-danger: #a51d2d;
    --color-danger-bg: #fde8ea;

    /* Typografie */
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;

    /* Geometrie */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

    /* Layout */
    --sidebar-width: 16rem;
    --topbar-height: 3.5rem;
    --max-width: 78rem;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-fg);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@supports (font-variation-settings: normal) {
    html, body { font-family: "Inter var", var(--font-sans); }
}

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-fg);
}

h1 { font-size: 1.6rem; line-height: 1.25; }
h2 { font-size: 1.2rem; line-height: 1.3; }
h3 { font-size: 1.05rem; }

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover { color: var(--color-accent-strong); text-decoration: underline; }

p { margin: 0 0 1rem 0; }
p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--color-border); margin: 1.5rem 0; }

/* ---------- App-Shell (mit Sidebar) ----------------------------- */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
    grid-column: 1;
    background: #fff;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-fg);
}
.brand:hover { text-decoration: none; }

.brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-strong));
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand__gemeinde {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.sidenav {
    flex: 1 1 auto;
    padding: 0.75rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sidenav__group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidenav__heading {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted-2);
    padding: 0 0.7rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.sidenav__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    color: var(--color-fg-soft);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidenav__link:hover {
    background: var(--color-surface-2);
    color: var(--color-fg);
    text-decoration: none;
}
.sidenav__link.is-active {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
}
.sidenav__link.is-active .sidenav__icon { color: var(--color-accent); }

.sidenav__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-muted);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.sidebar__footer {
    border-top: 1px solid var(--color-border);
    padding: 0.75rem;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
}

.user-card__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-fg-soft);
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    text-decoration: none;
}
.user-card__avatar:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; }
.user-card__meta:hover { text-decoration: none; }
.user-card__meta { color: inherit; }

.user-card__meta { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.user-card__name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-card__role {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: capitalize;
}

.user-card__logout { margin: 0; }

/* ---------- Topbar + Hauptbereich ------------------------------- */

.app-shell__content {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
}

.topbar__toggle { display: none; }

.topbar__title {
    font-weight: 600;
    color: var(--color-fg);
    font-size: 0.95rem;
}

.main {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.75rem 1.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    color: var(--color-muted);
    text-align: center;
    width: 100%;
}

/* ---------- Auth-Shell (Login/Setup) ---------------------------- */

.auth-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(180,12,30,0.05), transparent 40%),
        radial-gradient(circle at 80% 100%, rgba(24,100,171,0.04), transparent 40%),
        var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}

.auth-shell__main {
    width: 100%;
    max-width: 26rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-shell__footer {
    margin-top: 2rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* ---------- Cards ----------------------------------------------- */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.5rem;
    box-shadow: var(--shadow-xs);
}

.card + .card { margin-top: 0; }

.card--narrow {
    max-width: 28rem;
    margin: 0 auto;
    padding: 2rem;
}

.card--placeholder {
    border-style: dashed;
    background: transparent;
    box-shadow: none;
}

.card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card__header h1,
.card__header h2 {
    margin: 0;
}

.hero {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-xs);
}
.hero h1 { margin-top: 0; }

.lead {
    font-size: 1.05rem;
    color: var(--color-muted);
}

.breadcrumb {
    margin: 0 0 0.4rem 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}
.breadcrumb a { color: var(--color-muted); }
.breadcrumb a:hover { color: var(--color-fg); }

.error h1 { color: var(--color-accent); }

/* ---------- Formulare ------------------------------------------- */

fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 0 0 1.25rem 0;
    background: var(--color-surface);
}

legend {
    font-weight: 600;
    padding: 0 0.5rem;
    font-size: 0.95rem;
}

label {
    display: block;
    margin: 0.85rem 0;
    font-size: 0.9rem;
    color: var(--color-fg);
    font-weight: 500;
}

label small {
    color: var(--color-muted);
    font-weight: normal;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: #fff;
    font: inherit;
    color: var(--color-fg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--color-muted-2); }

input:hover, textarea:hover, select:hover { border-color: var(--color-muted-2); }

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus);
}

textarea {
    resize: vertical;
    line-height: 1.5;
    min-height: 5rem;
}

small.error {
    display: block;
    color: var(--color-accent);
    margin-top: 0.25rem;
    font-size: 0.85rem;
}

.muted { color: var(--color-muted); }

.form-actions {
    margin-top: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.inline-form label {
    margin: 0;
    flex: 0 1 14rem;
}

/* ---------- Buttons --------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border-strong);
    background: #fff;
    color: var(--color-fg);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.25;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--color-surface-2);
    border-color: var(--color-muted-2);
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
    border-color: var(--color-accent);
}

.btn--primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
    box-shadow: var(--shadow-xs);
}
.btn--primary:hover {
    background: var(--color-accent-strong);
    border-color: var(--color-accent-strong);
    color: #fff;
}

.btn--link {
    background: transparent;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    box-shadow: none;
}
.btn--link:hover {
    background: var(--color-accent-soft);
    color: var(--color-accent-strong);
    text-decoration: none;
}

.btn--danger {
    color: var(--color-danger);
}
.btn--danger:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-fg); }

/* Inline-Aktionsgruppe (z.B. neben Karten-Header) */
.topnav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Alerts ---------------------------------------------- */

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin: 0 0 1rem 0;
    border: 1px solid transparent;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.alert::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    margin-top: 0.42rem;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.85;
}

.alert--success { background: var(--color-success-bg); border-color: rgba(43,110,58,0.25); color: var(--color-success); }
.alert--info    { background: var(--color-info-bg); border-color: rgba(24,100,171,0.22); color: var(--color-info); }
.alert--warning { background: var(--color-warning-bg); border-color: rgba(168,88,0,0.22); color: var(--color-warning); }
.alert--error   { background: var(--color-danger-bg); border-color: rgba(165,29,45,0.25); color: var(--color-danger); }

/* ---------- Filterleiste ---------------------------------------- */

.filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin: 0 0 1rem 0;
    padding: 0.85rem 1rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.filterbar label {
    margin: 0;
    flex: 1 1 12rem;
}

/* ---------- Tabellen -------------------------------------------- */

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.92rem;
}

.table th,
.table td {
    text-align: left;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.table th {
    background: var(--color-surface-2);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    border-bottom: 1px solid var(--color-border);
}

.table--sortable th { padding: 0; }
.table--sortable th .sort-link {
    display: block;
    padding: 0.75rem 0.85rem;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    text-transform: inherit;
    letter-spacing: inherit;
    font-size: inherit;
    user-select: none;
}
.table--sortable th .sort-link:hover { color: var(--color-fg); background: rgba(0,0,0,0.02); text-decoration: none; }
.table--sortable th .sort-link.is-active { color: var(--color-fg); }

.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover td { background: var(--color-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.6rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--color-surface-2);
    color: var(--color-fg-soft);
    border: 1px solid var(--color-border);
    line-height: 1.4;
}
.badge::before {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
}

.badge--entwurf         { background: #eef0f3; color: #495057; border-color: #d8dde3; }
.badge--in_arbeit       { background: var(--color-info-bg); color: var(--color-info); border-color: rgba(24,100,171,0.22); }
.badge--in_freigabe     { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(168,88,0,0.22); }
.badge--freigegeben     { background: var(--color-success-bg); color: var(--color-success); border-color: rgba(43,110,58,0.25); }
.badge--veroeffentlicht { background: #d8f1de; color: #155724; border-color: rgba(21,87,36,0.2); }
.badge--archiviert      { background: #e3e6eb; color: #495057; border-color: #c9cdd4; }

.badge--inaktiv         { background: #eef0f3; color: #495057; }
.badge--offen           { background: var(--color-warning-bg); color: var(--color-warning); border-color: rgba(168,88,0,0.22); }
.badge--mit_auflagen    { background: #fff8e1; color: #b6790a; border-color: #ffd58a; }
.badge--zurueckgewiesen { background: var(--color-danger-bg); color: var(--color-danger); border-color: rgba(165,29,45,0.25); }
.badge--abgebrochen     { background: #e3e6eb; color: #495057; border-color: #c9cdd4; }

/* ---------- Tags ------------------------------------------------ */

.tag {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-fg-soft);
    border: 1px solid var(--color-border);
    font-size: 0.82rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* ---------- Detail-Meta ----------------------------------------- */

.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 1.25rem;
    margin: 0 0 1.5rem 0;
    padding: 1rem 1.25rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.meta dt {
    font-weight: 600;
    color: var(--color-muted);
    font-size: 0.85rem;
}
.meta dd {
    margin: 0;
    color: var(--color-fg);
    font-size: 0.9rem;
}

.prose { line-height: 1.65; margin-bottom: 1rem; color: var(--color-fg-soft); }
.prose--muted { color: var(--color-muted); }

/* ---------- Dashboard / KPI ------------------------------------- */

.status-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
}

.status-grid a {
    display: block;
    padding: 1.1rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--color-fg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    text-align: left;
}
.status-grid a:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.status-grid__count {
    display: block;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--color-fg);
    letter-spacing: -0.02em;
}

.status-grid__label {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* ---------- Listen ---------------------------------------------- */

.dossier-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dossier-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.dossier-list li.related {
    align-items: flex-start;
    justify-content: space-between;
}
.dossier-list li.related > div { flex: 1 1 auto; }
.dossier-list li.related b { font-weight: 600; }
.dossier-list li:last-child { border-bottom: none; }

/* ---------- Botschaftsarchitektur ------------------------------- */

.botschaft { margin: 0.5rem 0 0 0; }
.botschaft textarea { width: 100%; }

.botschaft__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.botschaft__delete { margin: 0.25rem 0 1rem 0; }

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-fg-soft);
}
.checkbox input[type="checkbox"] {
    width: auto;
    accent-color: var(--color-accent);
}

.add-form { margin-top: 0.75rem; }
.add-form summary {
    cursor: pointer;
    list-style: none;
    display: inline-block;
}
.add-form summary::-webkit-details-marker { display: none; }
.add-form[open] summary { margin-bottom: 0.5rem; }

/* ---------- Sortierbare Liste ----------------------------------- */

.sortable { list-style: none; margin: 0; padding: 0; }

.sortable > li {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem 0.85rem 0.85rem 2.4rem;
    margin-bottom: 0.75rem;
    position: relative;
    cursor: grab;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.sortable > li:hover { box-shadow: var(--shadow-sm); border-color: var(--color-border-strong); }
.sortable > li.is-dragging { opacity: 0.5; cursor: grabbing; }

.sortable__handle {
    position: absolute;
    left: 0.7rem;
    top: 0.95rem;
    color: var(--color-muted-2);
    user-select: none;
    font-weight: 700;
    letter-spacing: -0.1em;
}

.qa__head {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.4rem;
}
.qa label { margin: 0.5rem 0; }

/* ---------- Relevanz + Matrix ----------------------------------- */

.relevanz {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.relevanz__col legend { margin-bottom: 0.4rem; }

.checkbox--block {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.4rem 0;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.1s ease;
}
.checkbox--block:hover { background: var(--color-surface-2); }

.matrix-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }

.matrix { border-collapse: collapse; width: 100%; min-width: 40rem; }
.matrix th, .matrix td {
    border: 1px solid var(--color-border);
    padding: 0.65rem;
    vertical-align: top;
    text-align: left;
}
.matrix thead th {
    background: var(--color-surface-2);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-fg-soft);
}
.matrix tbody th {
    background: var(--color-surface-2);
    width: 12rem;
    font-size: 0.88rem;
}
.matrix__cell { min-width: 11rem; }

.cell {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    margin-bottom: 0.45rem;
    box-shadow: var(--shadow-xs);
}
.cell--leicht {
    background: #fff8e6;
    border-color: #ffd58a;
}
.cell__meta { font-size: 0.82rem; color: var(--color-muted); }
.cell__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.cell__actions form { margin: 0; }

/* ---------- Editor + KI-Chat (Workbench) ------------------------ */

.workbench {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(20rem, 1fr);
    gap: 1.25rem;
    align-items: start;
    margin: 0.5rem 0;
}

.workbench__editor { min-width: 0; }
.workbench__chat { min-width: 0; position: sticky; top: calc(var(--topbar-height) + 1rem); }

.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-2);
}
.panel__title { margin: 0; font-size: 0.95rem; font-weight: 600; }

/* EasyMDE styling integration: dezenter, auf unser Design abgestimmt */
#editor-form { padding: 0; }
.EasyMDEContainer {
    --easymde-border: var(--color-border);
}
.EasyMDEContainer .editor-toolbar {
    border: 0;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-2);
    padding: 0.4rem 0.6rem;
    border-radius: 0;
    opacity: 1;
}
.EasyMDEContainer .editor-toolbar button.mde-btn {
    width: auto;
    height: auto;
    min-width: 2rem;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-sm);
    color: var(--color-fg-soft);
    font-size: 0.92rem;
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
}
.EasyMDEContainer .editor-toolbar button.mde-btn:hover {
    background: #fff;
    border-color: var(--color-border);
    color: var(--color-fg);
}
.EasyMDEContainer .editor-toolbar button.mde-btn.active {
    background: #fff;
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.EasyMDEContainer .editor-toolbar i.separator {
    border-left: 1px solid var(--color-border);
    margin: 0 0.25rem;
    height: 1.4rem;
}
.EasyMDEContainer .editor-toolbar button.mde-btn--bold { font-weight: 800; }
.EasyMDEContainer .editor-toolbar button.mde-btn--italic { font-style: italic; }
.EasyMDEContainer .editor-toolbar button.mde-btn--preview {
    margin-left: auto;
}
.EasyMDEContainer .CodeMirror {
    border: 0;
    border-radius: 0;
    min-height: 320px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.55;
    padding: 0.5rem 0.85rem;
    background: #fff;
    color: var(--color-fg);
}
.EasyMDEContainer .CodeMirror .cm-header { font-weight: 700; }
.EasyMDEContainer .CodeMirror .cm-strong { font-weight: 700; }
.EasyMDEContainer .CodeMirror .cm-em     { font-style: italic; }
.EasyMDEContainer .CodeMirror-cursor { border-left-color: var(--color-accent); }
.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
    background: #fff;
    padding: 1rem 1.25rem;
    font-family: var(--font-sans);
    line-height: 1.6;
}
.EasyMDEContainer .editor-statusbar { display: none; }

.linter-hints {
    margin: 0.6rem 0.85rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-warning-bg);
    border: 1px solid rgba(168, 88, 0, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--color-warning);
}
.linter-hint { font-weight: 500; cursor: help; }

#editor-form .form-actions {
    margin: 0.85rem;
}

/* Chat-Panel */
.chat__newform { margin: 0; }
.chat__newform .btn--link { padding: 0.2rem 0.4rem; }

.chat__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    background: #fff;
}

.btn--chip {
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    border-radius: var(--radius-pill);
    font-weight: 500;
}

.chat__log {
    flex: 1 1 auto;
    overflow-y: auto;
    max-height: min(60vh, 540px);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: var(--color-surface-2);
}

.chat__empty {
    margin: 0;
    padding: 1rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 0.88rem;
}

.chat-msg {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    box-shadow: var(--shadow-xs);
    max-width: 100%;
}
.chat-msg--user {
    background: var(--color-info-bg);
    border-color: rgba(24, 100, 171, 0.18);
    align-self: flex-end;
    max-width: 92%;
}
.chat-msg--assistant {
    align-self: flex-start;
    max-width: 100%;
}

.chat-msg__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    color: var(--color-muted);
}
.chat-msg__rolle { font-weight: 600; color: var(--color-fg-soft); }
.chat-msg__time { margin-left: auto; }
.chat-msg__body {
    font-size: 0.92rem;
    line-height: 1.55;
    color: var(--color-fg);
}
.chat-msg__body > :first-child { margin-top: 0; }
.chat-msg__body > :last-child { margin-bottom: 0; }
.chat-msg__body h1, .chat-msg__body h2, .chat-msg__body h3 {
    font-size: 1rem;
    margin: 0.5rem 0 0.25rem 0;
}
.chat-msg__body ul, .chat-msg__body ol { padding-left: 1.25rem; }
.chat-msg__body code {
    background: var(--color-surface-2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
}

.chat-msg__actions { margin-top: 0.6rem; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chat-msg__applied { margin: 0.5rem 0 0 0; }

.chat__compose {
    border-top: 1px solid var(--color-border);
    padding: 0.65rem 0.85rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.chat__compose textarea {
    width: 100%;
    resize: vertical;
    min-height: 4rem;
    font-size: 0.9rem;
}
.chat__compose-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.chat__hint { font-size: 0.82rem; }

@media (max-width: 1100px) {
    .workbench { grid-template-columns: 1fr; }
    .workbench__chat { position: static; }
    .chat__log { max-height: 380px; }
}

/* ---------- Diff-Ansicht ---------------------------------------- */

.diff {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.55;
}
.diff span { display: block; padding: 0 0.25rem; }
.diff__add { background: var(--color-success-bg); color: var(--color-success); }
.diff__del { background: var(--color-danger-bg); color: var(--color-danger); }
.diff__eq  { color: var(--color-fg); }

/* ---------- KI-Toolbar im Editor -------------------------------- */

.ki-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem 0.85rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin: 0.75rem 0 1rem 0;
}
.ki-toolbar__form { margin: 0; }
.ki-toolbar__hint { margin-left: auto; color: var(--color-muted); font-size: 0.85rem; }

/* ---------- Leichte-Sprache-Banner ------------------------------ */

.leicht-banner {
    background: #fff8e6;
    border: 1px solid #ffd58a;
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin: 0.5rem 0 1rem 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}
.leicht-banner__refresh { margin: 0 0 0 auto; }

/* ---------- Dropdown ------------------------------------------- */

.dropdown {
    list-style: none;
    margin: 0.4rem 0 0 0;
    padding: 0.3rem;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 9rem;
    position: absolute;
    z-index: 10;
}
.dropdown li a,
.dropdown li button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.75rem;
    color: var(--color-fg);
    border-radius: var(--radius-sm);
}
.dropdown li a:hover,
.dropdown li button:hover {
    background: var(--color-surface-2);
    text-decoration: none;
}

/* ---------- Konsistenz-Linter ----------------------------------- */

mark.forbidden {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    padding: 0 0.18rem;
    border-radius: 3px;
    border-bottom: 2px dotted #ff6b6b;
    cursor: help;
}

/* ---------- Responsive ------------------------------------------ */

@media (max-width: 960px) {
    :root { --sidebar-width: 14rem; }
    .main { padding: 1.25rem 1rem 2.5rem; }
    .relevanz { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: min(80vw, 18rem);
        height: 100vh;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        z-index: 20;
    }
    .app-shell__content { grid-column: 1; }
    .topbar { padding: 0 1rem; }
    .topbar__toggle { display: inline-flex; }
    .card { padding: 1.25rem; border-radius: var(--radius); }
    .card__header { flex-direction: column; align-items: flex-start; }
    h1 { font-size: 1.4rem; }
}
