* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--color-bg); color: var(--color-text); font-family: var(--font);
  font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%;
  padding-top: env(safe-area-inset-top);
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: var(--max-width); margin: 0 auto; padding: 12px 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px); }

/* Kopf */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0 12px; }
.topbar h1 { font-size: 1.35rem; margin: 0; }
.topbar .sub { color: var(--color-text-muted); font-size: .85rem; }
.topbar-actions { display: flex; gap: 8px; }

/* Buttons */
.btn { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 9px 14px; cursor: pointer; min-height: 40px; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-contrast); }
.btn-danger { color: var(--color-danger); border-color: var(--color-danger); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .9rem; }

/* Eingaben */
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 10px 12px; min-height: 42px; color-scheme: dark;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
label { display: block; font-size: .85rem; color: var(--color-text-muted); margin: 12px 0 4px; }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--color-text); font-size: 1rem; margin-top: 12px; }
label.inline input { width: 20px; height: 20px; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; min-width: 0; }

/* Schnell anlegen */
.quickadd { display: flex; gap: 8px; margin-bottom: 14px; }
.quickadd input { flex: 1; }

/* Abschnitte & Karten */
.section { margin: 18px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); display: flex; justify-content: space-between; align-items: center; }
.section .count { background: var(--color-surface-2); border-radius: 999px; padding: 1px 8px; }
.section.overdue { color: var(--color-danger); }
.list { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--color-text-muted); text-align: center; padding: 22px 8px; border: 1px dashed var(--color-border); border-radius: var(--radius); }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; display: flex; gap: 12px; align-items: flex-start; }
.card.done .title { text-decoration: line-through; color: var(--color-text-muted); }
.card.event { border-left: 4px solid var(--color-accent); cursor: pointer; }
.card .body { flex: 1; min-width: 0; cursor: pointer; }
.card .title { overflow-wrap: anywhere; font-weight: 500; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--color-text-muted); font-size: .8rem; margin-top: 3px; }
.meta .late { color: var(--color-danger); }
.chip { background: var(--color-surface-2); border-radius: 999px; padding: 0 8px; }

.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--color-border); background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0; margin-top: 1px; color: var(--color-accent-contrast); }
.check.p-hoch { border-color: var(--color-prio-hoch); }
.check.p-mittel { border-color: var(--color-prio-mittel); }
.check.p-niedrig { border-color: var(--color-prio-niedrig); }
.check.is-done { background: var(--color-success); border-color: var(--color-success); }
.check:disabled { opacity: .4; cursor: default; }

/* Woche */
.day { margin-bottom: 14px; }
.day h3 { margin: 0 0 6px; font-size: .95rem; display: flex; justify-content: space-between; }
.day.today h3 { color: var(--color-accent); }
.weeknav { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.weeknav .label { flex: 1; text-align: center; color: var(--color-text-muted); }

/* Untere Navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--color-surface); border-top: 1px solid var(--color-border); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav a { flex: 1; text-align: center; padding: 8px 2px; color: var(--color-text-muted); text-decoration: none; font-size: .7rem; min-height: var(--nav-height); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.nav a .ico { font-size: 1.25rem; line-height: 1; }
.nav a.active { color: var(--color-accent); }
@media (min-width: 760px) { .nav { position: static; border: 0; background: transparent; margin: 0 auto; max-width: var(--max-width); } .app { padding-bottom: 24px; } .nav a { flex-direction: row; justify-content: center; font-size: .9rem; min-height: 40px; } }

/* Dialog */
dialog { border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); border-radius: var(--radius); padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; }
dialog::backdrop { background: var(--color-overlay); }
dialog h2 { margin: 0 0 4px; font-size: 1.15rem; }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: space-between; }
.dialog-actions .right { display: flex; gap: 8px; }
.error { color: var(--color-danger); margin: 10px 0 0; min-height: 1.2em; }
.prep { margin-top: 16px; border-top: 1px solid var(--color-border); padding-top: 8px; }
.prep .card { padding: 6px 8px; }

/* Login */
.login { max-width: 360px; margin: 14vh auto 0; padding: 0 20px; }
.login h1 { text-align: center; margin-bottom: 4px; }
.login p { text-align: center; color: var(--color-text-muted); margin-top: 0; }
.login .btn-primary { width: 100%; margin-top: 18px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px); background: var(--color-surface-2); border: 1px solid var(--color-border); padding: 10px 16px; border-radius: var(--radius); z-index: 50; max-width: calc(100vw - 32px); }
.toast.err { border-color: var(--color-danger); }

.meta .changed { color: var(--color-prio-mittel); font-style: italic; }

.topbar-actions .btn { white-space: nowrap; }
.topbar h1 { overflow-wrap: anywhere; }
