:root {
    color-scheme:light;
    --bg:#f2f2f7;
    --card:#fff;
    --text:#1c1c1e;
    --muted:#636366;
    --blue:#0066d6;
    --line:#d1d1d6
}

@media(prefers-color-scheme:dark) {
    :root:not([data-theme]) {
        color-scheme:dark;
        --bg:#000;
        --card:#1c1c1e;
        --text:#f5f5f7;
        --muted:#aaa;
        --blue:#2997ff;
        --line:#48484a
    }
}

* {
    box-sizing:border-box
}

body {
    margin:0;
    background:var(--bg);
    color:var(--text);
    font:16px -apple-system,BlinkMacSystemFont,system-ui,sans-serif
}

main {
    max-width:680px;
    margin:auto;
    padding:24px 16px 60px
}

header {
    margin-bottom:24px
}

header strong {
    font-size:30px;
    letter-spacing:-1px
}

small {
    display:block;
    color:var(--muted);
    margin-top:5px
}

h1 {
    font-size:28px;
    letter-spacing:-.7px
}

h2 {
    font-size:20px
}

section {
    background:var(--card);
    border-radius:18px;
    padding:18px;
    margin:12px 0
}

form {
    display:grid;
    gap:12px
}

form+form {
    margin-top:18px
}

label {
    display:grid;
    gap:6px;
    color:var(--muted)
}

input,select,button {
    font:inherit;
    border-radius:12px;
    padding:12px;
    border:1px solid var(--line);
    min-width:0
}

input,select {
    background:var(--bg);
    color:var(--text);
    width:100%
}

button {
    background:var(--blue);
    color:white;
    border:0;
    cursor:pointer;
    font-weight:600;
    min-height:44px
}

nav {
    display:flex;
    gap:4px;
    background:var(--card);
    padding:5px;
    border-radius:14px;
    flex-wrap:wrap
}

nav a {
    flex:1;
    text-align:center;
    padding:10px 5px;
    text-decoration:none;
    color:var(--text);
    font-size:14px;
    border-radius:10px
}

nav a.selected {
    background:var(--blue);
    color:white
}

.line {
    display:flex;
    align-items:center;
    gap:12px
}

.grow {
    flex:1;
    overflow-wrap:anywhere
}

.circle {
    background:transparent;
    color:var(--blue);
    font-size:25px;
    padding:4px 10px
}

.done {
    text-decoration:line-through;
    color:var(--muted)
}

details {
    margin-top:10px;
    color:var(--muted)
}

details form {
    margin-top:12px
}

.check {
    display:flex;
    align-items:center
}

.check input {
    width:auto
}

.danger {
    background:#b42318
}

.error {
    color:#c33
}

summary {
    cursor:pointer;
    font-size:14px
}

textarea {
    font:inherit;
    color:var(--text);
    background:var(--bg);
    border:1px solid var(--line);
    border-radius:12px;
    padding:12px;
    width:100%;
    resize:vertical
}

.date-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px
}

.travel-status {
    display:inline-block;
    background:var(--bg);
    color:var(--blue);
    padding:5px 10px;
    border-radius:20px;
    font-size:13px;
    font-weight:600
}

.travel-note {
    white-space:pre-wrap;
    overflow-wrap:anywhere
}

section a {
    color:var(--blue)
}

section h2 {
    margin-bottom:4px
}

@media(max-width:380px) {
    .date-grid {
        grid-template-columns:1fr
    }
}

.entry-edit {
    margin:0;
    min-width:0
}

.entry-title {
    list-style:none;
    font-size:16px;
    color:var(--text);
    padding:12px 0;
    overflow-wrap:anywhere;
    min-height:44px
}

.entry-title::-webkit-details-marker {
    display:none
}

.entry-title.done {
    color:var(--muted)
}

.entry-title:focus-visible,.map-link:focus-visible {
    outline:2px solid var(--blue);
    outline-offset:3px
}

.line,.travel-row {
    align-items:flex-start
}

.travel-row {
    display:flex;
    gap:12px
}

.map-link {
    display:grid;
    place-items:center;
    min-width:44px;
    min-height:44px;
    border-radius:12px;
    background:var(--bg);
    text-decoration:none
}

.entry-edit form {
    margin-bottom:8px
}

.entry-edit+.entry-edit {
    border-top:1px solid var(--line)
}

.weeknav {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    flex-wrap:wrap
}

textarea {
    font:inherit;
    width:100%;
    box-sizing:border-box;
    padding:12px;
    border:1px solid #888;
    border-radius:10px;
    background:transparent;
    color:inherit
}

#travel-map {
    height:420px;
    max-height:65vh;
    border-radius:14px
}

