:root {
  --accent: #7c5cff;
  --bg: #f6f5fa;
  --card: #ffffff;
  --text: #1a1a24;
  --muted: #71718a;
  --line: #e7e6ef;
  --ok: #1fa060;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --nav-h: calc(58px + env(safe-area-inset-bottom));
}
[data-theme="dark"] {
  --bg: #131318;
  --card: #1e1e27;
  --text: #f0eff6;
  --muted: #9c9bb0;
  --line: #2c2b38;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-top: env(safe-area-inset-top);
  padding-bottom: var(--nav-h);
}
button { font: inherit; cursor: pointer; touch-action: manipulation; }
/* 16px floor on text fields: below that iOS zooms the viewport on focus */
input, textarea, select { font-size: 16px; }
input, textarea, select { font: inherit; color: var(--text); }
a { color: var(--accent); }

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

/* ---------- layout ---------- */
.view { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }
.pagehead { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 2px 14px; }
.pagehead h1 { font-size: 24px; letter-spacing: -0.02em; }
.pagehead .sub { color: var(--muted); font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 8px; }

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

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; background: none; border: none; color: var(--muted); font-size: 9.5px;
}
.tabbar button span:last-child { white-space: nowrap; }
.tabbar button .ico { font-size: 18px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- tasks ---------- */
.task {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
}
.task:last-child { border-bottom: none; }
.task .tick {
  flex: none; width: 24px; height: 24px; margin-top: 1px;
  border: 2px solid var(--muted); border-radius: 50%; background: none;
  display: grid; place-items: center; color: transparent; font-size: 14px;
}
.task.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-size: 15px; line-height: 1.35; border: none; background: none;
  padding: 0; text-align: left; width: 100%; }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.badge { padding: 1px 7px; border-radius: 20px; background: var(--bg); border: 1px solid var(--line); }
.badge.due-over { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge.due-today { color: #fff; background: var(--warn); border-color: var(--warn); }
.badge.p0 { color: var(--danger); border-color: var(--danger); }
.badge.p1 { color: var(--warn); border-color: var(--warn); }
.badge.prog { color: var(--accent); border-color: var(--accent); }
.badge.who { color: var(--accent); }

.progressbar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 7px; overflow: hidden; }
.progressbar > div { height: 100%; background: var(--accent); border-radius: 4px; }

/* quick add */
.quickadd { display: flex; gap: 8px; margin-bottom: 12px; }
.quickadd input {
  flex: 1; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); outline: none;
}
.quickadd input:focus { border-color: var(--accent); }
.quickadd button {
  flex: none; width: 46px; border-radius: var(--radius); border: none;
  background: var(--accent); color: #fff; font-size: 22px; line-height: 1;
}

.chips { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chips button {
  flex: none; padding: 6px 13px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.chips button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chips .sortlab { flex: none; align-self: center; color: var(--muted); font-size: 12px; padding-right: 2px; }
.card h2.band-over { color: var(--danger); }

/* live urgency preview under task inputs */
.qa-hint { min-height: 18px; margin: -6px 2px 12px; font-size: 12.5px; line-height: 18px; }
.nt-hint { min-height: 18px; margin-top: 8px; font-size: 12.5px; line-height: 18px; }
.hint-chip { display: inline-block; padding: 2px 10px; border-radius: 20px; font-weight: 500; }
.hint-chip.hot { color: #fff; background: var(--danger); }
.hint-chip.warm { color: #fff; background: var(--warn); }
.hint-chip.cool { color: var(--muted); background: var(--bg); border: 1px solid var(--line); }
.hint-nudge { color: var(--muted); }

/* completion celebration */
.tick.pop { animation: tick-pop 320ms ease; }
@keyframes tick-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  70% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; width: 9px; height: 9px; opacity: 0;
  will-change: transform, opacity;
  animation: confetti-fly 950ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(0); }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 130px)) rotate(var(--rot));
  }
}
@media (prefers-reduced-motion: reduce) {
  .tick.pop { animation: none; }
}

