/* ─── Tasks Widget ─── */
.tasks-widget {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  z-index: 997;
}

.tw-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 28px;
  min-height: 200px;
  padding: 8px 0;
  background: var(--primary);
  color: #fff;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.18);
  user-select: none;
  transition: background 0.15s;
}
.tw-bar:hover { background: #1d4ed8; }

.tasks-widget.expanded .tw-bar { display: none; }

.tw-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  width: 28px;
  height: 24px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.tw-toggle:hover { background: rgba(255,255,255,0.2); }
.tw-toggle svg { display: block; }

.tw-badge {
  font-size: 1.1rem;
  font-weight: 800;
  min-width: 26px;
  text-align: center;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0 8px;
  line-height: 26px;
  margin-top: 2px;
}

/* ─── Expanded panel ─── */
.tw-panel {
  display: none;
  width: 570px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 100px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 12px 12px 0;
  box-shadow: 4px 4px 24px rgba(0,0,0,0.13);
  flex-direction: column;
  overflow: hidden;
}
.tasks-widget.expanded .tw-panel { display: flex; }

@keyframes twSlideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.tasks-widget.expanded .tw-panel {
  animation: twSlideIn 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes twSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-100%); opacity: 0; }
}
.tasks-widget.tw-leaving .tw-panel {
  animation: twSlideOut 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.tw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.tw-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
}

.tw-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  width: 26px;
  height: 26px;
  transition: background 0.15s, color 0.15s;
}
.tw-close:hover { background: var(--secondary); color: var(--text); }

.tw-body {
  flex: 1;
  overflow-y: auto;
  max-height: 350px;
  padding: 2px 0;
}

.tw-spin-cont {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.tw-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  transition: background 0.15s;
  min-height: 48px;
}
.tw-row:hover { background: var(--secondary); }
.tw-row.tw-done { opacity: 0.65; }

.tw-cbw {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
}
.tw-cb {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  margin: 0;
}
.tw-cbm {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.tw-cb:checked + .tw-cbm {
  background: var(--primary);
  border-color: var(--primary);
}
.tw-cb:checked + .tw-cbm::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -1px;
}

.tw-inp {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.2rem 0;
  min-width: 0;
  outline: none;
  font-family: inherit;
}
.tw-inp:focus { color: var(--primary); }
.tw-done .tw-inp {
  text-decoration: line-through;
  color: var(--text-muted);
}

.tw-del {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
  padding: 0;
}
.tw-row:hover .tw-del { opacity: 1; }
.tw-del:hover { background: var(--secondary); color: #ef4444; }

.tw-div {
  height: 1px;
  background: var(--border);
  margin: 4px 1rem;
}

.tw-none {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 600;
}

.tw-add {
  display: block;
  width: calc(100% - 2rem);
  margin: 0.5rem 1rem;
  padding: 0.6rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s;
  text-align: center;
  font-family: inherit;
}
.tw-add:hover {
  opacity: 0.88;
}

/* ─── Inline add-task form (used in widget + dashboard) ─── */
.inline-task-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
}
.inline-task-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
}
.inline-task-input:focus {
  border-color: var(--primary);
}
.inline-task-submit {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.inline-task-submit:hover {
  opacity: 0.88;
}
.inline-task-cancel {
  background: none;
  border: 1px solid #ef4444;
  border-radius: 6px;
  color: #ef4444;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  font-family: inherit;
}
.inline-task-cancel:hover {
  background: #fef2f2;
}
