:root {
  --bg-app: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #334155;
  --text-sidebar: #94a3b8;
  --text-sidebar-bright: #f8fafc;
  
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #e0e7ff;
  
  --badge-inbox: #4f46e5;
  --badge-mentions: #d97706;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

/* Phase 22.6: site-wide dark mode. Every view (Chat/Projects/Wiki/Admin/
   Account/Portal) is already built on the tokens above rather than literal
   colors — that's what makes a single override block here enough to
   retheme the whole app, rather than needing a pass over every view's own
   CSS. html[data-theme="dark"] (not a class, not prefers-color-scheme
   alone) so shell.js's toggle can force either mode regardless of the
   OS setting, while the FOUC-prevention inline script in index.html's
   <head> still falls back to prefers-color-scheme on a visitor's very
   first load, before any explicit choice has been saved.
   The dark sidebar chrome (--bg-sidebar and friends) is intentionally
   left unchanged — it's already a dark surface in light mode (this app's
   sidebar was never white), so it needs no retheming; only the "light"
   surfaces (main content, cards, dropdowns/modals, borders, body text)
   actually invert. Small decorative accents — status pills, mention
   pills, role badges with their own semantic hue — keep their light-mode
   pastel colors in both modes: each already pairs a tinted background
   with its own matching text color, so they stay legible on a dark page,
   just not restyled for it; a full per-accent dark palette is out of
   scope here. Neutral/gray chrome hardcoded to the exact hex of one of
   the tokens above (rather than using var(...)) was fixed to reference
   the token instead, so it retheme's with everything else — see the
   Phase 22.6 plan-doc entry for the specific rules this caught. */
html[data-theme="dark"] {
  --bg-app: #0b0f18;
  --bg-main: #141a26;
  --bg-card: #1a2130;
  --bg-surface: #1a2130;
  --bg-subtle: #212939;

  --border-color: #2a3346;
  --border-dark: #3a4558;

  --text-primary: #e7ebf2;
  --text-secondary: #9aa4b8;
  --text-muted: #6b7690;

  --accent-primary: #6366f1;
  --accent-hover: #818cf8;
  --accent-light: #26254f;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.error { color: #ef4444; font-size: 13px; margin-top: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-dark);
}

.btn-danger {
  background-color: #dc2626;
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
}

.btn-danger:disabled {
  background-color: #fca5a5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-sidebar);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  color: var(--text-sidebar-bright);
  background-color: var(--bg-sidebar-hover);
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--text-sidebar);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.btn-text-action:hover {
  color: var(--text-sidebar-bright);
  background-color: var(--bg-sidebar-hover);
}

/* Login View */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: var(--bg-app);
}

.login-card {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border-color);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-header .app-logo-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-header h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  color: var(--text-primary);
}

.login-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* App Shell */
#app-view {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background-color: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
  user-select: none;
}

.brand:hover {
  background-color: var(--bg-sidebar-hover);
}

.brand-logo-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 4px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-sidebar-bright);
  letter-spacing: -0.5px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Search Form */
.search-form {
  margin-bottom: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  font-size: 13px;
  background-color: var(--bg-sidebar-hover);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar-bright);
  outline: none;
}

#search-input::placeholder {
  color: var(--text-muted);
}

#search-input:focus {
  border-color: var(--accent-primary);
  background-color: #0f172a;
}

/* Vertical Sidebar Nav */
#sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sidebar);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background-color: var(--accent-primary);
  color: #ffffff;
}

.nav-item svg {
  flex-shrink: 0;
}

.nav-item > span:not(.badge) {
  flex: 1;
}

.badge {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  background-color: var(--badge-inbox);
  color: #ffffff;
  box-sizing: border-box;
}

.badge-amber {
  background-color: var(--badge-mentions);
}

.badge-gray {
  background-color: var(--bg-sidebar-active);
  color: var(--text-sidebar);
}

/* Sidebar Accordion Section */
.sidebar-section {
  margin-bottom: 16px;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 4px 8px 4px;
}

.channel-accordion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.channel-accordion-item {
  display: flex;
  flex-direction: column;
}

.channel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

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

.channel-accordion-item.active > .channel-header {
  color: var(--text-sidebar-bright);
  font-weight: 600;
}

.channel-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-arrow {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.channel-accordion-item.open > .channel-header .channel-arrow {
  transform: rotate(90deg);
}

/* Accordion Threads Sub-tree */
.channel-thread-tree {
  list-style: none;
  margin: 4px 0 4px 16px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--bg-sidebar-active);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-thread-item {
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s;
}

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

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

.thread-branch-marker {
  color: var(--accent-light);
  margin-right: 4px;
}

/* Main Panel */
#main-panel {
  flex: 1;
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h3 {
  margin: 0 0 6px 0;
  color: var(--text-primary);
  font-size: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Portal View (Landing Page) */
.portal-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow-y: auto;
  padding: 40px 24px;
  background-color: var(--bg-app);
}

.portal-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.portal-hero {
  text-align: center;
  margin-bottom: 40px;
}

.portal-hero-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 12px;
}

.portal-hero h1 {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.portal-hero p {
  margin: 0 auto;
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 580px;
  line-height: 1.5;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.portal-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
}

.portal-card-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  transition: transform 0.2s ease;
}

.portal-card:hover .portal-card-icon-wrap {
  transform: scale(1.05);
}

.icon-chat {
  background-color: #e0e7ff;
  color: #4338ca;
}

.icon-projects {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.icon-wiki {
  background-color: #fef3c7;
  color: #b45309;
}

.portal-card-content h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.portal-card-content p {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
  flex-grow: 1;
}

.portal-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.portal-card-stat {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 4px 8px;
  border-radius: 12px;
}

.portal-card-badge {
  font-weight: 500;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 8px;
  border-radius: 12px;
}

.portal-card-arrow {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.portal-card:hover .portal-card-arrow {
  transform: translateX(4px);
  color: var(--accent-primary);
}

/* Sidebar Section Headers */
.sidebar-section-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.sidebar-projects-header {
  margin-top: 4px;
}

/* Thread / Chat View */
#thread-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-main);
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

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

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#thread-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Branches Bar */
.branches-bar {
  padding: 8px 24px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.branches-bar a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
}

.branches-bar a:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Message Container */
.message-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: background 0.15s;
  position: relative;
}

.message:hover {
  background-color: var(--bg-subtle);
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}

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

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.message-meta-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-author {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

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

.star-indicator {
  color: #f59e0b;
  font-size: 14px;
}

.btn-message-reply {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  margin-left: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  line-height: 1.3;
  transition: all 0.15s ease;
  opacity: 0.8;
}

.message:hover .btn-message-reply,
.btn-message-reply:hover {
  opacity: 1;
  color: var(--text-primary);
  background-color: var(--bg-subtle, rgba(255, 255, 255, 0.06));
  border-color: var(--border-color, rgba(255, 255, 255, 0.1));
}

.btn-message-reply svg {
  flex-shrink: 0;
}

.message-menu-container {
  position: relative;
}

.message-menu-btn {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-muted);
  padding: 2px 6px;
  line-height: 1;
}

.message-menu-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.message-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  padding: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background-color: var(--bg-subtle);
  color: var(--accent-primary);
}

.message-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
}

.message-body.rich-text p {
  margin: 0 0 4px 0;
}

.message-body.rich-text p:last-child {
  margin-bottom: 0;
}

.message-body.rich-text pre {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  overflow-x: auto;
  margin: 4px 0;
}

.message-body.rich-text blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 10px;
  color: var(--text-secondary);
  margin: 4px 0;
}

.message-body.rich-text img {
  max-width: 100%;
  max-height: 380px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  margin-bottom: 4px;
  display: block;
  object-fit: contain;
}

/* Slack-style Branch Replies Component */
.branch-replies-container {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  clear: both;
}

.branch-reply-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  width: fit-content;
  max-width: 100%;
}

.branch-reply-row:hover {
  background-color: var(--bg-subtle);
}

.branch-reply-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.branch-creator-avatar {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background-color: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  flex-shrink: 0;
}

