/* Theme tokens */
:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --surface-hover: #f8fafc;
  --border: #e5e5e5;
  --border-strong: #0f172a;
  --border-color: #e5e7eb;
  --muted: #666;
  --text: #111;
  --text-primary: #111827;
  --text-muted: #6b7280;
  --accent: #3b82f6;
  --bg-elevated: #f3f4f6;
  --bg-card: #fff;
  --bg-hover: #f3f4f6;
  --danger: #ef4444;
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.2);
  --shadow-strong: 0 10px 24px rgba(15, 23, 42, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --mobile-keyboard-inset: 0px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Base elements */
body {
  margin: 0 auto;
  padding: 0.5rem 2rem;
  max-width: 1400px;
}
h1, h2, h3 {
  color: #1e293b;
}
h1 {
  margin: 0;
  font-size: 1.4rem;
}
.todo-list, .sidebar-nav, .doc-items, .delegation-list, .agent-timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
button {
  border: none;
  background: var(--text);
  color: var(--surface);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
a {
  color: inherit;
}
:where(.auth-panel, .summary-panel, .summary-card, .tag-filter-bar, .tag-input-wrapper, li) {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Layout helpers */
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.pill {
  border-radius: 999px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.muted {
  color: var(--muted);
}
[x-cloak] {
  display: none !important;
}

/* Header / session */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0;
  min-height: 40px;
}
.logo-icon {
  width: 24px;
  height: 24px;
}
.session-controls {
  position: relative;
  min-height: 48px;
  min-width: 48px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 0.65rem;
}
.avatar-chip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.avatar-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-strong);
}

/* Sync status ring indicators */
.avatar-chip.sync-status-synced {
  box-shadow: 0 0 0 3px #22c55e, var(--shadow-soft); /* green */
}
.avatar-chip.sync-status-unsynced {
  box-shadow: 0 0 0 3px #f97316, var(--shadow-soft); /* orange */
}
.avatar-chip.sync-status-syncing {
  box-shadow: 0 0 0 3px #3b82f6, var(--shadow-soft); /* blue */
  animation: sync-pulse 1.5s ease-in-out infinite;
}
@keyframes sync-pulse {
  0%, 100% { box-shadow: 0 0 0 3px #3b82f6, var(--shadow-soft); }
  50% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4), var(--shadow-soft); }
}
.avatar-chip.sync-status-synced:hover,
.avatar-chip.sync-status-unsynced:hover,
.avatar-chip.sync-status-syncing:hover {
  transform: translateY(-1px);
}

.avatar-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-fallback {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.25rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
  min-width: 140px;
  z-index: 20;
}
.avatar-menu-header {
  padding: 0.5rem 0.75rem 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.avatar-menu-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}
.avatar-menu button {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.5rem 0.75rem;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text);
}
.avatar-menu button:hover {
  background: #f3f4f6;
}
.subtitle {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Forms / hero */
.hero-entry {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: none;
}
.todo-form {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.todo-list-view {
  width: 100%;
}
.hero-input-wrapper {
  width: 100%;
}
.hero-input {
  display: block;
  padding: 0.85rem 1rem;
  width: 100%;
  font-size: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-sizing: border-box;
  line-height: 1.3;
  background: var(--surface);
  box-shadow: none;
}
.hero-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.25);
}
.remaining-summary {
  margin: 0 0 1rem;
  color: #333;
  font-weight: 500;
}
.hero-hint {
  margin: 0.5rem 0 0;
  color: #555;
  font-size: 0.9rem;
}
.hero-input:disabled {
  background: #f5f5f5;
  border-color: #ddd;
  cursor: not-allowed;
}

/* Lists */
.todo-list > li, .doc-items > li, .delegation-list > li, .agent-timeline > li {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.todo-title {
  font-weight: 600;
  flex: 1;
}
.badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
}
.badge {
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  text-transform: capitalize;
  border: 1px solid #ddd;
}
.badge.priority-rock {
  background: #ffe3e3;
  border-color: #f5b5b5;
}
.badge.priority-pebble {
  background: #fff1d6;
  border-color: #f5c97c;
}
.badge.priority-sand {
  background: #e9f4ff;
  border-color: #b5d8ff;
}
.badge.state-done {
  background: #e7f8e9;
  border-color: #b0e2b8;
}
.badge.state-in_progress {
  background: #f0e8ff;
  border-color: #cdbdff;
}
.badge.state-review {
  background: #fef3c7;
  border-color: #fcd34d;
}
.badge.state-ready {
  background: #fff2f0;
  border-color: #ffcfc3;
}
.badge.state-new {
  background: #f5f5f5;
  border-color: #ddd;
}
.badge.state-archive {
  background: #f0f0f0;
  border-color: #999;
  color: #666;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: #1e40af;
}
.tag-chip .remove-tag {
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.6;
}
.tag-chip .remove-tag:hover {
  opacity: 1;
}
.tags-display {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.4rem;
  min-height: 2.2rem;
  align-items: center;
  cursor: text;
}
.tag-input-wrapper:focus-within {
  border-color: #666;
  outline: none;
}
.tag-input-wrapper input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 60px;
  font-size: 0.9rem;
  padding: 0.2rem;
}
.tag-filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}
.tag-filter-bar .label {
  font-size: 0.85rem;
  color: var(--muted);
}
.tag-filter-bar .tag-chip {
  cursor: pointer;
}
.tag-filter-bar .tag-chip.active {
  background: #1e40af;
  color: #fff;
  border-color: #1e40af;
}
.tag-filter-bar .clear-filters {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.bulk-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.bulk-actions-bar .label {
  font-size: 0.85rem;
  color: #374151;
  font-weight: 600;
}
.bulk-actions-bar button {
  border-radius: var(--radius-sm);
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.bulk-actions-bar .btn-bulk-archive {
  color: #047857;
  border-color: #a7f3d0;
}
.bulk-actions-bar .btn-bulk-delete {
  color: #b91c1c;
  border-color: #fecaca;
}
.bulk-actions-bar .btn-bulk-clear {
  color: #4b5563;
}
.todo-body {
  margin-top: 0.75rem;
  border-top: 1px solid #f0f0f0;
  padding-top: 0.75rem;
  display: grid;
  gap: 0.75rem;
}
.todo-description {
  margin: 0;
  color: #444;
  white-space: pre-wrap;
}
.todo-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.edit-form {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}
.edit-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.76rem;
  color: #475569;
  gap: 0.35rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.edit-form input,
.edit-form textarea,
.edit-form select {
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
  border-radius: 10px;
  border: 1px solid #d9e2ec;
  background: #fbfdff;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  color: #0f172a;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.edit-form select {
  max-width: 100%;
}
.edit-form input:focus,
.edit-form textarea:focus,
.edit-form select:focus {
  outline: none;
  border-color: #7da2ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
  background: #ffffff;
}
.edit-form textarea.auto-expand {
  min-height: calc(3 * 1.5em + 0.7rem);
  max-height: calc(10 * 1.5em + 0.7rem);
  overflow-y: auto;
  resize: vertical;
  line-height: 1.5;
}
/* Two-column row for compact fields */
.edit-form .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 400px) {
  .edit-form .field-row {
    grid-template-columns: 1fr;
  }
}
/* Separator between form sections */
.edit-form .form-divider {
  border: none;
  border-top: 1px solid #e7edf5;
  margin: 0.35rem 0;
}
.work-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  border-top: 1px solid #ddd;
  padding-top: 1rem;
}
.work-header h2 {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.remaining-inline {
  font-size: 0.92rem;
  color: var(--muted);
  font-weight: 500;
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.archive-section {
  margin-top: 2rem;
}
.archive-toggle {
  text-decoration: none;
  font-size: 0.9rem;
  color: #111;
  border: 1px solid #ddd;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}
.compact-toggle {
  text-decoration: none;
  font-size: 0.82rem;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}
.compact-toggle.active {
  border-color: #1d4ed8;
  color: #1d4ed8;
  background: #eff6ff;
}
.select-many-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 999px;
  font-size: 0.82rem;
  padding: 0.2rem 0.65rem;
  cursor: pointer;
}
.select-many-btn.active {
  border-color: #1d4ed8;
  color: #1d4ed8;
  background: #eff6ff;
}
.mobile-task-action-select {
  display: none;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 999px;
  font-size: 0.82rem;
  padding: 0.26rem 0.65rem;
}

/* Auth panel */
.auth-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}
.auth-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}
.auth-description {
  margin: 0 0 1rem;
  color: #555;
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.auth-option {
  padding: 0.75rem 1rem;
  border: 1px solid var(--text);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.auth-option:hover:not(:disabled) {
  background: var(--text);
  color: var(--surface);
}
.auth-option:disabled {
  opacity: 0.6;
  cursor: progress;
}
.auth-extension,
.auth-keyteleport {
  background: #f5f5f5;
  color: #666;
  border-color: #999;
}
.auth-extension:hover:not(:disabled),
.auth-extension:active:not(:disabled),
.auth-keyteleport:hover:not(:disabled),
.auth-keyteleport:active:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.auth-advanced {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #ddd;
}
.auth-advanced summary {
  cursor: pointer;
  color: #333;
  font-weight: 600;
}
.auth-advanced .auth-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.auth-advanced input {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
}
.auth-advanced .auth-option {
  width: 100%;
}
.auth-divider {
  width: 80%;
  border: none;
  border-top: 1px solid #ddd;
  margin: 1rem auto;
}
.bunker-submit {
  align-self: flex-start;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  border: none;
  cursor: pointer;
}
.auth-error {
  margin-top: 0.75rem;
  color: #b91c1c;
  font-size: 0.9rem;
  padding: 0.5rem;
  background: #fee2e2;
  border-radius: 8px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  overflow-y: auto;
  padding: 1rem;
  box-sizing: border-box;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 340px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  margin: 0 auto;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover {
  color: #111;
}
.modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}
.modal p {
  margin: 0 0 1.25rem;
  color: #555;
  font-size: 0.9rem;
}
.qr-canvas-container {
  display: flex;
  justify-content: center;
}
.qr-canvas-container canvas {
  border-radius: 8px;
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

/* Key Teleport */
.teleport-modal {
  text-align: left;
}
.teleport-modal h2 {
  text-align: center;
}
.teleport-modal p {
  text-align: center;
}
.teleport-modal .hint {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1rem;
}
.teleport-npub {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}
.teleport-npub label {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.25rem;
}
.teleport-npub code {
  font-size: 0.75rem;
  word-break: break-all;
  display: block;
}
.teleport-identity {
  display: block;
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  word-break: break-all;
  text-align: center;
}
.teleport-modal .auth-form {
  margin-top: 0;
}
.teleport-modal .auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #333;
}
.teleport-modal .auth-form input {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.95rem;
}
.teleport-package-input,
.teleport-registration-output {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  line-height: 1.4;
  box-sizing: border-box;
}
.teleport-registration-label {
  margin-top: 0.75rem;
}
.teleport-copy-btn {
  margin-top: 0.75rem;
  width: 100%;
}
.teleport-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.teleport-actions .auth-option {
  flex: 1;
}
.teleport-actions .auth-option.secondary {
  background: transparent;
  border: 1px solid #ccc;
  color: #666;
}
.teleport-actions .auth-option.secondary:hover {
  background: #f5f5f5;
  color: #333;
}

/* SuperBased Modal */
.superbased-modal {
  text-align: left;
  max-width: 400px;
}
.superbased-modal h2 {
  text-align: center;
}
.superbased-modal > p {
  text-align: center;
}
.superbased-modal .auth-form {
  margin-top: 1rem;
}
.superbased-modal .auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #333;
}
.token-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.85rem;
  font-family: monospace;
  resize: vertical;
  box-sizing: border-box;
}
.superbased-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
.superbased-status.connected {
  background: #e7f8e9;
  color: #166534;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}
.superbased-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.superbased-actions .auth-option {
  flex: 1;
}
.superbased-actions .auth-option.secondary {
  background: transparent;
  border: 1px solid #ccc;
  color: #666;
}
.superbased-actions .auth-option.secondary:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}
/* Connection Details */
.superbased-connection-details {
  background: #f8fffe;
  border: 1px solid #d1fae5;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.connection-status.connected {
  color: #166534;
}
.connection-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.info-row {
  display: flex;
  gap: 0.5rem;
}
.info-label {
  color: #666;
  min-width: 70px;
}
.info-value {
  color: #333;
  word-break: break-all;
}
.info-npub {
  font-family: monospace;
  font-size: 0.8rem;
}
.connection-actions {
  display: flex;
  gap: 0.5rem;
}
.connection-actions .auth-option {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.auth-option.danger {
  background: transparent;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}
.auth-option.danger:hover {
  background: #fee2e2;
}

/* Quick Connect */
.superbased-quick-connect {
  margin-bottom: 1rem;
}
.otherstuff-connect {
  width: 100%;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  font-weight: 600;
  padding: 0.85rem 1rem;
  border: none;
}
.otherstuff-connect:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.quick-connect-divider {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  margin: 1rem 0 0.5rem;
  position: relative;
}
.quick-connect-divider::before,
.quick-connect-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: #ddd;
}
.quick-connect-divider::before {
  left: 0;
}
.quick-connect-divider::after {
  right: 0;
}

