:root {
  --bg: #07090d;
  --bg-soft: #0c1017;
  --card: rgba(255, 255, 255, 0.038);
  --card-strong: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f1ea;
  --muted: #a2abb9;
  --dim: #737d8d;
  --amber: #ffc76e;
  --orange: #ff8a5c;
  --mint: #63e6c8;
  --violet: #c0a8ff;
  --danger: #ff9494;
  --radius: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 88% -12%, rgba(255, 138, 92, 0.17), transparent 62%),
    radial-gradient(760px 480px at -12% 4%, rgba(99, 230, 200, 0.08), transparent 58%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.42;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 18px calc(26px + env(safe-area-inset-bottom));
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 2px 14px;
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.96) 55%, rgba(7, 9, 13, 0));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.wordmark {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.today {
  margin: 1px 0 0;
  color: var(--dim);
  font-size: 12px;
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.sync i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px rgba(99, 230, 200, 0.7);
}

.sync.is-off {
  color: var(--danger);
}

.sync.is-off i {
  background: var(--danger);
  box-shadow: none;
}

.summary {
  margin-top: 6px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 199, 110, 0.11), rgba(255, 255, 255, 0.028) 58%),
    rgba(12, 16, 23, 0.6);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.summary-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.goal {
  margin: 0;
  font-size: 40px;
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.goal-sep {
  margin: 0 3px;
  color: var(--dim);
  font-weight: 400;
}

.summary-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-bottom: 4px;
}

.pill {
  display: inline-flex;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.pill:first-child {
  color: var(--amber);
  border-color: rgba(255, 199, 110, 0.28);
  background: rgba(255, 199, 110, 0.08);
}

.bar {
  height: 9px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--orange));
  transition: width 0.35s ease;
}

.summary-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.group {
  margin-top: 26px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 10px;
}

.group-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.group-head h2.is-overdue {
  color: var(--danger);
}

.group-count {
  color: var(--dim);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 9px;
  padding: 15px 15px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.task:active {
  background: var(--card-strong);
}

.task.is-done {
  opacity: 0.55;
}

.task.is-done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.check {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  margin: 0;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.1s;
}

.check::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
}

.check:active {
  transform: scale(0.9);
}

.check svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check.is-done {
  border-color: var(--mint);
  background: var(--mint);
  color: #04251d;
}

.task-main {
  flex: 1 1 auto;
  min-width: 0;
}

.task-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15.5px;
  font-weight: 550;
  line-height: 1.35;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.chip {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.028);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.chip.plan {
  color: var(--amber);
  border-color: rgba(255, 199, 110, 0.25);
  background: rgba(255, 199, 110, 0.075);
}

.chip.overdue {
  color: var(--danger);
  border-color: rgba(255, 148, 148, 0.26);
  background: rgba(255, 148, 148, 0.075);
}

.chip.focus {
  color: var(--violet);
  border-color: rgba(192, 168, 255, 0.26);
  background: rgba(192, 168, 255, 0.075);
}

.subs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.sub {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 6px 0;
}

.sub-check {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}

.sub-check::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}

.sub-check svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sub-check.is-done {
  border-color: var(--mint);
  background: var(--mint);
  color: #04251d;
}

.sub-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sub.is-done .sub-text {
  color: var(--dim);
  text-decoration: line-through;
}

.done-group {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.done-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 2px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  list-style: none;
  touch-action: manipulation;
}

.done-group summary::-webkit-details-marker {
  display: none;
}

.done-group summary::after {
  content: '›';
  margin-left: 6px;
  color: var(--dim);
  font-size: 17px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.2s;
}

.done-group[open] summary::after {
  transform: rotate(-90deg);
}

.done-group .group-count {
  margin-left: auto;
}

.done-group .task {
  margin-top: 9px;
}

.waiting {
  padding: 44px 22px;
  text-align: center;
  color: var(--muted);
}

.waiting p {
  margin: 14px 0 4px;
  font-size: 15px;
}

.waiting small {
  color: var(--dim);
  font-size: 12.5px;
}

.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.all-done {
  margin-top: 24px;
  padding: 30px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.all-done strong {
  display: block;
  margin-bottom: 4px;
  color: var(--mint);
  font-size: 17px;
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
}

.foot form {
  margin: 0;
}

.foot button {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 11.5px;
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100vw - 40px);
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: #1b202b;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty {
  padding: 20px;
  color: var(--dim);
  text-align: center;
  font-size: 13px;
}

/* ---------- Wunschtag ---------- */

.plan {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--dim);
}

.plan svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plan:active {
  border-color: rgba(255, 199, 110, 0.35);
  background: rgba(255, 199, 110, 0.09);
  color: var(--amber);
}

body.sheet-open {
  overflow: hidden;
}

.sheet[hidden] {
  display: none;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: #11161f;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  animation: sheetIn 0.22s ease;
}

@keyframes sheetIn {
  from {
    transform: translateY(18px);
    opacity: 0;
  }
}

.sheet-grip {
  display: block;
  width: 42px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.sheet-panel h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.sheet-task {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.sheet-current {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 12px;
}

.sheet-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.sheet-quick button {
  padding: 12px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}

.sheet-quick button:active {
  background: rgba(255, 199, 110, 0.16);
}

.sheet-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  font-size: 13px;
}

.sheet-date input {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: right;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.sheet-actions button {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
}

.sheet-clear {
  color: var(--danger);
  border-color: rgba(255, 148, 148, 0.24);
}

.sheet-clear[hidden] {
  display: none;
}

button.sheet-cancel {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
}

/* ---------- Login ---------- */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 26px;
}

.login {
  width: 100%;
  max-width: 390px;
  text-align: center;
}

.logo {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 19px;
  background: linear-gradient(135deg, var(--amber), var(--orange));
  color: #241303;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 14px 40px rgba(255, 138, 92, 0.22);
}

.login h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.035em;
}

.login-hint {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14.5px;
}

.login-error {
  margin: 0 0 16px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 148, 148, 0.28);
  border-radius: 12px;
  background: rgba(255, 148, 148, 0.07);
  color: var(--danger);
  font-size: 13px;
}

.pin {
  width: 100%;
  margin: 0 0 12px;
  padding: 15px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  outline: none;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.34em;
  text-align: center;
}

.pin::placeholder {
  color: rgba(255, 255, 255, 0.18);
}

.pin:focus {
  border-color: rgba(255, 199, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 199, 110, 0.1);
}

.login button[type='submit'] {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--amber), var(--orange));
  color: #241303;
  font-size: 16px;
  font-weight: 700;
}

.login button[type='submit']:active {
  transform: translateY(1px);
}

.login-note {
  margin: 22px 0 0;
  color: var(--dim);
  font-size: 11.5px;
}

@media (min-width: 700px) {
  .app {
    padding-left: 28px;
    padding-right: 28px;
  }

  .task {
    padding: 17px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
