:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #0f172a;
    background-color: #f8fafc;
    /* DIE 5-Farben-Palette (+ Schwarz/Weiss/Grau): hier tauschen; Icons
       leben in grow-icons.js (dort dieselben Werte pflegen) */
    --c-blau: #3b82f6;
    --c-violett: #8b5cf6;
    --c-rot: #ef4444;
    --c-orange: #fb923c;
    --c-petrol: #14b8a6;
    /* Design-Token: eine Akzentfarbe, zwei Radien, zwei Schatten */
    --accent: var(--c-blau);
    --accent-hover: #1d4ed8;
    --border: #cbd5e1;
    --radius-control: 8px;   /* Buttons, Eingabefelder, Chips-Innenteile */
    --radius-card: 12px;     /* Karten, Modals, Menüs */
    --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-modal: 0 8px 32px rgba(15, 23, 42, 0.2);
    /* Menü-Icons im Sticker-Stil: Kontur und "Papier"-Füllung folgen dem Theme */
    --mi-ink: #0f172a;
    --mi-paper: #ffffff;
}

body.dark-mode {
    --mi-ink: #e2e8f0;
    --mi-paper: #334155;
}

body {
    margin: 0;
    padding: 0 1rem 2rem;
}

header {
    text-align: center;
    padding: 0.05rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.3rem 0 0;
    line-height: 1.1;
}

.header-logo {
    width: 32px;
    height: 32px;
}

.header-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.header-link:hover {
    opacity: 0.7;
}

.header-subtitle {
    display: block;
    font-size: 0.72rem;
    color: #64748b;
    text-align: center;
    margin-top: 0;
    line-height: 1;
}

body.dark-mode .header-subtitle {
    color: #94a3b8;
}

/* Wochentag-Hinweis neben "📅 Datum" im Eintragsformular */
.date-day-hint {
    font-weight: normal;
    opacity: 0.8;
}

/* Wochentag vor dem Datum: Sichtbarkeit gemäss ⚙️ Tabelle-Menü
   (Emoji + Tag, nur eines davon oder aus) */
body.daylabel-none .day-name {
    display: none;
}


.theme-toggle {
    position: absolute;
    right: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}


main {
    max-width: 1100px;
    /* Einheitlicher Abstand zwischen "Gesundheits-Tagebuch" und der ersten
       Karte auf allen Seiten - gleich gross wie das gap zwischen den Karten
       (z.B. Tabelle → Einblicke). */
    margin: 1.5rem auto 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-section,
.entries,
.suggestions {
    background: white;
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    /* JS setzt bei ziehbarer Breite (resizable.js) style.width auf die
       gewünschte GESAMTbreite - ohne border-box wäre das Padding on top,
       die Karte also breiter als eingestellt (sichtbar am Einblicke-
       Dashboard, das dieselbe Breite spiegelt, aber kein Padding hat) */
    box-sizing: border-box;
}

.suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.suggestions-header h2 {
    margin: 0;
}

.suggestions-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.suggestions-close:hover {
    color: #0f172a;
}

.form-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1rem;
}

/* Auto-Speichern-Status im Titel des Eintrags-Modals */
.entry-autosave-status {
    margin-left: 0.6rem;
    font-size: 0.8rem;
    font-weight: normal;
    color: #16a34a;
    opacity: 0.9;
}

body.dark-mode .entry-autosave-status {
    color: #4ade80;
}

.form-section h2,
.section-header h2 {
    font-size: 1.3rem;
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.section-header h2 .subtle-button {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.subtle-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    color: #64748b;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.subtle-button:hover {
    color: #334155;
    background: #f1f5f9;
    border-color: var(--border);
}

.subtle-button .toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.subtle-button .toggle-icon.expanded {
    transform: rotate(180deg);
}

body.dark-mode .subtle-button {
    color: #94a3b8;
    border-color: #334155;
}

body.dark-mode .subtle-button:hover {
    color: #e2e8f0;
    background: #1e293b;
    border-color: #475569;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    font-weight: 600;
    gap: 0.3rem;
}

.icon-label input[type="number"],
.icon-label input[type="text"],
.icon-label input[type="time"],
.icon-label input[type="date"],
.icon-label select {
    width: 140px;
    max-width: 100%;
}

.icon-label input,
.icon-label select,
.icon-label textarea {
    align-self: flex-start;
}

/* Massnahmen-Dropdowns im Formular wie die übrigen Eingabefelder gestalten
   (die Basisregel für input/textarea greift bei select nicht). */
.icon-label select {
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: inherit;
}
body.dark-mode .icon-label select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

/* Massnahmen-Namen kürzen (Ellipsis), damit mehr Felder pro Reihe passen;
   der volle Name erscheint per Hover-Tooltip (title im Template). */
#intervention-field-group .icon-label > span:first-child {
    display: block;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-label span:first-child {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.textarea-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

.textarea-row .icon-label {
    flex: 1 1 0;
    min-width: 240px;
}

.icon-label.wide textarea {
    width: 100%;
    align-self: stretch;
    min-width: 320px;
}

input, textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 0.5rem;
    font-size: 1rem;
    font-family: inherit;
}

/* Ein Fokus-Ring für alle Bedienelemente statt Browser-Zufall */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.4);
    outline-offset: 1px;
}

textarea {
    resize: vertical;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

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

button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-control);
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
}

.ghost-button {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

.ghost-button:hover {
    background: #e2e8f0;
}

.secondary-button {
    background: var(--accent);
    color: #ffffff;
    border: none;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 75vh;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

th {
    background: white;
}

th, td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.5rem;
    text-align: left;
    font-size: 0.9rem;
}

.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.link-button,
.icon-button {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
}

.icon-button {
    color: var(--accent);
    font-size: 1.1rem;
    line-height: 1;
}

.icon-button.danger,
.link-button {
    color: #ef4444;
}

.details-row {
    display: none;
    background: #eef2ff;
}

.details-row.show {
    display: table-row;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    font-size: 0.9rem;
}

.details-grid strong {
    display: block;
    margin-bottom: 0.2rem;
}

.details-grid p {
    margin: 0;
    white-space: pre-wrap;
}

.flash-messages {
    list-style: none;
    padding: 0;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    background: #0f172a;
    color: white;
    padding: 0.8rem 1.2rem;
    margin: 0;
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-modal);
    animation: toast-pop 2.5s ease-in-out forwards;
    font-size: 0.9rem;
}

.flash.success {
    background: #14b8a6;
}

.flash.info {
    background: var(--accent);
}

.flash.warning {
    background: #fb923c;
}

@keyframes toast-pop {
    0% { opacity: 0; transform: translateX(100%); }
    10% { opacity: 1; transform: translateX(0); }
    80% { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(100%); }
}

.time-field .time-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.refresh-button {
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--accent);
    border-radius: var(--radius-control);
    padding: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.datetime-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
}

.datetime-box {
    display: inline-flex;
    gap: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 0.6rem 0.8rem;
    background: #fff;
    align-items: flex-end;
}

.datetime-box .icon-label {
    margin: 0;
}

.datetime-box .icon-label input {
    width: 140px;
}

.chart-trigger {
    cursor: pointer;
    transition: color 0.2s;
}

.chart-trigger:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Klickbare Spaltenköpfe (Letzte Einträge, Tages- + Wochenansicht):
   öffnen denselben Verlaufs-Chart wie chart-trigger in Neuer Eintrag */
th.chart-header {
    cursor: pointer;
}
th.chart-header:hover {
    color: var(--accent);
}
body.dark-mode th.chart-header:hover {
    color: #3b82f6;
}

.chart-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.chart-modal.show {
    display: flex;
}

.chart-modal-content {
    background: white;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-modal);
    width: 90%;
    max-width: 960px;
    max-height: 90vh;
    overflow: hidden;
}

.chart-modal-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.8rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Titel links, Quellenwahl + Schliessen rechts */
.chart-modal-header h3 {
    margin: 0 auto 0 0;
    font-size: 1.2rem;
}

.chart-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-modal-close:hover {
    color: #0f172a;
}

.chart-controls {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

/* Erscheint erst nach dem Zoomen - rechtsbündig, damit es nie über den
   Rand hinaus abgeschnitten wird, und kompakt gehalten. */
#chart-reset-zoom {
    margin-left: auto;
    white-space: nowrap;
}

.chart-hint {
    margin: 0.6rem 1.5rem 0;
    font-size: 0.8rem;
    color: #64748b;
}
body.dark-mode .chart-hint { color: #94a3b8; }

.chart-quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
}

.chart-inline-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: normal;
    white-space: nowrap;
}
.chart-inline-field[hidden] { display: none; }
#chart-range-select,
#chart-source-select {
    height: 36px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    box-sizing: border-box;
}

/* Feste Breite: lange Quellen-Namen sprengen die Kopfzeile nicht, der
   sichtbare Text wird mit … gekürzt (volle Namen in der Options-Liste
   bzw. per Tooltip). */
#chart-source-select {
    width: 12rem;
    max-width: 100%;
    text-overflow: ellipsis;
}
.chart-trend-window input {
    width: 3.5rem;
    height: 36px;
    padding: 0.35rem 0.4rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    box-sizing: border-box;
}

