@font-face {
    font-family: "Ubuntu";
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url("../fonts/ubuntu-latin-300-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Ubuntu";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ubuntu-latin-400-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Ubuntu";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ubuntu-latin-500-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Ubuntu";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/ubuntu-latin-700-normal.woff2") format("woff2");
}

:root {
    --bg: #0f1420;
    --card: #1a2130;
    --card-border: #2a3448;
    --text: #e6ebf4;
    --muted: #8b98af;
    --accent: #4f8cff;
    --accent-hover: #6fa0ff;
    --radius: 10px;
    font-family: "Ubuntu", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

.hidden { display: none; }

html { font-size: 14px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 1.0rem;
    line-height: 1.45;
}

.container { max-width: 90%; margin: 0 auto; padding: 16px; }

/* Sticky top navbar: Startseite · Einstellungen · Newsfeed · Logout */
.topnav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--card-border);
}
.topnav .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topnav-links { display: flex; align-items: center; gap: 12px; }
.topnav-links a { color: var(--text); text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.topnav-links a:hover { background: rgba(255, 255, 255, 0.06); }
.topnav-links form { margin: 0; }
.nav-logout {
    background: none; border: 1px solid var(--card-border); color: var(--muted);
    padding: 4px 10px; border-radius: 6px; cursor: pointer; font: inherit;
}
.nav-logout:hover { color: var(--text); }

/* Responsive module grid: cards, single column on mobile (§5). */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
    margin-top: 14px;
}
/* Below 1000px the fixed 3 columns would get cramped (<290px each),
   so auto-fill steps down naturally (2 cols mid-size, 1 on mobile). */
@media (min-width: 1000px) {
    .module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.card {
    position: relative; /* anchor for the module gear (top-right, title line) */
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 14px;
}
.module-card { position: relative; }
.module-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.module-card-head h2 { margin: 0; font-size: 1.0667rem; }
.module-card-head h2 a { color: inherit; text-decoration: none; }
.module-card-head h2 a:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .module-grid { grid-template-columns: 1fr; }
    .container { padding: 10px; }
}

