/* Bergi2 - mobil zuerst, dunkel als Vorgabe.
   Grosse Trefferflaechen, weil das hier im Alltag mit dem Daumen bedient wird. */

:root {
  --bg: #16171a;
  --surface: #1f2126;
  --surface-2: #272a30;
  --line: #34383f;
  --text: #e8eaed;
  --muted: #9aa0a8;
  --accent: #6ea8fe;
  --overdue: #ff6b6b;
  --soon: #ffb454;
  --ok: #5bd68a;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f4;
    --line: #dcdfe5; --text: #1a1c1f; --muted: #6b7280; --accent: #2563eb;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Platz fuer die fixierte Schnellerfassung unten */
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

/* ---------------------------------------------------------- Anmeldung */

.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login .card { width: min(380px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.5px; }
.accent { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

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

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button.primary, .login button[type=submit] {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 13px;
  font-weight: 600;
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
}
.ghost.danger { color: var(--overdue); }

.error { color: var(--overdue); font-size: 14px; margin: 0; }

/* ------------------------------------------------------------ Kopfzeile */

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

/* Ampel. Die erste Sache auf dem Bildschirm und die einzige taegliche
   Pflichtinteraktion - deshalb gross, mit drei Fingern erreichbar, und ohne
   jede Zahl daneben. Rote Tage werden nicht gezaehlt. */

.ampel { display: flex; gap: 6px; flex: 1; }

.lamp {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 6px;
  color: var(--muted);
}
.lamp .dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--line);
  transition: background 0.15s, box-shadow 0.15s;
}
.lamp-label { font-size: 13px; }

.lamp[data-level=red].on    { border-color: var(--overdue); color: var(--text); }
.lamp[data-level=amber].on  { border-color: var(--soon);    color: var(--text); }
.lamp[data-level=green].on  { border-color: var(--ok);      color: var(--text); }

.lamp[data-level=red].on    .dot { background: var(--overdue); box-shadow: 0 0 0 4px rgba(255,107,107,.18); }
.lamp[data-level=amber].on  .dot { background: var(--soon);    box-shadow: 0 0 0 4px rgba(255,180,84,.18); }
.lamp[data-level=green].on  .dot { background: var(--ok);      box-shadow: 0 0 0 4px rgba(91,214,138,.18); }

/* Nur vorausgesetzt, nicht gemeldet: sichtbar blasser. */
.ampel.assumed .lamp.on { opacity: 0.55; }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.partner {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.partner .dot { width: 10px; height: 10px; border-radius: 50%; }
.partner .dot.red { background: var(--overdue); }
.partner .dot.amber { background: var(--soon); }
.partner .dot.green { background: var(--ok); }

.ghost.icon { padding: 9px 11px; }

.hint {
  margin: 10px 12px 0;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--soon);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--muted);
}
.hint button {
  background: none; border: 0; padding: 0; margin-left: 6px;
  color: var(--accent); text-decoration: underline; font-size: inherit;
}

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 0;
}
.toolbar input[type=search] { flex: 1; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.views {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 4px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.views::-webkit-scrollbar { display: none; }
.views button {
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 7px 4px;
}
.views button.active { color: var(--text); border-bottom-color: var(--accent); }

/* --------------------------------------------------------- Tagesplan */

/* Bewusst keine Fortschrittsanzeige und kein "1 von 3". Die Zahl ist eine
   Obergrenze, kein Soll - wer eine Sache schafft, hatte einen vollen Tag. */

.item .why {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.item.forced { border-left-color: var(--overdue); }
.item.forced .why { color: var(--overdue); }

.item-actions { display: flex; gap: 6px; margin-top: 9px; }
.item-actions button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--muted);
}

.done-today { margin: 22px 12px 0; }
.done-today h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.done-today .list { padding: 0; }

.handoffs { display: grid; gap: 8px; padding: 12px 12px 0; }
.handoff {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
}
.handoff p { margin: 0 0 9px; font-size: 14px; }
.handoff .from { color: var(--muted); font-size: 12.5px; }
.handoff .actions { display: flex; gap: 8px; }
.handoff .actions button { flex: 1; padding: 8px; border-radius: 9px; }

/* --------------------------------------------------------- Fristen */

/* Nicht rot und nicht laut. Eine Warnung, die drei Wochen vorher schreit,
   wird ignoriert - und dann auch die, die zu Recht kommt. */
.risks { display: grid; gap: 8px; padding: 12px 12px 0; }

.risk {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--soon);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13.5px;
}
.risk.at_risk, .risk.overdue { border-left-color: var(--overdue); }
.risk .what { color: var(--text); font-weight: 500; margin-bottom: 3px; }
.risk .math { color: var(--muted); font-size: 12.5px; }
.risk .actions { display: flex; gap: 6px; margin-top: 9px; }
.risk .actions button {
  background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; color: var(--muted);
}

/* ------------------------------------------------- Abhaken, das sich lohnt */