nav {
    flex-wrap:wrap
}

/* 1.9: fluid, edge-to-edge layout with safe-area support */
html {
    min-height:100%;
}

body {
    min-height:100vh;
    min-height:100dvh;
}

main {
    width:100%;
    max-width:none;
    min-height:100vh;
    min-height:100dvh;
    margin:0;
    padding:clamp(12px,2.5vw,40px);
    padding-top:max(clamp(12px,2.5vw,40px),env(safe-area-inset-top));
    padding-left:max(clamp(12px,2.5vw,40px),env(safe-area-inset-left));
    padding-right:max(clamp(12px,2.5vw,40px),env(safe-area-inset-right));
    padding-bottom:max(24px,env(safe-area-inset-bottom));
}

header {
    margin-bottom:18px
}

nav {
    width:100%;
}

nav a {
    min-height:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex:1 1 90px;
}

section {
    min-width:0;
    padding:clamp(12px,1.5vw,24px);
}

#travel-map {
    height:65vh;
    height:65dvh;
    max-height:none;
    min-height:220px;
    width:100%;
}

button {
    overflow-wrap:anywhere;
}

@media(min-width:900px) {
    nav a {
        font-size:16px;
    }
    #live-list {
        display:grid;
        grid-template-columns:repeat(2,minmax(0,1fr));
        gap:12px;
        align-items:start;
    }
    #live-list>section {
        margin:0;
    }
    #live-list>section:not(.item) {
        grid-column:1/-1;
    }
}

@media(min-width:1500px) {
    #live-list {
        grid-template-columns:repeat(3,minmax(0,1fr));
    }
}

@media(max-width:600px) {
    header strong {
        font-size:26px;
    }
    nav a {
        flex-basis:29%;
    }
    h1 {
        font-size:24px;
    }
    section {
        border-radius:14px;
    }
    input,select,textarea {
        font-size:16px;
    }
    #travel-map {
        height:55vh;
        height:55dvh;
    }
}

/* 2.0: compact navigation in the upper-right corner */
main {
    position:relative
}

header {
    padding-right:60px
}

.main-menu {
    position:absolute;
    top:max(clamp(12px,2.5vw,40px),env(safe-area-inset-top));
    right:max(clamp(12px,2.5vw,40px),env(safe-area-inset-right));
    margin:0;
    z-index:2000
}

.main-menu>summary {
    list-style:none;
    display:grid;
    place-items:center;
    width:48px;
    height:48px;
    border-radius:14px;
    background:var(--card);
    color:var(--blue)
}

.main-menu>summary::-webkit-details-marker {
    display:none
}

.hamburger {
    display:grid;
    gap:5px;
    width:23px
}

.hamburger i {
    display:block;
    height:2px;
    background:currentColor;
    border-radius:2px
}

.main-menu nav {
    position:absolute;
    right:0;
    top:56px;
    width:min(280px,calc(100vw - 32px));
    display:grid;
    gap:4px;
    padding:8px;
    box-shadow:0 8px 30px #0003;
    border:1px solid var(--line)
}

.main-menu nav a {
    justify-content:flex-start;
    text-align:left;
    padding:12px;
    font-size:16px
}

.main-menu summary:focus-visible {
    outline:2px solid var(--blue);
    outline-offset:3px
}

/* 2.2: compact, single-column lists on every screen */
#live-list {
    display:block;
    width:100%;
    background:var(--card);
    border-radius:14px;
    overflow:hidden
}

#live-list>section.item {
    margin:0;
    padding:0 12px;
    border-radius:0;
    background:transparent
}

#live-list>section.item+section.item {
    border-top:1px solid var(--line)
}

#live-list .line,#live-list .travel-row {
    gap:8px;
    align-items:flex-start
}

#live-list .entry-title {
    display:flex;
    align-items:center;
    gap:8px;
    min-height:44px;
    padding:8px 0;
    line-height:1.25
}

#live-list .entry-title strong {
    min-width:0;
    overflow-wrap:anywhere;
    flex:1;
    font-weight:500
}

#live-list .entry-title small {
    display:inline;
    margin:0;
    text-align:right;
    font-size:12px;
    max-width:45%;
    overflow-wrap:anywhere
}

#live-list .circle {
    width:44px;
    min-height:44px;
    padding:0;
    font-size:22px
}

#live-list .map-link {
    background:transparent;
    border-radius:8px
}

#live-list .entry-edit[open] {
    padding-bottom:10px
}

#live-list .entry-edit form {
    gap:8px
}

section>.entry-edit>.entry-title {
    padding:8px 0;
    min-height:44px
}

