/* Homeboard – Startseite + Todos */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f6; --border: #dde3ec;
  --text: #0f172a; --muted: #64748b; --accent: #2563eb; --accent-ink: #fff;
  --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --radius: 12px; --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 4px 16px rgb(15 23 42 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #22304d;
    --text: #e2e8f0; --muted: #8b9ab3; --accent: #60a5fa; --accent-ink: #0b1120;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #22304d;
  --text: #e2e8f0; --muted: #8b9ab3; --accent: #60a5fa; --accent-ink: #0b1120;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.1rem; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
pre { background: var(--surface-2); padding: .75rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; margin-top: 1rem; }
.err { color: var(--danger); }

/* Kopfzeile */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem clamp(1rem, 3vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: .9rem; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .linklike {
  color: var(--muted); padding: .35rem .7rem; border-radius: 8px; font: inherit; background: none; border: 0; cursor: pointer;
}
.topbar nav a:hover, .linklike:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
form.inline { display: inline; margin: 0; }

.page { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

.flash { max-width: 1400px; margin: 1rem auto 0; padding: .7rem 1rem; border-radius: 10px; width: calc(100% - 2rem); }
.flash-ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.flash-err { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }

/* Karten & Formulare */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card.narrow { max-width: 640px; margin-inline: auto; }
.card.highlight { border-color: var(--accent); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h1, .card-head h2 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.empty { text-align: center; padding: 2rem; }

input, select, textarea {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .65rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="color"] { padding: 2px; height: 2.4rem; width: 4rem; }
label, .field { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }
.check-label { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; align-items: end; }
.grid-form .checks { display: flex; gap: 1rem; flex-wrap: wrap; padding-bottom: .5rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.inline-form input:not([type]), .inline-form input[name="name"] { flex: 1 1 180px; width: auto; }
.inline-form .check-label { font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 500; padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }

/* Chips / Punkte */
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--c, var(--muted)); margin-right: .45rem; flex: none; }
.dot.big { width: .9rem; height: .9rem; }
.chip {
  display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; padding: .05rem .5rem; border-radius: 999px;
  background: color-mix(in srgb, var(--c, var(--muted)) 16%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--c, var(--muted)) 35%, transparent);
}
.chip:hover { text-decoration: none; filter: brightness(1.08); }
.chip.active { outline: 2px solid var(--accent); }

/* Startseite */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.greeting { margin: 0; color: var(--muted); }
.clock { margin: 0; font-size: clamp(2.2rem, 6vw, 3.4rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.date { margin: 0; color: var(--muted); }
.search { flex: 0 1 420px; }
.search input { padding: .75rem 1rem; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); }

.dash { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 960px) { .dash { grid-template-columns: 1fr; } }
.group { margin-bottom: 1.5rem; }
.group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.group-title::before { content: ""; width: .5rem; height: .5rem; border-radius: 2px; background: var(--c, var(--accent)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }
.tile {
  position: relative; display: flex; align-items: center; gap: .75rem; padding: .8rem .9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 4px solid var(--c, var(--border)); transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--c, var(--accent)); }
.tile.hidden, .group.hidden { display: none; }
.tile-icon {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; overflow: hidden;
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface-2)); font-weight: 700; font-size: 1.15rem;
}
.tile-icon img { width: 30px; height: 30px; object-fit: contain; }
.tile-icon.mini { width: 28px; height: 28px; font-size: .85rem; }
.tile-icon.mini img { width: 22px; height: 22px; }
.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-desc { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { position: absolute; top: .55rem; right: .55rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--muted); opacity: .5; }
.status.up { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.status.down { background: var(--danger); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }

.dash-todos { position: sticky; top: 5rem; }
.dash-todos h2 a { color: var(--text); }
.counters { display: flex; gap: .35rem; }
.counter { min-width: 1.8rem; text-align: center; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .85rem; font-weight: 600; }
.counter.overdue { background: var(--danger); color: #fff; }
.counter.today { background: var(--warn); color: #fff; }

/* Todos */
.todos-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 800px) { .todos-layout { grid-template-columns: 1fr; } }
.side-nav { display: flex; flex-direction: column; gap: .1rem; }
.side-nav h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1rem 0 .35rem .6rem; display: flex; justify-content: space-between; }
.side-nav h3:first-child { margin-top: 0; }
.side-nav h3 .add { color: var(--muted); }
.side-nav > a { display: flex; align-items: center; padding: .4rem .6rem; border-radius: 8px; color: var(--text); }
.side-nav > a:hover { background: var(--surface); text-decoration: none; }
.side-nav > a.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.side-nav .n { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 400; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: .3rem; padding: 0 .4rem; }
.filters { display: flex; gap: .5rem; }
.filters input { width: 200px; } .filters select { width: auto; }

.quick { display: flex; gap: .5rem; margin-bottom: 1rem; }
.quick input { flex: 1; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo { display: flex; gap: .75rem; align-items: flex-start; padding: .65rem .25rem; border-bottom: 1px solid var(--border); }
.todo:last-child { border-bottom: 0; }
.todo-list.compact .todo { padding: .45rem 0; }
.toggle-form { margin: 0; }
.check {
  display: block; width: 1.25rem; height: 1.25rem; margin-top: .15rem; border-radius: 50%; padding: 0; cursor: pointer; flex: none;
  border: 2px solid var(--muted); background: transparent; position: relative;
}
span.check { cursor: default; }
.prio-3 .check { border-color: var(--danger); } .prio-2 .check { border-color: var(--warn); } .prio-1 .check { border-color: var(--accent); }
button.check:hover { background: color-mix(in srgb, var(--ok) 20%, transparent); }
.done .check { background: var(--ok); border-color: var(--ok); }
.done .check::after { content: "✓"; color: #fff; font-size: .75rem; position: absolute; inset: 0; display: grid; place-items: center; }
.done .todo-title, .done .todo-title a { color: var(--muted); text-decoration: line-through; }
.todo-body { min-width: 0; flex: 1; }
.todo-title a { color: var(--text); }
.prio { color: var(--danger); font-weight: 800; margin-right: .25rem; }
.prio-1 .prio { color: var(--accent); } .prio-2 .prio { color: var(--warn); }
.todo-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.todo-meta:empty { display: none; }
.due.overdue { color: var(--danger); font-weight: 600; }
.due.today { color: var(--warn); font-weight: 600; }
.todo.pending { opacity: .5; }

/* Verwaltung */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table th, .table td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table .ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tr.muted td { opacity: .6; }
.table .inline-form { margin: 0; flex-wrap: nowrap; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.row-actions form { margin: 0; }
@media (max-width: 700px) {
  .table thead { display: none; }
  .table tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--border); padding: .4rem 0; }
  .table td { border: 0; padding: .2rem .4rem; }
  .table .ellipsis { max-width: 60vw; }
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.token { display: block; padding: .6rem; word-break: break-all; cursor: copy; font-size: 1rem; }
details summary { cursor: pointer; color: var(--muted); margin-top: 1rem; }

/* Öffentliche Startseite */
.public { min-height: 60vh; display: grid; place-items: center; }
.public-card { max-width: 560px; width: 100%; text-align: center; padding: 2.5rem 2rem; }
.public-card h1 { font-size: 1.8rem; margin-top: 1rem; }
.public-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 1.6rem; font-weight: 700; }
.public-text { color: var(--muted); margin-bottom: 1.5rem; }
.public-text p { margin: 0 0 .75rem; }
.btn.big { padding: .7rem 1.6rem; font-size: 1rem; }

/* Benutzer */
.badge { display: inline-grid; place-items: center; min-width: 1.2rem; height: 1.2rem; padding: 0 .3rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700; line-height: 1; vertical-align: middle; }
.user-link { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions.center { justify-content: center; }
.chip.role-admin { --c: var(--danger); } .chip.role-user { --c: var(--accent); } .chip.role-reader { --c: var(--muted); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.card h3 { margin-top: 1.25rem; font-size: 1rem; }