.chart-filter-btn {
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.chart-filter-btn:hover {
    background: #e2e8f0;
}

.chart-filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.chart-date-range {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.chart-date-range label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: normal;
}

.chart-date-range input[type="date"] {
    padding: 0.45rem 0.5rem;
    font-size: 0.85rem;
    width: auto;
    height: 36px;
    box-sizing: border-box;
}

.chart-apply-btn {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-control);
    padding: 0.45rem 0.8rem;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    height: 36px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.chart-apply-btn:hover {
    background: var(--accent-hover);
}

.chart-container {
    padding: 1.5rem;
    height: 400px;
}

/* Dark Mode */
body.dark-mode {
    background-color: #0f172a;
    color: #e2e8f0;
}

body.dark-mode .form-section,
body.dark-mode .entries,
body.dark-mode .suggestions {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

body.dark-mode input,
body.dark-mode textarea {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: #94a3b8;
}

body.dark-mode .theme-toggle {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .refresh-button {
    background: #334155;
    border-color: #475569;
    color: #60a5fa;
}

body.dark-mode .datetime-box {
    background: #1e293b;
    border-color: #475569;
}

body.dark-mode .ghost-button {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

body.dark-mode .ghost-button:hover {
    background: #475569;
}

body.dark-mode table th {
    background: #1e293b;
}

body.dark-mode table th,
body.dark-mode table td {
    border-bottom-color: #334155;
}

body.dark-mode .details-row {
    background: #334155;
}

body.dark-mode .icon-button {
    color: #60a5fa;
}

body.dark-mode .icon-button.danger {
    color: #f87171;
}

body.dark-mode .chart-modal-content {
    background: #1e293b;
}

body.dark-mode .chart-modal-header {
    border-bottom-color: #334155;
}

body.dark-mode .chart-modal-header h3 {
    color: #e2e8f0;
}

body.dark-mode .chart-modal-close {
    color: #94a3b8;
}

body.dark-mode .chart-modal-close:hover {
    color: #e2e8f0;
}

body.dark-mode .chart-controls {
    border-bottom-color: #334155;
}

body.dark-mode .chart-filter-btn {
    background: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

body.dark-mode .chart-filter-btn:hover {
    background: #475569;
}

body.dark-mode .chart-date-range label {
    color: #e2e8f0;
}

body.dark-mode .chart-date-range input[type="date"] {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
    color-scheme: dark;
}

body.dark-mode .chart-inline-field { color: #e2e8f0; }
body.dark-mode #chart-range-select,
body.dark-mode .chart-trend-window input {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
    color-scheme: dark;
}

body.dark-mode .suggestions-close {
    color: #94a3b8;
}

body.dark-mode .suggestions-close:hover {
    color: #e2e8f0;
}

/* Suggestions Modal */
.suggestions-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

/* Detail-Modal: Samples hervorheben, an denen das Ereignis passierte
   (SpO2-Abfall bzw. Puls über der Grenze); -soft = anhaltender Zustand */
tr.detail-event td { background: rgba(239, 68, 68, 0.16); }
tr.detail-event-soft td { background: rgba(239, 68, 68, 0.07); }
tr.detail-event td small,
tr.detail-event-soft td small { color: #ef4444; font-weight: 600; }
body.dark-mode tr.detail-event td { background: rgba(248, 113, 113, 0.24); }
body.dark-mode tr.detail-event-soft td { background: rgba(248, 113, 113, 0.12); }
body.dark-mode tr.detail-event td small,
body.dark-mode tr.detail-event-soft td small { color: #f87171; }

.suggestions-modal.show {
    display: flex;
}

.suggestions-modal-content {
    background: white;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-modal);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.suggestions-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.suggestions-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.suggestions-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
}

.suggestions-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 0 0 auto;
}

.modal-input-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.suggestions-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.suggestions-option-group {
    margin-bottom: 0;
}

.suggestions-option-group h4 {
    margin: 0 0 0.8rem 0;
    font-size: 0.95rem;
    color: #475569;
}

.suggestions-checkbox {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    cursor: pointer;
    font-weight: normal;
}

.suggestions-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.suggestions-checkbox span {
    font-size: 0.9rem;
}

.suggestions-preview {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.suggestions-preview h4 {
    margin: 0 0 0.8rem 0;
    font-size: 0.95rem;
    color: #475569;
}

.suggestions-preview-content {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 1rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    font-family: monospace;
    display: block;
    word-wrap: break-word;
}

.suggestions-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* Wachsender Modal-Inhalt (scrollt selbst, Kopf und Fusszeile bleiben stehen) */
.suggestions-modal-body.grow {
    flex: 1 1 auto;
    min-height: 0;
}

.settings-hint.inline { margin: 0; }

/* Zeile "Quellen suchen" auf der Sync-Seite */
.discover-row {
    margin: 0.25rem 0 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

body.dark-mode .suggestions-modal-content {
    background: #1e293b;
}

body.dark-mode .suggestions-modal-header {
    border-bottom-color: #334155;
}

body.dark-mode .suggestions-modal-header h3 {
    color: #e2e8f0;
}

body.dark-mode .suggestions-modal-close {
    color: #94a3b8;
}

body.dark-mode .suggestions-option-group h4 {
    color: #94a3b8;
}

body.dark-mode .suggestions-checkbox span {
    color: #e2e8f0;
}

body.dark-mode .suggestions-modal-footer {
    border-top-color: #334155;
}

body.dark-mode .suggestions-preview {
    border-top-color: #334155;
}

body.dark-mode .suggestions-preview h4 {
    color: #94a3b8;
}

body.dark-mode .suggestions-preview-content {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

/* Neuer-Eintrag/Bearbeiten-Modal: breiter als Standard-Modals (2-spaltiges
   Formular braucht mehr Platz), .form-section verliert seine Card-Optik
   (Hintergrund/Schatten/Padding), weil sie jetzt im Modal steckt. */
.entry-form-modal-content {
    max-width: 1000px;
}
.entry-form-modal-content .form-section {
    background: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
}
body.dark-mode .entry-form-modal-content .form-section {
    background: none;
    box-shadow: none;
}
/* flex-shrink:0 (Standard von .suggestions-modal-body) lässt den Body bei
   zu viel Inhalt (z.B. hochgezogenes Textfeld) über den Modal-Rand
   hinauswachsen statt intern zu scrollen - min-height:0 behebt das
   (derselbe Fix wie beim Zeilen-Detail-Modal #entry-modal). Zusätzlich
   Breite scrollen, falls ein Feld trotzdem breiter wird als der Modal. */
#entry-form-modal .suggestions-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

/* Primary Button (used in sync settings) */
.primary-button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-control);
    padding: 0.7rem 1.4rem;
    font-size: 1rem;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--accent-hover);
}

/* Trend Icons */
.trend-cell {
    position: relative;
    white-space: nowrap;
}

.trend-icon {
    display: none;
    margin-left: 0.25rem;
    font-size: 0.75rem;
}

.trends-visible .trend-icon {
    display: inline;
}

.trend-icon.positive {
    color: #14b8a6;
}

.trend-icon.negative {
    color: #ef4444;
}

.trend-icon.neutral {
    color: #94a3b8;
}

/* Dark mode for trends */
body.dark-mode .trend-icon.positive {
    color: #2dd4bf;
}

body.dark-mode .trend-icon.negative {
    color: #f87171;
}

/* Login Form */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    background: white;
    border-radius: var(--radius-card);
    padding: 2rem;
    box-shadow: var(--shadow-card);
}

.login-container.config-help {
    max-width: 600px;
}

.login-container.config-help h3 {
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem 0;
    color: #475569;
}

.login-container.config-help h3:first-of-type {
    margin-top: 1rem;
}

body.dark-mode .login-container.config-help h3 {
    color: #94a3b8;
}

.login-container h2 {
    margin: 0 0 1.5rem 0;
    text-align: center;
    font-size: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-form .btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-control);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
}

.login-form .btn-primary:hover {
    background: var(--accent-hover);
}

body.dark-mode .login-container {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.login-container .error-message {
    color: #64748b;
    line-height: 1.6;
}

.login-container code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.login-container pre {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: var(--radius-control);
    overflow-x: auto;
    margin: 1rem 0;
}

.login-container pre code {
    background: none;
    padding: 0;
}

body.dark-mode .login-container pre {
    background: #334155;
}

body.dark-mode .login-container .error-message {
    color: #94a3b8;
}

body.dark-mode .login-container code {
    background: #334155;
}

.flash.error {
    background: #ef4444;
}

/* Logout Button */
.logout-btn {
    position: absolute;
    left: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #64748b;
    text-decoration: none;
}

.logout-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Burger Menu */
.burger-menu-btn {
    position: absolute;
    left: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px;
}

.burger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: #64748b;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger-menu-btn.open .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.burger-menu-btn.open .burger-line:nth-child(2) {
    opacity: 0;
}

.burger-menu-btn.open .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.burger-menu {
    display: none;
    position: absolute;
    top: 50px;
    left: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: var(--shadow-modal);
    min-width: 230px;
    padding: 6px 0;
    z-index: 100;
    overflow: hidden;
}

.burger-menu.show {
    display: block;
}

/* Einträge als Pillen wie im Android-Drawer: abgerundete Klickfläche,
   die aktive Seite bekommt eine sanft getönte Akzent-Fläche */
.burger-menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    box-sizing: border-box;
    margin: 2px 8px;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    color: #0f172a;
    text-decoration: none;
    border: none;
    background: none;
    width: calc(100% - 16px);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}

.burger-menu-item:hover {
    background: #f1f5f9;
}

.burger-menu-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
    font-weight: 600;
}

/* Sticker-Icons (grow-icons.js): überall gleiche Grösse, dezenter Schatten
   für Tiefe; Kontur (.mi-s) und Papier-Füllung (.mi-p) folgen dem Theme */
.grow-icon,
.menu-icon {
    width: 20px;
    height: 20px;
    flex: none;
    vertical-align: -4px;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.25));
}

.menu-icon { width: 22px; height: 22px; }

h1 .grow-icon, h2 .grow-icon { width: 24px; height: 24px; vertical-align: -3px; }

.mi-s {
    stroke: var(--mi-ink);
    stroke-linejoin: round;
    stroke-linecap: round;
}

.mi-p { fill: var(--mi-paper); }
.mi-f { fill: var(--mi-ink); }

/* Design-Eintrag: nur das Icon des aktiven Modus ist sichtbar */
#menu-theme-toggle .menu-icon { display: none; }
#menu-theme-toggle[data-theme-mode="auto"] .theme-auto { display: block; }
#menu-theme-toggle[data-theme-mode="light"] .theme-light { display: block; }
#menu-theme-toggle[data-theme-mode="dark"] .theme-dark { display: block; }

/* Abschnittsüberschrift + Trennlinie im Burgermenü */
.burger-menu-section {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.burger-menu-divider {
    height: 1px;
    margin: 0.35rem 0;
    background: #e2e8f0;
}

body.dark-mode .burger-menu-section {
    color: #64748b;
}

body.dark-mode .burger-menu-divider {
    background: #475569;
}


body.dark-mode .burger-menu-btn {
    border-color: #475569;
}

body.dark-mode .burger-line {
    background: #94a3b8;
}

body.dark-mode .burger-menu {
    background: #1e293b;
    border-color: #475569;
}

/* Sprachwahl im Burger-Menü: Dropdown füllt die Zeile */
.burger-menu-lang { cursor: default; }
.burger-menu-lang select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 0.25rem 0.4rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.9rem;
}

body.dark-mode .burger-menu-item {
    color: #e2e8f0;
}

body.dark-mode .burger-menu-item:hover {
    background: #334155;
}

body.dark-mode .burger-menu-item.active {
    background: rgba(96, 165, 250, 0.16);
    color: #60a5fa;
}

/* Sync Settings Page */
.settings-section {
    background: white;
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    box-sizing: border-box;
}

.settings-header {
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-card {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 1rem;
    margin-bottom: 1rem;
}

.settings-card h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    color: #475569;
}

.settings-hint {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0 0 1rem 0;
}

ul.hint-list {
    margin: -0.5rem 0 1rem;
    padding-left: 1.4rem;
}

.hint-list li {
    margin: 0.2rem 0;
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.device-option:hover {
    background: #f8fafc;
    border-color: var(--border);
}

.device-option input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
}

.device-option .device-delete {
    margin-left: auto;
    flex-shrink: 0;
}

.device-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}

.device-title {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.device-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    margin-left: 0.25rem;
}

.device-badge.active {
    background: #ccfbf1;
    color: #0f766e;
}

.device-badge.inactive {
    background: #fef3c7;
    color: #92400e;
}

.device-meta {
    font-size: 0.75rem;
    color: #64748b;
}

.no-devices {
    color: #64748b;
    font-style: italic;
}

.pairing-row {
    margin-top: 0.75rem;
}