@media(max-width:480px) {
    #live-list>section.item {
        padding:0 8px
    }
    #live-list .entry-title {
        gap:5px
    }
    #live-list .entry-title small {
        font-size:11px
    }
}


/* 2.6 – Wischgesten ausschließlich in der Einkaufsliste */
:is([data-swipe-shop], #offline-list) .item { position:relative; overflow:hidden; touch-action:pan-y; }
:is([data-swipe-shop], #offline-list) .item > .line { position:relative; z-index:1; background:var(--card); }
:is([data-swipe-shop], #offline-list) .item.swiping::before {
    position:absolute; inset:0; display:flex; align-items:center;
    padding:0 12px; color:white; font-weight:600; font-size:13px;
}
:is([data-swipe-shop], #offline-list) .item.swipe-left::before { content:'✓'; background:#218739; justify-content:flex-end; }
:is([data-swipe-shop], #offline-list) .item.swipe-right::before { content:'✕'; background:#c62828; justify-content:flex-start; }

/* Compact drag handle, independent of horizontal swipe gestures. */
.sort-handle { touch-action: none; cursor: grab; background: transparent; color: inherit; border: 0; min-width: 44px; min-height: 44px; padding: 0; font-size: 24px; user-select: none; flex: 0 0 44px; }
.sorting { opacity: .7; outline: 2px solid #007aff; }
.sorting .sort-handle { cursor: grabbing; }

/* 2.9 – Kompakte Eingabe */
.shop-add { padding: 8px; margin: 6px 0 10px; }
.shop-add-form { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; align-items: center; }
.shop-add-form input[name="title"] { min-height: 44px; padding: 8px 12px; }
.shop-add-form button { padding: 0; width: 44px; font-size: 24px; }

/* 4.8 – Hauptnavigation nach tatsächlich verfügbarem Platz. */
.desktop-menu {
    position: absolute;
    top: max(clamp(12px,2.5vw,40px),env(safe-area-inset-top));
    right: calc(max(clamp(12px,2.5vw,40px),env(safe-area-inset-right)) + 60px);
    display: flex;
    width: max-content;
    flex-wrap: nowrap;
    padding: 2px 5px;
    visibility: hidden;
    pointer-events: none;
}
.desktop-menu a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 14px;
}
main.nav-fits .desktop-menu { visibility: visible; pointer-events: auto; }
main.nav-fits .main-menu nav a.mobile-module { display: none; }

/* Completed shopping items remain available without cluttering the active list. */
.completed-items { margin-top: 12px; padding: 0; }
.completed-items > summary { cursor: pointer; font-weight: 600; opacity: .8; padding: 10px 12px; }
.completed-items .item { margin: 0; padding: 0 12px; border-radius: 0; background: var(--card); border-top: 1px solid var(--line); }
.completed-items .line { display: flex; align-items: center; gap: 8px; }
.completed-items .done { text-decoration: line-through; }
.completed-items .line > form { margin: 0; gap: 0; }
.completed-items .completed-title { display: flex; align-items: center; min-height: 44px; padding: 8px 0; font-size: 16px; font-weight: 500; line-height: 1.25; }
@media(max-width:480px) { .completed-items .item { padding: 0 8px; } }

/* 3.4 – Kompakte Ersatzbedienung für Maus und Tastatur. */
.swipe-action { background:transparent; color:var(--muted); padding:4px 10px; }

/* 3.5 – Direkte Mausaktionen; Touch bleibt kompakt. */
:is([data-swipe-shop], #offline-list) .action-toggle { color:#218739; }
:is([data-swipe-shop], #offline-list) .action-delete { color:#c62828; }
:is([data-swipe-shop], #offline-list) button.desktop-action,
:is([data-swipe-shop], #offline-list) .desktop-action button { min-width:44px; min-height:44px; font-size:22px; padding:0 8px; }
@media (hover:none) and (pointer:coarse) {
  :is([data-swipe-shop], #offline-list) .desktop-action { display:none; }
}
@media (any-pointer:fine) {
  :is([data-swipe-shop], #offline-list) button.desktop-action { display:inline-block; }
  :is([data-swipe-shop], #offline-list) form.desktop-action { display:flex; }
}
@media (hover:none) and (pointer:coarse) and (not (any-pointer:fine)) {
  [data-swipe-shop] .line > form:has(> .desktop-action) { display:none; }
}

/* 3.6 – Einheitliche kompakte Offline-Zeilen. */
#offline-list > .item { margin: 0; padding: 0 12px; border-radius: 0; border-bottom: 1px solid var(--line); }
#offline-list .line { gap: 8px; align-items: center; }
#offline-list .line > button.grow { background: transparent; color: var(--text); text-align: left; padding: 8px 0; font-weight: 500; line-height: 1.25; }
@media(max-width:480px) { #offline-list > .item { padding: 0 8px; } }

.consumption-chart > div {display:grid;grid-template-columns: 2em minmax(0,1fr) 7em;gap:8px;align-items:center;margin:5px 0;}
.consumption-chart meter {width:100%;height:18px;}
.meter-overview{display:grid;grid-template-columns:repeat(auto-fit,minmax(125px,1fr));gap:8px}.meter-overview a{display:flex;flex-direction:column;border:1px solid #8884;border-radius:12px;padding:12px;color:inherit;text-decoration:none}.meter-overview strong{font-size:1.4rem}.meter-history{width:100%;height:280px;display:block}.meter-table{overflow:auto}.meter-table table{border-collapse:collapse;width:100%;white-space:nowrap}.meter-table th,.meter-table td{text-align:left;padding:7px;border-bottom:1px solid #8884}

.time-converter input { width:100%; min-width:0; box-sizing:border-box; }
.time-converter .time-actions { display:flex; flex-wrap:wrap; gap:8px; }
.time-converter [readonly] { font-variant-numeric:tabular-nums; }

#label-preview { display:block; max-width:100%; height:auto; border:1px solid #aaa; border-radius:4px; background:white; }

#label-preview { width: 260px; max-width: 100%; }

/* 4.9 – Navigation bleibt beim Scrollen am oberen Rand. */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 3000;
    background: var(--bg);
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 10px;
    margin-bottom: 8px;
    box-shadow: 0 1px 0 var(--line);
}
.app-topbar header { margin: 0; min-height: 48px; }
.app-topbar .main-menu { top: max(8px, env(safe-area-inset-top)); right: 0; }
.app-topbar .desktop-menu { top: max(8px, env(safe-area-inset-top)); right: 60px; }
.app-topbar .main-menu nav { max-height: calc(100dvh - 80px - env(safe-area-inset-top)); overflow-y: auto; }

:root[data-theme="dark"] { color-scheme:dark; --bg:#000; --card:#1c1c1e; --text:#f5f5f7; --muted:#aaa; --blue:#2997ff; --line:#48484a; }
.app-topbar:has(.theme-toggle) header { padding-right:112px; }
.app-topbar:has(.theme-toggle) .desktop-menu { right:112px; }
.theme-toggle { position:absolute; top:max(8px,env(safe-area-inset-top)); right:56px; width:48px; height:48px; padding:0; display:grid; place-items:center; background:var(--card); color:var(--blue); border:0; border-radius:14px; cursor:pointer; }
.theme-toggle svg { width:24px; height:24px; grid-area:1/1; }
.theme-toggle .sun { display:none; }
:root[data-theme="dark"] .theme-toggle .sun { display:block; }
:root[data-theme="dark"] .theme-toggle .moon { display:none; }
.theme-toggle:focus-visible { outline:2px solid var(--blue); outline-offset:2px; }
#note-body { width:100%; min-height: 12rem; font-family:monospace; }
#note-preview { overflow-wrap:anywhere; white-space:pre-wrap; padding: 12px 0; }
#note-form input[type=checkbox] { width:auto; }

#live-list .due-late {color:#d32f2f;font-weight:600} #live-list .due-today {color:#b86b00;font-weight:600}

/* 6.0 – compact shared to-do entry */
.todo-add-form { grid-template-columns:minmax(0,1fr) minmax(0,145px) 44px; gap:6px; }
.todo-add-form input, .todo-edit-form input { width:100%; min-width:0; box-sizing:border-box; }
.todo-add-form input[type=date], .todo-edit-form input[type=date] { min-height:44px; padding:6px; font-size:14px; }
#live-list .todo-edit-form { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,145px); gap:6px; }
#live-list .todo-edit-form button { min-width:0; padding:8px 4px; }
@media(max-width:360px) { .todo-add-form { grid-template-columns:minmax(0,1fr) minmax(0,120px) 44px; } #live-list .todo-edit-form {grid-template-columns:1fr;} }

/* Zeitumrechnung: zwei gleich breite Karten, sobald der Platz reicht. */
.time-converter-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%, 340px),1fr)); gap:12px; align-items:start; margin:12px 0; }
.time-converter-grid > .time-converter { min-width:0; margin:0; }
.time-converter-grid select { max-width:100%; }

/* Discreet release number at the end of each page. */
.app-version {
    margin-top: 16px;
    color: #48484a;
    font-size: 8px;
    text-align: right;
    line-height: 1.4;
}
@media print { .app-version { display: none; } }

:root[data-theme="dark"] .app-version { color: #77777c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .app-version { color: #77777c; } }
