@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/IBMPlexSans-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #22181c;
  --ink-soft: #5c5257;
  --paper: #ffffff;
  --chrome: #f5f1ec;
  --line: #ddd6cf;
  --done: #006d6d;
  --progress: #9a6700;
  --flag: #d94f54;
  --focus: #008080;
  --tap: 3rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2ece8;
    --ink-soft: #a89f9a;
    --paper: #22181c;
    --chrome: #191114;
    --line: #3a3033;
    --done: #35a3a3;
    --progress: #d79a2b;
    --flag: #ec696e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
  color: var(--ink);
  background: var(--chrome);
  -webkit-text-size-adjust: 100%;
}

button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 44rem; margin: 0 auto; }

/* Kopfzeile ------------------------------------------------------------- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  min-height: var(--tap);
}

.top h1 {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync {
  display: flex;
  align-items: center;
  gap: .375rem;
  padding: .25rem .5rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: .8125rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.sync .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--done); flex: none; }
.sync[data-state="syncing"] .dot { background: var(--progress); }
.sync[data-state="offline"] .dot { background: var(--flag); }

/* Fortschritt ----------------------------------------------------------- */
.progress { padding: .625rem .75rem; display: flex; align-items: center; gap: .75rem; }
.progress-track { flex: 1; height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--done); width: 0; transition: width .25s ease; }
.progress-count { font-variant-numeric: tabular-nums; font-size: .875rem; color: var(--ink-soft); }

/* Bereiche -------------------------------------------------------------- */
.section { margin: 0 0 .75rem; background: var(--paper); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.section-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem .75rem;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
.section-head h2 { flex: 1; margin: 0; font-size: 1rem; font-weight: 600; }
.tally { font-variant-numeric: tabular-nums; font-size: .875rem; color: var(--ink-soft); }

/* Punkte ---------------------------------------------------------------- */
.item { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }

.status {
  flex: none;
  width: var(--tap);
  min-height: var(--tap);
  margin: .5rem 0 .5rem .5rem;
  border: 2px solid var(--ink);
  border-radius: .375rem;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}
.status svg { width: 1.5rem; height: 1.5rem; }
.status[data-status="open"] svg { display: none; }
.status[data-status="in_progress"] { background: var(--progress); border-color: var(--progress); color: #fff; }
.status[data-status="done"] { background: var(--done); border-color: var(--done); color: #fff; }

.item-body {
  flex: 1;
  min-width: 0;
  padding: .625rem .75rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.item-title { font-weight: 500; overflow-wrap: anywhere; }
.item[data-status="done"] .item-title { color: var(--ink-soft); text-decoration: line-through; }
.item-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .1875rem; font-size: .8125rem; color: var(--ink-soft); }
.item-meta .due-late { color: var(--flag); font-weight: 600; }
.item-meta .flagged { color: var(--flag); font-weight: 600; }

/* Schaltflaechen -------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-height: var(--tap);
  padding: 0 1rem;
  border: 1px solid var(--ink);
  border-radius: .375rem;
  background: transparent;
  font-weight: 500;
  cursor: pointer;
}
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-quiet { border-color: transparent; color: var(--ink-soft); }
.btn-danger { border-color: var(--flag); color: var(--flag); }
.btn-wide { width: 100%; }
.btn-add { width: 100%; justify-content: flex-start; border: 0; border-radius: 0; color: var(--focus); padding: 0 .75rem; }

.field { display: block; margin-bottom: .875rem; }
.field span { display: block; margin-bottom: .25rem; font-size: .875rem; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .625rem;
  border: 1px solid var(--line);
  border-radius: .375rem;
  background: var(--paper);
}
.field textarea { min-height: 5rem; resize: vertical; }

.switch { display: flex; gap: .5rem; }
.switch button { flex: 1; min-height: var(--tap); border: 1px solid var(--line); border-radius: .375rem; background: var(--paper); cursor: pointer; }
.switch button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); font-weight: 600; }

/* Detailblatt ----------------------------------------------------------- */
dialog {
  width: min(34rem, 100%);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: .75rem .75rem 0 0;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: rgba(34, 24, 28, .55); }
.sheet { padding: 1rem; }
.sheet h2 { margin: 0 0 .875rem; font-size: 1.125rem; }
.sheet-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.sheet-actions .btn { flex: 1; }

.photos { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .875rem; }
.photo { position: relative; width: 5rem; height: 5rem; border-radius: .375rem; overflow: hidden; border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo[data-pending="true"]::after {
  content: '';
  position: absolute;
  inset: auto .25rem .25rem auto;
  width: .5rem; height: .5rem;
  border-radius: 50%;
  background: var(--progress);
}
.photo button { position: absolute; top: 0; right: 0; width: 1.75rem; height: 1.75rem; border: 0; background: rgba(34,24,28,.7); color: #fff; cursor: pointer; }

/* Startseite ------------------------------------------------------------ */
.start { padding: 1.5rem .75rem; }
.start h1 { font-size: 1.75rem; letter-spacing: -0.02em; margin: 0 0 .25rem; }
.start p { margin: 0 0 1.5rem; color: var(--ink-soft); }
.recent { list-style: none; margin: 1.5rem 0 0; padding: 0; background: var(--paper); border-top: 1px solid var(--line); }
.recent li { border-bottom: 1px solid var(--line); }
.recent a { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: var(--tap); padding: .625rem .75rem; color: inherit; text-decoration: none; }
.recent .when { font-size: .8125rem; color: var(--ink-soft); flex: none; }

.empty { padding: 2rem .75rem; text-align: center; color: var(--ink-soft); }
.error { margin: .75rem; padding: .75rem; border-left: 3px solid var(--flag); background: var(--paper); }

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

.item-open { display: grid; place-items: center; width: 1.75rem; flex: none; color: var(--ink-soft); opacity: .5; }
.item-open svg { width: 1.125rem; height: 1.125rem; }
