:root {
  --bg: #0f1115;
  --surface: #16191f;
  --surface-2: #1c2028;
  --border: #262b34;
  --text: #e6e8ec;
  --muted: #8b93a1;
  --accent: #4f8cff;
  --ok: #38b26b;
  --warn: #e5a13a;
  --danger: #e5484d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.tabs {
  display: flex; gap: 4px; margin: 16px 0 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  border-radius: 9px; padding: 9px 10px; font-weight: 600; font-size: 14px;
}
.tab.active { background: var(--surface-2); color: var(--text); }

.filter {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted); font-size: 12px; margin: 0 0 6px 2px;
}
.filter select {
  flex: 1; max-width: 240px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 10px; font-size: 14px;
}

.section { margin: 18px 0 10px; }
.section h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--muted); margin: 0 0 8px 2px; font-weight: 650;
}
.section.urgent h2 { color: var(--danger); }
.section-count {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #232833; color: var(--muted); letter-spacing: 0;
}
.section-hint { color: var(--muted); font-size: 11px; margin: -4px 0 8px 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}

.task {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-top: 1px solid var(--border);
  min-height: 58px;
}
.task:first-child { border-top: 0; }

.check {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #3a4150; background: transparent; padding: 0;
  transition: border-color .18s ease, background .18s ease;
}
.check:active { background: rgba(56, 178, 107, .18); border-color: var(--ok); }
.check:disabled { opacity: .5; }

.body { flex: 1 1 auto; min-width: 0; }
.title { font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin-top: 4px; font-size: 11.5px; color: var(--muted);
}
.chip {
  padding: 1px 7px; border-radius: 999px;
  background: rgba(79, 140, 255, .13); color: #9cbcff;
}
.due.late { color: var(--danger); font-weight: 600; }
.prio {
  padding: 1px 6px; border-radius: 999px; font-weight: 700;
  background: #232833; font-size: 10.5px;
}
.prio.p1 { background: rgba(229, 72, 77, .16); color: #ff8a8d; }
.prio.p2 { background: rgba(229, 161, 58, .16); color: #f0b45a; }
.prio.p3 { color: var(--muted); }

.postpone {
  flex: 0 0 auto; border: 1px solid var(--border);
  background: transparent; color: var(--muted);
  border-radius: 9px; padding: 7px 9px; font-size: 12px;
}
.postpone:active { background: var(--surface-2); }

.empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: 14px; }

.btn {
  background: var(--accent); color: #06101f; border: 0; border-radius: 11px;
  padding: 11px 15px; font-weight: 650; min-height: 42px;
}
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.full { width: 100%; }

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .58); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px;
}
.sheet h2 { font-size: 17px; margin: 0 0 10px; }
.modal-task { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 12px; color: var(--muted); }
.field input {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 12px; font-size: 15px; color: var(--text);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 400px) { .row2 { grid-template-columns: 1fr; } }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .btn { flex: 1; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.error { color: var(--danger); font-size: 12.5px; margin: 8px 0 0; }
.muted { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60;
  background: #232833; color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; font-size: 13px; max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.toast.error { color: #ffb4b6; border-color: rgba(229, 72, 77, .5); }