.branch-reply-info {
  font-size: 13px;
  color: var(--text-muted);
}

.branch-reply-title {
  color: #2563eb;
  font-weight: 600;
}

.branch-reply-row:hover .branch-reply-title {
  text-decoration: underline;
}

.branch-reply-time {
  color: var(--text-muted);
}

.branch-reply-quote {
  border-left: 3px solid var(--accent-primary);
  padding: 4px 10px;
  margin-left: 0;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  max-width: 650px;
}

.branch-reply-quote p {
  margin: 0;
}

.forked-badge:hover {
  background: #fde68a;
}

.star-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  padding: 2px 4px;
}

.star-btn.starred {
  color: #f59e0b;
}

/* Reactions */
.reactions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  position: relative;
}

.reaction-pill {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-main);
  cursor: pointer;
  transition: all 0.15s;
}

.reaction-pill:hover {
  border-color: var(--border-dark);
}

.reaction-pill.reacted {
  background-color: var(--accent-light);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

.reaction-add-btn {
  font-size: 12px;
  padding: 2px 8px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: var(--bg-main);
  color: var(--text-muted);
  cursor: pointer;
}

.reaction-add-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.emoji-picker {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  padding: 8px;
  display: flex;
  gap: 4px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.emoji-picker button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}

.emoji-picker button:hover {
  background-color: var(--bg-subtle);
}

/* Composer Container */
.composer-container {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-main);
}

.reply-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-body-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-main);
  transition: border-color 0.15s;
  overflow: hidden;
}

.composer-body-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Shared chrome for every TipTap toolbar/editor pairing: chat's own
   composer + fork-reply modal, issue create/edit, and issue comments.
   These were originally styled as literal Quill DOM (`.ql-toolbar`,
   `.ql-container`, `.ql-editor`, `.ql-blank`) from before this app's two
   Quill->TipTap swaps (Phase 13 for chat, Phase 14 for issues/comments).
   TipTap only ever renders a plain `.ProseMirror` class on the editable
   div it mounts — never `.ql-editor`/`.ql-container` — so those old
   selectors stopped matching anything once the swap landed, and every
   affected composer had been running with no internal text padding, no
   placeholder text rendering, and (for the issue/comment toolbars
   specifically, which never had chat's ID-scoped rules) no toolbar
   background/button chrome at all — just bare, unstyled `<button>`
   elements. Keyed off the `.quill-wrapper`/`.quill-toolbar`/
   `.quill-toolbar-compact` classes already present in index.html on every
   one of these composers (chat's own toolbar included, so a single
   ruleset now covers all of them instead of duplicating per-ID rules). */
.quill-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  overflow: hidden;
}

.quill-toolbar {
  border: none !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 6px 8px !important;
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quill-toolbar-compact {
  padding: 4px 6px !important;
  gap: 4px;
}

.quill-toolbar button {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  transition: all 0.15s ease;
}

.quill-toolbar-compact button {
  width: 22px;
  height: 22px;
}

.quill-toolbar button:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.quill-toolbar button svg {
  stroke: currentColor;
}

/* The actual TipTap/ProseMirror editable div. Padding and font live here
   (scoped per composer below) rather than on the container div passed to
   createEditor(), since the modal editors also get a min-height set
   inline in index.html on that same container. */
.ProseMirror {
  outline: none;
}

.ProseMirror p {
  margin: 0 0 0.5em;
}

.ProseMirror > *:last-child {
  margin-bottom: 0;
}

/* TipTap's Placeholder extension marks the empty first paragraph with
   `is-editor-empty` and a `data-placeholder` attribute, but supplies no
   CSS of its own — the `content: attr(...)` rule is the documented,
   required piece an integrator provides. Without it (as here, until now)
   the placeholder text never renders at all, empty or not. */
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: var(--text-muted);
  font-style: normal;
  pointer-events: none;
  height: 0;
}

.ProseMirror img {
  max-width: 100%;
  max-height: 380px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  display: block;
  object-fit: contain;
}

#quill-editor {
  border: none !important;
  min-height: 56px;
  max-height: 200px;
  overflow-y: auto;
}

#quill-editor .ProseMirror {
  padding: 8px 12px;
  min-height: 56px;
  font-family: inherit;
  font-size: 14px;
}

.create-issue-quill-wrapper .ProseMirror {
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
}

.new-comment-quill-wrapper .ProseMirror {
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
}

.composer-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.btn-send {
  align-self: flex-end;
}

/* List View (Inbox, Recent, Mentions, Starred, Drafts) */
#list-view {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.list-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-main);
}

.list-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.list-view-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.list-group-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 20px 0 8px 0;
}

.list-group-header:first-child {
  margin-top: 0;
}

.list-item {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background-color: var(--bg-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.15s;
}

.list-item:hover {
  border-color: var(--border-dark);
  box-shadow: var(--shadow-sm);
}

.list-item-main {
  min-width: 0;
  flex: 1;
}

.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-delete {
  font-size: 12px;
  padding: 4px 8px;
  color: #ef4444;
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
}

.list-item-delete:hover {
  background-color: #fef2f2;
}

.empty-state-inline {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

/* ============================================================
   Projects & Kanban Board (Phase 5)
   ============================================================ */

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

.project-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-sidebar-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px 8px;
  transition: all 0.15s;
}

.project-nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-sidebar);
}

.project-nav-item.active {
  background-color: var(--accent-primary);
  color: #ffffff;
}