/* Erste-Schritte-Karte für frische Konten */
.first-steps-card {
    background: linear-gradient(135deg, #eff6ff, #f0fdfa);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
}

.first-steps-card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.first-steps-card ol {
    margin: 0.5rem 0;
    padding-left: 1.3rem;
}

.first-steps-card li {
    margin-bottom: 0.5rem;
}

body.dark-mode .first-steps-card {
    background: linear-gradient(135deg, #172554, #134e4a);
    border-color: #1e40af;
}

/* Link unter der Tabelle: ältere Einträge nachladen */
.older-entries-row {
    margin: 0.6rem 0 0;
    text-align: center;
}

/* Konto-Zeile im Burger-Menü (über "Abmelden") */
.burger-menu-account {
    padding: 0.45rem 1rem 0.15rem;
    font-size: 0.78rem;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
    margin-top: 0.35rem;
}

body.dark-mode .burger-menu-account {
    color: #94a3b8;
    border-top-color: #334155;
}

#pairing-box {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

/* Weisser Rand hinter dem QR: bleibt auch im Dark-Mode scanbar */
#pairing-qr {
    background: #fff;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.data-types-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sync-chain-grid {
    display: grid;
    grid-template-columns: minmax(15rem, 2fr) repeat(4, minmax(8rem, 1fr));
    gap: 0.85rem;
    align-items: end;
    margin-bottom: 1rem;
}
.chain-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}
.chain-field > label {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
}
.chain-field select,
.chain-field input {
    min-width: 0;
    width: 100%;
    height: 2.5rem;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: white;
    padding: 0.45rem 0.6rem;
    color: #334155;
    font: inherit;
}
.chain-input-unit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.45rem;
}
.chain-input-unit span {
    color: #64748b;
    font-size: 0.8rem;
}
body.dark-mode .chain-field > label,
body.dark-mode .chain-input-unit span {
    color: #94a3b8;
}
body.dark-mode .chain-field select,
body.dark-mode .chain-field input {
    border-color: #475569;
    background: #1e293b;
    color: #e2e8f0;
}
.chain-apps {
    margin-top: 0.5rem;
}
.chain-app-filter {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.5rem;
}
.chain-app-list {
    max-height: 18rem;
    margin-top: 0.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.65rem;
}
.chain-app-option[hidden] {
    display: none !important;
}

@media (max-width: 900px) {
    .sync-chain-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .chain-mode-field {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .sync-chain-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .chain-mode-field {
        grid-column: auto;
    }
}

.data-type-item {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.75rem 0.9rem;
    background: white;
}

.data-type-toggle {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.data-type-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 0 !important;
    display: inline-block !important;
}

.data-type-icon {
    font-size: 1rem;
    line-height: 1;
    display: inline !important;
}

.data-type-label {
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
    display: inline !important;
}

/* Optionen eingerückt unter dem Toggle: Label-Spalte + Controls-Spalte */
.data-type-options {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.5rem 0.9rem;
    align-items: center;
    margin: 0.6rem 0 0 2.1rem;
}

.data-type-options.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.option-name {
    font-size: 0.85rem;
    color: #64748b;
    white-space: nowrap;
}

.option-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.5rem;
    align-items: center;
    min-width: 0;
}

.option-controls select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.85rem;
    /* Einheitliche Breite bei allen Datentypen, unabhängig vom längsten
       Options-Text */
    width: 15rem;
    max-width: 100%;
}

.source-check {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.15s;
}

.source-check:has(input:checked) {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #334155;
}

.source-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    flex-shrink: 0;
}

/* Lange Quellen-Namen (z.B. Health-Connect-Pakete) kürzen; voller Name
   per title-Tooltip im Template */
.source-check span {
    max-width: 13rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.option-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: normal;
}

.option-label span {
    color: #64748b;
    white-space: nowrap;
}

.option-label select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.85rem;
}

.display-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.checkbox-option {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.9rem;
}

.checkbox-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0 !important;
    flex-shrink: 0;
    display: inline-block !important;
}

.checkbox-option span {
    line-height: 1.2;
    display: inline !important;
}

.checkbox-option.sub-option {
    margin-left: 1.5rem;
}

.checkbox-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.checkbox-option.disabled input[type="checkbox"] {
    cursor: not-allowed;
}

