:root {
  --cream:      #FBF7F5;  /* warm light background */
  --cream-2:    #F3EBE7;  /* card / divider tint */
  --charcoal:   #33302E;  /* "black, not too dark" text */
  --charcoal-2: #6E6864;  /* muted text */
  --pink:       #EC6A95;  /* primary accent */
  --pink-soft:  #FBE2EA;  /* pink tint */
  --accent-glow: rgba(236, 106, 149, 0.35);  /* colored glow under active pills */
  --sage:       #7FB3A6;  /* done / secondary */
  --sage-soft:  #E4F0ED;
  --shadow:     0 6px 20px rgba(51, 48, 46, 0.10);
}

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

/* ---------- Portrait only ---------- */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate {
    display: flex; position: fixed; inset: 0; z-index: 1100;
    background: var(--cream); align-items: center; justify-content: center;
    text-align: center; padding: 24px;
  }
  #app, #splash, #install, .sheet, .modal { display: none !important; }
}
.rotate-emoji { font-size: 44px; margin-bottom: 12px; }
.rotate-card p { font-size: 19px; font-weight: 700; color: var(--charcoal); }
.rotate-card span { color: var(--charcoal-2); font-size: 14px; }

/* ---------- Add-to-home-screen guide ---------- */
.install {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100dvh;            /* visible viewport → true vertical centering on phones */
  z-index: 950;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 24px) 22px calc(env(safe-area-inset-bottom) + 24px);
}
.install.hidden { display: none; }
/* margin auto centers it AND still allows scrolling if it's taller than the screen */
.install-card { width: 100%; max-width: 460px; text-align: center; margin: auto 0; }
.install-logo { height: 40px; width: auto; max-width: 80%; display: block; margin: 0 auto 20px; }
.install-title { font-size: 23px; font-weight: 800; letter-spacing: -0.3px; color: var(--charcoal); }
.install-sub { color: var(--charcoal-2); font-size: 15.5px; margin: 8px 0 26px; }
.install-steps { list-style: none; text-align: left; display: flex; flex-direction: column; gap: 12px; margin: 0 0 24px; padding: 0; }
.install-steps li {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 16px; padding: 15px 16px;
  box-shadow: var(--shadow);
}
.install-steps li p { font-size: 15.5px; line-height: 1.45; color: var(--charcoal); }
.install-steps li b { font-weight: 700; }
.install-steps li span {
  flex: 0 0 auto; width: 26px; height: 26px;
  border-radius: 50%; background: var(--pink); color: #fff;
  font-weight: 800; font-size: 14px; display: grid; place-items: center;
}
.ios-share { width: 18px; height: 18px; vertical-align: -4px; color: var(--pink); margin: 0 1px; }
.install-other {
  background: #fff; border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow); color: var(--charcoal); margin-bottom: 24px; font-size: 15.5px;
}
.btn-install-done {
  width: 100%; border: none; background: var(--pink); color: #fff;
  border-radius: 16px; padding: 16px; font-size: 16.5px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
}
.btn-install-done:active { transform: scale(.98); }
.btn-install-later {
  width: 100%; border: none; background: transparent; color: var(--charcoal-2);
  padding: 14px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px;
}

/* ---------- Splash overlay (every launch, 2s) ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #FBF7F5;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .45s ease;
  will-change: opacity;            /* own compositing layer → smooth fade */
  transform: translateZ(0);
  backface-visibility: hidden;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: translateZ(0);
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--cream);
  color: var(--charcoal);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.app-header {
  padding: calc(env(safe-area-inset-top) + 18px) 20px 6px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--cream) 70%, rgba(251, 247, 245, 0));
  z-index: 5;
}
.header-row { display: flex; align-items: center; justify-content: center; gap: 10px; }

/* share button — top right, doesn't disturb the centered logo */
.share-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 20px);
  right: 16px;
  z-index: 6;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--cream-2);
  color: var(--pink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease;
}
.share-btn:active { transform: scale(.9); }
.share-btn svg { width: 20px; height: 20px; }

/* centered share popup */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(51, 48, 46, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade .2s ease;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  background: var(--cream);
  border-radius: 24px;
  padding: 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 18px 50px rgba(51, 48, 46, 0.3);
  animation: slideup .25s ease;
}
.share-native {
  position: absolute;
  top: 14px; right: 14px;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--cream-2);
  color: var(--pink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease;
}
.share-native:active { transform: scale(.9); }
.share-native svg { width: 19px; height: 19px; }
.modal-title { font-size: 21px; font-weight: 800; letter-spacing: -0.3px; }
.modal-sub { color: var(--charcoal-2); font-size: 14.5px; margin: 6px 0 18px; }
.share-qr {
  width: 220px; height: 220px;
  display: block;
  margin: 0 auto 20px;
  background: #fff;
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}
.modal-btn { width: 100%; }
.app-logo-wrap { margin: 0; line-height: 0; }
.app-logo {
  height: 45px;
  width: auto;
  max-width: 90vw;
  display: block;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none; /* no iOS image popup on long-press */
}
.subtitle { margin: 40px 0 0; color: var(--charcoal-2); font-size: 14px; font-weight: 500; }

