/* Task drawer, discussion threads, card quick actions and the activity feed. */

/* ---------- Card footer ---------- */

.task-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 14px 11px;
}

.task-foot:empty {
  display: none;
}

.note-chip {
  max-width: 150px;
  overflow: hidden;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--text);
  font: 500 12.5px/1.3 var(--f-body);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.note-chip:hover {
  border-color: var(--lime);
  color: var(--lime-hi);
}

.task-count {
  color: var(--dim);
  font-size: 12.5px;
}

.task-next {
  margin-left: auto;
  min-height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--dim);
  font: 600 12.5px/1 var(--f-body);
  cursor: pointer;
}

.task-next:hover {
  background: rgba(139, 198, 65, 0.12);
  color: var(--lime);
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--lime-hi);
  color: var(--on-lime);
  font-size: 11px;
  letter-spacing: 0;
  text-align: center;
}

/* ---------- Drawer ---------- */

.drawer {
  width: min(100%, 520px);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 4px solid var(--task-color, var(--line));
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}

.drawer[open] {
  display: flex;
  flex-direction: column;
}

.drawer::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-head .icon-btn {
  margin-left: 0;
  flex-shrink: 0;
}

.drawer-heading {
  flex: 1;
  min-width: 0;
}

.drawer-heading h2 {
  margin: 3px 0;
  font: 700 1.55rem/1.1 var(--f-display);
  overflow-wrap: anywhere;
}

.drawer-who {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.drawer-scroll > .chips {
  display: inline-flex;
}

.drawer-notes {
  margin: 16px 0 0;
  color: #d6dfca;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.drawer-section {
  margin-top: 24px;
}

.drawer-section h3,
.note-thread > h2 {
  margin: 0 0 10px;
  color: var(--muted);
  font: 600 14px/1.2 var(--f-body);
}

.drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.drawer-section-head h3 {
  margin: 0;
}

.drawer-links {
  display: grid;
  gap: 6px;
}

.linked-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.linked-note {
  flex: 1;
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font: 400 14px/1.3 var(--f-body);
  text-align: left;
  cursor: pointer;
}

.linked-note:hover {
  border-color: var(--line-strong);
}

.linked-note b {
  color: var(--lime);
  font-weight: 600;
}

.linked-note small {
  overflow: hidden;
  color: var(--dim);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unlink,
.comment-delete {
  flex-shrink: 0;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--dim);
  font: 500 12.5px/1 var(--f-body);
  cursor: pointer;
}

.unlink:hover,
.comment-delete:hover {
  color: var(--danger);
}

/* ---------- Picker ---------- */

.picker {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.picker input {
  min-height: 40px;
  font-size: 15px;
}

.picker-results {
  display: grid;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.picker-item {
  display: grid;
  gap: 1px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font: 500 14px/1.3 var(--f-body);
  text-align: left;
  cursor: pointer;
}

.picker-item:hover,
.picker-item:focus-visible {
  border-color: var(--lime);
}

.picker-item small {
  color: var(--dim);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* ---------- Thread ---------- */

.thread {
  display: grid;
  gap: 12px;
}

.thread-list {
  display: grid;
  gap: 10px;
}

.thread-empty {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
}

.comment {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  font-size: 13.5px;
}

.comment-head b {
  color: var(--lime);
  font-weight: 600;
}

.comment-head time {
  color: var(--dim);
  font-size: 12.5px;
}

.comment-head .comment-delete {
  min-height: 22px;
  margin-left: auto;
}

.comment-body.md {
  font-size: 15px;
  line-height: 1.5;
}

.comment-body.md > :last-child {
  margin-bottom: 0;
}

.thread-compose {
  display: grid;
  gap: 8px;
}

.thread-input {
  min-height: 74px;
  font-size: 15px;
}

.thread-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.thread-hint {
  color: var(--dim);
  font-size: 12.5px;
}

/* ---------- Note discussion and links ---------- */

.note-work {
  flex: 1;
  min-height: 0;
  display: flex;
}

.note-work .note-body {
  flex: 1;
  min-width: 0;
}

.note-thread {
  width: 340px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px;
  border-left: 1px solid var(--line);
  background: var(--bg-2);
}

.backlink-task {
  border-color: var(--line);
  color: var(--text);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backlink-add {
  border-style: dashed;
  color: var(--muted);
}

/* ---------- Activity ---------- */

.activity {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px var(--gutter) 60px;
}

.activity-feed {
  display: grid;
  gap: 2px;
}

.activity-day {
  margin: 20px 0 6px;
  color: var(--muted);
  font: 600 14px/1.2 var(--f-body);
}

.activity-day:first-child {
  margin-top: 0;
}

.activity-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 14px;
  padding: 9px 12px;
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--panel);
}

.kind-comment {
  border-left-color: var(--lime);
}

.kind-note {
  border-left-color: #5b9df5;
}

.kind-task {
  border-left-color: #a47bf0;
}

.activity-text {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.activity-text b {
  color: var(--text);
  font-weight: 600;
}

.activity-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--lime);
  font: 600 15px/1.4 var(--f-body);
  text-align: left;
  cursor: pointer;
}

.activity-link:hover {
  text-decoration: underline;
}

.activity-entry time {
  grid-column: 2;
  grid-row: 1;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
}

.activity-quote {
  grid-column: 1 / -1;
  margin: 3px 0 0;
  color: var(--dim);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.activity-more {
  display: block;
  margin: 18px auto 0;
}

.activity-more[hidden] {
  display: none;
}

/* ---------- Phones ---------- */

@media (max-width: 760px) {
  .note-work {
    flex-direction: column;
  }

  .note-thread {
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .drawer {
    width: 100%;
    border-left-width: 3px;
  }
}

/* ---------- AI bundle ---------- */

.drawer.workbench {
  width: min(100%, 640px);
  border-left-color: var(--lime);
}

#open-workbench {
  flex-shrink: 0;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bundle-section {
  margin-bottom: 20px;
}

.bundle-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font: 600 14px/1.2 var(--f-body);
}

.bundle-section .drawer-section-head h3 {
  margin: 0;
}

.bundle-list {
  display: grid;
  gap: 5px;
}

.bundle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}

.bundle-auto {
  border-style: dashed;
  background: none;
}

.bundle-label {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.bundle-label b {
  font-size: 14.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.bundle-label small {
  color: var(--dim);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.bundle-tag {
  flex-shrink: 0;
  color: var(--dim);
  font-size: 12.5px;
}

.bundle-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 8px;
}

.bundle-check {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.bundle-check input {
  width: 16px;
  min-height: 0;
  height: 16px;
  accent-color: var(--lime);
}

.bundle-rules {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
}

.bundle-preview {
  min-height: 240px;
  font: 500 13px/1.5 var(--f-mono);
  resize: vertical;
}

.bundle-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.bundle-size {
  margin-right: auto;
  color: var(--muted);
  font-size: 14px;
}

.bundle-size.too-big {
  color: var(--danger);
}
