/* Uses Nexa theme params injected by the SDK (--nexa-* on :root) with sensible
   fallbacks so it also looks fine when opened standalone. */
:root {
  --bg: var(--nexa-bg-color, #ffffff);
  --bg2: var(--nexa-secondary-bg-color, #f4f5f7);
  --text: var(--nexa-text-color, #1c1d21);
  --hint: var(--nexa-hint-color, #8a8f98);
  --accent: var(--nexa-button-color, #5b67f1);
  --on-accent: var(--nexa-button-text-color, #ffffff);
  --todo: #8a8f98;
  --doing: #e0922f;
  --done: #2ea66b;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over author `display` rules (e.g. .sheet /
   .footer use display:flex, which would otherwise override the UA [hidden]
   rule and show the sheet on load). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
  min-height: 100%;
}

.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 20px; margin: 4px 0 12px; }
.who { color: var(--hint); font-size: 13px; }

.status { color: var(--hint); padding: 24px 0; text-align: center; }
.status.error { color: #d23f3f; }

/* ── filters ── */
.filters { margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-filter input {
  font-size: 14px; padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent);
  border-radius: 10px; background: var(--bg); color: var(--text);
}
.seg { display: inline-flex; background: var(--bg2); border-radius: 10px; padding: 2px; margin-left: auto; }
.seg-btn {
  border: 0; background: transparent; color: var(--hint);
  font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.seg-btn.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: var(--bg); color: var(--text);
  font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  text-transform: capitalize;
}
.chip.active { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.chip.ghost { color: var(--hint); }

/* ── list ── */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border-radius: 12px;
  padding: 10px 12px;
}
.item.status-done .title { text-decoration: line-through; color: var(--hint); }

.st-chip {
  width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 1;
  color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.st-todo  { background: var(--todo); }
.st-doing { background: var(--doing); }
.st-done  { background: var(--done); }

.item-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--hint); }
.cat { text-transform: capitalize; font-weight: 600; }
.due { font-variant-numeric: tabular-nums; }
.note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.item-actions { display: flex; gap: 4px; }
.icon-btn {
  border: 0; background: transparent; color: var(--hint);
  font-size: 16px; padding: 6px; border-radius: 8px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { background: color-mix(in srgb, var(--hint) 18%, transparent); }
.icon-btn.danger:hover { color: #d23f3f; }

.empty { color: var(--hint); text-align: center; padding: 32px 0; }

/* ── FAB ── */
.fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  font-size: 28px; line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ── add / edit sheet ── */
.sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 640px;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.sheet-card h2 { margin: 0 0 4px; font-size: 17px; }
.sheet-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--hint); }
.sheet-card input, .sheet-card select {
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: var(--bg2); color: var(--text); }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.footer { margin-top: 16px; display: flex; justify-content: center; }