.project-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.project-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-toggle-group {
  display: flex;
  background-color: var(--bg-subtle);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.btn-toggle {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.btn-toggle.active {
  background-color: var(--bg-main);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.project-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  color: var(--text-primary);
  outline: none;
}

/* Kanban Board Columns */
.kanban-board {
  display: flex;
  gap: 16px;
  padding: 24px;
  overflow-x: auto;
  min-height: calc(100vh - 140px);
  background-color: var(--bg-app);
}

.kanban-column {
  width: 280px;
  min-width: 280px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
}

.kanban-column-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--border-color);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.column-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.column-count {
  font-size: 11px;
  font-weight: 600;
  background-color: var(--border-dark);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 10px;
}

.kanban-card-list {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
}

.kanban-card-list.drag-over {
  background-color: #e0e7ff;
  border: 2px dashed var(--accent-primary);
  border-radius: var(--radius-sm);
}

.issue-card {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  cursor: grab;
  transition: all 0.15s;
}

.issue-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.issue-card.dragging {
  opacity: 0.4;
}

.issue-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.issue-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.type-badge {
  background-color: #e0e7ff;
  color: #3730a3;
}

.type-badge.bug { background-color: #fee2e2; color: #991b1b; }
.type-badge.feature { background-color: #dbeafe; color: #1e40af; }
.type-badge.task { background-color: #f3f4f6; color: #374151; }
.type-badge.improvement { background-color: #e0e7ff; color: #3730a3; }

.priority-badge.high { background-color: #fee2e2; color: #dc2626; }
.priority-badge.medium { background-color: #fef3c7; color: #d97706; }
.priority-badge.low { background-color: #f3f4f6; color: #4b5563; }

.issue-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.issue-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

.issue-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Modal Styling */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background-color: var(--bg-main);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.issue-meta-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background-color: var(--bg-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.meta-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.form-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
}

.issue-section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.subtask-progress-badge {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.subtask-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.subtask-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
}

.subtask-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

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

.add-subtask-form {
  display: flex;
  gap: 8px;
}

.add-subtask-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.comment-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background-color: var(--bg-subtle);
}

.comment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.comment-author {
  font-weight: 600;
  color: var(--text-primary);
}

.comment-time {
  color: var(--text-muted);
}

.add-comment-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.project-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-count-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Project Filter Card */
.project-filters-card {
  margin: 0 24px 12px 24px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
}

.filters-grid {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.filter-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-select {
  width: 100%;
  height: 28px;
  padding: 2px 6px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  color: var(--text-primary);
  outline: none;
}

.filter-select:focus {
  border-color: var(--accent-primary);
}

.filter-actions-col {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

.filter-actions-col .btn {
  height: 28px;
  padding: 2px 10px;
  font-size: 12px;
}

/* List View Toolbar & Status Summary */
.list-view-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.list-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pills-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.status-summary-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-summary-pill.status-unassigned { background-color: #64748b; color: #ffffff; }
.status-summary-pill.status-in-progress { background-color: #f59e0b; color: #1e293b; }
.status-summary-pill.status-wfr { background-color: #06b6d4; color: #1e293b; }
.status-summary-pill.status-ready-for-qa { background-color: #f97316; color: #ffffff; }
.status-summary-pill.status-completed { background-color: #10b981; color: #ffffff; }
.status-summary-pill.status-wnd { background-color: #ef4444; color: #ffffff; }

.toggle-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-switch-label input[type="checkbox"] {
  cursor: pointer;
}

/* Dropdown Container */
.dropdown-container {
  position: relative;
  display: inline-block;
}

.dropdown-menu-list {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 170px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.dropdown-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.dropdown-menu-item:hover {
  background-color: var(--bg-subtle);
}

.dropdown-menu-item.text-danger {
  color: #dc2626;
}

.dropdown-menu-item.text-danger:hover {
  background-color: #fee2e2;
}

/* Issue Table */
.project-issue-list {
  padding: 0 24px 24px 24px;
}

.issue-table-responsive {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.issue-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.issue-table th {
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  user-select: none;
  white-space: nowrap;
}

.issue-table th.sortable-th {
  cursor: pointer;
}

.issue-table th.sortable-th:hover {
  color: var(--accent-primary);
  background-color: var(--bg-subtle);
}

.sort-icon {
  display: inline-block;
  margin-left: 2px;
  font-size: 11px;
}

.issue-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.issue-table tr:hover td {
  background-color: var(--bg-subtle);
}

.issue-table-row {
  cursor: pointer;
}

.issue-table-row.dragging {
  opacity: 0.4;
}

.issue-table-row.drag-target-nest {
  background-color: #ecfdf5 !important;
  outline: 2px dashed #10b981;
}

.issue-table .col-hidden {
  display: none !important;
}

.columns-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 6px 0;
  min-width: 140px;
  z-index: 100;
}

.columns-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.columns-menu-item:hover {
  background-color: var(--bg-subtle);
}

.columns-menu-item input[type="checkbox"] {
  cursor: pointer;
}

.group-header-row {
  background-color: var(--bg-subtle) !important;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.group-header-row:hover {
  background-color: var(--border-color) !important;
}

.group-header-row td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-dark);
}

.group-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  color: var(--text-secondary);
}

.group-header-row.collapsed .group-toggle-icon {
  transform: rotate(-90deg);
}

.drag-grip-handle {
  cursor: grab;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.drag-grip-handle:hover {
  color: var(--text-primary);
}

.issue-title-link {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.3;
}

.issue-title-link:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.description-preview-snippet {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.inline-status-select {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  outline: none;
  cursor: pointer;
  text-align: center;
}

.inline-status-select.status-unassigned { background-color: #64748b; color: #ffffff; }
.inline-status-select.status-in-progress { background-color: #f59e0b; color: #1e293b; }
.inline-status-select.status-wfr { background-color: #06b6d4; color: #1e293b; }
.inline-status-select.status-ready-for-qa { background-color: #f97316; color: #ffffff; }
.inline-status-select.status-completed { background-color: #10b981; color: #ffffff; }
.inline-status-select.status-wnd { background-color: #ef4444; color: #ffffff; }

.comment-count-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.assignee-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.row-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Modal Enhancements */
.create-issue-modal-content {
  max-width: 780px;
  width: 95%;
}

.create-issue-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.create-issue-quill-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  overflow: hidden;
}
/* Toolbar chrome and editable-area padding/font for this wrapper are now
   handled by the generic `.quill-toolbar`/`.ProseMirror` rules above —
   the `.ql-toolbar`/`.ql-container` selectors that used to live here
   targeted Quill's own DOM and never matched TipTap's (see the comment
   above `.quill-wrapper`). */

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  max-height: calc(85vh - 60px);
}

.modal-content.modal-sm {
  max-width: 360px;
}

/* ============================================================
   Chat <-> Projects Linking (Phase 6)
   ============================================================ */

.message-linked-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.linked-issue-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background-color: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}

.linked-issue-pill:hover {
  background-color: #c7d2fe;
  color: #1e1b4b;
}

.issue-mention-link {
  color: var(--accent-primary);
  font-weight: 600;
  text-decoration: none;
  background-color: var(--accent-light);
  padding: 1px 4px;
  border-radius: 3px;
}

.issue-mention-link:hover {
  text-decoration: underline;
  background-color: #c7d2fe;
}

.linked-messages-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.linked-chat-message-item {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  cursor: pointer;
  transition: all 0.15s;
}

.linked-chat-message-item:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-dark);
}

.linked-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.linked-msg-channel {
  font-weight: 600;
  color: var(--text-secondary);
}

.linked-msg-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}

/* User Menu Dropdown */
.user-menu-trigger {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.user-menu-trigger:hover {
  transform: scale(1.08);
}

.user-profile.dropdown-container {
  position: relative;
}

.user-profile .dropdown-menu-list {
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  min-width: 140px;
}

/* Account View */
#account-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  background-color: var(--bg-app);
}

.account-header {
  padding: 24px 32px 16px 32px;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
}

.account-header h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
}

.account-content-container {
  padding: 32px;
  max-width: 960px;
}

.account-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
}

.account-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.account-card-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.account-card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.form-input-readonly-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-role {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.badge-role.role-super-admin {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-role.role-admin {
  background-color: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.badge-role.role-user {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
}

.alert-inline {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-top: 12px;
}

.alert-inline.alert-success {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-inline.alert-error {
  background-color: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Admin View */
#admin-view {
  flex: 1;
  display: flex;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
}

.admin-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
}

.admin-sidebar {
  width: 240px;
  background-color: var(--bg-main);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.admin-sidebar-header {
  padding: 20px 20px 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.admin-nav-list {
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 4px;
}

.admin-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.admin-nav-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.admin-nav-btn.active {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  font-weight: 600;
}

.admin-main-panel {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.admin-panel-view {
  max-width: 1000px;
}

.admin-panel-header {
  margin-bottom: 24px;
}

.admin-panel-header h2 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
}

.admin-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

/* Upload Dropzone */
.upload-dropzone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-md);
  padding: 36px 20px;
  text-align: center;
  background-color: var(--bg-subtle);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--accent-primary);
  background-color: var(--accent-light);
}

.dropzone-inner svg {
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.dropzone-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

.inspect-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.inspect-stat-card {
  padding: 12px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  text-align: center;
}

.inspect-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary);
}

.inspect-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.user-mapping-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-subtle);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}

.fallback-user-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.import-actions-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.import-result-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.import-result-card.has-mismatches {
  background-color: #fffbeb;
  border-color: #fde68a;
}

/* Restore (Phase 19.5) — deliberately more visually alarming than the
   importer's inspect card, since restore permanently replaces existing
   data (see WIKI_INTEGRATION_PLAN.md Phase 19.5's UI notes). */
.restore-warning-box {
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.restore-confirm-row {
  margin-bottom: 16px;
}

.restore-confirm-row .form-input {
  max-width: 220px;
}

/* System Log Badges & Styles */
.badge-log-level {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-log-level.level-crash {
  background-color: #7f1d1d;
  color: #ffffff;
}

.badge-log-level.level-error {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.badge-log-level.level-warning {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-log-level.level-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-log-level.level-debug {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.log-message-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.log-detail-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}

.log-message-box {
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
  white-space: pre-wrap;
}

.log-code-box {
  background-color: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-x: auto;
  margin: 0;
}

.log-stack-box {
  max-height: 240px;
  overflow-y: auto;
}

/* ---- Mention & Reference Autocomplete Popover ---- */
.mention-popover {
  position: absolute;
  z-index: 2100;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  max-height: 300px;
  width: 580px;
  max-width: calc(100vw - 32px);
  overflow-y: auto;
  padding: 4px 0;
  font-size: 13px;
}

.mention-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text-primary);
  background-color: var(--bg-main);
  user-select: none;
}

.mention-popover-item:hover,
.mention-popover-item.active {
  background-color: var(--bg-subtle);
}

.mention-popover-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.mention-popover-icon.user {
  background: #e0e7ff;
  color: #4338ca;
}

.mention-popover-icon.channel {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.mention-popover-icon.topic {
  background: #f3e8ff;
  color: #7e22ce;
}

.mention-popover-icon.project {
  background: #ccfbf1;
  color: #0f766e;
}

.mention-popover-icon.issue {
  background: #ecfdf5;
  color: #047857;
}

.mention-popover-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  font-size: 13px;
}

.mention-popover-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

/* ---- Mention Pills in Rendered HTML ---- */
.mention-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  vertical-align: baseline;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.mention-pill:hover {
  opacity: 0.85;
  text-decoration: none;
}

.mention-pill.mention-user {
  background: #e0e7ff;
  color: #3730a3;
}

.mention-pill.mention-user.mention-me {
  background: #fef08a;
  color: #854d0e;
  box-shadow: 0 0 0 1px #facc15;
}

.mention-pill.mention-channel {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.mention-pill.mention-topic {
  background: #f3e8ff;
  color: #6b21a8;
}

.mention-pill.mention-project {
  background: #ccfbf1;
  color: #115e59;
}

.mention-pill.mention-issue {
  background: #ecfdf5;
  color: #065f46;
}

/* Phase 22: #wiki:slug references */
.mention-pill.mention-wiki {
  background: #fff7ed;
  color: #9a3412;
}

/* ============================================================
   Sidebar Gear Buttons & Settings Dialogs
   ============================================================ */

.sidebar-gear-btn {
  background: transparent;
  border: none;
  color: var(--text-sidebar-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  line-height: 1;
}

.channel-header:hover .sidebar-gear-btn,
.channel-thread-item:hover .sidebar-gear-btn,
.project-nav-item:hover .sidebar-gear-btn {
  opacity: 0.65;
}

.sidebar-gear-btn:hover {
  opacity: 1 !important;
  color: var(--text-sidebar-bright) !important;
  background-color: rgba(255, 255, 255, 0.2);
}

.channel-thread-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-thread-item .thread-title-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-members-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 0;
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-main);
}

.settings-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.settings-member-item:last-child {
  border-bottom: none;
}

.settings-member-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-member-name {
  font-weight: 500;
  color: var(--text-main);
}

.settings-member-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-sidebar-hover);
  color: var(--text-muted);
  font-weight: 500;
}

.settings-member-badge.creator {
  background: rgba(79, 70, 229, 0.15);
  color: var(--accent-primary);
  font-weight: 600;
}

.settings-member-remove-btn {
  background: none;
  border: 1px solid #fca5a5;
  color: #dc2626;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-member-remove-btn:hover {
  background-color: #fee2e2;
  border-color: #ef4444;
}

/* Phase 11.5: brief highlight flash for a #block-{id} deep link landing on
   a wiki block (block content itself lands in Phase 18). */
.block-highlight-flash {
  animation: block-highlight-flash-anim 2s ease-out;
}

@keyframes block-highlight-flash-anim {
  0% { background-color: #fef3c7; }
  100% { background-color: transparent; }
}

/* ============================================================
   Small utility classes (Phase 18). These class names were already used
   pervasively across admin/settings/modal markup from earlier phases
   (d-flex, text-muted, mb-3, etc.) but never actually defined anywhere in
   this file, so every element using them silently rendered without its
   intended color/spacing/layout. Phase 18's own new markup depends on the
   same classes, so defining them here is a strict improvement — it only
   ever adds styling to previously-unstyled elements, never removes or
   changes anything that was already working.
   ============================================================ */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: #dc2626; }
.text-center { text-align: center; }
.small { font-size: 12px; }
.d-flex { display: flex; }
.flex-grow-1 { flex: 1 1 auto; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.gap-2 { gap: 8px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
/* .me-1 was already referenced by the System Log tab's "Details" button
   (shell.js) with no matching rule — dead class, buttons sat flush.
   Defining it here (plus .me-2, needed by the new Wiki Trash tab's
   Restore/Delete Permanently pair) fixes both at once. */
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.fw-bold { font-weight: 700; }
.cursor-pointer { cursor: pointer; }

/* ============================================================
   Wiki (Phase 18)
   ============================================================ */

/* Missing since Phase 18: unlike #thread-view (chat), #wiki-view never
   got its own display:flex/height:100% rule. Without it, #wiki-view is
   just a shrink-to-fit block inside #main-panel's overflow:hidden flex
   column, so .wiki-body's `flex: 1` and .wiki-main's `overflow-y: auto`
   below have no bounded parent height to actually operate within — the
   whole view just grows with its content and gets silently clipped by
   #main-panel instead of scrolling, in both view and edit mode. */
#wiki-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Phase 22.5: the width of the centered reading column used by the
     toolbar and every content block below it (editor/read view, children
     list, backlinks, cross-links) — one variable so they all agree,
     rather than repeating the same max-width in five places. */
  --wiki-reading-width: 820px;
  /* Phase 22.6: a lighter divider than --border-color for the page's own
     chrome (toolbar underline, side-panel edge). The reference design's
     surfaces are separated by a hairline, not a visible rule. */
  --wiki-hairline: #eceef1;
  background-color: var(--bg-main);
}

/* "Full width" from the page "⋯" menu: every block that opts into the
   reading column (toolbar inner, page header, editor, children,
   backlinks) is capped by this one variable, so widening the document is
   a single override rather than a per-selector toggle. */
#wiki-view.wiki-full-width { --wiki-reading-width: 100%; }

/* Phase 22.6: the toolbar is a slim sticky strip holding only the
   breadcrumb and the page actions. The document's own title/byline moved
   into the scrolling column (.wiki-page-header) so the page reads as a
   document with a header rather than an app screen with a title bar. */
/* The toolbar lives inside the scrolling column (not above .wiki-body)
   so its inner max-width resolves against exactly the same box the page
   header and prose do — otherwise the breadcrumb centres over the full
   window while the title centres over the narrower column beside an open
   side panel, and the two visibly disagree. Sticky + negative horizontal
   margins give it the full-bleed background and hairline it would have
   had as a sibling. */
.wiki-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -32px;
  padding: 10px 32px;
  border-bottom: 1px solid var(--wiki-hairline);
  background-color: var(--bg-main);
  flex-shrink: 0;
}

.wiki-toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--wiki-reading-width);
  margin: 0 auto;
  min-height: 36px;
}

.wiki-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Edit/Read segmented switch — a grey track with a raised white pill on
   the active side, which is what reads as "a switch with two positions"
   rather than as two adjacent buttons. */
.wiki-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background-color: var(--bg-subtle);
}
.wiki-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.wiki-mode-btn:hover { color: var(--text-primary); }
.wiki-mode-btn.is-active {
  background-color: var(--bg-main);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.wiki-toolbar-text-btn {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.wiki-toolbar-text-btn:hover { background-color: var(--bg-subtle); }

/* The icon buttons are the "more prominent" chrome the redesign asks
   for: a real 34px hit target with a hover surface, not a bare glyph. */
.wiki-toolbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.wiki-toolbar-icon-btn:hover { background-color: var(--bg-subtle); color: var(--text-primary); }
.wiki-toolbar-icon-btn.is-active { background-color: var(--bg-subtle); color: var(--text-primary); }

/* Phase 22.6: theme toggle icon swap — driven purely by the html[data-theme]
   attribute below, no JS icon-swapping needed. */
#wiki-theme-toggle-btn .wiki-theme-icon-sun { display: none; }
html[data-theme="dark"] #wiki-theme-toggle-btn .wiki-theme-icon-moon { display: none; }
html[data-theme="dark"] #wiki-theme-toggle-btn .wiki-theme-icon-sun { display: block; }

/* Autosave state, shown in place of the Save/Cancel buttons 22.5 had. */
.wiki-save-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}
.wiki-save-status.is-error { color: #dc2626; }
.wiki-save-status.is-flash { color: var(--accent-primary); }

/* Rich Features Plan Phase 2: hard edit-lock status, next to the save
   status. Plain/muted while just informing ("locked by X"); the brief
   post-unlock "click to edit" state is styled as an actual affordance. */
.wiki-lock-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}
.wiki-lock-status.is-clickable {
  color: var(--accent-primary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Phase 22.8: explicit Save button — only visible while Edit mode is on,
   right next to the Edit/Read switch. Accent-colored rather than the
   plain toolbar-icon-btn's muted default so it reads as an action, not
   another view toggle. */
.wiki-save-btn {
  color: var(--accent-primary);
}
.wiki-save-btn:hover {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

/* Breadcrumb: darker and denser than 22.5's near-invisible muted trail,
   with the current page as a plain trailing crumb. */
#wiki-breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  overflow: hidden;
}
#wiki-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  padding: 3px 6px;
  margin: 0 -2px;
  border-radius: var(--radius-sm);
}
#wiki-breadcrumb a:hover { color: var(--text-primary); background-color: var(--bg-subtle); }
.wiki-breadcrumb-sep { color: var(--border-dark); flex-shrink: 0; }
.wiki-breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Document header inside the scrolling column. */
.wiki-page-header {
  max-width: var(--wiki-reading-width);
  margin: 36px auto 20px;
}
.wiki-page-header .title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px 0;
}
.wiki-page-header h2,
.wiki-page-title-input {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-primary);
  word-break: break-word;
}
.wiki-page-title-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  box-shadow: none;
}
.wiki-page-title-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}
.wiki-page-title-input:focus {
  outline: none;
}
.wiki-page-header .badge-role { flex-shrink: 0; margin-top: 8px; }

.wiki-byline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13.5px;
  color: var(--text-secondary);
}
.wiki-byline-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--accent-light);
  color: var(--accent-primary);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.wiki-byline-avatar.sm { width: 20px; height: 20px; font-size: 9px; }
.wiki-byline-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.wiki-byline-icon-btn:hover { background-color: var(--bg-subtle); color: var(--text-secondary); }
.wiki-byline-icon-btn.is-active { background-color: var(--bg-subtle); color: var(--accent-primary); }

/* Rich Features Plan Phase 2: live-viewer badges, next to the byline. */
.wiki-presence-badges {
  display: flex;
  align-items: center;
  margin-left: 2px;
}
.wiki-presence-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--bg-main);
  margin-left: -6px;
}
.wiki-presence-badge:first-child { margin-left: 0; }

.wiki-tags-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.wiki-tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background-color: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-color);
}
.wiki-tag-chip-remove { cursor: pointer; color: var(--text-muted); font-weight: 700; }
.wiki-tag-chip-remove:hover { color: #dc2626; }
.wiki-tag-add-btn {
  border: 1px dashed var(--border-color); background: transparent; border-radius: 999px;
  font-size: 12px; padding: 2px 8px; color: var(--text-muted); cursor: pointer;
}
.wiki-tag-add-btn:hover { color: var(--text-secondary); border-color: var(--border-dark); }
.wiki-tag-add-input { border: 1px solid var(--accent-primary); border-radius: 999px; padding: 2px 8px; font-size: 12px; width: 110px; }

/* The page "⋯" menu: wider than the shared dropdown default (its labels
   are full sentences, not one word), icon-led rows, and a summary footer
   mirroring the reference design's word-count/creator strip. */
.wiki-more-menu {
  left: auto;
  right: 0;
  min-width: 252px;
  padding: 6px 0 0;
  border-radius: var(--radius-lg);
}
.wiki-more-menu .dropdown-menu-item,
.wiki-tree-menu .dropdown-menu-item,
.wiki-table-context-menu .dropdown-menu-item,
.wiki-block-context-menu .dropdown-menu-item {
  gap: 10px;
  padding: 8px 14px;
  font-size: 13.5px;
}
.wiki-more-menu .dropdown-menu-item svg,
.wiki-tree-menu .dropdown-menu-item svg,
.wiki-table-context-menu .dropdown-menu-item svg,
.wiki-block-context-menu .dropdown-menu-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.wiki-more-menu .dropdown-menu-item.text-danger svg,
.wiki-tree-menu .dropdown-menu-item.text-danger svg,
.wiki-table-context-menu .dropdown-menu-item.text-danger svg,
.wiki-block-context-menu .dropdown-menu-item.text-danger svg { color: #dc2626; }
.wiki-more-menu .dropdown-menu-item.is-active svg { color: var(--accent-primary); fill: var(--accent-light); }
.wiki-block-context-menu .dropdown-menu-item.is-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.dropdown-menu-sep { height: 1px; margin: 6px 0; background-color: var(--border-color); }

/* Full-width switch inside the menu row. */
.wiki-menu-toggle {
  margin-left: auto;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background-color: var(--border-dark);
  position: relative;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}
.wiki-menu-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background-color: #ffffff;
  transition: transform 0.15s ease;
}
.wiki-menu-toggle.is-on { background-color: var(--accent-primary); }
.wiki-menu-toggle.is-on::after { transform: translateX(13px); }

.wiki-more-menu-footer {
  margin-top: 6px;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border-color);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-muted);
}

.wiki-body { flex: 1; display: flex; overflow: hidden; min-height: 0; background-color: var(--bg-main); }
.wiki-main { flex: 1; overflow-y: auto; padding: 0 32px 160px; min-width: 0; background-color: var(--bg-main); }

/* Phase 22.5: every content block in the main column is capped at
   --wiki-reading-width and centered, so a wide viewport reads as a
   document with generous margins either side rather than full-bleed
   text — the single highest-impact change for the "polished document"
   feel the redesign is going for. These are independent sibling blocks
   under .wiki-main (not nested in one wrapper), so the rule is repeated
   per selector rather than appliable once. */
.wiki-editor-shell,
.wiki-children-list,
.wiki-backlinks,
.wiki-selection-toolbar {
  max-width: var(--wiki-reading-width);
  margin-left: auto;
  margin-right: auto;
}

.wiki-editor-shell { position: relative; }
.wiki-editor-container { min-height: 200px; }
.wiki-editor-container .ProseMirror { min-height: 200px; padding: 4px 4px 4px 32px; }
.wiki-editor-container.wiki-readonly .ProseMirror { padding-left: 4px; cursor: default; }
.wiki-editor-container.wiki-readonly { cursor: default; }

/* Document-style prose typography. The generic .ProseMirror rules
   earlier in this file (shared with chat/issue composers) are
   deliberately minimal — a wiki page is read as a document, not a chat
   bubble, so it gets its own fuller heading/list/quote/code/table scale.
   Scoped to plain .wiki-editor-container (NOT ".wiki-editor-container
   .ProseMirror") because only edit mode's live TipTap instance wraps its
   content in a div.ProseMirror — read mode (renderTipTapToHTML) writes
   the rendered h1/p/ul/etc markup straight into #wiki-editor-container
   with no such wrapper, so a selector that required .ProseMirror would
   silently apply only while editing and never in the read view, which is
   where readers actually spend most of their time. Descendant matching
   still reaches the same elements in edit mode, just one level deeper
   inside .ProseMirror. */
.wiki-editor-container {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-primary);
}
.wiki-editor-container p { margin: 0 0 0.9em; }
.wiki-editor-container h1,
.wiki-editor-container h2,
.wiki-editor-container h3,
.wiki-editor-container h4 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 1.4em 0 0.5em;
}
.wiki-editor-container h1:first-child,
.wiki-editor-container h2:first-child,
.wiki-editor-container h3:first-child,
.wiki-editor-container h4:first-child {
  margin-top: 0;
}
.wiki-editor-container h1 { font-size: 1.85em; }
.wiki-editor-container h2 { font-size: 1.5em; }
.wiki-editor-container h3 { font-size: 1.25em; }
.wiki-editor-container h4 { font-size: 1.05em; }
.wiki-editor-container ul,
.wiki-editor-container ol {
  margin: 0 0 0.9em;
  padding-left: 1.4em;
}
.wiki-editor-container li { margin: 0.25em 0; }
.wiki-editor-container li > p { margin: 0; }
.wiki-editor-container blockquote {
  margin: 0 0 0.9em;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--border-dark);
  color: var(--text-secondary);
}
.wiki-editor-container code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background-color: var(--bg-subtle);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
.wiki-editor-container pre {
  margin: 0 0 0.9em;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background-color: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
}
.wiki-editor-container pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 0.85em;
}
.wiki-editor-container hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.6em 0;
}
/* :not(.mention-pill) so this doesn't fight the pill's own text-decoration
   rules (chat/issue mentions, #123/#topic:N/#wiki:slug references) —
   without it this rule's higher specificity would force an underline on
   pill hover despite .mention-pill:hover explicitly saying none. */