.auto-sync-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.test-button {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.settings-hint.sub-hint {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

.settings-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Dark mode for settings */
body.dark-mode .settings-section {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

body.dark-mode .settings-card {
    border-color: #475569;
}

body.dark-mode .settings-card h3 {
    color: #94a3b8;
}

body.dark-mode .settings-hint {
    color: #94a3b8;
}

body.dark-mode .device-option {
    border-color: #475569;
}

body.dark-mode .device-option:hover {
    background: #334155;
}

body.dark-mode .device-badge.active {
    background: #064e3b;
    color: #6ee7b7;
}

body.dark-mode .device-badge.inactive {
    background: #78350f;
    color: #fcd34d;
}

body.dark-mode .data-type-item {
    border-color: #475569;
    background: #1e293b;
}

body.dark-mode .option-label span {
    color: #94a3b8;
}

body.dark-mode .option-label select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .option-name {
    color: #94a3b8;
}

body.dark-mode .option-controls select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .device-meta {
    color: #94a3b8;
}

body.dark-mode .source-check {
    background: #334155;
    border-color: #475569;
    color: #cbd5e1;
}

body.dark-mode .source-check:has(input:checked) {
    background: #475569;
    border-color: #94a3b8;
    color: #e2e8f0;
}

/* Sync Button */
/* Info icon and tooltip */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 12px;
    cursor: help;
    margin-left: 6px;
    position: relative;
    transition: background 0.2s, transform 0.2s;
}

.info-icon:hover {
    background: #c7d2fe;
    transform: scale(1.1);
}

/* Hide tooltip content by default */
.info-icon .tooltip-content {
    display: none;
}

/* Tooltip for single-line (data-tooltip attribute) */
.info-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: var(--radius-control);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Multiline tooltip - show tooltip-content */
.info-icon[data-tooltip-multiline="true"]:hover .tooltip-content {
    display: block;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-control);
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.info-icon[data-tooltip-multiline="true"] .tooltip-content div {
    padding: 2px 0;
    line-height: 1.4;
}

/* Hide single-line tooltip for multiline icons */
.info-icon[data-tooltip-multiline="true"]::after {
    content: none;
}

.info-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.info-icon:hover::after,
.info-icon:hover::before {
    opacity: 1;
}

body.dark-mode .info-icon {
    background: #1e40af;
    color: #dbeafe;
}

body.dark-mode .info-icon:hover {
    background: #1e3a8a;
}

body.dark-mode .info-icon::after {
    background: #f8fafc;
    color: #1e293b;
}

body.dark-mode .info-icon[data-tooltip-multiline="true"]:hover .tooltip-content {
    background: #f8fafc;
    color: #1e293b;
}

/* AI Settings Page Styles */
.ai-provider-selection {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.radio-option input[type="radio"] {
    cursor: pointer;
}

.radio-option:has(input:checked) {
    border-color: var(--accent);
    background: #eff6ff;
}

body.dark-mode .radio-option {
    border-color: #475569;
}

body.dark-mode .radio-option:has(input:checked) {
    border-color: #60a5fa;
    background: #1e3a8a;
}

.model-selection {
    margin-top: 1rem;
}

.model-list {
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.model-list h4 {
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
    color: #475569;
    position: sticky;
    top: 0;
    background: white;
    padding: 0.5rem 0;
    z-index: 1;
}

body.dark-mode .model-list h4 {
    color: #94a3b8;
    background: #0f172a;
}

.model-option {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-control);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.model-option input[type="radio"] {
    cursor: pointer;
}

.model-option:has(input:checked) {
    border-color: var(--accent);
    background: #eff6ff;
}

body.dark-mode .model-option {
    border-color: #475569;
}

body.dark-mode .model-option:has(input:checked) {
    border-color: #60a5fa;
    background: #1e3a8a;
}

.model-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.model-created {
    font-size: 0.85rem;
    color: #64748b;
    text-align: right;
}

body.dark-mode .model-created {
    color: #94a3b8;
}

.card-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-header-with-action h3 {
    margin: 0;
}

.question-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.question-header-with-action h4 {
    margin: 0;
    font-size: 1rem;
}

.small-button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-control);
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.small-button:hover {
    background: var(--accent-hover);
}

.prompt-select {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

body.dark-mode .prompt-select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

.prompt-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.prompt-textarea[readonly] {
    background: #f8fafc;
    cursor: not-allowed;
}

body.dark-mode .prompt-textarea {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .prompt-textarea[readonly] {
    background: #1e293b;
}

.prompt-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.danger-text {
    color: #ef4444;
}

.danger-text:hover {
    background: #fee2e2;
}

body.dark-mode .danger-text {
    color: #f87171;
}

body.dark-mode .danger-text:hover {
    background: #7f1d1d;
}

.context-question-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
}

body.dark-mode .context-question-group {
    border-color: #475569;
}

.question-select-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.context-question-select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.9rem;
}

.question-count-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.count-label {
    font-size: 0.9rem;
    color: #475569;
    font-weight: 500;
}

.question-count-input {
    width: 80px;
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.9rem;
}

.question-count-input[readonly] {
    background: #f8fafc;
    cursor: not-allowed;
}

body.dark-mode .context-question-select {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .count-label {
    color: #cbd5e1;
}

body.dark-mode .question-count-input {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .question-count-input[readonly] {
    background: #1e293b;
}

.question-preview {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    font-size: 0.85rem;
    background: #f8fafc;
    resize: none;
    box-sizing: border-box;
}

.question-preview[readonly] {
    cursor: not-allowed;
}

body.dark-mode .question-preview {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

.question-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.modal-input,
.modal-textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    font-size: 0.95rem;
    font-family: inherit;
    box-sizing: border-box;
}

.modal-textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

body.dark-mode .modal-input,
body.dark-mode .modal-textarea {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

/* Spaltenauswahl + Spaltenbreiten (Eintrags-Tabelle) */
.column-picker {
    position: relative;
    display: inline-block;
}

.column-picker-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 12rem;
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.75rem;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-modal);
}

.column-picker-menu label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.column-picker-menu .subtle-button {
    margin-top: 0.5rem;
}

/* Feld-/Massnahmen-Zeile mit Verwaltungs-Buttons + Inline-Editor.
   min-height sorgt für einheitliche Zeilenhöhe/Abstände, egal ob die Zeile
   ein Dropdown/Buttons hat oder nur eine Checkbox (Tagebuch, Weitere Spalten). */
.column-picker-menu .picker-field-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 1.9rem;
}
.column-picker-menu .picker-field-label {
    flex: 1;
    min-width: 0;
    white-space: normal;
}
.column-picker-menu .picker-tools {
    display: flex;
    gap: 0.1rem;
    flex: 0 0 auto;
}
/* "beendet DD.MM.JJJJ" rechtsbündig in der Zeile: alle Marker stehen
   damit in derselben Spalte, egal wie lang der Massnahmen-Name ist */
.column-picker-menu .picker-ended {
    margin-left: auto;
    padding-left: 0.5rem;
    white-space: nowrap;
    opacity: 0.6;
}
.column-picker-menu .picker-tools .icon-button {
    padding: 0.05rem 0.25rem;
    font-size: 0.9rem;
    line-height: 1.3;
    background: none;
    border: none;
    cursor: pointer;
}
.column-picker-menu .picker-tools .icon-button:hover { opacity: 0.7; }
.column-picker-menu .picker-calc-btn {
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
    line-height: 1.4;
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
}
.column-picker-menu .picker-calc-btn:hover { background: #e2e8f0; }
.column-picker-menu .picker-calc-panel {
    flex: 1 1 100%;
    margin: 0.1rem 0 0.4rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    background: #f8fafc;
    font-size: 0.8rem;
}
.column-picker-menu .picker-calc-formula {
    margin: 0 0 0.4rem;
    color: #475569;
    line-height: 1.4;
}
.column-picker-menu .picker-calc-param {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
}
.column-picker-menu .picker-calc-param input {
    width: 4rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    box-sizing: border-box;
}
body.dark-mode .column-picker-menu .picker-calc-btn {
    background: #334155; border-color: #475569; color: #e2e8f0;
}
body.dark-mode .column-picker-menu .picker-calc-panel {
    background: #1e293b; border-color: #334155;
}
body.dark-mode .column-picker-menu .picker-calc-formula { color: #94a3b8; }
body.dark-mode .column-picker-menu .picker-calc-param input {
    background: #334155; border-color: #475569; color: #e2e8f0;
}
.column-picker-menu .picker-edit {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
    padding: 0.2rem 0;
}
.column-picker-menu .picker-edit-emoji { width: 3rem; flex: 0 0 auto; }
.column-picker-menu .picker-edit-name { flex: 1 1 6rem; min-width: 0; }
.column-picker-menu .picker-edit-unit { width: 5rem; flex: 0 0 auto; }

body.dark-mode .column-picker-menu {
    background: #1e293b;
    border-color: #475569;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ⚙️ Felder-Menü (Neuer Eintrag): jedes Thema auf-/zuklappbar, mit
   Trennlinie/Abstand zum vorherigen Thema statt einer flachen Liste */
.column-picker-menu .picker-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.column-picker-menu .picker-section:not(:first-of-type) {
    margin-top: 0.3rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e2e8f0;
}
.column-picker-menu .picker-section summary {
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    user-select: none;
}
.column-picker-menu .picker-section summary::-webkit-details-marker {
    display: none;
}
.column-picker-menu .picker-section summary::before {
    content: "▸";
    display: inline-block;
    font-size: 0.75em;
    transition: transform 0.15s ease;
}
.column-picker-menu .picker-section[open] summary::before {
    transform: rotate(90deg);
}
/* Gruppen-Werkzeuge im Sektionstitel (umbenennen/auflösen) und der
   ⠿-Griff zum Verschieben von Zeilen - auch zwischen Gruppen */
.column-picker-menu .picker-summary-tools {
    margin-left: auto;
    display: flex;
    gap: 0.1rem;
}
.column-picker-menu .picker-summary-tools .icon-button {
    padding: 0.05rem 0.25rem;
    font-size: 0.85rem;
    background: none;
    border: none;
    cursor: pointer;
}
.column-picker-menu .picker-summary-tools .icon-button:hover { opacity: 0.7; }
.column-picker-menu .drag-handle {
    cursor: grab;
    color: #94a3b8;
    flex: 0 0 auto;
    touch-action: none;
    padding: 0 0.15rem;
    user-select: none;
}
.column-picker-menu .sortable-ghost { opacity: 0.4; }
/* Block-Titel ("Spalten & Gruppen") direkt am Menüanfang: ohne Trennlinie */
.column-picker-menu > .picker-subheading:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
/* Sektion direkt nach einem Block-Titel ("Spalten & Gruppen"/"Darstellung"):
   der Titel trennt bereits - keine zweite Linie, und unter beiden Titeln
   derselbe Abstand (doppelte Klasse schlägt die :not(:first-of-type)-Regel) */
.column-picker-menu .picker-subheading + .picker-section.picker-section {
    border-top: none;
    margin-top: 0;
    padding-top: 0.55rem;
}
.column-picker-menu .picker-subheading {
    margin-top: 0.45rem;
    padding-top: 0.45rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
}
body.dark-mode .column-picker-menu .picker-section:not(:first-of-type) {
    border-top-color: #475569;
}
body.dark-mode .column-picker-menu .picker-subheading {
    border-top-color: #475569;
    color: #cbd5e1;
}

/* Emoji-Popup der Anlege-Box (Klick aufs Emoji-Feld) - schwebt über dem
   Menü, damit die ganze Palette ohne Scrollen sichtbar ist */
/* Anlege-Box (Neu anlegen): alle Bedienelemente in der komfortablen
   Grösse des Anlegen-Knopfs (statt kleiner Popup-Felder) */
.nf-name, .nf-type, .nf-unit, .nf-category, .nf-dose, .nf-start {
    box-sizing: border-box;
    height: 44px;
    padding: 0 0.7rem;
    font-size: 1rem;
}

.nf-name-bulk {
    box-sizing: border-box;
    padding: 0.55rem 0.7rem;
    font-size: 1rem;
}

.nf-add.primary-button {
    box-sizing: border-box;
    height: 44px;
    padding: 0 1.2rem;
}

.nf-emoji.icon-button {
    width: 44px;
    height: 44px;
}

.nf-emoji.icon-button .grow-icon {
    width: 24px;
    height: 24px;
}

.nf-emoji-picker {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem;
    width: min(21rem, calc(100vw - 1rem));
    max-height: 70vh;
    overflow-y: auto;
    padding: 0.4rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-card);
    background: #ffffff;
    box-shadow: var(--shadow-modal);
}
.nf-emoji-picker button {
    border: none;
    background: none;
    line-height: 1;
    padding: 0.3rem;
    cursor: pointer;
    border-radius: var(--radius-control);
}

/* Icon-Auswahl: Sticker-Icons etwas grösser als im Fliesstext */
.nf-emoji-picker button .grow-icon {
    width: 26px;
    height: 26px;
    vertical-align: middle;
}
.nf-emoji-picker button:hover {
    background: #e2e8f0;
}
body.dark-mode .nf-emoji-picker {
    border-color: #475569;
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
body.dark-mode .nf-emoji-picker button:hover {
    background: #334155;
}

#entries-table th {
    position: relative;
}

.col-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 10;
}

.col-resizer:hover {
    background: rgba(59, 130, 246, 0.35);
}

/* Fixes für Auswahlmenüs (Spalten/Metriken): hidden-Attribut respektieren,
   Checkbox und Text in einer Zeile */
.column-picker-menu[hidden] {
    display: none;
}

.column-picker-menu label {
    flex-direction: row;
    align-items: center;
    font-weight: 400;
    gap: 0.4rem;
}

.column-picker-menu input[type="checkbox"] {
    width: auto;
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
}

/* hidden-Attribut gewinnt immer, auch gegen display:flex-Regeln */
[hidden] {
    display: none !important;
}

/* Massnahmen (Erfassung auf Hauptseite, Auswertung auf Statistik) */
.stats-empty { color: #64748b; list-style: none; }
.intervention-form {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}
.intervention-form input[type="text"] { flex: 1; min-width: 12rem; }
.intervention-form .option-label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}
/* Massnahmen-Liste im ⚙️ Felder-Menü (Startseite) */
.intervention-legend {
    font-size: 0.72rem;
    opacity: 0.6;
    margin: 0.1rem 0 0.3rem;
}
.intervention-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid #e2e8f0;
}
body.dark-mode .intervention-item { border-bottom-color: #334155; }
.intervention-item:last-child { border-bottom: none; }
.intervention-name {
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}
.intervention-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.intervention-caption {
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Statistik-Bedienelemente in einer Zeile ausrichten */
.stats-controls {
    align-items: center;
}
.stats-controls .option-label {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: 400;
}
.stats-controls select,
.stats-controls input[type="date"] {
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
}

/* Statistik-Seite (vorher als <style>-Block in stats.html) */
.stats-page .stats-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.stats-controls .input-narrow { width: 4.5rem; }
.stats-chart-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}
.stats-table-wrap { overflow-x: auto; }
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.stats-table th, .stats-table td {
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
body.dark-mode .stats-table th, body.dark-mode .stats-table td { border-bottom-color: #334155; }
.stats-table .delta-up { color: var(--accent); }
.stats-table .delta-down { color: #d97706; }
body.dark-mode .stats-table .delta-up { color: #3b82f6; }
.stats-hint-list { margin: 0; padding-left: 1.2rem; }
.stats-hint-list li { margin-bottom: 0.4rem; }
.stats-hint-list .warn::marker { color: var(--c-orange); }
.stats-hint-list .info::marker { color: var(--c-blau); }
#intervention-analysis h4 { margin: 1rem 0 0.2rem; }
.weekly-table-block h4 { margin: 1.2rem 0 0.3rem; }
.weekly-table-block + .weekly-table-block { margin-top: 0.5rem; }
.stats-info {
    margin: 0 0 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    background: #f8fafc;
    font-size: 0.88rem;
}
.stats-info summary {
    cursor: pointer;
    padding: 0.5rem 0.8rem;
    font-weight: 600;
    user-select: none;
}
.stats-info[open] summary { border-bottom: 1px solid #e2e8f0; }
.stats-info > *:not(summary) { margin: 0.6rem 0.9rem; }
.stats-info h5 { margin: 0.9rem 0.9rem 0.2rem; font-size: 0.9rem; }
.stats-info ul { padding-left: 2rem; }
.stats-info li { margin-bottom: 0.25rem; }
body.dark-mode .stats-info { border-color: #334155; background: #1e293b; }
body.dark-mode .stats-info[open] summary { border-bottom-color: #334155; }

/* Sync-Kennzeichnung am Formularfeld + Formularkopf mit Feld-Wähler */
.sync-badge {
    font-size: 0.75rem;
    margin-left: 0.25rem;
    opacity: 0.7;
    cursor: help;
}
.form-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Analyse-/Berichtsdarstellung (Markdown) - auf Startseite und Statistik */
.report-item {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.8rem 1rem;
    margin-top: 1rem;
}
body.dark-mode .report-item { border-color: #334155; }
.report-item .report-meta { color: #64748b; font-size: 0.8rem; margin-bottom: 0.4rem; }
.report-item .report-body h1, .report-item .report-body h2, .report-item .report-body h3 {
    font-size: 1rem;
    margin: 0.6rem 0 0.2rem;
}
.report-item .report-body ul { padding-left: 1.2rem; margin: 0.2rem 0; }

/* KI-Analyse-Dialog */
.analysis-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.2rem 0.8rem;
}
.analysis-checkbox-grid label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    font-size: 0.9rem;
}
.analysis-checkbox-grid input[type="checkbox"] { width: auto; margin: 0; }

/* Feld-Gruppen im Eingabeformular */
.field-group {
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    padding: 0.5rem 0.9rem 0.9rem;
    margin: 0;
    min-width: 0;
}
body.dark-mode .field-group { border-color: #334155; }
.field-group legend {
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    padding: 0 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.field-group-body {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 2rem;
}
.field-group-body .icon-label.wide { flex: 1 1 100%; }

/* Anordnen-Modus */
form.arranging .field-item {
    cursor: grab;
    outline: 1px dashed #94a3b8;
    outline-offset: 4px;
    border-radius: var(--radius-control);
}
form.arranging .field-item input,
form.arranging .field-item textarea {
    pointer-events: none;
    opacity: 0.55;
}
form.arranging .field-group { border-style: dashed; }
.sortable-ghost { opacity: 0.4; }
.group-tools button {
    font-size: 0.75rem;
    padding: 0.05rem 0.3rem;
}

/* Felder-Menü: konstante Breite, einheitliche Bedienelemente */
.column-picker-menu {
    width: min(30rem, calc(100vw - 2rem));
    box-sizing: border-box;
}

.column-picker-menu .primary-button {
    font-size: 0.85rem;
    padding: 0.35rem 0.8rem;
}
.column-picker-menu select,
.column-picker-menu input[type="text"],
.column-picker-menu input[type="date"],
.column-picker-menu input[type="number"],
#field-create-modal select,
#field-create-modal input[type="text"],
#field-create-modal input[type="date"],
#field-create-modal input[type="number"] {
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    min-width: 0;
}
.column-picker-menu .subtle-button { justify-content: center; }
body.dark-mode .column-picker-menu select,
body.dark-mode .column-picker-menu input[type="text"],
body.dark-mode .column-picker-menu input[type="date"],
body.dark-mode .column-picker-menu input[type="number"],
body.dark-mode #field-create-modal select,
body.dark-mode #field-create-modal input[type="text"],
body.dark-mode #field-create-modal input[type="date"],
body.dark-mode #field-create-modal input[type="number"] {
    border-color: #475569;
}

/* Rand-Feld (px) nur aktiv, wenn Breiter/Höher gewählt ist */
.resize-settings input:disabled {
    opacity: 0.45;
}

/* Spaltenbreite/Tabellenbreite/Tabellenhöhe: Label, Auswahl und Rand-Feld
 * über alle Zeilen hinweg gleich breit und eingerückt */
.resize-settings {
    display: grid;
    grid-template-columns: max-content 9.5rem 4.5rem;
    column-gap: 0.5rem;
    row-gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.6rem;
}
.resize-settings-label {
    font-weight: 400;
    white-space: nowrap;
}
.resize-settings select,
.resize-settings input[type="number"] {
    width: 100%;
}

/* Tabelle: Zellen einzeilig; Header darf wie in der Wochenansicht umbrechen
   (z.B. zwischen Emoji und Text) und wird bei schmaler Spalte gekürzt */
#entries-table td {
    white-space: nowrap;
}
#entries-table th {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Breite von "Letzte Einträge"/Datenbank: per resizable.js gezogen */

/* Textzellen: Klick öffnet Volltext */
#entries-table td.text-cell { cursor: pointer; }
#entries-table td.text-cell:hover { text-decoration: underline dotted; }

/* Zeilen sind klickbar (öffnet Eintrags-Modal) - auch reine Sync-Tage */
#entries-table tbody tr[data-entry-id],
#entries-table tbody tr.sync-day-row { cursor: pointer; }
#entries-table tbody tr[data-entry-id]:hover td,
#entries-table tbody tr.sync-day-row:hover td { background: rgba(59, 130, 246, 0.05); }
body.dark-mode #entries-table tbody tr[data-entry-id]:hover td,
body.dark-mode #entries-table tbody tr.sync-day-row:hover td { background: rgba(59, 130, 246, 0.08); }

#entry-modal-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.5rem 0.8rem;
    overflow-y: auto;
}
.entry-modal-item {
    background: #f8fafc;
    border-radius: var(--radius-control);
    padding: 0.45rem 0.6rem;
    min-width: 0;
}
body.dark-mode .entry-modal-item { background: #1e293b; }
.entry-modal-item.text-item { grid-column: 1 / -1; }
.entry-modal-item strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.entry-modal-item div { font-size: 0.95rem; }

/* Eintrags-Modal: Inhalt scrollt bei Überhöhe, Navigation im Kopf */
#entry-modal .suggestions-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
#entry-modal .entry-nav {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: auto;
    margin-right: 0.6rem;
}
#entry-modal .entry-nav button {
    font-size: 1rem;
    line-height: 1;
    padding: 0.25rem 0.6rem;
}
#entry-modal .entry-nav button:disabled {
    opacity: 0.35;
    cursor: default;
}

/* Datenbank-Seite: Karte an den Seitenrändern breiter ziehen */
.db-resizable {
    position: relative;
}
.db-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: ew-resize;
    z-index: 5;
    border-radius: var(--radius-control);
}
.db-resize-handle[data-side="left"] { left: -5px; }
.db-resize-handle[data-side="right"] { right: -5px; }
.db-resize-handle:hover,
.db-resize-handle.dragging {
    background: rgba(59, 130, 246, 0.25);
}

/* Tabellen-Höhe ziehbar: Griff sitzt am Rand der Karte (handleParent),
   nicht am Rand der Tabelle selbst - siehe makeHeightResizable() */
.db-resizable-height-anchor {
    position: relative;
}
.db-resize-handle-bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 10px;
    cursor: ns-resize;
    z-index: 5;
    border-radius: var(--radius-control);
}
.db-resize-handle-bottom:hover,
.db-resize-handle-bottom.dragging {
    background: rgba(59, 130, 246, 0.25);
}

/* Datenbank-Seite: Eingaben/Auswahlen kompakt in einer Reihe */
#db-admin .stats-controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.7rem;
}
#db-admin .stats-controls select,
#db-admin .stats-controls input[type="text"] {
    font-size: 0.85rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-control);
    background: transparent;
    color: inherit;
    width: auto;
    max-width: 14rem;
}
#db-admin .stats-controls .option-label {
    font-size: 0.85rem;
    font-weight: 400;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    white-space: nowrap;
}
body.dark-mode #db-admin .stats-controls select,
body.dark-mode #db-admin .stats-controls input[type="text"] {
    border-color: #475569;
}