.superbased-sync-status {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed #ddd;
  text-align: center;
}
.superbased-sync-status p {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.75rem;
}

/* ===========================================
   Agent Connect Modal
   =========================================== */

.agent-connect-modal {
  max-width: 460px;
  text-align: left;
}
.agent-connect-modal h2 {
  text-align: center;
}
.agent-connect-modal > p {
  text-align: center;
  margin-bottom: 1rem;
}
.agent-connect-content {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 1rem;
}
.agent-config-json {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}
.agent-config-json code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}
.copy-button {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.copy-button:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
.copy-button.copied {
  background: #22c55e;
}

/* ===========================================
   Delegation UI Styles
   =========================================== */

.delegations-modal {
  max-width: 460px;
  text-align: left;
}
.delegations-modal h2 {
  text-align: center;
}
.delegations-modal > p {
  text-align: center;
}

.delegation-section {
  margin-bottom: 1.5rem;
}
.delegation-section:last-child {
  margin-bottom: 0;
}

.delegation-section h3 {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.delegation-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.delegation-form input[type="text"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: monospace;
  font-size: 0.85rem;
}

.permission-checkboxes {
  display: flex;
  gap: 1rem;
}

.permission-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #444;
}

.permission-checkboxes input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.delegation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.delegation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
}

.delegation-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.delegation-npub {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text);
}

.delegation-perms {
  display: flex;
  gap: 0.25rem;
}

.perm-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 500;
}

.perm-badge.read {
  background: #3b82f6;
}

.perm-badge.write {
  background: #22c55e;
}

.revoke-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: #fff;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
}

.revoke-btn:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.empty-delegations {
  color: #666;
  font-style: italic;
  text-align: center;
  padding: 1rem;
  background: transparent;
  border: none;
}

.discovered-agent {
  background: #f0f9ff;
  border-color: #93c5fd;
}

.agent-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: #6366f1;
  color: white;
  border-radius: 4px;
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 600;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.grant-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: #fff;
  color: #16a34a;
  border: 1px solid #86efac;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.grant-btn:hover {
  background: #dcfce7;
  border-color: #16a34a;
}

.grant-btn:disabled {
  color: #64748b;
  border-color: #cbd5e1;
  background: #f8fafc;
  cursor: default;
}

.delegation-hint {
  font-size: 0.8rem;
  color: #666;
  margin: 0 0 0.5rem 0;
}

.delegate-reencrypt-status {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
}

/* Assigned-to field in todo edit form */
.assigned-to-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.assigned-to-field .field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
}

.assigned-to-field input {
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 100%;
  box-sizing: border-box;
}

.assigned-to-hint {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.125rem;
}

/* Assign chip (selected assignee) */
.assign-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 0.85rem;
}

.assign-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.assign-npub-raw {
  font-family: monospace;
  font-size: 0.8rem;
  color: #666;
}

.assign-clear {
  margin-left: auto;
  cursor: pointer;
  color: #999;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
}

.assign-clear:hover {
  color: #e11d48;
}

/* Autocomplete dropdown */
.assign-autocomplete {
  position: relative;
}

.assign-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}

.assign-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: background 0.1s;
}

.assign-option:hover {
  background: #f0f4ff;
}

.assign-option-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.assign-option-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.assign-option-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #333;
}

.assign-option-npub {
  font-family: monospace;
  font-size: 0.72rem;
  color: #888;
}

/* Delegated todos indicator */
.delegated-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  background: #0ea5e9;
  color: white;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 500;
}

.loading {
  text-align: center;
  color: #666;
  padding: 1rem;
}

/* =========================================
   Todo Row (clickable list item)
   ========================================= */
.todo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}
.task-select-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}
.todo-row:hover {
  background: #f8fafc;
}

.todo-row.todo-has-unread-notes {
  border-color: #dc2626;
}

.kanban-card.todo-has-unread-notes {
  border: 1px solid #dc2626;
}

/* Share icon */
.share-icon {
  color: #a78bfa;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

/* Edit Modal */
.edit-modal {
  max-width: 640px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  text-align: left;
  padding: 1.3rem;
  border-radius: 18px;
  border: 1px solid #dce6f2;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
}

/* Footer: copy-link + actions in one row */
.edit-modal-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f0f0f0;
  margin-top: 0.25rem;
}
.edit-modal-footer .copy-link-btn {
  margin-right: auto;
}
/* Copy link + shared meta row */
.edit-modal-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.4rem 0;
  border-top: 1px solid #f0f0f0;
  margin-top: 0.25rem;
}
.copy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 120ms ease, background 120ms ease;
}
.copy-link-btn:hover {
  color: var(--accent);
  background: #eff6ff;
}
.delegate-status-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.share-icon-sm {
  color: #a78bfa;
  flex-shrink: 0;
}
.edit-modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}
.edit-modal-actions .btn-update {
  flex: 1;
  padding: 0.65rem 1rem;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #fff;
  border: 1px solid #1d4ed8;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.edit-modal-actions .btn-update:hover {
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
}
.edit-modal-actions .btn-delete {
  padding: 0.65rem 1rem;
  background: transparent;
  color: #dc2626;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.edit-modal-actions .btn-delete:hover {
  background: #fee2e2;
  border-color: #dc2626;
}
.edit-modal-actions .btn-archive {
  padding: 0.65rem 1rem;
  background: transparent;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}
.edit-modal-actions .btn-archive:hover {
  background: #ecfdf5;
  border-color: #10b981;
}

.task-detail-page {
  margin-top: 1rem;
  background: #ffffff;
  border: 1px solid #dbe5f1;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.task-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid #e5edf7;
  padding-bottom: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.task-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid #d4deea;
  background: #f8fbff;
  color: #1e293b;
  border-radius: 10px;
  padding: 0.42rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.task-detail-heading {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 0.3rem;
}

.task-detail-heading h2 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  color: #0f172a;
  word-break: break-word;
}

.task-detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.task-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.task-detail-main {
  margin: 0;
}

.task-detail-actions {
  border-top: 1px solid #e7edf5;
  padding-top: 0.8rem;
}

.task-detail-actions .edit-modal-actions {
  margin-top: 0;
}

.task-detail-notes {
  border: 1px solid #dbe7ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f8ff 100%);
  padding: 0.75rem;
}

.task-detail-notes-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.task-detail-notes-header h3 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #334155;
}