.wiki-editor-container a:not(.mention-pill) { color: var(--accent-primary); text-decoration: none; }
.wiki-editor-container a:not(.mention-pill):hover { text-decoration: underline; }
.wiki-editor-container table {
  border-collapse: collapse;
  margin: 0 0 0.9em;
  width: 100%;
}
.wiki-editor-container th,
.wiki-editor-container td {
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  text-align: left;
  position: relative;
}
.wiki-editor-container th {
  background-color: var(--bg-subtle);
  font-weight: 600;
}
.wiki-editor-container .selectedCell:after {
  z-index: 2;
  position: absolute;
  content: "";
  left: 0; right: 0; top: 0; bottom: 0;
  background: var(--accent-light);
  opacity: 0.4;
  pointer-events: none;
}

/* Toggle (details/summary) blocks — Rich Features Plan.md Phase 4.
   Two DOM shapes to cover, not one — found live, after the first version
   of this CSS shipped with no visible chevron and a stray unstyled UA
   button rendering as a blank pill (see the plan doc's Phase 4 UX-fix
   note): the *live editor* renders `@tiptap/extension-details`'s own
   custom NodeView (`<div class="details" data-type="details">` wrapping a
   plain `<button>` toggle + a content `<div>` holding `<summary>`/
   `[data-type="detailsContent"]`, open state tracked via an `.is-open`
   class on the wrapper) rather than a real `<details>` tag — only
   read-mode's `renderTipTapToHTML` (which serializes via the schema's
   declarative `renderHTML`, not the NodeView) emits an actual
   `<details><summary>`. Both need their own toggle-affordance styling,
   since neither DOM shape is a subset of the other. */