/* ==================== Smartphone-Layout ==================== */
/* Gleiche Schwelle wie resizable.js (720px): Sektionen füllen die Breite,
 * Tabellen scrollen horizontal (.table-wrapper), Modals fast vollflächig.
 * Der Datenbank-Browser bleibt Desktop-only (Link im Menü ausgeblendet). */
@media (max-width: 720px) {
    body { padding: 0 0.5rem 1.5rem; }
    main { gap: 1rem; margin-top: 1rem; }

    .burger-menu-item.desktop-only { display: none; }

    .form-section, .entries, .suggestions { padding: 1rem 0.75rem; }

    /* Kopfzeilen und Button-Leisten dürfen umbrechen */
    .form-header, .section-header { flex-wrap: wrap; gap: 0.5rem; }
    .section-actions { flex-wrap: wrap; gap: 0.4rem; }
    .form-actions button, .form-actions .ghost-button {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
    }

    /* Eingabeformular */
    .textarea-row { gap: 1rem; }
    .textarea-row .icon-label { min-width: 100%; }
    .icon-label.wide textarea { min-width: 0; }

    /* Datum, Zeit und ↻-Button zusammen in einer Reihe */
    .datetime-wrapper { width: 100%; }
    .datetime-box {
        width: 100%;
        box-sizing: border-box;
        gap: 0.5rem;
        padding: 0.5rem 0.6rem;
    }
    .datetime-box .datetime-field { flex: 1 1 0; min-width: 0; }
    .datetime-box .icon-label input {
        width: 100%;
        box-sizing: border-box;
    }
    .datetime-box .refresh-button { flex: 0 0 auto; }

    /* Pro Feldgruppe (Umrandung) zwei Spalten; Textfelder über beide */
    .field-group-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.8rem 0.6rem;
    }
    .field-group-body .icon-label.wide { grid-column: 1 / -1; }
    .field-group-body .icon-label {
        min-width: 0;
        /* langer Titel (z.B. "Bauchumfang (cm)") darf umbrechen, die
           Eingabefelder einer Reihe bleiben trotzdem unten bündig */
        justify-content: flex-end;
    }
    .field-group-body .icon-label > span:first-child {
        font-size: 0.85rem;
    }
    .field-group-body .icon-label input,
    .field-group-body .icon-label select {
        width: 100%;
        box-sizing: border-box;
    }

    /* Dropdown-Menüs (⚙️ Felder / Spalten) nie breiter als der Schirm */
    .column-picker-menu {
        max-width: calc(100vw - 1.5rem);
        overflow-x: auto;
    }

    /* Modals fast vollflächig, Inhalte scrollen */
    .suggestions-modal-content,
    .chart-modal-content {
        width: 96%;
        max-width: none;
        max-height: 94vh;
    }
    .suggestions-modal-header,
    .suggestions-modal-body,
    .suggestions-modal-footer,
    .suggestions-preview { padding-left: 0.9rem; padding-right: 0.9rem; }
    .suggestions-modal-body { overflow-x: auto; }
    .suggestions-columns { grid-template-columns: 1fr; gap: 1rem; }
    .modal-input-row { flex-wrap: wrap; }

    /* Tabellen kompakter; horizontales Scrollen übernimmt .table-wrapper */
    th, td { padding: 0.4rem 0.35rem; font-size: 0.85rem; }

    /* Ziehbare Sektionsbreite ist deaktiviert (resizable.js) */
    .db-resize-handle,
    .db-resize-handle-bottom { display: none; }

    .adherence-label { width: 6rem; font-size: 0.75rem; }
}

/* Sync-Werte in der Tages-Ansicht: gleicher Stil wie die Wochen-Ansicht,
 * klickbar für die Herleitung (Herkunft steht im Modal) */
.sync-cell-value {
    cursor: pointer;
}

/* Markierung: mehrere Quellen am selben Tag (Vergleich im Modal) */
.multi-source-mark {
    opacity: 0.65;
    font-weight: bold;
    margin-left: 1px;
}

.weekly-source-comparison {
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid #d9e0e8;
}
.weekly-source-comparison-title {
    margin: 0 0 0.4rem;
}
.weekly-source-comparison-table {
    margin-bottom: 0;
}
.weekly-source-comparison-table td:nth-child(4) {
    min-width: 12rem;
}
.weekly-source-row {
    cursor: pointer;
}
.weekly-source-row:hover,
.weekly-source-row:focus,
.weekly-source-selected {
    background: #eef6ff;
}
.weekly-source-selected td:first-child {
    font-weight: bold;
}
body.dark-mode .weekly-source-comparison {
    border-color: #334155;
}
body.dark-mode .weekly-source-row:hover,
body.dark-mode .weekly-source-row:focus,
body.dark-mode .weekly-source-selected {
    background: #1e3a5f;
}

/* Einblicke-Dashboard unter "Letzte Einträge": frei anordenbares Raster aus
   Karten (Massnahmen-Adhärenz, Trend-Vergleich, Wochentag-Muster,
   Massnahme Vorher/Nachher, Ausreisser) - siehe insights.js */
.dashboard-grid {
    display: grid;
    gap: 1.5rem;
}
.dashboard-cell {
    min-width: 0;
}
.insight-card {
    background: white;
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}
.insight-card h3 {
    margin: 0 0 0.3rem;
}
.insight-card canvas {
    max-height: 260px;
}
.insight-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}
.insight-card-header h3 {
    margin: 0;
}
.insight-card select {
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.insight-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #475569;
}
.insight-window {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    font-weight: normal;
}
.insight-window[hidden] { display: none; }
.insight-window input {
    width: 3.5rem;
    font-size: 0.85rem;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    box-sizing: border-box;
}