.task-detail-notes-count {
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1d4ed8;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.task-detail-notes-hint {
  margin: 0.2rem 0 0.55rem;
  color: #64748b;
  font-size: 0.76rem;
}

.task-detail-notes .task-note-add {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.task-detail-notes .task-note-add textarea {
  min-height: 3.8rem;
}

.task-detail-notes .task-note-add button {
  padding: 0.45rem 0.8rem;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}

.task-detail-notes .task-note-add button:hover {
  background: #1d4ed8;
}

.task-detail-notes-list {
  margin-top: 0.7rem;
  max-height: 420px;
}

.task-detail-notes-empty {
  color: #64748b;
  font-size: 0.85rem;
  padding: 0.4rem 0.2rem;
}

.task-detail-notes .task-note-row {
  position: relative;
  margin-left: 0.45rem;
  padding: 0.55rem 0.6rem 0.55rem 0.85rem;
  border-left: 2px solid #93c5fd;
  background: #fff;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.task-detail-notes .task-note-row::before {
  content: '';
  position: absolute;
  left: -0.38rem;
  top: 0.75rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 0 0 2px #dbeafe;
}

@media (min-width: 1080px) {
  .task-detail-layout {
    grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr);
    gap: 1.1rem;
    align-items: start;
  }

  .task-detail-notes {
    position: sticky;
    top: 0.5rem;
    max-height: calc(100vh - 180px);
    overflow: hidden;
  }

  .task-detail-notes-list {
    max-height: calc(100vh - 340px);
  }
}

/* Todo update flash animation */
@keyframes todo-saved-flash {
  0% { background-color: #d1fae5; }
  100% { background-color: var(--surface); }
}
li.todo-saved {
  animation: todo-saved-flash 600ms ease-out;
}

/* DER Delegate UI */
.delegate-badge {
  background: #a78bfa !important;
  color: #fff !important;
  font-size: 0.65rem;
}

.delegate-status-section {
  margin-top: 0.5rem;
}

.delegate-status-section label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  display: block;
}

.delegate-status-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.delegate-chip-readonly {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.delegate-chip-readonly .badge-sm {
  font-size: 0.6rem;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: rgba(0,0,0,0.08);
  color: #64748b;
}

.delegate-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: monospace;
}

.delegate-chip.read {
  background: #dbeafe;
  color: #1e40af;
}

.delegate-chip.write {
  background: #fef3c7;
  color: #92400e;
}

.delegate-chip .badge-sm {
  font-size: 0.6rem;
  padding: 0 0.2rem;
  border-radius: 3px;
  background: rgba(0,0,0,0.1);
}

.delegate-chip .remove-tag {
  cursor: pointer;
  opacity: 0.6;
}

.delegate-chip .remove-tag:hover {
  opacity: 1;
}

/* ===========================================
   AI Review Card
   =========================================== */
.ai-review-card {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.ai-review-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  user-select: none;
}
.ai-review-collapse-hint {
  font-size: 1rem;
  color: var(--muted);
  line-height: 1;
  margin-left: auto;
  padding-left: 0.5rem;
}
.ai-review-type {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  background: #818cf8;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.ai-review-date {
  font-size: 0.8rem;
  color: var(--muted);
}
.ai-review-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: #1e293b;
}
.ai-review-body {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.6;
  transition: max-height 0.2s ease;
}
.ai-review-body.is-preview {
  max-height: calc(1.6em * 3);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}