.wiki-editor-container details,
.wiki-editor-container .details {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 0.9em;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5em 0.8em;
}
/* Read mode: a real <details>/<summary> pair. `display: flex` on <details>
   above already drops its UA `list-item` rendering, which is what a plain
   `list-style: none` on <summary> alone would NOT have suppressed — that
   only kills the bullet glyph a list-item draws, not the separate native
   disclosure-triangle marker (`::-webkit-details-marker` in Chrome/Safari,
   `::marker` in Firefox) — so both are belt-and-suspenders here too. */
.wiki-editor-container details > summary {
  list-style: none;
  cursor: pointer;
}
.wiki-editor-container details > summary::-webkit-details-marker { display: none; }
.wiki-editor-container details > summary::marker { display: none; content: ""; }
.wiki-editor-container details > summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  font-size: 0.85em;
  transition: transform 0.12s ease;
  color: var(--text-muted);
}
.wiki-editor-container details[open] > summary::before { transform: rotate(90deg); }
.wiki-editor-container details > div[data-type="detailsContent"] {
  padding: 0.5em 0 0 1.3em;
}

/* Live editor: the NodeView's own <button> toggle. `all: unset` first to
   strip the browser's default button chrome (border/background/padding) —
   without it, an otherwise-empty <button> renders as a small blank pill
   with no indication it's a collapse/expand control at all, which is
   exactly the bug this replaces. */