/* Der Haken soll einen Moment lang etwas sein, nicht nur verschwinden. */
@keyframes tick-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.45); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
@keyframes item-leave {
  0%   { opacity: 1; transform: translateX(0); max-height: 240px; }
  60%  { opacity: 0.35; transform: translateX(14px); }
  100% { opacity: 0; transform: translateX(30px); max-height: 0;
         margin-top: -8px; padding-top: 0; padding-bottom: 0; border-width: 0; }
}
@keyframes spark {
  0%   { opacity: 1; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(2.4); }
}

.tick.popping {
  animation: tick-pop 340ms ease-out;
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
}
.item.leaving { animation: item-leave 420ms 200ms ease-in forwards; overflow: hidden; }

.spark {
  position: absolute;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--ok);
  pointer-events: none;
  animation: spark 500ms ease-out forwards;
  z-index: 30;
}

/* Figurenmeldung. Unten, kurz, nie im Weg. */
.speech {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  z-index: 25;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  animation: speech-in 260ms cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes speech-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
.speech.leaving { animation: speech-out 260ms ease-in forwards; }
@keyframes speech-out {
  to { opacity: 0; transform: translateY(10px); }
}

.speech .face { font-size: 26px; line-height: 1.1; flex: none; }
.speech .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.speech .said { font-size: 14.5px; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  .tick.popping, .item.leaving, .speech, .spark { animation: none; }
  .item.leaving { display: none; }
}

/* ------------------------------------------------------------- Ablehnen */

.reject-task { margin: 0 0 4px; font-weight: 500; }
.reject-hint { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.reject-reasons { display: grid; gap: 7px; margin-bottom: 14px; }
.reason-group {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 10px;
}
.reason-group:first-child { margin-top: 0; }
.reject-reasons button {
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 14.5px;
}
.reject-reasons button:hover { border-color: var(--accent); }
.wide-inline { width: 100%; margin-top: 9px; }

/* ------------------------------------------------------- Bereiche */

.area-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
}
.area-row h3 { margin: 0 0 10px; font-size: 15.5px; }
.area-opts { display: grid; gap: 9px; }
.area-opt {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 13.5px; color: var(--muted);
}
.area-opt select { width: auto; padding: 6px 9px; font-size: 13.5px; }
.area-opt input[type=checkbox] { width: auto; }
.area-members { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------- Runde */

.round-setup { margin: 12px; display: grid; gap: 13px; }
.round-intro { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.wide { width: calc(100% - 24px); margin: 12px; }

/* ----------------------------------------------------------- Routinen */

.routine-form { margin: 12px; display: grid; gap: 12px; }
.routine-form .row { display: flex; gap: 10px; }
.routine-form .row label { flex: 1; }

.preview {
  margin: 0; font-size: 13px; color: var(--accent); min-height: 18px;
}
.preview.bad { color: var(--overdue); }

.routine {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.routine .body { flex: 1; min-width: 0; }
.routine .off { color: var(--muted); }

/* ------------------------------------------------------------- Liste */

.list { padding: 10px 12px; display: grid; gap: 8px; }

.item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 12px;
}
.item.is-overdue { border-left-color: var(--overdue); }
.item.is-today   { border-left-color: var(--soon); }
.item.is-done    { opacity: 0.5; }

/* Grosse Trefferflaeche zum Abhaken - der haeufigste Handgriff ueberhaupt */
.tick {
  flex: none;
  width: 26px; height: 26px;
  margin-top: 1px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: transparent;
  font-size: 15px; line-height: 1;
  transition: background 0.12s, border-color 0.12s;
}
.tick:hover { border-color: var(--ok); }
.item.is-done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }

.body { flex: 1; min-width: 0; }
.title { font-weight: 500; word-break: break-word; }
.item.is-done .title { text-decoration: line-through; }

/* Der erste Handgriff steht direkt unter dem Titel - das ist die Stelle,
   an der das Anfangen sonst scheitert. */
.first-step {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--accent);
}
.first-step::before { content: "▸ "; }

.consequence {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--soon);
}

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.badge {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 7px;
}
.badge.due-overdue { color: var(--overdue); }
.badge.due-today   { color: var(--soon); }
.badge.stuck       { color: var(--soon); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ------------------------------------------------------ Schnellerfassung */

.quickadd {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.quickadd input { flex: 1; }
.quickadd button {
  flex: none; width: 48px;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 10px; font-size: 24px; line-height: 1;
}

/* ---------------------------------------------------------- Detailblatt */

.sheet {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-inner {
  width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) {
  .sheet { align-items: center; }
  .sheet-inner { border-radius: var(--radius); }
}

.close { position: absolute; top: 12px; right: 12px; padding: 6px 10px; }
.sheet-inner h2 { margin: 4px 40px 10px 0; font-size: 19px; }

.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.notes-label { margin-top: 10px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .primary { flex: 1; }

.history { margin-top: 16px; font-size: 13px; color: var(--muted); }
.history summary { cursor: pointer; }
.history ul { list-style: none; padding: 8px 0 0; margin: 0; display: grid; gap: 4px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(94px + env(safe-area-inset-bottom));
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 14px;
  z-index: 20;
}