.ai-review-card.is-expanded .ai-review-body {
  max-height: calc(1.6em * 21);
  overflow-y: auto;
  -webkit-mask-image: none;
  mask-image: none;
}
.ai-review-read-more {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  padding: 0.1rem 0;
  cursor: pointer;
  text-decoration: underline;
}
.ai-review-read-more:hover {
  color: #1d4ed8;
}
.ai-review-body p {
  margin: 0 0 0.5rem;
}
.ai-review-body ul,
.ai-review-body ol {
  margin: 0.25rem 0 0.5rem 1.25rem;
  padding: 0;
  display: block;
}
.ai-review-body li {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  list-style: disc;
}
.ai-review-body ol li {
  list-style: decimal;
}
.ai-review-body strong {
  color: #1e293b;
}
.ai-review-body code {
  background: #e2e8f0;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.ai-review-body a {
  color: var(--accent);
  text-decoration: underline;
}
.ai-review-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
.ai-review-nav button {
  background: transparent;
  color: var(--text);
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.ai-review-nav button:hover:not(:disabled) {
  background: #e2e8f0;
}
.ai-review-nav button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.ai-review-nav span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ===========================================
   Agent Activity Timeline
   =========================================== */
.agent-activity-section {
  margin-bottom: 1.5rem;
}
.agent-activity-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  user-select: none;
}
.agent-activity-header:hover {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}
.agent-activity-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569;
}
.agent-activity-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.3rem;
  background: #818cf8;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.agent-activity-toggle {
  margin-left: auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.agent-timeline {
  list-style: none;
  padding: 0.5rem 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.agent-action-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid #818cf8;
  background: #f8fafc;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-top: none;
  border-bottom: none;
  border-right: none;
}
.action-date {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 5.5rem;
}
.action-title {
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.action-type {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: #818cf8;
  color: white;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ===========================================
   Status Recent Changes
   =========================================== */
.status-changes-section {
  margin-bottom: 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.85rem;
}
.status-changes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.status-changes-header h3 {
  margin: 0;
  font-size: 0.9rem;
  color: #1e293b;
}
.status-changes-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-changes-header select {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  color: #334155;
}
.status-changes-empty {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}
.status-changes-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.status-change-row {
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 10px;
  text-align: left;
  padding: 0.55rem 0.65rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "type title time"
    "type subtitle time";
  gap: 0.1rem 0.55rem;
  cursor: pointer;
}
.status-change-row:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}
.status-change-type {
  grid-area: type;
  align-self: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: #1d4ed8;
  background: #dbeafe;
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-change-title {
  grid-area: title;
  font-size: 0.84rem;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-change-subtitle {
  grid-area: subtitle;
  font-size: 0.75rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-change-time {
  grid-area: time;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 7.5rem;
}
.status-change-time span:first-child {
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
}
.status-change-time span:last-child {
  font-size: 0.7rem;
  color: #64748b;
}
@media (max-width: 640px) {
  .status-change-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title time"
      "subtitle time"
      "type time";
  }
  .status-change-type {
    justify-self: start;
  }
  .status-change-time {
    min-width: 5.5rem;
  }
  .status-change-time span:last-child {
    display: none;
  }
  .status-changes-header {
    align-items: flex-start;
  }
  .status-changes-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ===========================================
   Assignment Filter + Badge
   =========================================== */
.assignment-filter-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.secondary-controls-panel {
  display: grid;
  gap: 0.5rem;
}
.assignment-filter-bar .label {
  font-size: 0.85rem;
  color: var(--muted);
}
.assignment-filter-bar .tag-chip {
  cursor: pointer;
}
.secondary-controls-toggle {
  text-decoration: none;
  font-size: 0.82rem;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}
.secondary-controls-toggle.active {
  border-color: #1d4ed8;
  color: #1d4ed8;
  background: #eff6ff;
}
.badge-assigned {
  background: #ddd6fe;
  border-color: #a78bfa;
  color: #5b21b6;
  font-weight: 600;
  font-size: 0.7rem;
}
.badge-project {
  background: #d1fae5;
  border-color: #34d399;
  color: #065f46;
  font-weight: 600;
  font-size: 0.7rem;
}

/* View toggle */
.work-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.view-toggle {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.view-toggle-btn {
  background: transparent;
  color: var(--muted);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  line-height: 1;
}
.view-toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.view-toggle-btn:hover:not(.active) {
  color: var(--text);
}

/* Kanban board */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  min-height: 300px;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.kanban-column {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  min-width: 220px;
  flex: 1 0 220px;
}
.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.kanban-column-title {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.kanban-column-count {
  background: var(--surface);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  min-width: 1.2rem;
  text-align: center;
}
.kanban-column-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.kanban-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
}
.task-select-checkbox-board {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
}
.kanban-card:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.kanban-card-title {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  word-break: break-word;
}
.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.kanban-card-meta .badge,
.kanban-card-meta .tag-chip {
  font-size: 0.65rem;
}
.kanban-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1rem 0;
  opacity: 0.6;
}

/* Compact board mode */
.tasks-section.compact-board .hero-entry {
  margin-top: 0.75rem;
  margin-bottom: 1rem;
}
.tasks-section.compact-board .hero-input {
  padding: 0.65rem 0.9rem;
  font-size: 0.94rem;
}
.tasks-section.compact-board .work-header {
  margin-top: 1rem;
  padding-top: 0.7rem;
}
.tasks-section.compact-board .remaining-summary {
  margin-bottom: 0.55rem;
  font-size: 0.98rem;
}
.tasks-section.compact-board .work-header-actions {
  gap: 0.45rem;
}
.tasks-section.compact-board .assignment-filter-bar,
.tasks-section.compact-board .tag-filter-bar,
.tasks-section.compact-board .bulk-actions-bar {
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.45rem;
  gap: 0.35rem;
}
.tasks-section.compact-board .secondary-controls-panel {
  gap: 0.35rem;
}
.tasks-section.compact-board .tag-filter-bar {
  flex-wrap: nowrap;
  overflow-x: auto;
  white-space: nowrap;
}
.tasks-section.compact-board .tag-filter-bar .label,
.tasks-section.compact-board .tag-filter-bar .clear-filters {
  flex: 0 0 auto;
}
.tasks-section.compact-board .tag-filter-bar .tag-chip {
  flex: 0 0 auto;
}
.tasks-section.compact-board .kanban-board {
  margin-top: 0.55rem;
  gap: 0.5rem;
}
.tasks-section.compact-board .kanban-column {
  padding: 0.38rem;
}
.tasks-section.compact-board .kanban-column-header {
  padding: 0.25rem 0.35rem;
  margin-bottom: 0.35rem;
}
.tasks-section.compact-board .kanban-column-body {
  gap: 0.35rem;
}
.tasks-section.compact-board .kanban-card {
  padding: 0.45rem 0.52rem;
}
.tasks-section.compact-board .kanban-card-title {
  font-size: 0.81rem;
  margin-bottom: 0.22rem;
  line-height: 1.24;
}
.tasks-section.compact-board .kanban-card-meta {
  gap: 0.2rem;
}
.tasks-section.compact-board .kanban-card-meta .badge,
.tasks-section.compact-board .kanban-card-meta .tag-chip {
  font-size: 0.61rem;
}
.tasks-section.compact-board .task-select-checkbox-board {
  top: 0.38rem;
  right: 0.38rem;
}

/* Kanban drag-and-drop */
.kanban-card[draggable="true"] {
  cursor: grab;
}
.kanban-card[draggable="true"]:active {
  cursor: grabbing;
}
.kanban-card.dragging {
  opacity: 0.4;
}
.kanban-column-body.drag-over {
  background: rgba(59, 130, 246, 0.08);
  border-radius: var(--radius-sm);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* Column header accent colors */
.kanban-col-summary .kanban-column-header { border-bottom-color: #a78bfa; }
.kanban-col-new .kanban-column-header { border-bottom-color: #ccc; }
.kanban-col-ready .kanban-column-header { border-bottom-color: #ffcfc3; }
.kanban-col-in_progress .kanban-column-header { border-bottom-color: #cdbdff; }
.kanban-col-review .kanban-column-header { border-bottom-color: #fcd34d; }
.kanban-col-done .kanban-column-header { border-bottom-color: #b0e2b8; }

/* Summary column */
.kanban-col-summary {
  background: rgba(167, 139, 250, 0.06);
}
.summary-card {
  border-left: 3px solid #a78bfa;
  cursor: pointer;
}
.summary-card[draggable="false"] {
  cursor: pointer;
}

/* Progress dots */
.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.subtask-count {
  font-size: 0.65rem;
  color: var(--muted);
}

/* Subtask list in edit modal */
.subtask-list-field,
.parent-selector-field {
  margin-top: 0.15rem;
}
.subtask-list-field .field-label,
.parent-selector-field .field-label {
  font-weight: 700;
  font-size: 0.76rem;
  color: #475569;
  margin-bottom: 0.35rem;
  display: block;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.parent-selector-field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #d9e2ec;
  border-radius: 10px;
  font-size: 0.9rem;
  background: #fbfdff;
  box-sizing: border-box;
}
.subtask-list {
  border: 1px solid #dbe7ff;
  background: linear-gradient(180deg, #f8fbff 0%, #f1f7ff 100%);
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  margin-top: 0.15rem;
  overflow: hidden;
}
.subtask-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
  font-size: 0.88rem;
}
.subtask-row:hover {
  background: rgba(37, 99, 235, 0.08);
}
.subtask-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subtask-add-inline {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.45rem;
}
.subtask-add-inline input {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border: 1px solid #c9dafc;
  border-radius: 9px;
  font-size: 0.86rem;
  background: #fff;
}
.subtask-add-inline button {
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
  border-radius: 9px;
  background: #2563eb;
  color: #fff;
}
.auto-computed-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 0.5rem;
  font-style: italic;
}

/* Task notes */
.task-notes-field {
  margin-top: 0.35rem;
}
.task-notes-field .field-label {
  font-weight: 700;
  font-size: 0.76rem;
  color: #475569;
  margin-bottom: 0.35rem;
  display: block;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.task-notes-list {
  max-height: 240px;
  overflow-y: auto;
  margin-top: 0.25rem;
}
.task-note-row {
  padding: 0.4rem 0.5rem;
  border-left: 2px solid var(--accent);
  margin-bottom: 0.4rem;
  background: var(--bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.task-note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.15rem;
}
.task-note-sender {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text);
}
.task-note-time {
  font-size: 0.7rem;
  color: var(--muted);
}
.task-note-body {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text);
}
.task-note-body p {
  margin: 0;
}
.task-note-body a {
  color: var(--accent);
  text-decoration: underline;
}
.task-note-add {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.35rem;
  align-items: flex-end;
}
.task-note-add textarea {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  min-height: 2rem;
}
.task-note-add button {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* List view: summary section + inline subtasks */
.summary-list-section {
  margin-bottom: 1rem;
}
.summary-list-section .section-heading h2 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a78bfa;
  margin: 0;
}
.summary-todo-row {
  border-left: 3px solid #a78bfa;
  padding-left: 0.5rem;
}
.subtask-inline-list {
  border-left: 2px solid #e2d8ff;
  margin-left: 1.25rem;
  padding-left: 0.75rem;
  margin-bottom: 0.5rem;
}
.subtask-inline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.subtask-inline-row:hover {
  background: var(--bg);
}

/* Responsive: stack columns on small screens */
@media (max-width: 768px) {
  .work-header-actions > .view-toggle,
  .work-header-actions > .compact-toggle,
  .work-header-actions > .select-many-btn,
  .work-header-actions > .secondary-controls-toggle,
  .work-header-actions > .archive-toggle {
    display: none;
  }
  .mobile-task-action-select {
    display: inline-flex;
  }
  .kanban-board {
    flex-direction: column;
    overflow-x: visible;
    gap: 0.5rem;
  }
  .kanban-column {
    min-height: auto;
    min-width: 0;
    flex: none;
  }
}

/* ========== DOCUMENTS VIEW ========== */

.docs-view {
  margin-top: 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.docs-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.docs-search-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
}

.btn-add-doc {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--accent, #4a9eff);
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* New doc/folder modal */
.new-doc-modal {
  max-width: 400px;
  width: 90%;
}
.new-doc-modal h3 {
  margin: 0 0 1rem;
}
.new-doc-modal-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
  font-size: 0.95rem;
  box-sizing: border-box;
}
.new-doc-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}
.new-doc-modal-actions .btn-cancel {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #888);
  cursor: pointer;
}
.new-doc-modal-actions .btn-confirm {
  padding: 0.4rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent, #4a9eff);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.doc-group-share-modal {
  max-width: 520px;
  width: min(95vw, 520px);
  text-align: left;
}
.doc-group-share-modal h3 {
  margin: 0;
  font-size: 1.1rem;
}
.doc-group-share-modal p {
  margin: 0.35rem 0 0.8rem;
}
.doc-group-share-loading,
.doc-group-share-empty {
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: #555;
  margin-bottom: 0.75rem;
}
.doc-group-share-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
}
.doc-group-share-list li + li {
  border-top: 1px solid color-mix(in srgb, var(--border, #ddd) 80%, transparent);
}
.doc-group-share-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
}
.doc-group-share-name {
  font-weight: 600;
  color: #222;
}
.doc-group-share-perm {
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  background: var(--surface, #fff);
  color: var(--text, #111);
}
.doc-group-share-list .doc-group-share-count {
  position: static;
  min-width: auto;
  height: auto;
  line-height: 1.2;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: #eef2ff;
  color: #374151;
}
.doc-group-share-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
  font-size: 0.86rem;
  color: #333;
}
.doc-group-share-ack {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #333;
  margin-bottom: 0.65rem;
}
.doc-group-share-confirm {
  margin-bottom: 0.65rem;
}
.doc-group-share-confirm label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
  color: #333;
}
.doc-group-share-confirm input {
  width: 100%;
  border: 1px solid var(--border, #ddd);
  border-radius: 7px;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

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

.doc-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  background: var(--surface, #1a1a1a);
  transition: background 0.15s;
}

.doc-item:hover {
  background: var(--surface-hover, #222);
}

.doc-item.doc-item-shared-incoming {
  background: color-mix(in srgb, var(--accent, #4a9eff) 12%, var(--surface, #1a1a1a));
  border-color: color-mix(in srgb, var(--accent, #4a9eff) 42%, var(--border, #333));
}

.doc-item-title {
  font-weight: 500;
  color: var(--text, #e0e0e0);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-item-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.doc-item-date {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
}

.doc-shared-pill {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent, #4a9eff) 85%, #fff);
  background: color-mix(in srgb, var(--accent, #4a9eff) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #4a9eff) 45%, transparent);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}

.doc-linked-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--accent, #4a9eff);
  color: #fff;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Folder breadcrumbs */
.folder-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted, #888);
}

.breadcrumb-item {
  color: var(--text-muted, #888);
}

.breadcrumb-link {
  cursor: pointer;
  color: var(--accent, #4a9eff);
}

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

.breadcrumb-sep {
  margin: 0 0.25rem;
  color: var(--text-muted, #666);
}

/* Folder add row */
.btn-add-folder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text-muted, #888);
  cursor: pointer;
  flex-shrink: 0;
}

.btn-add-folder:hover {
  background: var(--surface-hover, #222);
  color: var(--text, #e0e0e0);
}

/* Folder items in doc list */
.doc-item-icon {
  display: flex;
  align-items: center;
  margin-right: 0.5rem;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.doc-item-folder .doc-item-icon {
  color: var(--accent, #4a9eff);
}

.doc-item-folder .doc-item-title {
  font-weight: 600;
}

.group-share-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #888);
  cursor: pointer;
}
.group-share-trigger:hover {
  background: color-mix(in srgb, var(--accent, #4a9eff) 12%, transparent);
  color: var(--text, #e0e0e0);
}
.group-share-trigger.active {
  color: var(--accent, #4a9eff);
  border-color: color-mix(in srgb, var(--accent, #4a9eff) 55%, var(--border, #333));
}
.group-share-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent, #4a9eff);
  color: #fff;
  font-size: 0.62rem;
  line-height: 14px;
  font-weight: 700;
  text-align: center;
  padding: 0 3px;
}

.doc-item[draggable="true"] {
  cursor: grab;
}
.doc-item[draggable="true"]:active {
  cursor: grabbing;
}
.doc-item.dragging {
  opacity: 0.4;
}
.doc-item.drag-over-folder {
  background: rgba(59, 130, 246, 0.08);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Doc editor */

.doc-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.doc-back-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
  cursor: pointer;
}

.doc-editor-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.doc-shared-banner {
  margin: 0.55rem 0 0.35rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--accent, #4a9eff) 45%, var(--border, #333));
  background: color-mix(in srgb, var(--accent, #4a9eff) 13%, var(--surface, #1a1a1a));
  color: var(--text, #e0e0e0);
  font-size: 0.85rem;
  font-weight: 600;
}

.doc-link-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
  max-width: 200px;
}

.btn-source-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #666);
  cursor: pointer;
}
.btn-source-toggle:hover {
  background: var(--bg, #f0f2f5);
  color: var(--text, #111);
}
.btn-source-toggle.active {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: var(--accent, #2563eb);
}

.doc-source-block {
  padding: 0.5rem 0;
}

.doc-source-editor {
  width: 100%;
  min-height: 300px;
  padding: 1rem;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  background: var(--bg, #f8f9fa);
  color: var(--text, #111);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  tab-size: 2;
}

.doc-source-editor:focus {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.btn-doc-history {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #666);
  cursor: pointer;
}
.btn-doc-history:hover {
  background: var(--bg, #f0f2f5);
  color: var(--text, #111);
}

.btn-delete-doc {
  padding: 0.35rem 0.75rem;
  border: 1px solid #c0392b;
  border-radius: 6px;
  background: transparent;
  color: #e74c3c;
  cursor: pointer;
}

.btn-delete-doc:hover {
  background: #c0392b;
  color: #fff;
}

.doc-export-dropdown {
  position: relative;
}

.btn-doc-export {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted, #888);
  cursor: pointer;
}

.btn-doc-export:hover {
  background: var(--bg, #f0f2f5);
  color: var(--text, #111);
}

.doc-export-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  min-width: 150px;
  z-index: 20;
  overflow: hidden;
}

.doc-export-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text, #ccc);
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
}

.doc-export-menu button:hover {
  background: var(--bg-hover, #2a2a4a);
}

/* Version history panel */
.doc-history-panel {
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  background: var(--surface, #fff);
  margin-bottom: 1rem;
  overflow: hidden;
}
.doc-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #e5e5e5);
  background: var(--bg, #f0f2f5);
}
.doc-history-header h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}
.doc-history-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted, #666);
  padding: 0 0.25rem;
  line-height: 1;
}
.doc-history-loading, .doc-history-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted, #666);
  font-size: 0.85rem;
}
.doc-history-body {
  display: flex;
  min-height: 200px;
  max-height: 60vh;
}
.doc-history-list {
  width: 200px;
  min-width: 200px;
  border-right: 1px solid var(--border, #e5e5e5);
  overflow-y: auto;
}
.doc-history-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border, #e5e5e5);
}
.doc-history-item:hover {
  background: var(--bg, #f0f2f5);
}
.doc-history-item-active {
  background: var(--accent, #3b82f6);
  color: #fff;
}
.doc-history-item-active:hover {
  background: var(--accent, #3b82f6);
}
.doc-history-version {
  font-weight: 600;
  font-size: 0.85rem;
}
.doc-history-date {
  font-size: 0.75rem;
  opacity: 0.7;
}
.doc-history-preview {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.doc-history-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border, #e5e5e5);
  font-size: 0.85rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.btn-restore-version {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--accent, #3b82f6);
  border-radius: 6px;
  background: var(--accent, #3b82f6);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
}
.btn-restore-version:hover {
  opacity: 0.9;
}
.doc-history-preview-content {
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-y: auto;
}

/* Title block — click to edit */

.doc-title-block {
  cursor: text;
  margin-bottom: 1rem;
}

.doc-title-display {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  margin: 0;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.doc-title-display:hover {
  border-bottom-color: var(--border, #333);
}

.doc-title-input {
  font-size: 1.5rem;
  font-weight: 600;
  width: 100%;
  padding: 0.25rem 0;
  border: none;
  border-bottom: 2px solid var(--accent, #4a9eff);
  background: transparent;
  color: var(--text, #e0e0e0);
  outline: none;
}

/* Content block — click to edit */

.doc-content-block {
  min-height: 200px;
}

/* Block-level editing */

.doc-block {
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 0.25rem;
  position: relative;
}

.doc-block:hover:not(.doc-block-active) {
  border-left-color: rgba(59, 130, 246, 0.4);
  background: var(--surface, rgba(255,255,255,0.03));
}

.doc-block-active {
  border-left-color: var(--accent, #3b82f6);
  background: var(--surface, rgba(255,255,255,0.05));
}

.doc-block-rendered {
  cursor: text;
  padding: 0.5rem 0.75rem;
  color: var(--text, #e0e0e0);
  line-height: 1.6;
}

.doc-block-rendered h1, .doc-block-rendered h2, .doc-block-rendered h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.doc-block-rendered p {
  margin: 0 0 0.25rem;
}

.doc-block-rendered code {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.doc-block-rendered pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  position: relative;
}

.doc-block-rendered pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* Copy button on code blocks */
.code-block-wrapper {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.25rem 0.5rem;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: #a6adc8;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
  z-index: 1;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #cdd6f4;
}

.code-copy-btn.copied {
  color: #a6e3a1;
  border-color: rgba(166,227,161,0.3);
}

.doc-block-rendered a {
  color: var(--accent, #3b82f6);
}

.doc-block-rendered ul, .doc-block-rendered ol {
  padding-left: 1.5rem;
  margin: 0;
}

.doc-block-rendered ul li, .doc-block-rendered ol li {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.doc-block-rendered table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.doc-block-rendered th,
.doc-block-rendered td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.doc-block-rendered th {
  background: var(--bg);
  font-weight: 600;
}

.doc-block-rendered tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

/* Markdown checkboxes in docs */
.md-checkbox {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0.15rem 0;
}
.md-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  accent-color: var(--accent, #3b82f6);
}
.md-checkbox input[type="checkbox"]:checked + span {
  text-decoration: line-through;
  opacity: 0.6;
}

.doc-block-editor {
  width: 100%;
  min-height: 5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--accent, #3b82f6);
  border-radius: 6px;
  background: var(--bg, #f0f2f5);
  color: var(--text, #111);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  overflow-y: auto;
}

.doc-block-editor:focus {
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.doc-block-placeholder {
  cursor: text;
  padding: 0.75rem;
  min-height: 100px;
}

.doc-placeholder {
  color: var(--muted, #666);
  font-style: italic;
}

.doc-block-add {
  padding: 0.4rem 0.75rem;
  color: var(--muted, #666);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
  margin-top: 0.25rem;
}

.doc-block-add:hover {
  background: var(--bg, #f0f2f5);
  color: var(--text, #111);
}

/* ===========================================
   App Layout (Sidebar + Main Content)
   =========================================== */

.app-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 120px);
}

/* Sidebar */
.sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 0;
  display: flex;
  transition: width 0.2s ease;
  flex-direction: column;
  transition: width 0.2s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}
.sidebar-collapsed .sidebar-logo-text {
  display: none;
}
.sidebar-collapsed .sidebar-logo {
  justify-content: center;
  padding: 0.6rem 0;
}

.sidebar-collapsed {
  width: 48px;
}

.sidebar-hidden {
  display: none;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  background: transparent;
  border: none;
}

.sidebar-nav li:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-nav li.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.sidebar-collapsed .sidebar-label {
  display: none;
}

.sidebar-collapse-btn {
  margin-top: auto;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-collapse-btn:hover {
  color: var(--text);
}

/* Sidebar channel sub-items */
.sidebar-channels {
  display: flex;
  flex-direction: column;
  padding-left: 0;
}

.sidebar-channel-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem 0.35rem 2rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
  transition: background 0.15s, color 0.15s;
}

.sidebar-channel-item:hover {
  background: var(--bg);
  color: var(--text);
}

.sidebar-channel-item.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.sidebar-channel-item .channel-hash {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
}

.sidebar-channel-item.channel-unread .sidebar-label {
  font-weight: 700;
  color: var(--text);
}

.sidebar-channel-item.channel-unread .channel-hash {
  color: var(--text);
  font-weight: 700;
}

/* Unread notification dot */
.nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.unread-dot {
  position: absolute;
  top: -3px;
  right: -5px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--surface, #1a1a1a);
}

.sidebar-collapsed .sidebar-channels {
  display: none;
}

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  padding-left: 1.5rem;
}

/* ===========================================
   Chat Section
   =========================================== */

.chat-section {
  height: calc(100vh - 140px);
  height: calc(100dvh - 140px);
  min-height: 0;
}

.chat-main,
.chat-thread-panel {
  min-height: 0;
}

.chat-feed,
.thread-replies {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* Keep composer pinned at bottom while feed scrolls above it */
.chat-input-bar,
.thread-input-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
}

.thread-input-bar {
  z-index: 5;
}

.chat-layout {
  display: flex;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

/* Chat main */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Chat feed */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
  font-size: 0.9rem;
}

.chat-load-more {
  align-self: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.chat-load-more:hover {
  border-color: var(--muted);
  background: var(--bg);
}

/* Chat post (flat card style) */
.chat-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.chat-post.chat-post-thread-unread {
  background: #f3f8ff;
  border-color: #c5ddff;
}

.chat-post-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.chat-post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-post-avatar-fallback {
  background: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-post-sender {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.chat-post-time {
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-session-badge {
  font-size: 0.6rem;
  padding: 0.05rem 0.35rem;
  background: #818cf8;
  color: white;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 600;
}

.chat-post-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.chat-post-content p {
  margin: 0 0 0.4rem;
}

.chat-post-content p:last-child {
  margin-bottom: 0;
}

.chat-post-content ul, .chat-post-content ol,
.thread-msg-text ul, .thread-msg-text ol,
.doc-block-rendered ul, .doc-block-rendered ol,
.review-card ul, .review-card ol {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 0.3rem 0;
}

.chat-post-content ol, .thread-msg-text ol,
.doc-block-rendered ol, .review-card ol {
  list-style: decimal;
}

.chat-post-content li, .thread-msg-text li,
.doc-block-rendered li, .review-card li {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.1rem 0;
}

.chat-post-content a, .thread-msg-text a {
  color: var(--accent);
  text-decoration: underline;
}

.chat-post-content code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}

.chat-post-content table,
.thread-msg-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.85rem;
}

.chat-post-content th, .chat-post-content td,
.thread-msg-text th, .thread-msg-text td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
}

.chat-post-content th,
.thread-msg-text th {
  background: var(--bg);
  font-weight: 600;
}

/* Inline thread preview */
.chat-thread-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
}

.chat-thread-preview:hover {
  background: #eff6ff;
}

.chat-thread-preview-count {
  font-weight: 600;
  color: var(--text);
}

.chat-thread-preview-link {
  color: var(--muted);
}

/* Reply bar (opens thread) */
.chat-post-reply-bar {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--bg);
}

.chat-post-reply-bar:hover {
  border-color: var(--muted);
}

.chat-post-reply-placeholder {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Shared sender styles (used in thread panel too) */
.chat-sender {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}

.chat-time {
  font-size: 0.7rem;
  color: var(--muted);
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 120px;
  background: var(--bg);
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-send-btn-text {
  padding: 0.5rem 1rem;
  background: var(--text);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.chat-send-btn-text:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send-btn-text:hover:not(:disabled) {
  opacity: 0.85;
}

/* Thread panel (Marginal Gains style) */
.chat-thread-panel {
  width: 420px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  transition: width 0.2s ease;
}

/* Thread size variants */
.chat-thread-panel.thread-wide {
  width: 66%;
}

.chat-thread-panel.thread-full {
  width: 100%;
}

.thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.thread-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.thread-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.thread-resize-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.thread-resize-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.thread-close-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem;
  line-height: 1;
}

.thread-close-btn:hover {
  color: var(--text);
}

.thread-replies {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Thread message (flat list, no bubbles) */
.thread-message {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.thread-message:last-child {
  border-bottom: none;
}

.thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.thread-avatar-fallback {
  background: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.thread-msg-body {
  flex: 1;
  min-width: 0;
}

.thread-msg-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.thread-msg-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.thread-msg-text p {
  margin: 0 0 0.4rem;
}

.thread-msg-text p:last-child {
  margin-bottom: 0;
}

.thread-msg-text code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
}

/* Thread input */
.thread-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-end;
}

.thread-reply-btn {
  padding: 0.5rem 1rem;
  background: var(--text);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

.thread-reply-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.thread-reply-btn:hover:not(:disabled) {
  opacity: 0.85;
}

/* ===========================================
   Responsive: Chat
   =========================================== */

/* Mobile header (hamburger + section label) */
.mobile-header {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .app-shell {
    padding: 0 0.5rem 0.5rem;
  }

  .page-header {
    display: none;
  }

  .app-layout {
    flex-direction: column;
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Sidebar becomes a slide-out drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    z-index: 100;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    flex-direction: column;
  }

  .sidebar.sidebar-mobile-open {
    transform: translateX(0);
  }

  .sidebar-nav {
    flex-direction: column;
  }

  .sidebar-nav li {
    margin: 0;
  }

  .sidebar-label {
    display: inline !important;
  }

  .sidebar-channels {
    display: flex !important;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .sidebar-collapsed {
    width: 240px;
    transform: translateX(-100%);
  }

  .sidebar-collapsed.sidebar-mobile-open {
    transform: translateX(0);
  }

  .sidebar-collapsed .sidebar-label {
    display: inline !important;
  }

  .sidebar-collapsed .sidebar-channels {
    display: flex !important;
  }

  /* Overlay behind drawer */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
  }

  /* Mobile header bar */
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.4rem 0.1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.35rem;
  }

  .mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text);
    padding: 0.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
  }

  .mobile-session-controls {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    order: 3;
  }

  .mobile-avatar-chip {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.2);
  }

  .mobile-section-label {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    margin-left: 0.1rem;
    order: 2;
  }

  .mobile-session-controls .avatar-menu {
    right: 0;
    left: auto;
    top: calc(100% + 0.35rem);
  }

  .main-content {
    padding-left: 0;
    width: 100%;
    overflow-x: hidden;
  }

  .task-detail-page {
    padding: 0.75rem;
    margin-top: 0.5rem;
    border-radius: 10px;
  }

  .task-detail-header {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .task-detail-heading h2 {
    font-size: 1rem;
  }

  .tag-input-wrapper {
    max-width: 100%;
    overflow-x: auto;
  }

  .hero-entry {
    margin-top: 0.85rem;
    margin-bottom: 1rem;
  }

  .work-header {
    margin-top: 1.1rem;
    padding-top: 0.65rem;
  }

  .docs-view {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
  }

  .chat-section {
    height: calc(100vh - 104px - var(--mobile-keyboard-inset, 0px));
    height: calc(100dvh - 104px - var(--mobile-keyboard-inset, 0px));
    overflow: hidden;
  }

  .chat-input-bar,
  .thread-input-bar {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  }

  .todo-row {
    padding: 0.55rem 0.6rem;
  }

  .todo-list > li,
  .doc-items > li {
    border-radius: 8px;
  }

  .doc-item {
    align-items: flex-start;
    flex-wrap: wrap;
    row-gap: 0.3rem;
    padding: 0.62rem 0.72rem;
  }

  .doc-item-icon {
    margin-top: 0.1rem;
  }

  .doc-item-title {
    flex: 1 1 calc(100% - 2rem);
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.28;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .doc-item-meta {
    width: 100%;
    margin-left: 1.85rem;
    flex-wrap: wrap;
    gap: 0.35rem 0.45rem;
    align-items: center;
  }

  .doc-linked-badge {
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
  }

  .chat-layout {
    border: none;
    border-radius: 0;
  }

  .chat-thread-panel {
    position: fixed;
    inset: 0 0 var(--mobile-keyboard-inset, 0px) 0;
    width: 100%;
    z-index: 50;
    border-left: none;
  }

  /* iOS Safari can clip the last thread reply near the composer/keyboard boundary. */
  .chat-thread-panel .thread-replies {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }

  .chat-feed {
    padding: 0.5rem 0;
    gap: 0;
  }

  .chat-post {
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 0.75rem 1rem;
  }

  .chat-input-bar {
    padding: 0.5rem 0.75rem;
  }
}

/* ===========================================
   Privacy Toggle (lock icon)
   =========================================== */
.privacy-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
  font-size: 0.8rem;
  line-height: 1;
}
.privacy-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}
.lock-private {
  color: #4ade80;
}
.lock-shared {
  color: #9ca3af;
}
.privacy-toggle-sm {
  padding: 1px 2px;
}
.privacy-toggle-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.privacy-toggle-field label {
  font-size: 0.85rem;
  color: #333;
  margin: 0;
  flex-direction: row;
}
.privacy-toggle-field .privacy-toggle {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.privacy-toggle-field .privacy-toggle span {
  font-size: 0.8rem;
}
.shared-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.delegate-avatar-sm {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
}
.delegate-avatar-xs {
  width: 12px;
  height: 12px;
}

/* ===========================================
   @mention chips + dropdown
   =========================================== */
.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.85em;
  color: #1d4ed8;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: baseline;
}

.mention-dropdown {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 60;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}

.mention-dropdown .assign-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: background 0.1s;
}

.mention-dropdown .assign-option:hover {
  background: #f0f4ff;
}

/* ===========================
   People Section
   =========================== */

.people-view {
  margin-top: 1rem;
}

.people-toolbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.people-search-input {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
}

.people-filter-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  overflow: hidden;
}

.people-filter-tabs button {
  padding: 0.4rem 0.75rem;
  border: none;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  border-right: 1px solid var(--border, #333);
}
.people-filter-tabs button:last-child { border-right: none; }
.people-filter-tabs button.active {
  background: var(--accent);
  color: #fff;
}

.btn-add-person {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--accent, #4a9eff);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.people-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.people-empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem;
  font-style: italic;
}

.person-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.person-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}

.person-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.avatar-person { background: #6366f1; }
.avatar-org { background: #0891b2; border-radius: var(--radius-sm); }

.person-card-info {
  flex: 1;
  min-width: 0;
}
.person-card-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.person-card-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}
.person-card-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 4px;
}
.person-tag {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.person-type-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.type-person { background: #ede9fe; color: #6366f1; }
.type-org { background: #ecfeff; color: #0891b2; }

/* Person detail view */
.person-detail {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.person-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.btn-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  color: var(--text);
}
.person-detail-actions {
  display: flex;
  gap: 0.5rem;
}
.btn-edit-person, .btn-delete-person {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
}
.btn-delete-person { color: var(--danger); border-color: var(--danger); }

.person-detail-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.person-detail-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: #fff;
  flex-shrink: 0;
}
.person-detail-avatar.avatar-org { border-radius: var(--radius-sm); }
.person-detail-meta {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.person-detail-section {
  margin-bottom: 1.5rem;
}
.person-detail-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.person-contact-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.person-detail-tags {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.person-notes-content {
  font-size: 0.9rem;
  line-height: 1.5;
}
.person-related-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.person-related-link {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.person-related-link:hover {
  border-color: var(--accent);
  background: var(--bg);
}
.person-related-name {
  font-weight: 600;
}
.person-related-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Activities */
.activity-add {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.activity-input {
  flex: 1;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.activity-type-select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}
.btn-add-activity {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.activity-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  padding-top: 2px;
}
.activity-content {
  flex: 1;
  min-width: 0;
}
.activity-text {
  font-size: 0.9rem;
}
.activity-time {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.activity-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.activity-item:hover .activity-delete { opacity: 1; }

/* Person modal */
.person-modal {
  max-width: 480px;
  width: 90%;
}
.opportunity-modal {
  max-width: 680px;
  width: min(94vw, 680px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 1rem 1rem 0.85rem;
}
.person-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.opportunity-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 0.75rem;
}
.opportunity-form .form-row.wide {
  grid-column: 1 / -1;
}
.person-form .form-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.person-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.person-form input,
.person-form textarea,
.person-form select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.person-form textarea {
  resize: vertical;
  min-height: 60px;
}

.person-type-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
}
.person-type-toggle button {
  padding: 0.4rem 1rem;
  border: none;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  border-right: 1px solid var(--border);
}
.person-type-toggle button:last-child { border-right: none; }
.person-type-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.person-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Opportunities */
.opportunities-view {
  margin-top: 1rem;
}
.opportunities-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.opportunities-toolbar h2 {
  margin: 0;
}
.opportunities-subtitle {
  margin: 0.35rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.opportunity-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.opportunity-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.opportunity-summary-card .summary-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.opportunity-summary-card .summary-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.opportunity-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
.opportunity-lane {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem;
}
.opportunity-lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.opportunity-lane-header h3 {
  margin: 0;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #334155;
}
.lane-count {
  background: #e2e8f0;
  color: #334155;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
}
.opportunities-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.opportunities-header h3 { margin-bottom: 0; }
.btn-add-opportunity {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
.opportunity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.opportunity-card {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  border-left: 4px solid var(--border);
}
.opp-stage-idea { border-left-color: #3b82f6; }
.opp-stage-happening { border-left-color: #eab308; }
.opp-stage-doing { border-left-color: #f97316; }
.opp-stage-done { border-left-color: #22c55e; }
.opp-stage-lead { border-left-color: #eab308; }
.opp-stage-proposal { border-left-color: #f97316; }
.opp-stage-negotiation { border-left-color: #f59e0b; }
.opp-stage-won { border-left-color: #22c55e; }
.opp-stage-lost { border-left-color: #9ca3af; }

.opp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.opp-title {
  font-weight: 600;
  font-size: 0.95rem;
}
.opp-type-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.opp-type-idea { background: #dbeafe; color: #2563eb; }
.opp-type-financial { background: #fef3c7; color: #b45309; }
.opp-type-partnership { background: #ede9fe; color: #7c3aed; }
.opp-type-project { background: #d1fae5; color: #059669; }

.opp-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.opp-value {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.opp-stage-badge {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  text-transform: capitalize;
}
.opp-probability {
  font-size: 0.8rem;
  color: var(--muted);
}
.opp-description {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.25rem 0;
}
.opp-linked-person {
  margin-top: 0.3rem;
  color: #475569;
  font-size: 0.8rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.opp-link-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
  color: #334155;
  font-size: 0.75rem;
}
.opp-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.opp-card-actions button {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
}
.btn-delete-opp { color: var(--danger); border-color: var(--danger); }
.opp-value-row {
  display: flex;
  gap: 0.5rem;
}
.opp-type-toggle { flex-wrap: wrap; }
.opp-people-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem;
  background: var(--surface);
}
.opp-people-input-row {
  display: flex;
  gap: 0.4rem;
}
.opp-people-input-row input {
  flex: 1;
  min-width: 0;
}
.opp-people-input-row button {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}
.opp-selected-people {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.opp-person-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.78rem;
}
.opp-person-chip button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.opp-people-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 120px;
  overflow-y: auto;
}
.opp-person-suggestion {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  padding: 0.3rem 0.45rem;
  cursor: pointer;
  text-align: left;
}
.opp-person-avatar {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}
.opp-person-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  background: #64748b;
}
.opp-people-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}
.task-note-actions {
  margin-top: 0.25rem;
  display: flex;
  justify-content: flex-end;
}
.task-note-delete {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
}

@media (max-width: 900px) {
  .opportunity-summary-grid {
    grid-template-columns: 1fr;
  }
  .opportunity-lanes {
    grid-template-columns: 1fr;
  }
  .opportunity-form {
    grid-template-columns: 1fr;
  }
  .opportunity-form .form-row.wide {
    grid-column: auto;
  }
  .opportunity-modal {
    width: 96vw;
    max-height: 90vh;
    padding: 0.85rem 0.8rem 0.75rem;
  }
}

/* ===========================
   Settings Section
   =========================== */

.settings-section {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.settings-header {
  margin-bottom: 1.25rem;
}

.settings-section h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.settings-tab-button {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.settings-tab-button:hover {
  background: color-mix(in srgb, var(--surface) 80%, var(--bg));
  color: var(--text);
}

.settings-tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.settings-panel {
  display: block;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.settings-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.settings-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
  line-height: 1.4;
}

/* Trigger banners */
.trigger-banner {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.trigger-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.trigger-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

/* Triggers list */
.triggers-list {
  margin-bottom: 1.25rem;
}

.trigger-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: opacity 0.2s;
}

.trigger-item.trigger-disabled {
  opacity: 0.5;
}

.trigger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.trigger-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.trigger-info strong {
  font-size: 0.9rem;
}

.trigger-id-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: monospace;
}

.trigger-type-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 500;
  width: fit-content;
}

.trigger-auto-hint {
  margin-top: 0.35rem;
}

.trigger-actions {
  display: flex;
  gap: 0.35rem;
}

.trigger-fire {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.trigger-message-input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn-sm:hover {
  background: var(--bg);
}

.btn-fire {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.btn-fire:hover {
  background: #2563eb;
}

.btn-fire:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-trigger-toggle {
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
}

.backup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.backup-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.backup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

.backup-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.group-request-section {
  margin-top: 1rem;
}

.group-request-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Add trigger form */
.trigger-add-form {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.trigger-add-form h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.trigger-add-form .form-row {
  margin-bottom: 0.65rem;
}

.trigger-add-form .form-row label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  color: var(--muted);
}

.trigger-add-form .form-row input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.trigger-select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--surface);
  box-sizing: border-box;
}

.trigger-add-form .btn-primary {
  margin-top: 0.25rem;
  padding: 0.45rem 1rem;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.trigger-add-form .btn-primary:hover {
  background: #2563eb;
}

/* ===== Linked Docs / Task Links ===== */

.linked-docs-field {
  margin-top: 0.25rem;
  position: relative;
  min-width: 0;
}

.linked-docs-field .field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.linked-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

.linked-chips-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.linked-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-elevated, #f3f4f6);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-primary, #333);
}

.linked-chip-title {
  all: unset;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s ease;
}

.linked-chip-title:hover {
  text-decoration-color: currentColor;
}

.linked-chip-sm {
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
}

.linked-chip-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
}

.linked-chip-remove:hover {
  color: var(--danger, #ef4444);
}

.doc-link-autocomplete {
  position: relative;
}

.doc-link-autocomplete input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 0.375rem;
  background: var(--bg-primary, #f9fafb);
  color: var(--text-primary, #111);
}

.doc-link-autocomplete-inline {
  display: inline-block;
}

.doc-link-autocomplete-inline input {
  width: 140px;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
}

.doc-link-input-sm {
  width: 140px;
}

.doc-link-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 0.375rem;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.12);
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 0.25rem;
}

/* In-flow dropdown for modals — must come after base rule to override */
.edit-modal .doc-link-dropdown,
.edit-form .doc-link-dropdown {
  position: relative;
  top: auto;
  bottom: auto;
  left: auto;
  right: auto;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  max-height: 160px;
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.doc-link-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary, #333);
}

.doc-link-option:hover {
  background: var(--bg-hover, #f3f4f6);
}

.doc-link-option svg {
  flex-shrink: 0;
  color: var(--text-muted, #999);
}

.doc-task-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  position: relative;
}

/* Doc mention links in rendered markdown */
.doc-mention-link {
  color: var(--accent, #60a5fa);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent, #60a5fa);
  cursor: pointer;
}

.doc-mention-link:hover {
  color: var(--accent-hover, #93c5fd);
}

/* Doc mention option in dropdown */
.doc-mention-option svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

/* Mention section labels */
.mention-section-label {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color, #3a3a4a);
}

.mention-section-label:first-child {
  border-top: none;
}

/* Docs count badge on kanban cards */
.badge-docs {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Reverse link badge (task → doc) */
.doc-linked-reverse {
  opacity: 0.7;
  font-style: italic;
}

/* Prevent iOS Safari auto-zoom on input focus (triggers when font-size < 16px) */
@supports (-webkit-touch-callout: none) {
  input, textarea, select {
    font-size: 16px !important;
  }
}

/* ── Voice Notes ── */
.voice-notes-view { padding: 0 0 8px; }
.voice-notes-toolbar {
  display: flex; align-items: center; justify-content: flex-start;
  margin-bottom: 10px;
}
.voice-notes-toolbar h2 { margin: 0; font-size: 1.25rem; }
.voice-notes-record-cta {
  display: flex;
  justify-content: center;
  margin: 0 0 18px;
  padding: 8px 0 12px;
}

.btn-record {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 14px 26px; border-radius: 999px;
  background: linear-gradient(180deg, #334155 0%, #1f2937 100%);
  border: 1px solid #111827;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.22);
  color: #f8fafc;
  cursor: pointer; font-size: 1rem; font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-record:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(15, 23, 42, 0.28); filter: brightness(1.04); }
.btn-record:active { transform: translateY(0); }
.btn-record.recording {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  border-color: #b91c1c;
  color: #fff;
  animation: pulse-record 1.5s ease-in-out infinite;
}
.btn-record:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
@keyframes pulse-record {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(229, 62, 62, 0); }
}

.voice-waveform-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
  border-radius: 10px;
}
.voice-waveform-label {
  color: #b91c1c;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.voice-waveform {
  flex: 1;
  display: flex;
  align-items: end;
  gap: 3px;
  height: 34px;
}
.voice-wave-bar {
  flex: 1;
  min-width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
  opacity: 0.9;
  transition: height 90ms linear;
}

.voice-upload-status {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; margin-bottom: 12px;
  background: #f0f7ff; border-radius: 8px;
  color: #3182ce; font-size: 0.9rem;
}

.voice-notes-list { display: flex; flex-direction: column; gap: 8px; }

.voice-note-card {
  display: flex; flex-direction: column;
  padding: 12px 16px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; transition: all 0.15s;
}
.voice-note-card:hover { border-color: #cbd5e0; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.voice-note-card.playing { border-color: #3182ce; background: #f0f7ff; }

.voice-note-header { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.voice-note-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.voice-note-title { font-weight: 500; font-size: 0.95rem; }
.voice-note-title--generic { opacity: 0.5; }
.voice-note-meta { font-size: 0.8rem; color: #718096; }
.voice-note-transcribed { color: #38a169; font-weight: 500; }

.voice-note-transcript { margin-top: 8px; }
.voice-note-transcript-preview {
  font-size: 0.85rem; color: #718096; cursor: pointer;
  line-height: 1.5; transition: color 0.15s;
}
.voice-note-transcript-preview:not(.expanded) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.voice-note-transcript-preview.expanded {
  color: #4a5568; white-space: pre-wrap;
}
.voice-note-transcript-preview:hover { color: #4a5568; }
.voice-note-transcript-toggle {
  border: none;
  background: transparent;
  margin-top: 4px;
  padding: 0;
  color: #3182ce;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.voice-note-transcript-toggle:hover { color: #2c5282; text-decoration: underline; }

.voice-note-actions { display: flex; align-items: center; gap: 6px; }
.btn-play {
  width: 36px; height: 36px; border-radius: 50%;
  background: #3182ce; color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
}
.btn-play:hover { background: #2c5282; }
.btn-play:disabled { background: #cbd5e0; cursor: not-allowed; }

.btn-delete-note {
  width: 32px; height: 32px; border-radius: 6px;
  background: transparent; border: none; color: #a0aec0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: color 0.15s;
}
.btn-delete-note:hover { color: #e53e3e; }

.voice-notes-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 48px 0; color: #a0aec0; text-align: center;
}
.voice-notes-empty p { margin: 0; font-size: 0.95rem; }

@media (max-width: 640px) {
  .voice-notes-record-cta {
    margin-bottom: 14px;
    padding: 6px 0 10px;
  }
  .btn-record {
    width: 100%;
    max-width: 320px;
    justify-content: center;
  }
}

/* ===========================
   Schedules
   =========================== */
.schedules-view { padding: 0 0 8px; }
.schedules-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.schedules-toolbar h2 { margin: 0; font-size: 1.25rem; }
.schedules-subtitle { margin: 0 0 16px; font-size: 0.85rem; color: var(--text-secondary, #666); }

.btn-add-schedule {
  background: var(--accent-color, #4a9eff);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-add-schedule:hover { background: #3a8eef; }
.btn-add-schedule:active { transform: scale(0.97); }

/* ---- Modal overlay ---- */
.schedule-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.schedule-modal {
  background: var(--surface-color, #fff);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
}
.schedule-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.schedule-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.schedule-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #666);
  cursor: pointer;
  transition: background 0.15s;
}
.schedule-modal-close:hover {
  background: var(--hover-bg, #f0f0f0);
}
.schedule-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px;
}
.schedule-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color, #eee);
}

/* ---- Form fields ---- */
.sched-field { display: flex; flex-direction: column; gap: 5px; }
.sched-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #555);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sched-input, .sched-select, .sched-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg-color, #fafafa);
  color: var(--text-primary, #222);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  font-family: inherit;
}
.sched-input:focus, .sched-select:focus, .sched-textarea:focus {
  outline: none;
  border-color: var(--accent-color, #4a9eff);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}
.sched-textarea { resize: vertical; min-height: 72px; }
.sched-select { cursor: pointer; }

.sched-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.sched-row-2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.sched-toggle-field { align-items: flex-start; min-width: 80px; }

/* ---- Modal buttons ---- */
.sched-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
}
.sched-btn:active { transform: scale(0.97); }
.sched-btn-cancel {
  background: transparent;
  color: var(--text-secondary, #666);
  border: 1px solid var(--border-color, #ddd);
}
.sched-btn-cancel:hover { background: var(--hover-bg, #f5f5f5); }
.sched-btn-save {
  background: var(--accent-color, #4a9eff);
  color: white;
}
.sched-btn-save:hover { background: #3a8eef; }
.sched-btn-save:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Day chips ---- */
.schedule-day-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.schedule-day-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border-color, #ddd);
  background: transparent;
  color: var(--text-secondary, #777);
  user-select: none;
  transition: all 0.15s;
}
.schedule-day-chip.active {
  background: var(--accent-color, #4a9eff);
  color: white;
  border-color: var(--accent-color, #4a9eff);
}
button.schedule-day-chip:hover {
  border-color: var(--accent-color, #4a9eff);
  color: var(--accent-color, #4a9eff);
}
button.schedule-day-chip.active:hover { color: white; }

/* ---- Schedule cards ---- */
.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.schedule-card {
  background: var(--surface-color, #fff);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 12px;
  padding: 16px 20px;
  transition: all 0.15s;
  cursor: pointer;
}
.schedule-card:hover {
  border-color: var(--accent-color, #4a9eff);
  box-shadow: 0 2px 12px rgba(74, 158, 255, 0.08);
}
.schedule-card.schedule-inactive { opacity: 0.5; }

.schedule-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.schedule-card-info { flex: 1; min-width: 0; }
.schedule-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.schedule-title { font-weight: 600; font-size: 0.95rem; }
.schedule-repeat-badge {
  background: var(--tag-bg, #e8f0fe);
  color: var(--tag-color, #3b5bdb);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.schedule-card-controls {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Toggle switch */
.schedule-toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.schedule-toggle input { opacity: 0; width: 0; height: 0; }
.schedule-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-color, #ccc);
  border-radius: 22px;
  transition: background 0.2s;
}
.schedule-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.schedule-toggle input:checked + .schedule-toggle-slider { background: var(--accent-color, #4a9eff); }
.schedule-toggle input:checked + .schedule-toggle-slider::before { transform: translateX(18px); }

.schedule-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-secondary, #666);
}
.schedule-card-meta svg { flex-shrink: 0; opacity: 0.5; }
.schedule-time-window { font-size: 0.82rem; color: var(--text-secondary, #555); font-weight: 500; }
.schedule-description {
  margin: 10px 0 0;
  font-size: 0.84rem;
  color: var(--text-secondary, #666);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.schedule-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color, #f0f0f0);
}
.schedule-last-run { font-size: 0.75rem; color: var(--text-muted, #aaa); }

.btn-delete-schedule {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted, #bbb);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-delete-schedule:hover {
  background: #fff0f0;
  color: #e53e3e;
}

.schedules-empty {
  text-align: center;
  color: var(--text-secondary, #aaa);
  padding: 60px 0;
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .sched-row-3 { grid-template-columns: 1fr 1fr; }
  .sched-row-2 { grid-template-columns: 1fr; }
  .schedule-modal { margin: 10px; }
}

/* ===== Doc editor mobile drawer ===== */

/* Toggle button: hidden on desktop, visible on mobile */
.doc-actions-drawer-toggle {
  display: none;
  padding: 0.4rem;
  background: var(--surface, #1a1a1a);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  cursor: pointer;
  line-height: 1;
}

/* Overlay + drawer use x-show for visibility, CSS just for layout */
.doc-actions-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 199;
}

.doc-actions-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface, #1e1e1e);
  border-top: 1px solid var(--border, #333);
  border-radius: 12px 12px 0 0;
  padding: 1rem;
  z-index: 200;
  max-height: 70vh;
  overflow-y: auto;
}

.doc-actions-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border, #333);
}

.doc-actions-drawer-header h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text, #e0e0e0);
}

.doc-actions-drawer-close {
  background: none;
  border: none;
  color: var(--text-dim, #888);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.doc-actions-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.doc-actions-drawer-body .drawer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-actions-drawer-body .drawer-row label {
  font-size: 0.8rem;
  color: var(--text-dim, #888);
  min-width: 70px;
}

.doc-actions-drawer-body .drawer-row select,
.doc-actions-drawer-body .drawer-row input {
  flex: 1;
  min-width: 0;
}

.doc-actions-drawer-body .drawer-btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.doc-actions-drawer-body .drawer-btn-row button {
  flex: 1;
  min-width: 80px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  background: var(--surface, #1a1a1a);
  color: var(--text, #e0e0e0);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.doc-actions-drawer-body .drawer-btn-row button.active {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}

.doc-actions-drawer-body .drawer-btn-row .btn-delete-doc {
  background: transparent;
  color: #ef4444;
  border-color: #ef4444;
}

@media (max-width: 768px) {
  .doc-editor-actions {
    display: none !important;
  }

  .doc-actions-drawer-toggle {
    display: flex;
  }

  .doc-editor-header {
    gap: 0.5rem;
  }

  .doc-block-rendered {
    padding: 0.4rem 0.5rem;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .doc-block-rendered pre {
    font-size: 0.8rem;
    padding: 0.5rem;
  }

  .doc-title-display {
    font-size: 1.2rem;
  }

  .doc-title-input {
    font-size: 1.2rem;
  }

  .doc-content-block {
    padding: 0;
  }
}