.wiki-editor-container .details > button {
  all: unset;
  cursor: pointer;
  flex: 0 0 auto;
  width: 1.2em;
  height: 1.2em;
  margin-top: 0.15em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
}
.wiki-editor-container .details > button:hover { background-color: var(--bg-subtle); }
.wiki-editor-container .details > button::before {
  content: "▸";
  display: inline-block;
  font-size: 0.85em;
  transition: transform 0.12s ease;
}
.wiki-editor-container .details.is-open > button::before { transform: rotate(90deg); }
.wiki-editor-container .details > div { flex: 1 1 auto; min-width: 0; }
/* The NodeView's toggle button — not the summary text itself — is what's
   clickable in edit mode (clicking into the summary just places the
   cursor, same as any other editable text), so it gets the ordinary text
   cursor rather than summary's read-mode pointer cursor above. */
.wiki-editor-container .details summary { cursor: text; }
.wiki-editor-container .details div[data-type="detailsContent"] {
  padding-top: 0.5em;
}

.wiki-editor-container details summary,
.wiki-editor-container .details summary {
  font-weight: 600;
}
.wiki-editor-container details div[data-type="detailsContent"] > *:last-child,
.wiki-editor-container .details div[data-type="detailsContent"] > *:last-child {
  margin-bottom: 0;
}

/* Callouts — four variants, same light-mode pastel treatment in both
   themes as this app's other small semantic accents (status/mention
   pills — see the Phase 22.6 dark-mode comment above). */
.wiki-editor-container .callout {
  display: block;
  margin: 0 0 0.9em;
  padding: 0.7em 1em;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
}
.wiki-editor-container .callout > *:last-child { margin-bottom: 0; }
.wiki-editor-container .callout-info {
  background-color: #e0e7ff;
  border-left-color: #4f46e5;
  color: #312e81;
}
.wiki-editor-container .callout-warning {
  background-color: #fef3c7;
  border-left-color: #d97706;
  color: #78350f;
}
.wiki-editor-container .callout-success {
  background-color: #d1fae5;
  border-left-color: #059669;
  color: #064e3b;
}
.wiki-editor-container .callout-danger {
  background-color: #fee2e2;
  border-left-color: #dc2626;
  color: #7f1d1d;
}

/* Rich embeds (Phase 5, Rich Features Plan.md) — a sandboxed <iframe> for
   an allowlisted provider (server-enforced, see
   internal/tiptap/sanitize.go's embedAllowedHosts). 16:9 is a reasonable
   default for the supported providers (YouTube/Loom video, Figma/Miro/Docs
   canvases all read fine letterboxed to it) without per-provider aspect
   logic. */
.wiki-editor-container .wiki-embed {
  margin: 0 0 0.9em;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}
.wiki-editor-container .wiki-embed iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}
/* The iframe fills its wrapper edge-to-edge with no exposed margin, so a
   live cross-origin iframe would otherwise swallow every mouse event over
   the block entirely (a cross-origin child document never bubbles mouse
   events up to the parent page) — including the mousemove hover
   `setupBlockHandles` (wiki.js) needs to find and position the block's
   own drag handle. Only while actually editing: disabling pointer events
   here lets hover reach the `.wiki-embed` wrapper underneath instead,
   the same way a click-to-select-then-drag block editor (Notion, etc.)
   treats an embedded iframe as inert until you leave edit mode — read
   mode (`.wiki-readonly`) is untouched, where the embed must stay fully
   interactive (playable video, clickable canvas, etc). */
.wiki-editor-container:not(.wiki-readonly) .wiki-embed iframe {
  pointer-events: none;
}
.wiki-editor-container .wiki-embed-blocked .wiki-embed-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 1em;
  color: var(--text-muted);
  font-size: 0.9em;
  text-align: center;
}