.adherence-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.8rem;
}
.adherence-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.adherence-label {
    flex: 0 0 auto;
    width: 9rem;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.adherence-strip {
    display: flex;
    gap: 1px;
    flex: 1;
    min-width: 0;
}
.adherence-cell {
    flex: 1 1 0;
    min-width: 0;
    height: 18px;
    border-radius: 1px;
}
.adh-taken { background: #14b8a6; }
.adh-missed { background: #ef4444; }
.adh-open { background: #e2e8f0; }
.adh-inactive { background: transparent; }

/* Trend-Vergleich: Einstellungen im aufpoppenden Modal (wie in der App) */
.insight-settings-content {
    max-width: 420px;
    width: min(92%, 420px);
}
.insight-settings-body {
    padding: 1rem 1.5rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}
.insight-settings-section {
    margin: 0.3rem 0 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.insight-settings-section:first-child {
    margin-top: 0;
}
.insight-settings-row {
    display: flex;
    /* die globale label-Regel stellt sonst untereinander */
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 400;
    min-width: 0;
}
.insight-settings-row select {
    flex: 1 1 auto;
    min-width: 0;
}
.insight-settings-row input[type="number"] {
    width: 4rem;
    min-width: 0;
    flex: 0 0 auto;
}
.insight-settings-row input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
}
.insight-settings-grow {
    flex: 1 1 auto;
}
/* Versatz und Zeitraum nebeneinander */
.insight-settings-split {
    display: flex;
    gap: 0.8rem;
}
.insight-settings-split > label {
    flex: 1 1 0;
}
/* Farb-Modal (öffnet per Klick auf den Farbpunkt einer Metrik-Zeile):
   Auto-Chip, Palette-Vorschläge, freier Farbwähler */
.insight-color-content {
    max-width: 320px;
    width: min(92%, 320px);
}
.insight-swatch-btn {
    width: 1rem;
    height: 1rem;
    border: none;
    padding: 0;
    cursor: pointer;
}
.insight-color-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.insight-color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
}
.insight-color-dot.selected {
    outline: 2px solid var(--c-blau);
    outline-offset: 2px;
}
.insight-color-auto {
    border: 1px solid var(--border, #cbd5e1);
    background: none;
    border-radius: 999px;
    font-size: 0.82rem;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
    color: inherit;
    align-self: flex-start;
}
.insight-color-auto.selected {
    border-color: var(--c-blau);
    color: var(--c-blau);
    font-weight: 600;
}
/* Freie Farbe: nativer Farbwähler als runder Punkt mit Palette-Ring */
.insight-color-customwrap {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    padding: 2px;
    box-sizing: border-box;
    display: inline-flex;
    background: conic-gradient(#ef4444, #fb923c, #14b8a6,
        #3b82f6, #8b5cf6, #ef4444);
    cursor: pointer;
}
.insight-color-customwrap.selected {
    outline: 2px solid var(--c-blau);
    outline-offset: 2px;
}
.insight-color-custom {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    border-radius: 50%;
    cursor: pointer;
}
.insight-color-custom::-webkit-color-swatch-wrapper {
    padding: 0;
}
.insight-color-custom::-webkit-color-swatch {
    border-radius: 50%;
    border: none;
}
.insight-color-custom::-moz-color-swatch {
    border-radius: 50%;
    border: none;
}
body.dark-mode .insight-color-dot {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}
/* Kopfzeilen-Werkzeuge der Trend-Karte rechtsbündig gebündelt */
.insight-card-tools {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
}
/* Bedien-Hinweis unter dem Trend-Chart; auf Touch-Geräten (kein Hover)
   gilt Pinch statt Strg+Mausrad, dort ausgeblendet */
.insight-zoom-hint {
    margin: 0.3rem 0 0;
    font-size: 0.72rem;
    color: #94a3b8;
}
@media (hover: none) {
    .insight-zoom-hint { display: none; }
}
body.dark-mode .insight-zoom-hint {
    color: #64748b;
}
/* Grosse, interaktive Trend-Ansicht */
.insight-large-content {
    max-width: 1100px;
    width: 94%;
}
.insight-large-body {
    position: relative;
    height: min(72vh, 620px);
    padding: 1rem 1.5rem 1.4rem;
}
body.dark-mode .insight-settings-section {
    color: #94a3b8;
}
.dualtrend-swatch {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.15);
}
body.dark-mode .dualtrend-swatch {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Massnahme Vorher/Nachher */
.corr-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 0.9rem;
}
.corr-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.55rem;
}
.corr-label {
    flex: 0 0 9rem;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.corr-bar-track {
    flex: 1;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}
.corr-bar { height: 100%; }
.corr-bar.corr-better { background: #14b8a6; }
.corr-bar.corr-worse { background: #ef4444; }
.corr-bar.corr-neutral { background: #94a3b8; }
.corr-verdict {
    flex: 0 0 auto;
    font-size: 0.75rem;
    opacity: 0.75;
    max-width: 11rem;
}

/* Ausreisser-Hinweis */
.stats-hint-list {
    margin: 0;
    padding-left: 1.2rem;
}
.stats-hint-list li {
    margin-bottom: 0.4rem;
}
.stats-hint-list .warn::marker { color: var(--c-orange); }
.stats-hint-list .info::marker { color: var(--c-blau); }

/* ⚙️ Anordnen: Spalten-Steuerung und Karten-Liste (frei sortierbar, Karten
   fliessen wie Text in das Raster - "Zeilen" ergeben sich automatisch aus
   Spaltenzahl + Kartenbreite, siehe renderViewGrid in insights.js) */
.dashboard-arrange-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    margin-bottom: 1.2rem;
    padding: 0.8rem 1rem;
    background: linear-gradient(135deg, #f8fafc, #eff6ff);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-card);
}
.dashboard-arrange-bar label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}
/* Kurz-Hinweis rechtsbündig in derselben Zeile wie die Spaltenwahl */
.dashboard-arrange-hint {
    margin-left: auto;
    text-align: right;
}
/* Segment-Buttons (Spaltenzahl der Leiste, Breite je Karte) */
.dashboard-seg {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    overflow: hidden;
    background: #ffffff;
}
.dashboard-seg button {
    background: transparent;
    color: inherit;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
}
.dashboard-seg button:last-child {
    border-right: none;
}
.dashboard-seg button:hover:not(.active) {
    background: #f1f5f9;
}
.dashboard-seg button.active {
    background: var(--accent);
    color: #ffffff;
}
.dashboard-tips {
    flex: 1 1 100%;
    margin-top: 0.4rem;
    font-size: 0.82rem;
}
.dashboard-tips summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    user-select: none;
}
.dashboard-tips summary::-webkit-details-marker {
    display: none;
}
.dashboard-tips summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.3rem;
    font-size: 0.75em;
    transition: transform 0.15s ease;
}
.dashboard-tips[open] summary::before {
    transform: rotate(90deg);
}
.dashboard-tips ul {
    margin: 0.3rem 0 0.6rem;
    padding-left: 1.2rem;
}
.dashboard-tips li {
    margin-bottom: 0.25rem;
}
.dashboard-tips p {
    margin: 0.5rem 0 0;
}
/* Bearbeitungs-Karte: sitzt im selben Raster wie die echten Karten (gleiche
   grid-column: span N) - Spaltenbreite ändern zeigt die Struktur sofort */
.dashboard-cell-editor {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
    padding: 0.9rem;
    background: #ffffff;
    border: 2px dashed #94a3b8;
    border-radius: var(--radius-card);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-cell-editor:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.12);
}
.dashboard-cell-editor-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Widget-Icon als runde Plakette; der Papierkorb rechtsbündig */
.dashboard-cell-editor-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #eff6ff;
}
.dashboard-cell-editor-top .icon-button {
    margin-left: auto;
}
.dashboard-row-handle {
    cursor: grab;
    opacity: 0.45;
    font-size: 1.1rem;
}
.dashboard-row-handle:active { cursor: grabbing; }
.dashboard-cell-editor select {
    width: 100%;
    box-sizing: border-box;
}
.dashboard-span-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

body.dark-mode .insight-card {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
body.dark-mode .insight-card select {
    border-color: #475569;
    background: transparent;
    color: inherit;
}
body.dark-mode .insight-controls { color: #94a3b8; }
body.dark-mode .insight-window input {
    border-color: #475569;
    background: transparent;
    color: inherit;
}
body.dark-mode .adh-open { background: #334155; }
body.dark-mode .corr-bar-track { background: #334155; }
body.dark-mode .dashboard-arrange-bar {
    background: linear-gradient(135deg, #1e293b, #172033);
    border-color: #334155;
}
body.dark-mode .dashboard-cell-editor { background: #1e293b; border-color: #475569; }
body.dark-mode .dashboard-cell-editor:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
body.dark-mode .dashboard-cell-editor-icon { background: #334155; }
body.dark-mode .dashboard-seg {
    background: #1e293b;
    border-color: #475569;
}
body.dark-mode .dashboard-seg button { border-right-color: #475569; }
body.dark-mode .dashboard-seg button:hover:not(.active) { background: #334155; }

/* ---------- Heutige Fragen / Fragen & Erinnerungen ---------- */
.checkin-card h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.checkin-state { font-size: 0.85rem; color: #64748b; margin-bottom: 0.6rem; }
.checkin-state.answered { color: #14b8a6; font-weight: 600; }
.checkin-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.checkin-scale-btn { min-width: 2.6rem; }
.checkin-input { flex: 1 1 8rem; min-width: 0; padding: 0.4rem 0.5rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); box-sizing: border-box; }
.checkin-group-details { width: 100%; margin-top: 0.4rem; }
.checkin-group-details summary { cursor: pointer; font-size: 0.9rem; color: var(--accent); }
.checkin-group-item { display: flex; align-items: center; gap: 0.4rem;
    padding: 0.3rem 0; }
.checkin-group-name { flex: 1; min-width: 0; }
.checkin-section-title { margin: 0.5rem 0 0.75rem; font-size: 1.05rem; }
.checkin-all-done { margin: 0 0 1rem; color: #14b8a6; font-weight: 600; }
.checkin-completed-section { margin-top: 1.25rem; border-top: 1px solid #e2e8f0;
    padding-top: 0.85rem; }
.checkin-completed-section > summary { cursor: pointer; font-weight: 700;
    font-size: 1.05rem; }
.checkin-completed-content { margin-top: 0.75rem; }
body.dark-mode .checkin-completed-section { border-color: #334155; }

/* ---------- KI-Einstellungen ---------- */
.ai-settings-page { max-width: 980px; margin: 0 auto; }
.ai-settings-page .settings-header { padding-bottom: 1rem; margin-bottom: 1.25rem;
    border-bottom: 1px solid #e2e8f0; }
.ai-settings-page .settings-card { padding: 1.25rem; margin-bottom: 1.25rem; }
.ai-settings-page .settings-card h3 { margin-bottom: 0.45rem; color: #334155;
    font-size: 1.05rem; }
.ai-settings-page .settings-hint { line-height: 1.55; margin-bottom: 1rem; }
.ai-settings-page .ai-intro-card { border-left: 4px solid var(--accent); }

.ai-form-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0;
    margin: 0; font-size: 0.85rem; font-weight: 600; color: #475569; }
.ai-form-field select, .ai-form-field input { width: 100%; height: 42px;
    box-sizing: border-box; border: 1px solid var(--border); border-radius: var(--radius-control);
    padding: 0.5rem 0.65rem; background: #fff; color: #0f172a;
    font: inherit; font-weight: 400; }
.ai-form-field select:focus, .ai-form-field input:focus, .ai-prompt-editor:focus {
    outline: 2px solid rgba(59, 130, 246, 0.2); border-color: var(--accent); }

.ai-key-list { display: grid; gap: 0.75rem; margin: 1rem 0; }
.ai-key-row { display: grid; grid-template-columns: minmax(15rem, 1fr) 8.5rem auto;
    align-items: end; gap: 0.75rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid #f1f5f9; }
.ai-key-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ai-key-status { align-self: center; margin-top: 1.25rem; white-space: nowrap; }
.ai-key-status.configured, .ai-inline-status { color: #0f766e; font-weight: 600; }

.ai-provider-grid { display: grid; grid-template-columns: minmax(12rem, 0.8fr)
    minmax(18rem, 1.4fr) auto; gap: 1rem; align-items: end; margin-top: 1rem; }
.ai-provider-actions { display: flex; gap: 0.6rem; align-items: center; }
.ai-provider-actions #refresh-models { width: 42px; height: 42px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex: 0 0 42px; }
.ai-inline-status { display: inline-block; min-height: 1.25rem; margin-top: 0.65rem;
    font-size: 0.85rem; }
#provider-access-hint { margin-top: 0.35rem; margin-bottom: 0; }

.ai-template-toolbar { display: grid; grid-template-columns: minmax(16rem, 1fr) auto 5rem;
    align-items: end; gap: 0.75rem; margin: 1rem 0; }
.ai-template-toolbar .ai-inline-status { align-self: center; margin: 1.25rem 0 0; }
.ai-prompt-editor { display: block; width: 100%; box-sizing: border-box;
    margin-top: 0.5rem; padding: 0.75rem; border-color: var(--border); border-radius: var(--radius-control);
    line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.9rem; background: #fff; color: #0f172a; }
.ai-card-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center;
    margin-top: 0.85rem; }
.ai-card-actions .settings-hint { margin: 0; }
.ai-danger-action { color: #b91c1c; }

body.dark-mode .ai-settings-page .settings-header,
body.dark-mode .ai-key-row { border-color: #334155; }
body.dark-mode .ai-settings-page .settings-card h3,
body.dark-mode .ai-form-field { color: #cbd5e1; }
body.dark-mode .ai-form-field select, body.dark-mode .ai-form-field input,
body.dark-mode .ai-prompt-editor { background: #0f172a; border-color: #475569;
    color: #e2e8f0; }
body.dark-mode .ai-inline-status, body.dark-mode .ai-key-status.configured {
    color: #2dd4bf; }
body.dark-mode .ai-danger-action { color: #fca5a5; }

@media (max-width: 760px) {
    .ai-settings-page { padding: 1rem; }
    .ai-settings-page .settings-card { padding: 1rem; }
    .ai-provider-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .ai-provider-actions { width: 100%; }
    .ai-provider-actions #save-provider { flex: 1; }
    .ai-template-toolbar { grid-template-columns: 1fr auto; }
    .ai-template-toolbar .ai-form-field { grid-column: 1 / -1; }
    .ai-template-toolbar .ai-inline-status { margin-top: 0; align-self: center; }
}
@media (max-width: 640px) {
    .ai-key-row { grid-template-columns: 1fr auto; }
    .ai-key-row .ai-form-field { grid-column: 1 / -1; }
    .ai-key-status { margin-top: 0; }
    .ai-card-actions > button { flex: 1 1 100%; }
}

.checkin-inline { display: inline-flex; align-items: center; gap: 0.3rem;
    flex-direction: row; font-weight: 400; }
.checkin-iv-row { display: flex; flex-wrap: wrap; gap: 0.2rem 1.2rem;
    align-items: center; padding: 0.15rem 0; }
.checkin-row { display: flex; align-items: center; gap: 0.5rem;
    margin: 0.45rem 0; }
.checkin-row.checkin-wrap { flex-wrap: wrap; }
.checkin-sub { font-size: 0.85rem; font-weight: 600; color: #475569;
    margin-top: 0.5rem; }
.checkin-time-input, .checkin-select { padding: 0.35rem 0.5rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); box-sizing: border-box; }
.checkin-num { width: 4rem; padding: 0.3rem 0.4rem; border: 1px solid var(--border);
    border-radius: var(--radius-control); box-sizing: border-box; }
.checkin-num-label { display: inline-flex; flex-direction: row;
    align-items: center; gap: 0.25rem; font-size: 0.85rem; }
.checkin-field { border-top: 1px solid #e2e8f0; padding: 0.6rem 0; }
.checkin-field:first-of-type { border-top: none; }
.checkin-field-config { margin: 0.3rem 0 0.2rem 1.4rem; }
.checkin-preset-row { display: flex; align-items: center; gap: 0.4rem;
    margin: 0.35rem 0; }
.checkin-preset-name { flex: 1; min-width: 0; padding: 0.35rem 0.5rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); box-sizing: border-box; }
.checkin-chip { padding: 0.3rem 0.6rem; border: 1px solid var(--border);
    border-radius: 999px; background: transparent; cursor: pointer;
    font-size: 0.85rem; color: inherit; }
.checkin-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

body.dark-mode .checkin-input, body.dark-mode .checkin-time-input,
body.dark-mode .checkin-select, body.dark-mode .checkin-num,
body.dark-mode .checkin-preset-name, body.dark-mode .checkin-chip {
    border-color: #475569; background: transparent; color: inherit; }
body.dark-mode .checkin-field { border-color: #334155; }
body.dark-mode .checkin-sub { color: #94a3b8; }
body.dark-mode .checkin-chip.active { background: var(--accent); color: #fff; }

/* Gesundheits-Seestern: eine gezeichnete Seestern-Silhouette (Tusche-Stil),
 * deren Arme sich je nach Tagespunkten von innen mit Farbe füllen. Ungefüllt
 * bleibt Hintergrundfarbe; die Berechnung pro Arm öffnet sich als Modal. */
.starfish-page { max-width: 880px; margin: 0 auto; padding: 0 1rem 2rem; }
.starfish-heading { display: flex; justify-content: space-between; align-items: end;
    gap: 1rem; margin: 0 0 0.8rem; flex-wrap: wrap; }
.starfish-heading h2 { margin: 0 0 0.2rem; }
.starfish-heading p { margin: 0; }
/* Umschalter, Datum und Zahnrad bleiben zusammen in EINER Reihe -
 * bei Platznot rutscht der ganze Block unter den Titel */
.starfish-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: nowrap; }
.starfish-period-toggle { display: flex; border: 1px solid var(--border);
    border-radius: var(--radius-control); overflow: hidden; }
.starfish-period-toggle button { border: none; background: #fff; color: #334155;
    padding: 0 0.85rem; height: 2.5rem; cursor: pointer; font: inherit; }
.starfish-period-toggle button.active { background: var(--accent); color: #fff; }
.starfish-date-controls { display: flex; align-items: center; gap: 0.4rem; }
.starfish-weekday { font-weight: 600; white-space: nowrap; }
.starfish-date-controls button { width: 2.5rem; height: 2.5rem; padding: 0;
    font-size: 1.45rem; line-height: 1; display: flex; align-items: center;
    justify-content: center; }
.starfish-date-controls .starfish-today { width: auto; padding: 0 0.7rem;
    font-size: 0.95rem; font-weight: 600; }
.starfish-date-controls input { height: 2.5rem; box-sizing: border-box;
    padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: var(--radius-control);
    background: #fff; color: #0f172a; font: inherit; }
.starfish-week { height: 2.5rem; box-sizing: border-box; display: flex;
    align-items: center; padding: 0 0.7rem; border: 1px solid var(--border);
    border-radius: var(--radius-control); background: #fff; font-weight: 600; white-space: nowrap; }
.starfish-visual-card { border: 1px solid #e2e8f0; background: #fff;
    border-radius: var(--radius-card); padding: 0.5rem 0.75rem 0.9rem; text-align: center;
    position: relative; }
#starfish-chart { display: block; width: 100%; height: auto; max-height: 640px;
    margin: 0 auto; }
#starfish-status { margin: 0.1rem 0 0; }

/* Die Zeichnung: schwarze Tusche-Linien und -Punkte, Körper in
 * Hintergrundfarbe. Der ganze Stern wiegt sich sanft, die Farbfüllungen
 * wachsen beim Laden aus der Körpermitte in die Arme. */
/* Wochenmodus "7": ein kleiner Seestern pro Tag (Mo-So), drei pro Reihe;
   die Gesichter sind der Reihe nach "dran" (blinzeln, Blick) */
.starfish-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.2rem;
    padding: 0.6rem 0.4rem;
}
.starfish-mini {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-card);
    padding: 0.3rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    color: inherit;
    font: inherit;
}
.starfish-mini:hover {
    border-color: var(--border);
    background: rgba(59, 130, 246, 0.05);
}
.starfish-mini-svg { width: 100%; height: auto; }
.starfish-mini-label {
    font-size: 0.85rem;
    color: #475569;
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
}
.starfish-mini-label strong { color: #0f172a; }
body.dark-mode .starfish-mini-label { color: #94a3b8; }
body.dark-mode .starfish-mini-label strong { color: #e2e8f0; }

.starfish-star { transform-origin: 360px 300px;
    animation: starfish-sway 9s ease-in-out infinite alternate; }
@keyframes starfish-sway {
    from { transform: rotate(-1.6deg) scale(0.995); }
    to { transform: rotate(1.6deg) scale(1.005); }
}
.starfish-body { fill: #fff; stroke: #0f172a; stroke-width: 3;
    stroke-linejoin: round; }
.starfish-outline { fill: none; stroke: #0f172a; stroke-width: 3;
    stroke-linejoin: round; pointer-events: none; }
.starfish-ink { stroke: #0f172a; fill: none; stroke-linecap: round;
    pointer-events: none; }
.starfish-dot { fill: #0f172a; pointer-events: none; }
.starfish-fill circle { transition: r 1100ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 160ms ease; }
.starfish-fill.hover circle { filter: brightness(1.1) saturate(1.15); }
.starfish-center { fill: #fff; stroke: #0f172a; stroke-width: 2.5;
    pointer-events: none; }
/* Gesamtwert oben rechts, klickbar (Modal mit Berechnung + Insights) */
.starfish-mean { position: absolute; top: 0.6rem; right: 0.75rem; z-index: 2;
    margin: 0; padding: 0.3rem 0.6rem; font: inherit; font-weight: 700;
    color: inherit; background: none; border: 1px solid transparent;
    border-radius: var(--radius-control); cursor: pointer; }
.starfish-mean:hover { border-color: var(--border); background: rgba(148, 163, 184, 0.12); }
.starfish-insights { margin: 0.9rem 0 0; font-size: 0.9rem; line-height: 1.7; }

/* Standardansicht (Gesicht abgeschaltet): Emoji + Gesamtpunkte in der Mitte */
.starfish-center-big { font-size: 38px; font-weight: 700; fill: #0f172a;
    pointer-events: none; }
body.dark-mode .starfish-center-big { fill: #e2e8f0; }

/* Cartoon-Gesicht in der Mitte: Pupillen wandern (transform-Übergang),
 * Augen blinzeln per kurzem scaleY */
.starfish-face { pointer-events: none; }
.starfish-face .starfish-eye { transform-box: fill-box; transform-origin: center;
    transition: transform 100ms ease; }
.starfish-face .starfish-eye.blink { transform: scaleY(0.12); }
.starfish-face .starfish-pupil { transition: transform 500ms ease; }
.starfish-mouth-filled { fill: #0f172a; stroke: #0f172a; stroke-linejoin: round;
    pointer-events: none; }
.starfish-zzz { fill: #0f172a; opacity: 0.55; font-weight: 700; font-style: italic;
    pointer-events: none; }
.starfish-tongue { stroke: #0f172a; pointer-events: none; }

/* Zwischendurch-Moves: Requisiten tauchen hinter dem Stern auf,
 * Körper-Gesten ersetzen kurz das Wiegen (gleiche animation-Eigenschaft) */
.starfish-prop { pointer-events: none; opacity: 0;
    transition: transform 700ms cubic-bezier(0.2, 1.3, 0.4, 1), opacity 350ms ease; }
.starfish-star.move-shimmy { animation: starfish-shimmy 0.5s ease-in-out 3; }
.starfish-star.move-bounce { animation: starfish-bounce 0.65s ease-in-out 2; }
.starfish-star.move-twist { animation: starfish-twist 1.3s ease-in-out 1; }
.starfish-star.move-shake { animation: starfish-shake 0.3s linear 4; }
.starfish-star.move-pulse { animation: starfish-pulse 1.1s ease-in-out 1; }
@keyframes starfish-shimmy { 0%, 100% { transform: rotate(0); }
    25% { transform: rotate(4deg); } 75% { transform: rotate(-4deg); } }
@keyframes starfish-bounce { 0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-18px) scale(1.02, 0.98); }
    70% { transform: translateY(3px) scale(0.99, 1.01); } }
@keyframes starfish-twist { 0%, 100% { transform: rotate(0); }
    30% { transform: rotate(9deg); } 70% { transform: rotate(-7deg); } }
@keyframes starfish-shake { 0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes starfish-pulse { 0%, 100% { transform: scale(1); }
    35% { transform: scale(1.06); } 70% { transform: scale(0.97); } }
.starfish-label { font-size: 17px; font-weight: 700; fill: #1e293b;
    pointer-events: none; }
.starfish-score { font-size: 13px; font-weight: 500; fill: #64748b; }
.starfish-armzone { fill: transparent; cursor: pointer; outline: none; }
.starfish-armzone:focus-visible { fill: rgba(59, 130, 246, 0.12); }
/* Einstellungen: "Wiegen & Wachsen" abgeschaltet */
.starfish-still .starfish-star { animation: none !important; }
.starfish-config-btn { width: 2.5rem; height: 2.5rem; padding: 0;
    display: flex; align-items: center; justify-content: center; }
/* flex-direction:row explizit - die globale label-Regel stellt sonst
 * Häkchen und Text untereinander */
.starfish-cfg-check { display: flex; flex-direction: row; gap: 0.5rem;
    align-items: center; margin: 0.3rem 0; font-weight: 500; }
.starfish-cfg-check:has(input:disabled),
.starfish-cfg-interval:has(input:disabled) { opacity: 0.45; }
/* Unterpunkte von "Gesicht anzeigen" eingerückt */
.starfish-cfg-sub { margin-left: 1.9rem; }
.starfish-cfg-interval { margin-left: 3.8rem; }
.starfish-cfg-interval { display: flex; align-items: center; gap: 0.4rem;
    margin: 0.3rem 0 0 1.9rem; font-size: 0.9rem; }
.starfish-cfg-interval input { width: 3.6rem; padding: 0.25rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff;
    color: inherit; font: inherit; }
body.dark-mode .starfish-cfg-interval input { background: #0f172a;
    border-color: #334155; }
/* Der Konfig-Inhalt kann hoch werden: Body scrollt, der Fuss mit den
 * Aktions-Buttons bleibt fest unten im Modal */
.starfish-cfg-history { margin-top: 0.7rem; }
.starfish-cfg-history summary { cursor: pointer; font-weight: 600;
    font-size: 0.9rem; }
.starfish-cfg-history p { margin: 0.4rem 0; font-size: 0.8rem;
    line-height: 1.45; color: #64748b; }
body.dark-mode .starfish-cfg-history p { color: #94a3b8; }
.starfish-detail table input { width: 5.5rem; padding: 0.3rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff;
    color: inherit; font: inherit; }
body.dark-mode .starfish-detail table input { background: #0f172a;
    border-color: #334155; }
@media (prefers-reduced-motion: reduce) {
    .starfish-star { animation: none; }
    .starfish-fill circle { transition: none; }
}

/* Mini-Seestern als App-Logo im Kopfbereich: gleiche Zeichnung, dickere
 * Linien, damit sie bei ~38px lesbar bleiben; klickbar zur Seestern-Seite.
 * Der Stern sitzt im h1 (wie das frühere Icon), Titel/Untertitel sind
 * eigene Links zur Übersicht. */
.header-stack { display: flex; flex-direction: column; align-items: center; }
.header-title-link { color: inherit; text-decoration: none; cursor: pointer;
    transition: opacity 0.2s ease; }
.header-title-link:hover { opacity: 0.7; }
.header-star-link { display: block; transition: opacity 0.2s ease; }
.header-star-link:hover { opacity: 0.7; }
#header-starfish { width: 38px; height: 38px; display: block; }
#header-starfish .starfish-body, #header-starfish .starfish-outline { stroke-width: 14px; }
#header-starfish .starfish-center { stroke-width: 10px; }

/* Arm-Detail als Modal */
.starfish-modal-content { max-width: 560px; }
.starfish-modal-swatch { width: 0.85rem; height: 0.85rem; border-radius: 50%;
    display: inline-block; flex: 0 0 auto; }
#starfish-modal-title { display: flex; align-items: center; gap: 0.55rem; }
.starfish-modal-points { color: #64748b; font-weight: 600; }
.starfish-detail-table-wrap { overflow-x: auto; margin-top: 0.75rem; }
.starfish-detail table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.starfish-detail th, .starfish-detail td { padding: 0.55rem 0.4rem; text-align: right;
    border-bottom: 1px solid #e2e8f0; vertical-align: top; white-space: nowrap; }
.starfish-detail th:first-child, .starfish-detail td:first-child { text-align: left; white-space: normal; }
.starfish-detail td small { display: block; margin-top: 0.2rem; color: #64748b;
    font-size: 0.76rem; line-height: 1.3; font-weight: 400; }

.starfish-ai { margin-top: 1rem; }
.starfish-ai-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end; gap: 1rem; }
.starfish-ai-head h3, .starfish-ai-head p { margin: 0 0 0.25rem; }
.starfish-ai-head select { height: 2.5rem; padding: 0.4rem 0.55rem;
    border: 1px solid var(--border); border-radius: var(--radius-control); background: #fff; color: #0f172a; }
#starfish-ai-result { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e2e8f0; }

body.dark-mode .starfish-date-controls input, body.dark-mode .starfish-visual-card,
body.dark-mode .starfish-ai-head select, body.dark-mode .starfish-period-toggle {
    background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.dark-mode .starfish-period-toggle button { background: #0f172a; color: #cbd5e1; }
body.dark-mode .starfish-period-toggle button.active { background: var(--accent); color: #fff; }
body.dark-mode .starfish-body, body.dark-mode .starfish-center { fill: #0f172a; stroke: #e2e8f0; }
body.dark-mode .starfish-outline { stroke: #e2e8f0; }
body.dark-mode .starfish-ink { stroke: #e2e8f0; }
body.dark-mode .starfish-dot { fill: #e2e8f0; }
body.dark-mode .starfish-mouth-filled { fill: #e2e8f0; stroke: #e2e8f0; }
body.dark-mode .starfish-zzz { fill: #e2e8f0; }
body.dark-mode .starfish-week { background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.dark-mode .starfish-mean:hover { border-color: #334155; background: rgba(51, 65, 85, 0.4); }
body.dark-mode .starfish-label { fill: #e2e8f0; }
body.dark-mode .starfish-score,
body.dark-mode .starfish-modal-points { color: #94a3b8; fill: #94a3b8; }
body.dark-mode .starfish-detail th, body.dark-mode .starfish-detail td,
body.dark-mode #starfish-ai-result { border-color: #334155; }
body.dark-mode .starfish-detail td small { color: #94a3b8; }

@media (max-width: 620px) {
    .starfish-page { padding: 0 0.65rem 1.5rem; }
    .starfish-heading { align-items: stretch; flex-direction: column; }
    .starfish-date-controls { flex: 1; }
    .starfish-date-controls input { flex: 1; min-width: 0; }
    .starfish-visual-card { padding-left: 0.25rem; padding-right: 0.25rem; }
    .starfish-label { font-size: 15px; }
    .starfish-score { font-size: 12px; }
    .starfish-ai-head { grid-template-columns: 1fr 1fr; }
    .starfish-ai-head > div { grid-column: 1 / -1; }
    .starfish-ai-head button { height: 2.5rem; }
}

/* ---------- Moderne-App-Politur: Typografie-Grundlinie ---------- */
/* Einheitliche Ueberschriften im Inhalt; spezifischere Regeln (Karten,
   Modals, Reports) behalten Vorrang */
main h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

main h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

/* ---------- Skeleton-Loader: pulsierende Platzhalter beim Laden ---------- */
.skeleton {
    border-radius: var(--radius-control);
    background: #e2e8f0;
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}

body.dark-mode .skeleton {
    background: #334155;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ---------- Leere Zustaende: Icon + Satz statt leerer Flaeche ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    text-align: center;
    color: #64748b;
}

.empty-state .grow-icon {
    width: 40px;
    height: 40px;
}

.empty-state p {
    margin: 0;
    font-size: 0.9rem;
}

body.dark-mode .empty-state {
    color: #94a3b8;
}

/* ---------- Micro-Interactions: Bedienelemente federn beim Druck ---------- */
.primary-button, .ghost-button, .secondary-button, .icon-button,
.burger-menu-item {
    transition: transform 0.12s ease, background-color 0.2s ease,
        border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.subtle-button:active, .primary-button:active, .ghost-button:active,
.secondary-button:active, .icon-button:active, .burger-menu-item:active,
button[type="submit"]:active {
    transform: scale(0.97);
}

.insight-card {
    transition: box-shadow 0.15s ease;
}

@media (hover: hover) {
    .insight-card:hover {
        box-shadow: 0 10px 28px rgba(15, 23, 42, 0.13);
    }
}

/* Reduzierte Bewegung respektieren: alle Animationen/Uebergaenge aus */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