.bell-btn {
  border: none;
  background: var(--cream-2);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: transform .12s ease, background .2s;
}
.bell-btn:active { transform: scale(.9); }
.bell-btn.is-on { background: var(--pink-soft); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  background: var(--cream-2);
  border-radius: 14px;
  padding: 4px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  color: var(--charcoal-2);
  cursor: pointer;
  transition: all .18s ease;
}
.tab.is-active {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 3px 10px var(--accent-glow);
}

/* ---------- Main / lists ---------- */
#main { flex: 1; padding: 14px 16px 130px; }
.view.hidden, .hidden { display: none !important; }

.task-list { list-style: none; margin: 0; padding: 0; }

.task {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: #fff;
  border-radius: 16px;
  padding: 16px 15px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: opacity .25s ease, transform .12s ease, box-shadow .2s ease;
  animation: pop .22s ease;
}
.task:active { transform: scale(.985); }

/* dragging row follows the finger with no lag and lifts off the page */
.task.dragging {
  transition: none;
  z-index: 10;
  box-shadow: 0 14px 30px rgba(51, 48, 46, 0.22);
  cursor: grabbing;
  opacity: 0.97;
}

/* grip handle (≡) on the right */
.drag-handle {
  flex: 0 0 auto;
  align-self: center;
  width: 34px;
  margin: -10px -6px -10px 0;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  cursor: grab;
  touch-action: none;            /* let us own the gesture instead of scrolling */
}
.drag-handle span {
  display: block;
  height: 2.5px;
  width: 18px;
  border-radius: 2px;
  background: #D9CFC9;
}
.drag-handle:active { cursor: grabbing; }
.task.done .drag-handle { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.check {
  position: relative;
  flex: 0 0 auto;
  align-self: center;        /* center the circle with the colored bar */
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2.5px solid var(--pink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .2s ease;
}
/* invisible, larger tap area so the circle is easy to hit */
.check::before {
  content: '';
  position: absolute;
  inset: -12px;
}
.check:active { transform: scale(.85); }
.check svg { width: 14px; height: 14px; opacity: 0; transform: scale(.4); transition: all .2s ease; }

.task-body { flex: 1; min-width: 0; }
.task-text {
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--charcoal);
  word-break: break-word;
  transition: color .25s ease;
}
.task-meta {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--pink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-note {
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--charcoal-2);
  white-space: pre-wrap;
  word-break: break-word;
  padding-left: 10px;
  border-left: 2px solid var(--sage);
}
.task.done .task-note { border-left-color: #D9CFC9; }

/* Done state — crossed out, NOT deleted */
.task.done { opacity: 0.62; }
.task.done .check { background: var(--sage); border-color: var(--sage); }
.task.done .check svg { opacity: 1; transform: scale(1); }
.task.done .task-text {
  text-decoration: line-through;
  text-decoration-color: var(--pink);
  text-decoration-thickness: 2px;
  color: var(--charcoal-2);
}
.task.done .task-meta { color: var(--sage); }

/* ---------- Done divider ---------- */
.done-block { margin-top: 22px; }
.done-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 12px;
}
.done-divider span {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--sage);
}
.clear-done {
  border: none; background: none;
  color: var(--charcoal-2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

/* ---------- History ---------- */
.history-day { margin-bottom: 24px; }
.history-day h3 {
  margin: 0 4px 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--charcoal);
}
.history-day .count { color: var(--sage); font-weight: 700; }

/* ---------- Empty ---------- */
.empty {
  text-align: center;
  color: var(--charcoal-2);
  font-size: 15.5px;
  line-height: 1.6;
  margin-top: 60px;
  font-weight: 500;
}

/* ---------- Powered by ---------- */
.powered {
  text-align: center;
  font-size: 12px;
  color: var(--charcoal-2);
  padding: 26px 0 6px;
  opacity: .8;
}
.powered a { color: var(--pink); text-decoration: none; font-weight: 700; }
.powered-by { margin-top: 10px; }
.support-link {
  border: none; background: none; cursor: pointer;
  color: var(--pink); font-weight: 700; font-size: 13px; font-family: inherit;
  padding: 4px;
}

/* modal text inputs (support) */
.modal-input {
  width: 100%; border: none; background: #fff; border-radius: 14px;
  padding: 14px 15px; font-size: 16px; color: var(--charcoal);
  box-shadow: var(--shadow); outline: none; margin-bottom: 12px;
  font-family: inherit;
}
textarea.modal-input { resize: none; line-height: 1.45; }
.modal-input:focus { box-shadow: 0 0 0 3px var(--pink-soft), var(--shadow); }
.modal-note { font-size: 13px; min-height: 18px; margin: 0 0 6px; }
.modal-note.ok { color: var(--sage); font-weight: 600; }
.modal-note.err { color: #D9728F; font-weight: 600; }
.modal-card .modal-btn { margin-top: 2px; }
.modal-card .btn-ghost { width: 100%; background: transparent; }

/* ---------- Add bar ---------- */
.add-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(rgba(251,247,245,0), var(--cream) 28%);
}
#task-input {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 16.5px;
  color: var(--charcoal);
  box-shadow: var(--shadow);
  outline: none;
}
#task-input::placeholder { color: #B8B0AB; }
#task-input:focus { box-shadow: 0 0 0 3px var(--pink-soft), var(--shadow); }

