:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --text: #1d2624;
  --muted: #66716e;
  --line: #e4e2da;
  --accent: #4f7f6f;
  --accent-ink: #ffffff;
  --accent-soft: #e2eee9;
  --danger: #a8432f;
  --danger-soft: #f8e6e1;
  --warn: #9a6a2f;
  --warn-soft: #f6ecdf;
  --ok: #2f6b4f;
  --ok-soft: #e1f1e8;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 30, 28, .06), 0 4px 16px rgba(20, 30, 28, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a19;
    --surface: #1c2423;
    --text: #e9efec;
    --muted: #9aa6a2;
    --line: #2a3432;
    --accent: #7fb3a0;
    --accent-ink: #0f1716;
    --accent-soft: #243530;
    --danger: #e0826f;
    --danger-soft: #3a2420;
    --warn: #e0b47f;
    --warn-soft: #3a2f22;
    --ok: #8fd0b0;
    --ok-soft: #1f3429;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
}
h1 { font-size: 1.75rem; line-height: 1.2; margin: .2rem 0 .4rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }

.content { padding: 1rem 1rem 6rem; max-width: 720px; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.page-head { margin-bottom: 1.25rem; }
.block { margin: 1.5rem 0 .5rem; }

.card { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.empty p { margin: 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .5rem; }
.stat { margin: 0; }
.stat p { margin: 0 0 .35rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text) !important; }
progress {
  width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden;
  appearance: none; -webkit-appearance: none; background: var(--line); margin: .35rem 0;
}
progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

.auth-card { max-width: 420px; margin: 6vh auto 0; }
.form { display: grid; gap: 1rem; }
.form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 1rem; display: grid; gap: .85rem; margin: 0; }
.form legend { padding: 0 .4rem; font-weight: 600; color: var(--muted); }
label { display: grid; gap: .35rem; font-weight: 500; }
input, select, textarea {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .9rem; min-height: 48px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.radio {
  display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 500;
}
.radio input { width: auto; min-height: auto; accent-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 14px;
  padding: .8rem 1.1rem; min-height: 48px; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn-block { width: 100%; }
.btn-ghost { background: none; box-shadow: none; color: var(--muted); padding: .5rem .75rem; min-height: 40px; }
.add-main { margin: 1rem 0 .5rem; }
.add-link { display: inline-block; margin-top: .6rem; font-weight: 600; text-decoration: none; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0; }
.inline-form input { flex: 1; min-width: 160px; }
.inline-form .btn-block { flex-basis: 100%; }
.list { display: grid; gap: .6rem; }

.flash { padding: .85rem 1rem; border-radius: 14px; margin-bottom: 1rem; font-weight: 500; }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-success { background: var(--ok-soft); color: var(--ok); }

.count, .badge {
  font-size: .8rem; padding: .1rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.task {
  display: flex; gap: .8rem; align-items: center; min-width: 0;
  background: var(--surface); border-radius: 16px; padding: .75rem .9rem;
  box-shadow: var(--shadow); border-left: 4px solid var(--line);
}
.task.prio-urgent { border-left-color: var(--danger); }
.task.prio-high { border-left-color: var(--warn); }
.task.is-done { opacity: .65; }
.task-check { margin: 0; }
.check {
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface); color: var(--accent-ink);
  font-size: 1.2rem; display: grid; place-items: center; padding: 0;
}
.check.is-checked { background: var(--accent); border-color: var(--accent); }
.task-body { display: grid; gap: .1rem; flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.task-title { font-weight: 600; overflow-wrap: anywhere; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { font-size: .85rem; color: var(--muted); }

.cat-icon { font-size: 1.2em; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; margin: .25rem 0 .5rem; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .2rem .7rem; font-size: .9rem; }

.cal-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.seg { display: inline-flex; background: var(--surface); border-radius: 14px; padding: .25rem; box-shadow: var(--shadow); }
.seg-item { padding: .5rem .8rem; border-radius: 11px; text-decoration: none; color: var(--muted); font-weight: 500; }
.seg-item.is-active { background: var(--accent); color: var(--accent-ink); }
.cal-nav { display: flex; gap: .4rem; }
.cal-nav .btn { padding: .5rem .8rem; min-height: 44px; }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month-head { text-align: center; font-size: .8rem; color: var(--muted); padding: .3rem 0; }
.month-cell {
  position: relative; background: var(--surface); border-radius: 12px; min-height: 58px; padding: .4rem;
  text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between;
}
.month-cell.is-outside { opacity: .4; }
.month-cell.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.month-num { font-weight: 600; }
.month-count {
  align-self: flex-end; background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; font-size: .75rem; padding: 0 .45rem;
}

.sidebar { display: none; }
.is-soon { opacity: .45; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: .4rem .25rem calc(.4rem + env(safe-area-inset-bottom));
}
.bottom-nav a, .bottom-nav span {
  display: flex; align-items: center; justify-content: center;
  min-height: 52px; padding: .35rem 0; border-radius: 12px;
  font-size: .8rem; text-align: center; text-decoration: none; color: var(--muted);
}
.bottom-nav .is-active { color: var(--accent); font-weight: 600; }
.bottom-nav .add-btn { color: var(--accent); font-weight: 700; }

@media (min-width: 900px) {
  body.is-authed { display: grid; grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: .4rem;
    padding: 1.5rem 1rem; background: var(--surface);
    border-right: 1px solid var(--line);
    position: sticky; top: 0; height: 100vh; height: 100dvh;
  }
  .brand { font-size: 1.2rem; padding: .3rem .9rem 1rem; }
  .sidebar a, .sidebar span { padding: .7rem .9rem; border-radius: 12px; text-decoration: none; color: var(--text); }
  .sidebar .is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .bottom-nav { display: none; }
  .content { padding: 2rem; margin: 0; max-width: 960px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