/* Buttons, forms */
.btn {
    background: var(--accent); color: #fff; border: 0; border-radius: 6px;
    padding: 8px 14px; cursor: pointer; font: inherit;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-error { background: #b3475a; }
.btn-small { padding: 4px 10px; font-size: 0.8667rem; }
label { display: block; margin-bottom: 10px; }
input[type="text"], input[type="password"], textarea {
    width: 100%; padding: 8px 10px; border-radius: 6px;
    border: 1px solid var(--card-border); background: var(--bg);
    color: var(--text); font: inherit;
}
.hint { color: var(--muted); font-size: 0.8667rem; }
.error { background: #472027; border: 1px solid #7c3a44; color: #ffb3bd; padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }
.flash { background: #1d3a2a; border: 1px solid #2f6b48; color: #a9e5c2; padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }
.empty-hint { color: var(--muted); }
.auth-card { max-width: 380px; margin: 60px auto 0; }
.auth-card h1 { margin-top: 0; font-size: 1.3333rem; }

/* Module list (Einstellungen) */
.module-list { list-style: none; margin: 0; padding: 0; }
.module-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 6px; border-bottom: 1px solid var(--card-border);
    background: var(--card);
}
.module-row .drag-handle { cursor: grab; color: var(--muted); touch-action: none; user-select: none; }
.module-row .module-title { flex: 1; }
.module-row.dragging { opacity: 0.5; }

/* Notes module (§6.2) */
.notes-module { position: relative; }
.note-slot { margin-bottom: 10px; }
.note-slot.hidden { display: none; }
.note-textarea { min-height: 220px; resize: vertical; font-family: inherit; }
.note-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.note-status { color: var(--muted); font-size: 0.8rem; }

/* Invisible 48x48 click area: no visuals at all, default cursor (§6.2). */
.invisible-click-area {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 48px;
    height: 48px;
    background: transparent;
    border: 0;
    outline: 0;
    /* deliberately NO cursor: pointer — no hint, no visuals */
}

/* Search module (§6.1) — gear anchors to the module CARD (position:relative on .card) */
.search-rows { display: flex; flex-direction: column; gap: 8px; }
.search-row { display: flex; align-items: center; gap: 8px; }
.search-logo { flex: 0 0 auto; border-radius: 5px; }
.search-input { flex: 1; min-width: 0; padding: 6px 8px; }
.module-gear {
    position: absolute; top: 10px; right: 10px;
    background: transparent; border: 0; cursor: pointer;
    font-size: 1.0667rem; color: var(--muted); padding: 4px;
}
.module-gear:hover { color: var(--fg, inherit); }
.module-settings-panel {
    margin-top: 10px; padding: 10px;
    border: 1px solid var(--border, #ddd); border-radius: 8px;
    background: var(--panel-bg, rgba(0,0,0,0.03));
}
.module-settings-panel.hidden { display: none; }
.engine-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.engine-row { display: flex; align-items: center; gap: 8px; }
.engine-row.dragging { opacity: 0.5; }
.engine-row .drag-handle { cursor: grab; color: var(--muted); touch-action: none; user-select: none; }
.engine-label { display: flex; align-items: center; gap: 6px; }
.search-settings-actions { display: flex; align-items: center; gap: 10px; }
.search-settings-status { color: var(--muted); font-size: 0.8rem; }
.btn-error { border-color: #b00020; color: #b00020; }

/* Bookmarks module (§6.3) */
.bm-category { margin-bottom: 4px; }
.bm-cat-head {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: none; border: 0; color: var(--text); font: inherit;
    padding: 6px 4px; cursor: pointer; text-align: left;
}
.bm-cat-head:hover { background: rgba(255, 255, 255, 0.05); border-radius: 6px; }
.bm-chevron { display: inline-block; transition: transform 0.15s; color: var(--muted); }
.bm-category.open .bm-chevron { transform: rotate(90deg); }
.bm-cat-name { flex: 1; font-weight: 600; }
.bm-count { color: var(--muted); font-size: 0.8rem; }
.bm-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.bm-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 4px; border-radius: 6px;
}
.bm-row.dragging { opacity: 0.5; }
.bm-row .bm-drag { cursor: grab; color: var(--muted); touch-action: none; user-select: none; }
.bm-link { flex: 1; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-link:hover { color: var(--accent); }
.bm-favicon {
    width: 32px; height: 32px; flex: 0 0 32px; border-radius: 4px;
    background-image: url('/modules/bookmarks/favicon');
    background-size: 512px auto; background-repeat: no-repeat; background-color: var(--bg);
}
.bm-favicon-letter {
    background-image: none;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 1.0rem; font-weight: 600;
}
.bm-edit-form { display: flex; gap: 6px; flex: 1; align-items: center; }
.bm-edit-form input { min-width: 0; }
.bm-edit-form .bm-edit-name { flex: 1; }
.bm-row .bm-edit-form.hidden { display: none; }
.icon-btn {
    background: none; border: 0; color: var(--muted); cursor: pointer;
    font: inherit; padding: 2px 6px; border-radius: 4px;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.bm-add { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.bm-add .bm-status { color: var(--muted); font-size: 0.8rem; }
.bm-cat-list { list-style: none; margin: 8px 0 0; padding: 0; }
.bm-cat-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.bm-cat-row .bm-cat-drag { color: var(--muted); touch-action: none; user-select: none; cursor: grab; }
.bm-cat-row .bm-cat-name-input { flex: 1; }

/* --- RSS-Newsfeeds (§6.4) --- */
.rss-feed-block { margin-bottom: 12px; }
.rss-feed-title { font-weight: 600; margin-bottom: 4px; }
.rss-feed-head { margin-bottom: 4px; }
.rss-feed-name { font-weight: 600; }
.rss-items { list-style: none; margin: 0; padding: 0; }
.rss-item-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.rss-item { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.rss-item:hover { color: var(--accent); }
.rss-item.rss-read, a.rss-read, a[data-read="1"] { opacity: 0.45; }
.rss-date { color: var(--muted); font-size: 0.8rem; flex: 0 0 auto; }
.rss-add { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.rss-feed-list { list-style: none; margin: 8px 0 0; padding: 0; }
.rss-feed-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.rss-feed-row-name { font-weight: 600; }
.rss-feed-row-url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.8rem; }
.newsfeed-list { list-style: none; margin: 0; padding: 0; }
.newsfeed-row { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.newsfeed-feed-name { color: var(--muted); font-size: 0.8rem; flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.newsfeed-row .rss-item { flex: 1; min-width: 0; }

/* --- About me (§6.5) --- */
.about-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.about-list dt { color: var(--muted); }
.about-list dd { margin: 0; overflow-wrap: anywhere; }
.about-ua { font-size: 0.8rem; color: var(--muted); }

/* --- Arbeitszeit (§6.6) --- */
.wt-start-row { display: flex; align-items: baseline; gap: 4px; }
.wt-label { display: flex; align-items: baseline; gap: 4px; color: var(--muted); }
.wt-input { width: 3.2em; }
.wt-times dd.wt-over { color: #f0883e; }
.wt-times { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; }
.wt-times dt { color: var(--muted); }
.wt-times dd { margin: 0; font-variant-numeric: tabular-nums; }
.wt-set-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; font-size: 0.8667rem; }
.wt-set-row input[type="number"] { width: 5em; }
.wt-set-duo { display: flex; align-items: center; gap: 4px; }
.wt-set-duo input[type="number"] { width: 4em; }
.wt-set-check { flex-direction: row; align-items: center; gap: 6px; }
.wt-settings-status { color: var(--muted); font-size: 0.8rem; }

/* --- Translator (§6.8) --- */
.tr-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tr-field { display: flex; flex-direction: column; gap: 4px; }
.tr-lang-label { color: var(--muted); font-size: 0.8rem; }
.tr-textarea { width: 100%; resize: vertical; box-sizing: border-box; cursor: copy; }
.tr-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.tr-status { color: var(--muted); font-size: 0.8rem; min-height: 1em; }
.tr-status.tr-error { color: #f0883e; }
.tr-set-row { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; font-size: 0.8667rem; }
.tr-settings-status { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 640px) { .tr-fields { grid-template-columns: 1fr; } }

/* --- E-Mail (§6.7) --- */
.email-account { margin-bottom: 4px; }
.email-account-line { display: flex; align-items: center; gap: 6px; }
.email-account-name { font-weight: 600; }
.email-unread { color: var(--muted); }
.email-status-error { color: #f0883e; font-size: 0.8rem; }
.email-toggle, .email-webmail { text-decoration: none; cursor: pointer; background: none; border: none; font-size: inherit; padding: 0 2px; }
.email-mails { margin: 4px 0 8px 0; }
.email-mail-list { list-style: none; margin: 0; padding: 0; }
.email-mail { display: flex; gap: 6px; font-size: 0.8667rem; padding: 2px 0; align-items: baseline; }
.email-mail-check, .email-mail-del { background: none; border: none; cursor: pointer; padding: 0 2px; font-size: 0.9333rem; line-height: 1; }
.email-mail-check { color: #2ea043; }
.email-mail-del { color: #f85149; }
.email-mail-check:disabled, .email-mail-del:disabled { opacity: 0.4; cursor: wait; }
.email-mail-unread .email-mail-subject, .email-mail-unread .email-mail-from { font-weight: 700; }
.email-mail-subject, .email-mail-from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-mail-from { color: var(--muted); }
.email-mail-date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.email-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.email-add input[type="number"] { width: 6em; }
.email-add button { grid-column: 1 / -1; }
.email-account-list { list-style: none; margin: 0; padding: 0; }
.email-account-row { margin-bottom: 8px; }
.email-account-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: center; }
.email-account-edit input[type="number"] { width: 6em; }
.email-account-edit .btn { justify-self: start; }
.email-cert-check { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.email-account-row-host { color: var(--muted); font-size: 0.8rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Admin (§7) --- */
.admin-matrix-wrap { overflow-x: auto; }
.admin-matrix { border-collapse: collapse; min-width: 480px; }
.admin-matrix th, .admin-matrix td { border: 1px solid var(--border); padding: 4px 8px; text-align: center; }
.admin-matrix thead th { font-size: 0.8rem; white-space: nowrap; }
.admin-matrix tbody th { text-align: left; white-space: nowrap; font-weight: 600; }
.matrix-cell label { display: inline-flex; align-items: center; gap: 2px; cursor: pointer; }
.override-mark { color: var(--muted); font-weight: 700; cursor: help; }
.admin-users { border-collapse: collapse; margin-top: 6px; }
.admin-users th, .admin-users td { border: 1px solid var(--border); padding: 4px 10px; text-align: left; font-size: 0.8667rem; }
.admin-users thead th { font-size: 0.8rem; color: var(--muted); }

/* --- Weather module (wetter.com) --- */
.weather-module { position: static; }
.weather-head { display: flex; align-items: flex-start; gap: 8px; }
.weather-head-main { flex: 1; }
.weather-title { color: var(--muted); font-size: 0.8rem; }
.weather-stand { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.weather-current { font-size: 1.3333rem; font-weight: 700; margin-top: 2px; }
.weather-current-state { color: var(--muted); font-size: 0.8667rem; }
.weather-stale { color: #f0883e; font-size: 0.8rem; margin-top: 2px; }
.weather-refresh { font-size: 1.2rem; }
.weather-refresh.btn-error { color: #f85149; }
.weather-days { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.weather-day { text-align: center; padding: 4px 0; border-top: 1px solid var(--border); }
.weather-day-name { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.weather-icon { height: 34px; display: flex; align-items: center; justify-content: center; margin: 3px 0; }
.weather-svg { width: 28px; height: 28px; color: var(--muted-foreground, #9aa4b2); }
.weather-svg-sun { color: #e3b341; }
.weather-svg-drop { color: #58a6ff; }
.weather-svg-bolt { color: #e3b341; }
.weather-temps { font-size: 0.8667rem; white-space: nowrap; }
.weather-rain { font-size: 0.7333rem; color: var(--muted); margin-top: 2px; }
.weather-sun { font-size: 0.7333rem; color: var(--muted); }
.weather-empty { color: var(--muted); }
.weather-settings .hint { font-size: 0.8rem; color: var(--muted); margin: 0; }
@media (max-width: 700px) {
    .weather-days { grid-template-columns: repeat(3, 1fr); row-gap: 10px; }
}

/* Air module: pushed device data (CO2 / indoor / outdoor temp / rain) */
.air-rows { display: flex; flex-direction: column; gap: 10px; }
/* Label | fixed value column (units align) | chart — charts all start flush. */
.air-row { display: grid; grid-template-columns: 92px 140px 1fr; align-items: center; gap: 8px; }
.air-label { color: var(--muted); }
.air-value { font-size: 1.0rem; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.air-chart { grid-column: 3; position: relative; min-width: 0; }
.air-spark { display: block; width: 100%; height: 18px; overflow: visible; cursor: crosshair; }
.air-spark-line { stroke: var(--muted, #8b949e); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.air-spark-bar { fill: #58a6ff; opacity: 0.85; }
.air-spark-hour { stroke: var(--border, rgba(128,128,128,0.25)); stroke-width: 1; vector-effect: non-scaling-stroke; }
.air-spark-dot { fill: var(--accent, #58a6ff); r: 2.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.air-tip {
    position: fixed; z-index: 50; pointer-events: none;
    background: var(--card, #161b22); color: var(--foreground, #e6edf3);
    border: 1px solid var(--border, #30363d); border-radius: 4px;
    padding: 3px 8px; font-size: 0.75rem; white-space: nowrap;
    transform: translate(-50%, -130%); display: none;
}
.air-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.air-dot-ok { background: #3fb950; }
.air-dot-warn { background: #e3b341; }
.air-dot-bad { background: #f85149; }
.air-co2-hint { color: #f0883e; font-size: 0.8rem; margin-top: 6px; }
.air-foot { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.air-stale { color: #f0883e; }
.air-empty { color: var(--muted); }
.air-settings .hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.air-url-row { display: flex; gap: 8px; align-items: center; }
.air-url-input { flex: 1; min-width: 0; font-size: 0.8rem; padding: 5px 8px; }
.air-settings-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.air-settings-status { color: var(--muted); font-size: 0.8rem; }
.air-settings-status.air-error { color: #f85149; }
.air-set-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 0.8667rem; }
.air-set-input { width: 90px; padding: 4px 8px; }
.hint-inline { font-size: 0.7333rem; color: var(--muted); }
