:root {
  --todoist-red: #dc4c3e;
  --text-primary: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-muted: #8e8e93;
  --divider: #f0f0f0;
  --bg-page: #f3f4f6;
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.phone-frame {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ios-status-bar {
  display: none;
}

@media (min-width: 768px) {
  .stage {
    padding: 24px;
  }
  .phone-frame {
    width: 393px;
    height: 852px;
    border-radius: 52px;
    border: 10px solid #1c1c1e;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.22);
  }
  .ios-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 26px 4px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.92);
    flex-shrink: 0;
  }
  .dynamic-island {
    width: 104px;
    height: 28px;
    background: #1c1c1e;
    border-radius: 999px;
  }
  .status-icons {
    display: flex;
    align-items: center;
    gap: 5px;
  }
}

/* TopBar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.top-bar-spacer {
  width: 84px;
}

.top-bar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.top-bar-actions {
  position: relative;
  width: 84px;
  display: flex;
  justify-content: flex-end;
}

.liquid-pill {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
}

.top-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.pill-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
}

.pill-icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.popover-menu {
  position: absolute;
  right: 0;
  top: 44px;
  width: 210px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(24px);
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  padding: 6px 0;
  z-index: 60;
}

.popover-item {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.popover-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.popover-item.danger {
  color: var(--todoist-red);
}

.popover-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 4px 0;
}

/* Task List */
.task-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 112px;
  scrollbar-width: none;
}
.task-list-scroll::-webkit-scrollbar {
  display: none;
}

.section-header {
  margin-top: 14px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #efefef;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.section-header.drop-active {
  background: rgba(220, 76, 62, 0.08);
  border-bottom: 2px solid var(--todoist-red);
}