/* ---------- feedback ---------- */
.feedcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px;
}
.fc-top { display: flex; align-items: flex-start; gap: 8px; }
.fc-kind { flex: none; font-size: 16px; line-height: 1.3; }
.fc-title { flex: 1; min-width: 0; font-size: 15px; line-height: 1.35; font-weight: 500; }
.fc-body { color: var(--muted); font-size: 13.5px; line-height: 1.4; margin-top: 6px; white-space: pre-wrap; }
.fc-meta { color: var(--muted); font-size: 12px; margin-top: 7px; }
.pill { flex: none; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; border: 1px solid var(--line); white-space: nowrap; }
.pill.fb-accent { color: #fff; background: var(--accent); border-color: var(--accent); }
.pill.fb-warn { color: #fff; background: var(--warn); border-color: var(--warn); }
.pill.fb-good { color: #fff; background: var(--ok); border-color: var(--ok); }
.pill.fb-muted { color: var(--muted); }

/* ---------- sheet (task detail / dialogs) ---------- */
.sheet-back {
  position: fixed; inset: 0; background: rgba(10,10,20,0.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet .grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 2px auto 12px; }
.sheet h2.tasktitle { font-size: 18px; margin-bottom: 4px; }
.sheet textarea, .sheet input[type=text], .sheet input[type=email], .sheet input[type=date], .sheet input[type=url] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); outline: none; margin-top: 6px;
}
.sheet textarea:focus, .sheet input:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row label { font-size: 12.5px; color: var(--muted); min-width: 68px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { padding: 7px 12px; border: none; background: var(--card); color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }
input[type=range] { flex: 1; accent-color: var(--accent); }

.btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: none; }
.btn.wide { width: 100%; margin-top: 12px; }

.comments { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.comment { margin-bottom: 10px; }
.comment .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comment .what { font-size: 14px; white-space: pre-wrap; }
.comment.event .what { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---------- boards ---------- */
.board-head { display: flex; align-items: center; gap: 8px; }
.board-head h2 { flex: 1; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
.board-head .mini { border: none; background: none; color: var(--muted); font-size: 15px; padding: 4px; }
.blk { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; }
.blk input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); margin-top: 1px; }
.blk .txt { flex: 1; border: none; background: none; padding: 0; font-size: 16px;
  line-height: 1.4; outline: none; width: 100%; resize: none; }
.blk.checked .txt { color: var(--muted); text-decoration: line-through; }
.blk .del { border: none; background: none; color: var(--muted); padding: 0 2px; }
.addline { display: flex; gap: 8px; margin-top: 6px; }
.addline input { flex: 1; border: none; border-bottom: 1px dashed var(--line);
  background: none; padding: 6px 2px; outline: none; font-size: 16px; }

/* ---------- feed ---------- */
.feed-day { font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.06em; margin: 16px 4px 6px; }
.feed-item { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-item .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; }
.feed-item .what { font-size: 14px; line-height: 1.4; }
.feed-item .ctx { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

/* ---------- settings ---------- */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; }
.swatch.active { border-color: var(--text); }
.setting-row { display: flex; align-items: center; justify-content: space-between;
  padding: 11px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.setting-row:last-child { border-bottom: none; }
.setting-row .lab { font-size: 14.5px; }
.setting-row .lab small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

/* ---------- join ---------- */
.join { max-width: 400px; margin: 0 auto; padding: 12vh 22px 0; text-align: center; }
.join .logo { width: 74px; height: 74px; border-radius: 20px; margin-bottom: 18px; }
.join h1 { font-size: 22px; margin-bottom: 6px; }
.join p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.join input {
  width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-size: 16px; margin-bottom: 10px;
}
.join .err { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 18px; }
.join-or { color: var(--muted); font-size: 12.5px; margin: 12px 0 10px; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 12px); z-index: 60;
  background: var(--text); color: var(--bg);
  padding: 9px 18px; border-radius: 24px; font-size: 13.5px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
