:root {
  --bg: var(--tg-theme-bg-color, #0f0f12);
  --text: var(--tg-theme-text-color, #f2f2f4);
  --hint: var(--tg-theme-hint-color, #8b8b96);
  --link: var(--tg-theme-link-color, #6ab7ff);
  --btn: var(--tg-theme-button-color, #3390ec);
  --btn-t: var(--tg-theme-button-text-color, #fff);
  --card: var(--tg-theme-secondary-bg-color, #1a1a22);
  --danger: #e85d5d;
  --warn: #e6a23c;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.top h1 { margin: 0; font-size: 1.25rem; font-weight: 650; }
.sub { margin: 4px 0 0; font-size: 0.85rem; color: var(--hint); }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--btn); color: var(--btn-t); }
.btn.ghost { background: transparent; color: var(--link); }
.btn.warn { background: rgba(230, 162, 60, 0.2); color: var(--warn); }
.btn.danger { background: rgba(232, 93, 93, 0.2); color: var(--danger); }

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
}
.tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--card);
  color: var(--hint);
  font-weight: 600;
}
.tab.active {
  color: var(--text);
  border-color: var(--btn);
  background: rgba(51, 144, 236, 0.15);
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0 12px;
}
.task-list li {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.06);
}
.task-list li:active { opacity: 0.92; }
.task-list .t-title { font-weight: 650; margin: 0 0 6px; font-size: 1rem; }
.task-list .t-row { font-size: 0.8rem; color: var(--hint); display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--hint);
}
.pill.done { background: rgba(80, 180, 120, 0.25); color: #9dffb0; }

.empty { text-align: center; color: var(--hint); padding: 2rem 1rem; }
.hidden { display: none !important; }

.banner.err {
  margin: 0 16px 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(232, 93, 93, 0.15);
  color: #ffb4b4;
  font-size: 0.9rem;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  padding: 12px 16px 28px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-panel h2 { margin: 8px 0; font-size: 1.1rem; line-height: 1.35; }
.meta { color: var(--hint); font-size: 0.85rem; margin: 0 0 12px; }
.desc {
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.95;
  margin-bottom: 16px;
  max-height: 40vh;
  overflow: auto;
}
.actions { display: flex; flex-direction: column; gap: 10px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.08);
}
.modal-box h3 { margin: 0 0 12px; font-size: 1rem; }
.modal-box textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg);
  color: var(--text);
  padding: 10px;
  font-size: 1rem;
  resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