.add-btn, .mic-btn {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  border: none;
  border-radius: 50%;
  font-size: 26px;
  cursor: pointer;
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.add-btn { background: var(--pink); line-height: 0; }
.mic-btn { background: #F4E8A6; color: #8A7B3A; font-size: 20px; }
.add-btn:active, .mic-btn:active { transform: scale(.9); }
.mic-btn.listening { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(127,179,166,.5); } 50% { box-shadow: 0 0 0 10px rgba(127,179,166,0); } }

/* ---------- Time sheet ---------- */
.sheet {
  position: fixed; inset: 0;
  background: rgba(51,48,46,.35);
  display: flex; align-items: flex-end;
  z-index: 20;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-card {
  background: var(--cream);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 24px 24px 0 0;
  padding: 24px 22px calc(env(safe-area-inset-bottom) + 24px);
  animation: slideup .25s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#time-input, #edit-input, #note-input {
  width: 100%;
  border: none;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  font-size: 18px;
  box-shadow: var(--shadow);
  outline: none;
}
#note-input {
  font-size: 16.5px;
  font-family: inherit;
  line-height: 1.45;
  resize: none;
  -webkit-appearance: none;
}
#edit-input:focus, #note-input:focus { box-shadow: 0 0 0 3px var(--pink-soft), var(--shadow); }

/* action menu rows */
.action-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.action {
  text-align: left;
  border: none;
  background: #fff;
  border-radius: 14px;
  padding: 16px 17px;
  font-size: 16.5px;
  font-weight: 600;
  color: var(--charcoal);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease;
}
.action:active { transform: scale(.98); }
.action.danger { color: #D23F6B; }
.action.selected {
  background: var(--pink);
  color: #fff;
  box-shadow: 0 3px 10px var(--accent-glow);
}
.btn-ghost.full { flex: none; width: 100%; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn-ghost, .btn-primary {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost { background: var(--cream-2); color: var(--charcoal-2); }
.btn-primary { background: var(--pink); color: #fff; }

/* ---------- Lists / buckets ---------- */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: none;
  background: var(--cream-2);
  color: var(--charcoal-2);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.chip.is-active { background: var(--charcoal); color: #fff; }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; }
.chip-add { color: var(--pink); font-size: 17px; font-weight: 600; padding: 9px 14px; }
.chip-edit { color: var(--charcoal-2); }

/* colored edge stripe showing a task's list */
.task-stripe {
  position: absolute;
  left: 6px;
  top: 12px;
  bottom: 12px;
  width: 5px;
  border-radius: 5px;
  background: transparent;
}
.task.done .task-stripe { opacity: .5; }

.task-tag {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}

/* dots inside the list-picker sheet */
.opt-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: -2px;
}

/* manage-lists sheet */
.manage-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.manage-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-btn {
  border: none;
  background: var(--cream-2);
  color: var(--charcoal-2);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn.danger { color: #D23F6B; }
.manage-empty { color: var(--charcoal-2); text-align: center; padding: 8px; }
.sheet-note { margin: 2px 4px 14px; font-size: 13.5px; font-weight: 500; color: var(--charcoal-2); text-align: center; }
.btn-primary.full, .btn-ghost.full { flex: none; width: 100%; }

/* ---------- Toast hint ---------- */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  max-width: 86vw;
  background: var(--charcoal);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(51, 48, 46, 0.28);
  z-index: 1200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