/* Table Management Floating Toolbar */
.wiki-table-floating-toolbar {
  position: absolute;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  user-select: none;
}
.wiki-table-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}
.wiki-table-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 7px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.wiki-table-toolbar-btn svg {
  flex-shrink: 0;
}
.wiki-table-toolbar-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}
.wiki-table-toolbar-btn.text-danger {
  color: #dc2626;
}
.wiki-table-toolbar-btn.text-danger:hover {
  background-color: #fee2e2;
  color: #b91c1c;
}
.wiki-table-toolbar-sep {
  width: 1px;
  height: 18px;
  background-color: var(--border-color);
  margin: 0 4px;
}
.wiki-table-context-menu {
  position: fixed;
  z-index: 2200;
  min-width: 185px;
  box-shadow: var(--shadow-lg);
}
.wiki-block-context-menu {
  position: fixed;
  z-index: 2200;
  min-width: 160px;
  box-shadow: var(--shadow-lg);
}

.wiki-block-handle {
  position: absolute;
  left: 4px;
  width: 22px;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
  z-index: 5;
}
.wiki-block-handle-btn {
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-secondary); cursor: grab;
  padding: 3px; border-radius: 4px;
}
.wiki-block-handle-btn svg { width: 14px; height: 14px; }
.wiki-block-handle-btn:hover { background-color: var(--bg-subtle); color: var(--text-primary); }

.wiki-drop-indicator {
  position: absolute; left: 4px; right: 4px; height: 2px; background-color: var(--accent-primary);
  display: none; z-index: 6; pointer-events: none;
}

[data-block-id].tiptap-block-selected {
  background-color: var(--accent-light, rgba(59, 130, 246, 0.1));
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.wiki-selection-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 12px;
  background-color: var(--bg-subtle); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  position: sticky; top: 0; z-index: 4;
}
.wiki-selection-toolbar span { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-right: 4px; }

.wiki-children-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wiki-children-list:empty {
  display: none;
  margin: 0;
}
.wiki-children-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 2px 0;
}
.wiki-children-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.wiki-child-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.wiki-child-pill:hover {
  background-color: var(--bg-hover, var(--bg-main));
  border-color: var(--border-dark);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}
.wiki-child-pill-icon {
  font-size: 12px;
  line-height: 1;
  opacity: 0.85;
}
.wiki-child-pill-title {
  white-space: nowrap;
}
.wiki-child-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border: 1px solid var(--border-color); border-radius: var(--radius-md); background-color: var(--bg-main);
  cursor: pointer; text-decoration: none; color: var(--text-primary);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.wiki-child-card:hover { border-color: var(--border-dark); box-shadow: var(--shadow-sm); }

.wiki-backlinks { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.wiki-backlinks:empty { display: none; margin: 0; padding: 0; border: none; }
.wiki-backlinks h4 { margin: 0 0 8px 0; font-size: 13px; color: var(--text-secondary); }
.wiki-backlinks-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wiki-backlinks-heading { margin: 0 0 8px 0; }
.wiki-graph-toggle-btn { font-size: 12px; margin-bottom: 8px; }
.wiki-backlinks-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.wiki-backlinks-list a { color: var(--accent-primary); text-decoration: none; font-size: 13px; }
.wiki-backlinks-list a:hover { text-decoration: underline; }

/* Link graph (Phase 20 stretch): local incoming/outgoing neighborhood */
.wiki-link-graph { margin-top: 12px; padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background-color: var(--bg-subtle); overflow-x: auto; }
.wiki-link-graph-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.wiki-link-graph-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.wiki-link-graph-dot-in { background-color: var(--accent-primary); }
.wiki-link-graph-dot-out { background-color: #f59e0b; }
.wiki-link-graph-svg { width: 100%; min-width: 480px; max-width: 640px; height: auto; display: block; margin: 0 auto; }
.wiki-link-graph-edge { stroke: var(--border-color); stroke-width: 1.5; }
.wiki-link-graph-edge-in { stroke: var(--accent-primary); opacity: 0.5; }
.wiki-link-graph-edge-out { stroke: #f59e0b; opacity: 0.5; }
.wiki-link-graph-arrowhead { fill: var(--text-muted); }
.wiki-link-graph-node rect { fill: var(--bg-main); stroke: var(--border-color); stroke-width: 1; }
.wiki-link-graph-node text { font-size: 11px; fill: var(--text-primary); }
.wiki-link-graph-node-side { cursor: pointer; }
.wiki-link-graph-node-side rect { transition: fill 0.1s ease; }
.wiki-link-graph-node-side:hover rect, .wiki-link-graph-node-side:focus rect { fill: var(--bg-sidebar-hover); stroke: var(--accent-primary); }
.wiki-link-graph-node-side:focus { outline: none; }
.wiki-link-graph-node-center rect { fill: var(--accent-primary); }
.wiki-link-graph-node-center text { fill: #fff; font-weight: 600; }

/* Phase 22.6: one right-hand panel, three modes (details / table of
   contents / block comments). It sits on the app's subtle grey so the
   document column beside it reads as the white "page". */
.wiki-side-panel {
  width: 340px; flex-shrink: 0; border-left: 1px solid var(--wiki-hairline);
  background-color: var(--bg-subtle); display: flex; flex-direction: column;
}
.wiki-side-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-weight: 600; font-size: 15px; color: var(--text-primary);
}
.wiki-side-panel-close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0; border: none; background: transparent;
  color: var(--text-muted); border-radius: var(--radius-sm); cursor: pointer;
}
.wiki-side-panel-close-btn:hover { background-color: var(--border-color); color: var(--text-primary); }
.wiki-side-panel-body { flex: 1; overflow-y: auto; padding: 4px 18px 20px; }

/* Details panel */
.wiki-details-rows { display: flex; flex-direction: column; gap: 10px; }
.wiki-details-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13.5px;
}
.wiki-details-label { color: var(--text-muted); }
.wiki-details-value { color: var(--text-primary); font-weight: 500; text-align: right; }
.wiki-details-person { display: inline-flex; align-items: center; gap: 7px; }
.wiki-details-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.wiki-details-section h4 {
  margin: 0 0 12px 0; font-size: 15px; font-weight: 600; color: var(--text-primary);
}
.wiki-details-link-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 7px 8px; margin: 0 -8px; border: none; background: transparent;
  font-family: inherit; font-size: 13.5px; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
}
.wiki-details-link-row:hover { background-color: var(--border-color); color: var(--text-primary); }
.wiki-details-link-count { display: inline-flex; align-items: center; gap: 8px; color: var(--text-primary); font-weight: 500; }
.wiki-details-chevron { color: var(--text-muted); font-size: 15px; line-height: 1; }
.wiki-details-labels { display: flex; flex-wrap: wrap; gap: 6px; }

/* Table of contents */
.wiki-toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.wiki-toc-link {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  font-family: inherit; font-size: 13px; line-height: 1.45; color: var(--text-secondary);
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer;
  border-left: 2px solid transparent;
}
.wiki-toc-link:hover { background-color: var(--border-color); color: var(--text-primary); }
.wiki-toc-link.is-active { color: var(--accent-primary); font-weight: 600; border-left-color: var(--accent-primary); }
.wiki-toc-level-1 > .wiki-toc-link { font-weight: 600; color: var(--text-primary); }
.wiki-toc-level-2 > .wiki-toc-link { padding-left: 20px; }
.wiki-toc-level-3 > .wiki-toc-link { padding-left: 32px; font-size: 12.5px; }

.wiki-comment-item { padding: 8px 0; border-bottom: 1px solid var(--border-color); }
.wiki-comment-item:last-child { border-bottom: none; }
.wiki-comment-author { font-weight: 600; font-size: 12px; color: var(--text-primary); }
.wiki-comment-time { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.wiki-comment-body { font-size: 13px; margin-top: 2px; }
.wiki-comment-compose { margin-top: 12px; border-top: 1px solid var(--border-color); padding-top: 12px; }
.wiki-comment-compose-editor { border: 1px solid var(--border-color); border-radius: var(--radius-sm); min-height: 60px; }

.wiki-history-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.wiki-history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); cursor: pointer;
}
.wiki-history-item:hover { background-color: var(--bg-subtle); }
.wiki-history-item .wiki-history-meta { font-size: 12px; color: var(--text-muted); }
.wiki-history-preview { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-color); max-height: 320px; overflow-y: auto; }

