:root {
  --bg: #0b0e14;
  --sheet: #12161f;
  --sheet-2: #171c26;
  --line: rgba(255, 255, 255, 0.07);
  --txt: #eef2f8;
  --dim: #8b95a7;
  --dim2: #5f6878;
  --accent: #5b8cff;
  --accent-2: #8b5cf6;
  --good: #3ddc97;
  --danger: #ff6b6b;
  --r: 26px;
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 70% at 50% -10%, #1b2436 0%, #0b0e14 55%, #080a0f 100%);
}

.stage {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* fake chat backdrop so the sheet reads as "sliding over a chat" */
.behind {
  position: absolute;
  inset: 0 0 auto 0;
  padding: 18px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0.5;
  filter: blur(0.4px);
  pointer-events: none;
}
.bubble {
  height: 26px;
  border-radius: 13px 13px 13px 4px;
  background: rgba(255, 255, 255, 0.055);
}
.bubble.b1 { width: 46%; }
.bubble.b2 { width: 62%; margin-left: auto; border-radius: 13px 13px 4px 13px; background: rgba(91, 140, 255, 0.16); }
.bubble.b3 { width: 34%; }

.sheet {
  position: relative;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #151a24 0%, var(--sheet) 22%, #0f1319 100%);
  border-radius: var(--r) var(--r) 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: rise 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: transform;
  touch-action: pan-y;
}

@keyframes rise {
  from { transform: translateY(102%); }
  to { transform: translateY(0); }
}

.handle {
  padding: 9px 0 3px;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}
.handle span {
  width: 42px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 2px 20px 12px;
  flex: 0 0 auto;
}
.titles { min-width: 0; flex: 1; }
.eyebrow {
  margin: 0 0 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--dim2);
}
h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--dim);
  display: flex;
  gap: 6px;
  align-items: center;
}
.dot { color: var(--dim2); }

.iconbtn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--dim);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.iconbtn:active { transform: scale(0.93); color: var(--txt); background: rgba(255, 255, 255, 0.09); }

.track {
  height: 3px;
  margin: 0 20px 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  flex: 0 0 auto;
}
.track i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.chips {
  display: flex;
  gap: 7px;
  padding: 0 20px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--dim);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.chip.active {
  background: rgba(91, 140, 255, 0.16);
  border-color: rgba(91, 140, 255, 0.4);
  color: #a9c3ff;
}
.chip.ghost { margin-left: auto; color: var(--dim2); }
.chip.ghost:active { color: var(--danger); border-color: rgba(255, 107, 107, 0.35); }
.chip[hidden] { display: none; }

.items {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: none;
}
.items::-webkit-scrollbar { display: none; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 13px;
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.033);
  border: 1px solid rgba(255, 255, 255, 0.045);
  animation: pop 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.item.done { background: rgba(61, 220, 151, 0.05); border-color: rgba(61, 220, 151, 0.12); }

.check {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 9px;
  border: 1.8px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.16s ease;
  padding: 0;
}
.check svg { opacity: 0; transform: scale(0.6); transition: all 0.16s ease; color: #0b1a12; }
.item.done .check {
  background: var(--good);
  border-color: var(--good);
}
.item.done .check svg { opacity: 1; transform: scale(1); }
.check:active { transform: scale(0.9); }

.body { flex: 1 1 auto; min-width: 0; }
.text {
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
  transition: color 0.18s ease;
}
.item.done .text { color: var(--dim2); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.by {
  margin-top: 3px;
  font-size: 11px;
  color: var(--dim2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.who {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 8.5px;
  font-weight: 800;
  color: #0b0e14;
  background: linear-gradient(135deg, #7ea8ff, #b18bff);
  flex: 0 0 auto;
}

.del {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--dim2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: all 0.15s ease;
}
.del:active { opacity: 1; color: var(--danger); background: rgba(255, 107, 107, 0.12); }

.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 42px;
  animation: pop 0.3s ease both;
}
.empty[hidden] { display: none; }
.emptyIcon { font-size: 34px; margin-bottom: 10px; opacity: 0.9; }
.emptyTitle { margin: 0; font-size: 16px; font-weight: 650; }
.emptySub { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--dim2); }

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(15, 19, 25, 0) 0%, rgba(13, 16, 22, 0.92) 30%, #0d1016 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.composer input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 16px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt);
  font-size: 15.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.composer input::placeholder { color: var(--dim2); }
.composer input:focus {
  border-color: rgba(91, 140, 255, 0.45);
  background: rgba(91, 140, 255, 0.07);
}
.composer button {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg, var(--accent), #6f6bff);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.32);
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.composer button:active { transform: scale(0.92); }
.composer button:disabled { opacity: 0.4; box-shadow: none; }

.safe { display: none; }

/* name modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  padding: 0;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modalCard {
  width: 100%;
  max-width: 460px;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, #1a202c, #12161f);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateY(14px);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}
.modal.open .modalCard { transform: none; }
.modalEmoji { font-size: 30px; }
.modalCard h2 { margin: 8px 0 4px; font-size: 21px; letter-spacing: -0.01em; }
.modalCard p { margin: 0 0 16px; font-size: 13px; color: var(--dim); }
.modalCard input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--txt);
  font-size: 16px;
  font-family: inherit;
  text-align: center;
  outline: none;
}
.modalCard input:focus { border-color: rgba(91, 140, 255, 0.5); }
.modalCard button {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(145deg, var(--accent), #6f6bff);
  color: #fff;
  font-size: 15.5px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
}
.modalCard button:active { transform: scale(0.985); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: rgba(24, 30, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--txt);
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 99px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 60;
  max-width: 84vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 620px) {
  .stage { padding: 0; align-items: center; }
  .sheet {
    max-width: 520px;
    height: min(100dvh, 860px);
    border-radius: var(--r) var(--r) 0 0;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
  }
  .modal { place-items: center; }
  .modalCard { border-radius: 26px; }
}