.section-toggle-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-count {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.section-add-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-add-btn:hover {
  color: var(--todoist-red);
  background: rgba(0, 0, 0, 0.04);
}

/* Task Row */
.task-row-wrap {
  position: relative;
  user-select: none;
  transition: opacity 150ms ease;
}

.task-row-wrap.dragging {
  opacity: 0.35;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
}

.task-row:active {
  background: rgba(0, 0, 0, 0.025);
}

.task-checkbox {
  margin-top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1.75px solid #8e8e93;
  background: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  color: #fff;
  transition: transform 150ms ease;
}

.task-checkbox.p1 {
  border-color: #dc4c3e;
  background: rgba(220, 76, 62, 0.08);
}
.task-checkbox.p2 {
  border-color: #eb8909;
  background: rgba(235, 137, 9, 0.08);
}
.task-checkbox.p3 {
  border-color: #246fe0;
  background: rgba(36, 111, 224, 0.08);
}

.task-checkbox.checked {
  background: #8e8e93;
  border-color: #8e8e93;
  animation: checkPop 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.task-checkbox.checked.p1 {
  background: #dc4c3e;
  border-color: #dc4c3e;
}
.task-checkbox.checked.p2 {
  background: #eb8909;
  border-color: #eb8909;
}
.task-checkbox.checked.p3 {
  background: #246fe0;
  border-color: #246fe0;
}

@keyframes checkPop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.task-content {
  flex: 1;
  min-width: 0;
}

.task-title {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  word-break: break-word;
}

.task-title.completed {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-desc {
  margin: 2px 0 0;
  font-size: 13.5px;
  line-height: 1.3;
  color: var(--text-secondary);
}

.task-meta {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta-due.today {
  color: #058527;
}
.meta-due.tomorrow {
  color: #eb8909;
}

.task-chevron-btn {
  border: none;
  background: transparent;
  padding: 4px;
  margin-right: -4px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-chevron-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.row-divider {
  height: 1px;
  background: var(--divider);
}

/* Smooth Todoist Red Insertion Line (No Text Clue) */
.insertion-line {
  position: absolute;
  right: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: left 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.insertion-line.top {
  top: -1px;
}
.insertion-line.bottom {
  bottom: -1px;
}

.insertion-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--todoist-red);
  margin-left: -3px;
  flex-shrink: 0;
}

.insertion-bar {
  height: 2px;
  width: 100%;
  background: var(--todoist-red);
  border-radius: 999px;
}

/* Drag Ghost */
.drag-ghost {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 14px;
  font-weight: 500;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* FAB & Bottom Tab Bar */
.fab-add {
  position: absolute;
  right: 20px;
  bottom: 84px;
  z-index: 30;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 999px;
  background: var(--todoist-red);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(220, 76, 62, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.fab-add:active {
  transform: scale(0.95);
}

.bottom-tab-wrap {
  position: sticky;
  bottom: 0;
  z-index: 30;
  padding: 8px 16px 16px;
  pointer-events: none;
}

.bottom-tab-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-primary);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(0, 0, 0, 0.06);
  color: var(--todoist-red);
  font-weight: 600;
}

/* Undo Toast */
.undo-toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 92px;
  z-index: 40;
  background: rgba(28, 28, 30, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.undo-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.undo-btn {
  border: none;
  background: transparent;
  color: #ff7e73;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* Bottom Sheets */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
}

.bottom-sheet {
  width: 100%;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 10px 16px 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18);
}

.detail-sheet {
  max-height: 82%;
  overflow-y: auto;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sheet-close {
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.qa-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  padding: 4px 0;
}

.qa-desc-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 13.5px;
  color: var(--text-secondary);
  padding: 4px 0 10px;
}

.qa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.qa-select {
  border: none;
  background: #f5f5f7;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
}

.qa-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 10px;
}

.qa-tags-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 12.5px;
}

.qa-submit-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: var(--todoist-red);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-delete-btn {
  border: none;
  background: rgba(220, 76, 62, 0.1);
  color: var(--todoist-red);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.detail-main-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.detail-inputs {
  flex: 1;
}

.dt-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 17px;
  font-weight: 600;
}

.dt-desc-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-secondary);
  resize: none;
  margin-top: 4px;
}

.dt-priority-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.dt-label {
  font-size: 12px;
  color: var(--text-muted);
}

.prio-pill {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.prio-pill.active {
  border-color: var(--todoist-red);
  background: rgba(220, 76, 62, 0.1);
  color: var(--todoist-red);
}

.dt-subtasks-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.dt-subtasks-heading {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.dt-subtasks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dt-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.dt-add-sub-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.dt-plus {
  color: var(--todoist-red);
  font-size: 18px;
  font-weight: 600;
}

.dt-add-sub-form input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
}

.dt-add-sub-btn {
  border: none;
  background: transparent;
  color: var(--todoist-red);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
}

/* Desktop Research Panel */
.research-panel {
  display: none;
}

@media (min-width: 768px) {
  .research-panel {
    display: flex;
    flex-direction: column;
    width: 340px;
    height: 852px;
    background: #fff;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    padding: 20px;
  }
}

.rp-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.rp-header p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.rp-header {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.rp-label {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.rp-card {
  background: #f9f9fb;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #3a3a3c;
  margin-bottom: 8px;
}

.rp-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.rp-btn {
  flex: 1;
  border: none;
  background: #f5f5f7;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
}

.rp-btn.danger {
  background: rgba(220, 76, 62, 0.1);
  color: var(--todoist-red);
}

.rp-log-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rp-log-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rp-log-item {
  background: #f9f9fb;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
}

.rp-log-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rp-log-action {
  font-weight: 600;
  color: var(--todoist-red);
}

.rp-log-time {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: monospace;
}

.rp-log-detail {
  margin: 3px 0 0;
  color: #3a3a3c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full Page Mode */
body.full-page {
  background: #ffffff;
}

body.full-page .stage {
  padding: 0;
}

body.full-page .research-panel,
body.full-page .ios-status-bar {
  display: none !important;
}

body.full-page .phone-frame {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

body.full-page .task-list-scroll {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

body.full-page .bottom-tab-bar {
  max-width: 440px;
  margin: 0 auto;
}

body.full-page .undo-toast {
  max-width: 440px;
  margin: 0 auto;
}

body.full-page .bottom-sheet {
  max-width: 600px;
  margin: 0 auto;
}