.wiki-page-picker-results { list-style: none; margin: 8px 0 0 0; padding: 0; max-height: 240px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.wiki-page-picker-item { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-color); }
.wiki-page-picker-item:last-child { border-bottom: none; }
.wiki-page-picker-item:hover { background-color: var(--bg-subtle); }
.wiki-page-picker-item.selected { background-color: #e0e7ff; font-weight: 600; }

.wiki-slash-popover .mention-popover-item { font-family: ui-monospace, monospace; }

/* Sidebar Wiki Tree (Phase 22.5 redesign: hover-reveal row actions,
   per-row page icon, clearer active state) */
.wiki-tree-list { list-style: none; margin: 0; padding: 0; }
.wiki-tree-empty { color: var(--text-muted); }
.wiki-tree-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-sidebar); font-size: 13px;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.wiki-tree-row:hover { background-color: var(--bg-sidebar-hover); color: var(--text-sidebar-bright); }
.wiki-tree-row.active { background-color: var(--bg-sidebar-active); color: var(--text-sidebar-bright); font-weight: 600; }
.wiki-tree-toggle { width: 14px; text-align: center; flex-shrink: 0; color: var(--text-muted); font-size: 10px; cursor: pointer; }
.wiki-tree-toggle.empty { visibility: hidden; }
.wiki-tree-icon { flex-shrink: 0; font-size: 12px; line-height: 1; opacity: 0.85; }
.wiki-tree-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-tree-children { list-style: none; margin: 0; padding-left: 16px; }

/* Phase 22.8: sidebar drag-and-drop reordering/reparenting affordances.
   drop-before/drop-after render as a thin insertion line (an inset box-
   shadow rather than a border, so they don't shift row height); drop-onto
   highlights the whole row as the reparent target, matching the existing
   hover/active treatment's language. */
.wiki-tree-row.dragging { opacity: 0.4; }
.wiki-tree-row.drop-before { box-shadow: inset 0 2px 0 0 var(--accent-primary); }
.wiki-tree-row.drop-after { box-shadow: inset 0 -2px 0 0 var(--accent-primary); }
.wiki-tree-row.drop-onto { background-color: var(--accent-light); color: var(--text-sidebar-bright); }
.wiki-tree-list.drop-onto-root { box-shadow: inset 0 -2px 0 0 var(--accent-primary); }

/* Rich Features Plan Phase 1.5: drill-down navigation — the sidebar shows
   either the space picker (a plain row per space, .wiki-space-picker-row)
   or one space's page tree (renderTreeItem, unchanged), never both/all at
   once the way Phase 1 first built it. */
.wiki-space-mode-badge {
  flex-shrink: 0; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--text-muted); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 1px 5px;
}
.wiki-space-picker-row { cursor: pointer; }
.wiki-space-star {
  background: transparent; border: none; cursor: pointer; font-size: 14px; line-height: 1;
  color: var(--text-muted); flex-shrink: 0; opacity: 0; transition: opacity 0.1s ease;
}
.wiki-space-picker-row:hover .wiki-space-star, .wiki-space-star.is-favorite { opacity: 1; }
.wiki-space-star.is-favorite { color: #eab308; }

/* Sidebar header, two rows (not crammed onto one — a long space name has
   no room to breathe sharing a line with "← Wiki", a settings icon, and
   Select all at once): row 1 (.sidebar-section-header, always present)
   is "Wiki"/"← Wiki" left, "+ Space"/"+ New" right; row 2
   (.wiki-sidebar-space-row, space mode only) is the current space's own
   name left, its settings button + Select right. See
   setWikiSidebarHeaderMode in wiki.js. */
.wiki-sidebar-header-title { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.wiki-sidebar-back-link {
  color: var(--text-sidebar); text-decoration: none; flex-shrink: 0; font-size: 13px;
}
.wiki-sidebar-back-link:hover { color: var(--text-sidebar-bright); }
.wiki-sidebar-space-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 4px 8px 4px; margin-top: -4px;
}
.wiki-sidebar-current-space {
  font-weight: 600; font-size: 13px; color: var(--text-sidebar-bright);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

/* Sidebar multi-select (batch move/copy to space): a checkbox on every
   row, hidden unless #wiki-page-tree carries .select-mode — toggling
   Select just adds/removes that one class rather than re-rendering every
   row in the tree. */
.wiki-tree-row-checkbox { display: none; flex-shrink: 0; margin-right: 2px; }
#wiki-page-tree.select-mode .wiki-tree-row-checkbox { display: inline-block; }
#wiki-page-tree.select-mode .wiki-tree-row-actions { display: none; }
.wiki-multi-select-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px; margin-top: 4px; border-top: 1px solid var(--border-color);
}

/* Phase 22.6: the row actions are the sidebar's primary affordance, so
   they get a real 24px target and a visible icon weight instead of 22.5's
   thin "+"/"⋯" text glyphs. They still stay out of the way — revealed on
   hover, while the menu is open, or on the active row (where the user is
   demonstrably working) — so an idle tree stays quiet. */
.wiki-tree-row-actions {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: auto;
  opacity: 0; transition: opacity 0.1s ease;
}
.wiki-tree-row:hover .wiki-tree-row-actions,
.wiki-tree-row.active .wiki-tree-row-actions,
.wiki-tree-row-actions.menu-open {
  opacity: 1;
}
.wiki-tree-action-btn {
  border: none; background: transparent; color: var(--text-sidebar);
  width: 24px; height: 24px; padding: 0; border-radius: var(--radius-sm);
  line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.wiki-tree-action-btn svg { width: 16px; height: 16px; }
.wiki-tree-action-btn:hover { background-color: var(--bg-sidebar-active); color: var(--text-sidebar-bright); }
.wiki-tree-row-actions.menu-open .wiki-tree-action-btn { color: var(--text-sidebar-bright); }
.wiki-tree-menu-container { position: relative; }
/* Right-aligned rather than dropdown-menu-list's default left:0 — the
   sidebar is only ~250px of usable width once padding is subtracted, so
   a menu anchored to the far-right "⋮" button and opening leftward is
   what actually stays inside the sidebar instead of spilling past its
   edge. */
.wiki-tree-menu {
  position: absolute; top: 100%; right: 0; left: auto; margin-top: 4px;
  min-width: 208px; border-radius: var(--radius-lg);
}

/* Wiki Landing Page */
.wiki-landing-section { margin-bottom: 32px; }
.wiki-landing-section h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; color: var(--text-secondary); margin: 0 0 12px 0; }
.wiki-landing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.wiki-landing-search { max-width: 100%; margin-bottom: 32px; }

/* Rich Features Plan Phase 1.5: the top-level wiki landing page is a
   space-tile grid (renderSpaceCard) instead of the old page tiles — same
   .wiki-landing-grid layout, a richer card. */
.wiki-space-card {
  position: relative; display: block; padding: 14px 16px;
  border: 1px solid var(--border-color); border-radius: var(--radius-md); background-color: var(--bg-main);
  cursor: pointer; text-decoration: none; color: var(--text-primary);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.wiki-space-card:hover { border-color: var(--border-dark); box-shadow: var(--shadow-sm); }
.wiki-space-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; padding-right: 48px; }
.wiki-space-card-icon { font-size: 18px; line-height: 1; }
.wiki-space-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-space-card-description {
  margin: 0 0 8px 0; font-size: 13px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.wiki-space-card-description:empty { display: none; margin: 0; }
/* Settings + favorite-star, together, top-right of the tile — reachable
   without entering the space first. */
.wiki-space-card-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 2px; }
.wiki-space-card-icon-btn {
  background: transparent; border: none; cursor: pointer; color: var(--text-muted);
  width: 22px; height: 22px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.wiki-space-card-icon-btn:hover { background-color: var(--bg-subtle); color: var(--text-primary); }
.wiki-space-card-icon-btn svg { width: 15px; height: 15px; }
.wiki-space-card-star { font-size: 16px; line-height: 1; }
.wiki-space-card-star.is-favorite { color: #eab308; }






