/* ==========================================================================
   GameBitTodo — Modern Notion & Linear-Inspired Theme
   Tailored for Studio Gamebit
   ========================================================================== */

/* --- 1. Variables & Design Tokens --- */
:root {
  /* Color Palette - Modern Deep Dark (Default) */
  --bg: #0b0d13;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.08) 0%, transparent 45%),
                 radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.05) 0%, transparent 45%);
  --panel: #12151f;
  --panel-elevated: #181d2a;
  --panel-glass: rgba(18, 21, 31, 0.85);
  --col: #141724;
  --col-header: rgba(20, 23, 36, 0.92);
  --card: #191e2c;
  --card-hover: #202638;
  --card-active: #252d42;
  --line: #242c3f;
  --line-subtle: #1c2232;
  --line-highlight: rgba(99, 102, 241, 0.4);
  --txt: #f3f6fc;
  --txt-secondary: #94a3b8;
  --txt-muted: #64748b;
  --dim: #79879c;

  /* Accent & Status Colors */
  --acc: #4f46e5;
  --acc-hover: #6366f1;
  --acc-glow: rgba(99, 102, 241, 0.28);
  --acc-bg: rgba(99, 102, 241, 0.12);
  --acc-border: rgba(99, 102, 241, 0.35);

  --todo-txt: #f87171;
  --todo-bg: rgba(239, 68, 68, 0.12);
  --todo-border: rgba(239, 68, 68, 0.28);

  --prog-txt: #60a5fa;
  --prog-bg: rgba(59, 130, 246, 0.12);
  --prog-border: rgba(59, 130, 246, 0.28);

  --ok: #10b981;
  --ok-txt: #34d399;
  --ok-bg: rgba(16, 185, 129, 0.12);
  --ok-border: rgba(16, 185, 129, 0.28);

  --warn-txt: #fbbf24;
  --warn-bg: rgba(245, 158, 11, 0.12);

  --danger-txt: #fca5a5;
  --danger-bg: rgba(220, 38, 38, 0.2);
  --danger-border: rgba(220, 38, 38, 0.4);

  /* Geometry & Typography */
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --fs: 15px;

  /* Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35), 0 2px 5px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.25);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);

  /* Transitions */
  --tr-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-normal: 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Variables */
body[data-theme=light] {
  --bg: #f8fafc;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.05) 0%, transparent 45%),
                 radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.04) 0%, transparent 45%);
  --panel: #ffffff;
  --panel-elevated: #f8fafc;
  --panel-glass: rgba(255, 255, 255, 0.88);
  --col: #f1f5f9;
  --col-header: rgba(241, 245, 249, 0.95);
  --card: #ffffff;
  --card-hover: #fbfcfe;
  --card-active: #f1f5f9;
  --line: #e2e8f0;
  --line-subtle: #edf2f7;
  --line-highlight: rgba(99, 102, 241, 0.3);
  --txt: #0f172a;
  --txt-secondary: #475569;
  --txt-muted: #94a3b8;
  --dim: #64748b;

  --acc: #4f46e5;
  --acc-hover: #4338ca;
  --acc-glow: rgba(79, 70, 229, 0.18);
  --acc-bg: #eef2ff;
  --acc-border: #c7d2fe;

  --todo-txt: #dc2626;
  --todo-bg: #fef2f2;
  --todo-border: #fecaca;

  --prog-txt: #2563eb;
  --prog-bg: #eff6ff;
  --prog-border: #bfdbfe;

  --ok: #059669;
  --ok-txt: #059669;
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;

  --danger-txt: #b91c1c;
  --danger-bg: #fee2e2;
  --danger-border: #fca5a5;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 5px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 14px 32px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.05);
  --shadow-modal: 0 24px 60px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

/* --- 2. Font Configurations --- */
body[data-font=inter] { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
body[data-font=serif] { font-family: 'Charter', 'Bitstream Vera Serif', 'Cambria', Georgia, serif; }
body[data-font=mono] { font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace; }
body[data-font=game] { font-family: 'Comfortaa', 'Trebuchet MS', 'Fredoka', 'Quicksand', Verdana, sans-serif; }

/* --- 3. Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--txt);
  font-size: var(--fs);
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Slim Custom Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--txt-muted);
}

/* --- 4. Interactive Elements (Buttons, Inputs, Selects) --- */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--tr-fast);
  user-select: none;
}

button:hover {
  background: var(--card-hover);
  border-color: var(--line-highlight);
  color: var(--txt);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary {
  background: linear-gradient(135deg, var(--acc), var(--acc-hover));
  border-color: var(--acc);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--acc-glow);
}

button.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px var(--acc-glow);
}

button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-txt);
  font-weight: 600;
}

button.danger:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

button.secondary {
  background: var(--card);
  border-color: var(--line);
  color: var(--txt-secondary);
}

button.secondary:hover {
  background: var(--card-hover);
  border-color: var(--line-highlight);
  color: var(--txt);
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--txt-secondary);
}

button.ghost:hover {
  background: var(--card-hover);
  border-color: var(--line);
  color: var(--txt);
}

input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  background: var(--card);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-glow);
}

/* --- 5. Topbar & Branding --- */
.topbar {
  display: flex;
  flex-direction: column;
  background: var(--panel-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 25;
  padding: 0;
}

.topbar-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line-subtle);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand .logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--acc-bg);
  border: 1px solid var(--acc-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px var(--acc-glow);
  transition: transform var(--tr-normal);
  flex-shrink: 0;
  overflow: hidden;
}

.brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(3.8);
  transform-origin: 12% 46%;
  pointer-events: none;
}

.brand .logo:hover {
  transform: rotate(-8deg) scale(1.05);
}

.brand-info h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub {
  color: var(--txt-muted);
  font-weight: 500;
  font-size: 12px;
  background: var(--col);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--tr-fast);
  user-select: none;
}

.sidebar-toggle-btn:hover {
  background: var(--card-hover);
  border-color: var(--line-highlight);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--acc-glow);
}

.sidebar-toggle-icon {
  font-size: 15px;
  line-height: 1;
}

.sidebar-toggle-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.active-project-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--col);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--txt-secondary);
  cursor: pointer;
  transition: all var(--tr-fast);
  user-select: none;
}

.active-project-pill:hover {
  border-color: var(--line-highlight);
  background: var(--card-hover);
  color: var(--txt);
}

.active-project-pill .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  flex-shrink: 0;
}

.active-project-pill .active-label {
  color: var(--txt-muted);
  font-weight: 500;
}

.active-project-pill #curProjectName {
  color: var(--txt);
  font-weight: 600;
}

/* --- App Layout & Left Sidebar --- */
.app-layout {
  display: flex;
  min-height: calc(100vh - 65px);
  position: relative;
  width: 100%;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sidebar {
  width: 270px;
  min-width: 270px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  transition: width var(--tr-normal), margin-left var(--tr-normal), opacity var(--tr-normal);
  z-index: 20;
}

body[data-theme=light] .sidebar {
  background: #ffffff;
  border-color: var(--line);
}

/* Sidebar Collapsed State */
body.sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0 !important;
  margin-left: -270px !important;
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
}

.sidebar-inner {
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 270px;
  box-sizing: border-box;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-subtle);
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-close-btn {
  background: transparent;
  border: none;
  color: var(--txt-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--tr-fast);
}

.sidebar-close-btn:hover {
  background: var(--card-hover);
  color: var(--txt);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Clickable Projects Accordion Header */
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--txt-secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--tr-fast);
  font-family: inherit;
  box-sizing: border-box;
  user-select: none;
}

.sidebar-section-header:hover {
  background: var(--col);
  color: var(--txt);
  border-color: var(--line-subtle);
}

.sidebar-section-header .section-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sidebar-section-header .chevron {
  font-size: 11px;
  display: inline-block;
  transition: transform var(--tr-normal);
  color: var(--txt-muted);
}

.sidebar-section-header .badge {
  font-size: 10.5px;
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--dim);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* Projects Content Drawer */
.sidebar-projects-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all var(--tr-normal);
}

body.projects-collapsed .sidebar-projects-content {
  display: none;
}

body.projects-collapsed #projListChevron {
  transform: rotate(-90deg);
}

/* Projects List in Sidebar */
.sidebar-projects-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 48vh;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 2px;
}

.sidebar-proj-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--tr-fast);
  overflow: visible;
}

.sidebar-proj-item:hover {
  background: var(--card-hover);
  border-color: var(--line-subtle);
}

.sidebar-proj-item.active {
  background: var(--acc-bg);
  border-color: var(--acc-border);
}

body[data-theme=light] .sidebar-proj-item.active {
  background: var(--acc-bg);
  border-color: var(--acc-border);
}

.sidebar-proj-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--txt-secondary);
  text-align: left;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  transition: color var(--tr-fast);
}

.sidebar-proj-item.active .sidebar-proj-btn {
  color: #ffffff;
  font-weight: 600;
}

body[data-theme=light] .sidebar-proj-item.active .sidebar-proj-btn {
  color: var(--acc);
}

.sidebar-proj-btn .proj-icon {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-proj-btn .proj-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.sidebar-proj-btn .proj-counts {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 11px;
}

.sidebar-proj-btn .cnt-all {
  background: rgba(0, 0, 0, 0.25);
  color: var(--dim);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
  border: 1px solid var(--line-subtle);
}

body[data-theme=light] .sidebar-proj-btn .cnt-all {
  background: rgba(0, 0, 0, 0.05);
  color: var(--txt-muted);
}

.sidebar-proj-btn .cnt-done {
  background: rgba(16, 185, 129, 0.18);
  color: var(--ok-txt);
  padding: 1px 5px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* ⋯ Project Options button */
.sidebar-proj-opt {
  border: none;
  background: transparent;
  color: var(--txt-muted);
  padding: 4px 7px;
  margin-right: 4px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--tr-fast), background var(--tr-fast), color var(--tr-fast);
}

.sidebar-proj-item:hover .sidebar-proj-opt,
.sidebar-proj-opt:focus {
  opacity: 1;
}

.sidebar-proj-opt:hover {
  background: var(--card);
  color: var(--txt);
}

/* Project Actions Dropdown Menu */
.proj-menu-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  right: 6px;
  background: var(--panel-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 55;
  min-width: 160px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: modalScaleIn 0.15s ease;
}

.proj-menu-dropdown button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  color: var(--txt);
  cursor: pointer;
  transition: background var(--tr-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.proj-menu-dropdown button:hover {
  background: var(--card-hover);
  color: var(--txt);
}

.proj-menu-dropdown button:disabled {
  opacity: 0.38;
  cursor: default;
  background: transparent;
}

.proj-menu-dropdown button.danger {
  color: var(--danger-txt);
}

.proj-menu-dropdown button.danger:hover {
  background: var(--danger-bg);
}

/* Floating variant: attached to <body>, never clipped by the scrolling sidebar lists */
.proj-menu-dropdown.floating {
  position: fixed;
  top: auto;
  right: auto;
  z-index: 400;
  min-width: 168px;
}

/* + New Project button in Sidebar */
.sidebar-add-btn {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--txt-muted);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--tr-fast);
  font-family: inherit;
}

.sidebar-add-btn:hover {
  border-color: var(--acc);
  color: var(--acc-hover);
  background: var(--acc-bg);
}

/* Quick Links Section in Sidebar */
.sidebar-links-section {
  padding-top: 8px;
}

.sidebar-subhead.with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-subhead.with-badge .badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--txt-muted);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-full);
  padding: 1px 7px;
}

body[data-theme=light] .sidebar-subhead.with-badge .badge {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-links-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 30vh;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 6px;
}

.sidebar-link-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--tr-fast);
}

.sidebar-link-item:hover {
  background: var(--card-hover);
  border-color: var(--line-subtle);
}

.sidebar-link-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border: none;
  background: transparent;
  color: var(--txt-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: color var(--tr-fast);
}

.sidebar-link-btn:hover {
  color: var(--txt);
}

.sidebar-link-btn .link-icon {
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.sidebar-link-btn .link-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link-btn .link-host {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 10px;
  color: var(--txt-muted);
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-full);
  padding: 1px 5px;
  max-width: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* always-visible edit affordance (administrators) + ⋯ actions */
.sidebar-link-edit,
.sidebar-link-item .sidebar-proj-opt {
  border: none;
  background: transparent;
  color: var(--txt-muted);
  padding: 4px 5px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: all var(--tr-fast);
}

.sidebar-link-edit:hover,
.sidebar-link-item .sidebar-proj-opt:hover {
  background: var(--card);
  color: var(--txt);
}

.sidebar-link-item .sidebar-proj-opt {
  margin-right: 4px;
}

/* the ⋯ on a quick-link row is hover-revealed, like project rows */
.sidebar-link-item:hover .sidebar-proj-opt,
.sidebar-link-item .sidebar-proj-opt:focus {
  opacity: 1;
}

body[data-theme=light] .sidebar-link-btn .link-host {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-links-empty {
  font-size: 12px;
  color: var(--txt-muted);
  padding: 6px 10px;
  line-height: 1.4;
}

/* Views Section in Sidebar */
.sidebar-views-section {
  padding-top: 8px;
  border-top: 1px solid var(--line-subtle);
}

.sidebar-subhead {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--txt-muted);
  padding: 4px 10px;
}

.sidebar-nav-views {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: var(--txt-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: all var(--tr-fast);
  font-family: inherit;
}

.sidebar-nav-item:hover {
  background: var(--card-hover);
  color: var(--txt);
}

.sidebar-nav-item.active {
  background: var(--card);
  color: var(--txt);
  font-weight: 600;
  border: 1px solid var(--line);
}

body[data-theme=light] .sidebar-nav-item.active {
  background: #ffffff;
  color: var(--acc);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-subtle);
}

.sidebar-signout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--line-subtle);
  color: var(--danger-txt);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr-fast);
  font-family: inherit;
}

.sidebar-signout-btn:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.danger-hover:hover {
  color: var(--danger-txt) !important;
  border-color: var(--danger-border) !important;
  background: var(--danger-bg) !important;
}

.sidebar-help {
  padding: 0 4px;
}

.sidebar-version-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-subtle);
  font-size: 11px;
  color: var(--txt-muted);
  user-select: none;
}

.sidebar-version-tag {
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  font-size: 11px;
  color: var(--txt-secondary);
  background: var(--col);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line-subtle);
}

.sidebar-version-sep {
  color: var(--line-highlight);
}

.sidebar-version-date {
  font-size: 10.5px;
  color: var(--txt-muted);
}

/* Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--tr-normal);
}

/* Responsive Sidebar Drawer */
@media (max-width: 768px) {
  #btnSidebarToggle,
  #btnImport,
  #btnExport,
  #btnBackup {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    width: 280px;
    min-width: 280px;
    margin-left: 0 !important;
    box-shadow: var(--shadow-modal);
  }

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

  body.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }
}

/* Top Actions */
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.top-actions button {
  padding: 7px 12px;
  font-size: 12.5px;
}

#btnNew {
  padding: 8px 16px;
  font-size: 13.5px;
}

/* --- 6. Navigation Views & Tools Bar --- */
.views {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 28px;
  background: transparent;
  border-bottom: 1px solid var(--line-subtle);
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
}

.tab {
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--txt-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.tab:hover {
  color: var(--txt);
  background: rgba(255, 255, 255, 0.04);
}

body[data-theme=light] .tab:hover {
  background: rgba(0, 0, 0, 0.04);
}

.tab.active {
  background: var(--card);
  color: var(--txt);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--line);
}

body[data-theme=light] .tab.active {
  background: #ffffff;
  color: var(--acc);
}

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#search {
  width: 210px;
  background: var(--panel);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 12.5px;
}

#filterStatus {
  background: var(--panel);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 12.5px;
}

#sortBtn, #themeBtn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: var(--panel);
  border-color: var(--line);
}

/* --- 7. Kanban Board Layout & Columns --- */
#boardWrap {
  padding: 20px 28px 60px;
  overflow-x: auto;
}

.board {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 24px;
  min-height: calc(100vh - 220px);
  scroll-behavior: smooth;
}

.col {
  min-width: 320px;
  width: 340px;
  max-width: 380px;
  flex-shrink: 0;
  background: var(--col);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 480px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--tr-fast), background-color var(--tr-fast);
}

.col.drag-over {
  border-color: var(--acc);
  background-color: var(--acc-bg);
}

.col h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

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

.col-header-left small {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--txt-muted);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.col-opt-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.col-opt-btn {
  background: transparent;
  border: none;
  color: var(--txt-muted);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all var(--tr-fast);
}

.col-opt-btn:hover {
  background: var(--card);
  color: var(--txt);
}

.col-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  min-width: 180px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: modalScaleIn 0.15s ease;
}

.col-menu-dropdown button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: none;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  color: var(--txt);
  cursor: pointer;
  transition: background var(--tr-fast);
}

.col-menu-dropdown button:hover {
  background: var(--card-hover);
  color: var(--txt);
}

.col-menu-dropdown button.danger {
  color: var(--danger-txt);
}

.col-menu-dropdown button.danger:hover {
  background: var(--danger-bg);
}

.col-menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--line-subtle);
  margin: 4px 0;
}

.pill {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
}

.pill.todo {
  background: var(--todo-bg);
  color: var(--todo-txt);
  border-color: var(--todo-border);
}

.pill.prog {
  background: var(--prog-bg);
  color: var(--prog-txt);
  border-color: var(--prog-border);
}

.pill.done {
  background: var(--ok-bg);
  color: var(--ok-txt);
  border-color: var(--ok-border);
}

/* Quick Add button inside Column */
.col > button.ghost {
  width: 100%;
  margin-top: auto;
  border: 1px dashed var(--line);
  padding: 9px;
  border-radius: var(--radius);
  color: var(--txt-muted);
  font-size: 12.5px;
  transition: all var(--tr-fast);
}

.col > button.ghost:hover {
  background: var(--card-hover);
  border-color: var(--acc);
  color: var(--acc-hover);
}

/* Add column card at end of board */
.add-col-card {
  min-width: 260px;
  width: 260px;
  flex-shrink: 0;
  padding-top: 2px;
}

.add-col-btn {
  width: 100%;
  min-height: 90px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--txt-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--tr-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.add-col-btn:hover {
  background: var(--card-hover);
  border-color: var(--acc);
  color: var(--acc-hover);
  box-shadow: 0 4px 14px var(--acc-glow);
}

/* --- 8. Card Surfaces --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 0;
  cursor: grab;
  box-shadow: var(--shadow-xs);
  transition: transform var(--tr-normal), box-shadow var(--tr-normal), border-color var(--tr-normal);
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-highlight);
  background: var(--card-hover);
}

.card:active {
  cursor: grabbing;
}

.card.dragging {
  opacity: 0.45 !important;
  transform: none !important;
  transition: none !important;
  border-color: var(--acc) !important;
  box-shadow: 0 8px 24px var(--acc-glow) !important;
}

/* Card Top Bar & Prominent Status Badge */
.card-top-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  justify-content: space-between;
}

.card-status-wrap {
  position: relative;
}

.card-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--col);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.card-status-pill:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.card-status-pill .arrow {
  font-size: 9px;
  opacity: 0.75;
}

.card-step-arrows {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.card-arrow-btn {
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt-secondary);
  font-size: 10px;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  line-height: 1;
  transition: all var(--tr-fast);
}

.card-arrow-btn:hover {
  background: var(--card-hover);
  color: var(--txt);
  border-color: var(--line-highlight);
}

.card-more-btn {
  background: transparent;
  border: none;
  color: var(--txt-muted);
  font-size: 15px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  line-height: 1;
  transition: all var(--tr-fast);
}

.card-more-btn:hover {
  background: var(--card-hover);
  color: var(--txt);
}

/* Card Floating Dropdown Menu */
.card-menu-dropdown {
  position: fixed;
  top: calc(100% + 4px);
  left: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 175px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: modalScaleIn 0.12s ease;
}

.card-menu-dropdown .menu-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--txt-muted);
  padding: 4px 8px 2px;
}

.card-menu-dropdown button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: none;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  color: var(--txt);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--tr-fast);
}

.card-menu-dropdown button:hover {
  background: var(--card-hover);
}

.card-menu-dropdown button.active-status {
  background: var(--acc-bg);
  color: var(--acc-hover);
  font-weight: 600;
}

.card-menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--line-subtle);
  margin: 3px 0;
}

/* Visual cue when dragging over board */
.board.is-dragging-card .card {
  transition: none !important;
  transform: none !important;
}

.board.is-dragging-card .col {
  border: 1px dashed var(--line-highlight);
}

.board.is-dragging-card .col.drag-over {
  border: 2px solid var(--acc) !important;
  background-color: var(--acc-bg) !important;
  box-shadow: 0 0 15px var(--acc-glow);
}

.col-empty-zone {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 14px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  color: var(--txt-muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
  pointer-events: none;
  transition: all var(--tr-fast);
}

.col.is-empty .col-empty-zone {
  display: flex;
}

.board.is-dragging-card .col-empty-zone {
  display: flex;
  border-color: var(--acc-border);
  background: var(--acc-bg);
  color: var(--acc-hover);
}

.card.done {
  opacity: 0.82;
  border-color: var(--line-subtle);
}

.card.done .title-txt {
  text-decoration: line-through;
  color: var(--txt-muted);
}

.card.done h3 {
  text-decoration: none;
}

.card .chk-icon {
  user-select: none;
  flex-shrink: 0;
}

.card .chk-prog {
  margin-top: 8px;
}

.card .chk-prog small {
  font-size: 11px;
  color: var(--txt-muted);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--txt);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  word-break: break-word;
}

.card img.cover {
  width: 100%;
  border-radius: var(--radius-sm);
  max-height: 170px;
  object-fit: cover;
  margin-top: 10px;
  display: block;
  border: 1px solid var(--line-subtle);
  background: #000000;
  pointer-events: none;
  -webkit-user-drag: none;
}

.card video.cover {
  width: 100%;
  border-radius: var(--radius-sm);
  max-height: 170px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  margin-top: 10px;
  display: block;
  border: 1px solid var(--line-subtle);
  background: #000000;
  pointer-events: none;
  -webkit-user-drag: none;
}

body[data-density=compact] .card img.cover,
body[data-density=compact] .card video.cover {
  display: none !important;
}

/* Progress bar inside cards */
.progbar {
  height: 5px;
  background: var(--col);
  border-radius: var(--radius-full);
  margin-top: 2px;
  overflow: hidden;
  border: 1px solid var(--line-subtle);
}

.progbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Card Metadata & Tags */
.meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11.5px;
  color: var(--txt-muted);
  margin-top: 10px;
}

.tag {
  background: var(--col);
  color: var(--txt-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--tr-fast);
}

.tag.deadline {
  color: var(--warn-txt);
  background: var(--warn-bg);
  border-color: rgba(245, 158, 11, 0.25);
}

.tag.media-cnt {
  color: var(--txt-muted);
}

.tag[data-tag*="bug"] {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.tag[data-tag*="art"] {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.3);
}

.tag[data-tag*="code"] {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.3);
}

.tag[data-tag*="design"] {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}

.tag[data-tag*="ui"] {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.tag[data-tag*="tweak"] {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.tag[data-tag*="fortress"] {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}

/* Card Footer Operations */
.card .ops {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-subtle);
  flex-wrap: wrap;
}

.card .ops button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all var(--tr-fast);
}

.card .ops button:hover {
  color: var(--txt);
  border-color: var(--line-highlight);
  background: var(--card-hover);
}

.card .ops button[data-a=done] {
  color: var(--ok-txt);
  border-color: var(--ok-border);
  background: var(--ok-bg);
}

.card .ops button[data-a=done]:hover {
  filter: brightness(1.15);
}

.card .col-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  transition: border-color var(--tr-fast);
}

.card .col-nav-group:hover {
  border-color: var(--line-highlight);
}

.card .btn-nav {
  background: transparent !important;
  border: none !important;
  color: var(--txt-muted) !important;
  font-size: 10px !important;
  padding: 2px 5px !important;
  border-radius: var(--radius-xs) !important;
  cursor: pointer;
  line-height: 1;
  transition: all var(--tr-fast);
}

.card .btn-nav:hover:not(:disabled) {
  background: var(--card-hover) !important;
  color: var(--txt) !important;
}

.card .btn-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.card .card-col-select {
  background: transparent;
  border: none;
  color: var(--txt);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 3px;
  outline: none;
  cursor: pointer;
  max-width: 125px;
}

.card .card-col-select:hover {
  color: var(--acc-hover);
}

.card .card-col-select option {
  background: var(--panel);
  color: var(--txt);
}

.card .card-proj-select {
  background: var(--col);
  color: var(--txt-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  padding: 3px 6px;
  max-width: 105px;
  margin-left: auto;
  cursor: pointer;
}

.card .card-proj-select:hover {
  border-color: var(--line-highlight);
  color: var(--txt);
}

.card .card-proj-select option {
  background: var(--panel);
  color: var(--txt);
}

/* --- 9. Modal Dialog --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 36px 20px;
  z-index: 60;
  overflow-y: auto;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-width: 780px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-modal);
  position: relative;
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-cover {
  position: relative;
  margin: -24px -24px 18px -24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
  max-height: 250px;
  background: #000000;
}

.modal-cover .media-thumb-name-badge {
  top: 12px;
  left: 12px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.75);
}

.modal-cover img {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  display: block;
}

.modal-cover video {
  width: 100%;
  max-height: 250px;
  object-fit: contain;
  display: block;
  background: #000000;
}

.modal-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

#mTitle {
  width: 100%;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--txt);
  margin: 0;
}

#mTitle:hover {
  border-color: var(--line);
}

#mTitle:focus {
  background: var(--card);
  border-color: var(--acc);
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.modal-head .row select,
.modal-head .row input {
  font-size: 13px;
  padding: 7px 11px;
}

#mStatus {
  font-weight: 600;
}

#mTags {
  flex: 1;
  min-width: 160px;
}

.modal-close-row {
  position: relative;
  height: 0;
  z-index: 2;
}

#mClose {
  position: absolute;
  top: -10px;
  right: 0;
}

/* Modal Toolbar */
.toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  margin: 12px 0;
}

.toolbar button {
  font-size: 13px;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--txt-secondary);
}

.toolbar button:hover {
  background: var(--card);
  border-color: var(--line);
  color: var(--txt);
}

.toolbar .sp {
  width: 1px;
  height: 20px;
  background: var(--line);
  margin: 0 4px;
}

.upload {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--txt-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--tr-fast);
}

.upload:hover {
  border-color: var(--acc);
  color: var(--acc-hover);
  background: var(--card);
}

/* Modal Description */
.desc {
  min-height: 140px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--txt);
  outline: none;
  transition: border-color var(--tr-fast);
}

.desc:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-glow);
}

.desc:empty:before {
  content: attr(placeholder);
  color: var(--txt-muted);
}

.desc h1 { font-size: 20px; font-weight: 700; margin: 12px 0 6px; }
.desc pre {
  background: var(--bg);
  color: #a7f3d0;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  border: 1px solid var(--line);
  overflow-x: auto;
}
.desc blockquote {
  border-left: 3px solid var(--acc);
  margin: 8px 0;
  padding: 4px 12px;
  color: var(--txt-secondary);
  background: var(--col);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* Markdown-rendered description content — Notion-like typography */
.desc > *:first-child { margin-top: 0; }
.desc > *:last-child { margin-bottom: 0; }

.desc h1 {
  font-size: 1.85em;
  font-weight: 600;
  line-height: 1.3;
  margin: 1.4em 0 0.15em;
  padding-bottom: 0.15em;
  border-bottom: 1px solid var(--line);
}
.desc h2 { font-size: 1.5em; font-weight: 600; line-height: 1.3; margin: 1.2em 0 0.1em; }
.desc h3 { font-size: 1.25em; font-weight: 600; line-height: 1.3; margin: 1em 0 0.1em; }
.desc h4 { font-size: 1.1em; font-weight: 600; margin: 0.9em 0 0.1em; }
.desc h5 { font-size: 1em; font-weight: 600; margin: 0.8em 0 0.1em; }
.desc h6 { font-size: 0.9em; font-weight: 600; margin: 0.8em 0 0.1em; color: var(--txt-secondary); }

.desc p { margin: 0.4em 0; }
.desc strong { font-weight: 600; }
.desc em { font-style: italic; }
.desc del { color: var(--txt-muted); }

.desc ul, .desc ol { margin: 0.4em 0; padding-left: 1.5em; list-style-position: outside; }
.desc ul { list-style-type: disc; }
.desc ol { list-style-type: decimal; }
.desc ul ul { list-style-type: circle; }
.desc ul ul ul { list-style-type: square; }
.desc li { margin: 0.15em 0; padding-left: 0.1em; }
.desc li::marker { color: var(--txt-secondary); }
.desc li > p { margin: 0.15em 0; }
.desc li.task-list-item { list-style: none; }
.desc li.task-list-item::marker { content: ''; }
.desc input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0 6px 0 0;
  vertical-align: -2px;
  accent-color: var(--acc);
}
.desc hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.2em 0;
}
.desc a { color: var(--acc-hover); text-decoration: underline; text-underline-offset: 2px; }
.desc img { max-width: 100%; border-radius: var(--radius-sm); margin: 0.4em 0; }
.desc code {
  background: rgba(135, 131, 120, 0.15);
  border: none;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: var(--font-mono, monospace);
  font-size: 0.88em;
  color: #eb5757;
}
.desc pre code { background: none; border: none; padding: 0; font-size: 13px; color: inherit; }
.desc table { border-collapse: collapse; margin: 0.6em 0; }
.desc th, .desc td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.desc th { background: var(--col); font-weight: 600; }

/* Checklist Section in Modal */
/* Add-checklist row sits BELOW the checklist items (#mChecks) */
.check-add {
  display: flex;
  gap: 8px;
  margin: 8px 0 16px;
  flex-wrap: wrap;
  align-items: center;
}

.check-add input:not(.check-search-input) {
  flex: 1;
  min-width: 140px;
}

.check-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 130px;
  max-width: 220px;
}

.check-search-input {
  width: 100%;
  padding: 5px 24px 5px 10px !important;
  font-size: 12px !important;
  height: 30px !important;
  border-radius: var(--radius-sm) !important;
  background: var(--col) !important;
  border: 1px solid var(--line-subtle) !important;
  box-sizing: border-box;
}

.check-search-input:focus {
  border-color: var(--line-highlight) !important;
  box-shadow: 0 0 0 2px var(--acc-glow) !important;
}

.check-search-clear {
  position: absolute;
  right: 6px;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-size: 12px !important;
  color: var(--txt-muted) !important;
  cursor: pointer;
  line-height: 1;
}

.check-search-clear:hover {
  color: var(--txt) !important;
}

#mChecks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chk-item-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--radius-sm);
  transition: all var(--tr-fast);
}

.chk-item-wrap.chk-item-hidden-search {
  display: none !important;
}

.chk-search-empty-hint {
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--txt-muted);
  text-align: center;
  background: var(--col);
  border: 1px dashed var(--line-subtle);
  border-radius: var(--radius-sm);
  margin: 4px 0;
}

.chk-item-wrap.open {
  background: rgba(18, 21, 31, 0.4);
  border: 1px solid var(--line-subtle);
  padding: 3px;
}

.chk-item-wrap.has-comments > .chk {
  border-left: 3px solid #eab308;
}

.chk-item-wrap.mention-unread .chk {
  border-color: #facc15;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.28), 0 0 16px rgba(250, 204, 21, 0.16);
  background: rgba(250, 204, 21, 0.07);
}

.chk-item-wrap.mention-unread .chk-cmt-btn {
  border-color: #facc15 !important;
  color: #fde047 !important;
}

.chk {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition: all var(--tr-fast);
}

.chk input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.chk:hover {
  border-color: var(--line);
  background: var(--card-hover);
}

.chk.done {
  opacity: 0.65;
}

.chk.done .txt {
  text-decoration: line-through;
  color: var(--txt-muted);
}

.chk .txt {
  flex: 1;
  outline: none;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  min-width: 60px;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
  /* Shift+Enter soft line breaks inside a checklist item must stay visible */
  white-space: pre-wrap;
}

.chk .txt:focus {
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--acc-glow);
}

.chk .grip {
  cursor: grab;
  color: var(--txt-muted);
  font-size: 16px;
  user-select: none;
  opacity: 0.5;
  transition: opacity var(--tr-fast);
  margin-top: 1px;
  flex-shrink: 0;
}

.chk:hover .grip {
  opacity: 1;
}

.chk-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.chk-actions button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  padding: 3px 6px;
  color: var(--txt-muted);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.chk-actions button:hover {
  background: var(--col);
  border-color: var(--line);
  color: var(--txt);
}

.chk-actions button.del:hover {
  color: var(--danger-txt);
  background: var(--danger-bg);
}

/* Checklist Item Author Initials Avatar Badge */
.chk-author-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  user-select: none;
  flex: 0 0 auto;
  text-transform: uppercase;
  cursor: default;
  transition: transform var(--tr-fast), box-shadow var(--tr-fast);
}

.chk-author-badge:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.chk-author-badge.mini {
  width: 17px;
  height: 17px;
  font-size: 8px;
  border-width: 1px;
}

/* Checklist Item "Responsible" (assignee) Badge */
.chk-actions .chk-assignee {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffffff;
  text-transform: uppercase;
  background: var(--asg-color, #64748b);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
  transition: transform var(--tr-fast), box-shadow var(--tr-fast);
}

.chk-actions .chk-assignee::after {
  content: "👤";
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-size: 8px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
}

.chk-actions .chk-assignee:hover {
  transform: scale(1.12);
  background: var(--asg-color, #64748b);
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.5);
  color: #ffffff;
}

.chk-actions .chk-assignee.empty {
  background: transparent;
  color: var(--txt-muted);
  border: 1.5px dashed var(--line);
  box-shadow: none;
  gap: 0;
}

.chk-actions .chk-assignee.empty:hover {
  background: var(--card-hover);
  border-color: var(--line);
  color: var(--txt);
}

.chk-actions .chk-assignee.empty::after {
  content: none;
}

.chk-actions .chk-assignee.empty span {
  font-size: 11px;
  font-weight: 700;
  margin-left: -1px;
}

/* Assignee dropdown picker (rendered on <body>, fixed-positioned) */
.chk-assignee-picker {
  position: fixed;
  z-index: 2000;
  min-width: 230px;
  max-width: 290px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chk-assignee-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--txt);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--tr-fast), border-color var(--tr-fast);
}

.chk-assignee-row:hover {
  background: var(--card-hover);
  border-color: var(--line-subtle);
}

.chk-assignee-row.selected {
  background: var(--acc-glow);
}

.chk-assignee-av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffffff;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.chk-assignee-av.empty {
  background: transparent;
  color: var(--txt-muted);
  border: 1px dashed var(--line);
  font-size: 12px;
}

.chk-assignee-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chk-assignee-role {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--txt-muted);
  background: var(--col);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  flex: 0 0 auto;
}

.chk-assignee-role.admin {
  color: var(--acc-hover);
  border-color: var(--acc-glow);
}

.chk-assignee-check {
  color: var(--acc-hover);
  font-weight: 700;
  flex: 0 0 auto;
}

.chk-assignee-divider {
  height: 1px;
  background: var(--line-subtle);
  margin: 4px 2px;
}

.chk-assignee-empty-note {
  padding: 8px;
  font-size: 12px;
  color: var(--txt-muted);
  text-align: center;
}

/* Checklist Item Priority Badge */
.chk-actions .chk-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--radius-xs);
  font-size: 11px;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--pr-color, var(--line));
  color: var(--pr-color, var(--txt-muted));
  cursor: pointer;
  user-select: none;
  flex: 0 0 auto;
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), border-color var(--tr-fast);
}

.chk-actions .chk-priority:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.chk-actions .chk-priority.empty {
  color: var(--txt-muted);
  border-color: var(--line);
}

.chk-actions .chk-priority.empty:hover {
  color: var(--txt);
  border-color: var(--line-highlight);
}

/* Priority enum picker (shared by checklist items and cards; rendered on <body>) */
.priority-picker {
  position: fixed;
  z-index: 2000;
  min-width: 180px;
  max-width: 240px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.priority-picker-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--txt-muted);
  padding: 4px 8px 2px;
}

.priority-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--txt);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--tr-fast), border-color var(--tr-fast);
}

.priority-row:hover {
  background: var(--card-hover);
  border-color: var(--line-subtle);
}

.priority-row.selected {
  background: var(--acc-glow);
}

.priority-dot {
  width: 20px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  flex: 0 0 auto;
}

.priority-dot.none {
  color: var(--txt-muted);
}

.priority-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-check {
  color: var(--acc-hover);
  font-weight: 700;
  flex: 0 0 auto;
}

/* Card-level priority pill (top bar of a board card) */
.card-priority-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--pr-color, var(--txt-muted));
  background: var(--col);
  border: 1px solid var(--pr-color, var(--line));
  cursor: pointer;
  transition: all var(--tr-fast);
}

.card-priority-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card-priority-pill.empty {
  color: var(--txt-muted);
  border-color: var(--line);
}

.card-priority-pill.empty:hover {
  color: var(--txt);
  border-color: var(--line-highlight);
}

.card-priority-pill .pr-ico {
  font-size: 11px;
  line-height: 1;
}

.thread-author-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--txt-secondary);
  background: var(--col);
  padding: 2px 8px 2px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line-subtle);
}

/* Checklist Comment Button */
.chk-cmt-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 3px 8px !important;
  font-size: 12px !important;
  border-radius: var(--radius-full) !important;
  border: 1px solid var(--line-subtle) !important;
  background: var(--col) !important;
  color: var(--txt-secondary) !important;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.chk-cmt-btn:hover {
  background: var(--panel-elevated) !important;
  border-color: var(--line-highlight) !important;
  color: var(--txt) !important;
}

.chk-cmt-btn.has-comments,
.chk-item-wrap.has-comments .chk-cmt-btn {
  background: rgba(234, 179, 8, 0.16) !important;
  border-color: rgba(234, 179, 8, 0.5) !important;
  color: #facc15 !important;
}

.chk-cmt-btn.has-comments:hover,
.chk-item-wrap.has-comments .chk-cmt-btn:hover {
  background: rgba(234, 179, 8, 0.28) !important;
  border-color: #fde047 !important;
  color: #fef08a !important;
}

.chk-cmt-btn.has-comments .cmt-icon {
  filter: drop-shadow(0 0 2px rgba(250, 204, 21, 0.6));
}

.chk-cmt-btn .cmt-badge {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.chk-cmt-btn.has-comments .cmt-badge {
  background: #eab308;
  color: #1a1a1a;
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

.chk-cmt-btn .cmt-hint {
  font-size: 11px;
  opacity: 0.6;
}

/* Checklist Media Button on row */
.chk-media-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 3px 8px !important;
  font-size: 12px !important;
  border-radius: var(--radius-full) !important;
  border: 1px solid var(--line-subtle) !important;
  background: var(--col) !important;
  color: var(--txt-secondary) !important;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.chk-media-btn:hover {
  background: var(--panel-elevated) !important;
  border-color: var(--line-highlight) !important;
  color: var(--txt) !important;
}

.chk-media-btn.has-media {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.4) !important;
  color: #34d399 !important;
}

.chk-media-btn.has-media:hover {
  background: rgba(16, 185, 129, 0.25) !important;
  border-color: #10b981 !important;
}

.chk-media-btn .media-badge {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.chk-media-btn .media-hint {
  font-size: 11px;
  opacity: 0.6;
}

#btnHideCompleted.active,
.check-hide-done-btn.active,
.check-only-mine-btn.active {
  background: rgba(99, 102, 241, 0.22) !important;
  color: var(--acc) !important;
  border-color: var(--acc) !important;
  font-weight: 600;
}

.chk-item-hidden-done,
.chk-item-hidden-not-mine {
  display: none !important;
}

/* Discussion Thread Drawer */
.chk-thread {
  margin: 4px 6px 6px 28px;
  padding: 10px 12px;
  background: var(--panel);
  border-left: 2px solid var(--acc);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: threadFadeIn 160ms ease-out;
}

@keyframes threadFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chk-thread-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--txt-muted);
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 5px;
}

.chk-thread-header .thread-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 75%;
}

.chk-thread-header em {
  color: var(--txt-secondary);
  font-style: normal;
  font-weight: 500;
}

.thread-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thread-media-tag {
  color: #34d399;
  font-weight: 600;
  font-size: 11px;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.chk-section-subtitle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--txt-muted);
  margin-bottom: 6px;
}

/* Checklist Media Gallery Grid */
.chk-media-sec {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--line-subtle);
  transition: all var(--tr-fast);
}

.chk-media-sec:empty {
  display: none;
}

.chk-media-sec.collapsed {
  padding-bottom: 4px;
}

.chk-media-sec.collapsed .chk-media-grid {
  display: none !important;
}

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

.chk-media-toggle-btn {
  background: transparent;
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-xs);
  color: var(--txt-muted);
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.chk-media-toggle-btn:hover {
  background: var(--card-hover);
  border-color: var(--line);
  color: var(--txt);
}

.chk-media-btn.preview-active {
  box-shadow: 0 0 0 1.5px #10b981;
}

.chk-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 220px));
  gap: 8px;
}

.chk-media-item {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all var(--tr-fast);
  display: flex;
  flex-direction: column;
}

.chk-media-item:hover {
  border-color: var(--line-highlight);
  box-shadow: var(--shadow-sm);
}

.chk-media-item img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  cursor: pointer;
  background: #0c0e14;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
  transition: transform var(--tr-fast);
  display: block;
}

.chk-media-item img:hover {
  transform: scale(1.03);
}

.chk-media-item video {
  width: 100%;
  height: auto;
  max-height: 140px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000000;
  display: block;
}

.chk-media-item .chk-media-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--tr-fast), background var(--tr-fast);
  z-index: 2;
}

.chk-media-item:hover .chk-media-del {
  opacity: 1;
}

.chk-media-item .chk-media-del:hover {
  background: #ef4444;
}

.chk-media-item.is-dragging-media {
  opacity: 0.35;
  transform: scale(0.96);
  border: 1px dashed var(--acc);
}

.chk-media-item.drop-before {
  border-left: 3px solid var(--acc) !important;
}

.chk-media-item.drop-after {
  border-right: 3px solid var(--acc) !important;
}

.chk-media-drag-handle {
  cursor: grab;
  padding: 0 2px;
  font-size: 11px;
  opacity: 0.6;
}

.chk-media-drag-handle:hover {
  opacity: 1;
  color: var(--txt);
}

.chk-media-move-btn {
  font-size: 10px !important;
  padding: 1px 3px !important;
}

.chk-media-cap {
  padding: 4px 6px;
  font-size: 11px;
  color: var(--txt-muted);
  background: var(--card);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  border-top: 1px solid var(--line-subtle);
  min-height: 26px;
}

.chk-media-cap span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chk-media-missing {
  padding: 16px 8px;
  font-size: 11px;
  color: var(--warn-txt);
  text-align: center;
  background: var(--card);
}

.chk-cmt-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}

.chk-cmt-list:empty::before {
  content: 'No comments yet. Discuss this checklist task with teammates below:';
  font-size: 11.5px;
  color: var(--txt-muted);
  font-style: italic;
  padding: 4px 0;
}

.chk-cmt {
  background: var(--card);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 12.5px;
  position: relative;
  transition: border-color var(--tr-fast);
}

.chk-cmt:hover {
  border-color: var(--line);
}

.chk-cmt-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
  font-size: 11.5px;
}

.chk-cmt-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--acc-bg);
  color: var(--acc);
  font-weight: 700;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--acc-border);
  text-transform: uppercase;
}

.chk-cmt-author {
  font-weight: 600;
  color: var(--txt);
}

.chk-cmt-time {
  color: var(--txt-muted);
  font-size: 10.5px;
}

.chk-cmt-del {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--txt-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.4;
  border-radius: 3px;
  transition: all var(--tr-fast);
}

.chk-cmt:hover .chk-cmt-del {
  opacity: 1;
}

.chk-cmt-del:hover {
  color: var(--danger-txt);
  background: var(--danger-bg);
}

.chk-cmt-text {
  color: var(--txt);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.chk-reply-box {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.chk-reply-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--txt);
  outline: none;
  transition: all var(--tr-fast);
}

.chk-reply-input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 2px var(--acc-glow);
}

.chk-reply-btn {
  background: var(--acc);
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--tr-fast);
  white-space: nowrap;
}

.chk-reply-btn:hover {
  background: var(--acc-hover);
}

/* Attach button in reply row */
.chk-attach-btn {
  background: var(--col);
  color: var(--txt-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all var(--tr-fast);
  white-space: nowrap;
}

.chk-attach-btn:hover {
  background: var(--panel-elevated);
  border-color: var(--line-highlight);
  color: var(--txt);
}

.chk-attach-btn .attach-lbl {
  font-weight: 500;
}

/* Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: threadFadeIn 150ms ease-out;
  user-select: none;
}

.lightbox-overlay.open {
  display: flex;
}

.lightbox-bar {
  position: absolute;
  top: 14px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
  pointer-events: auto;
}

.lightbox-title-area {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #f3f6fc;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  max-width: 60%;
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.lightbox-title-area .media-name {
  color: #fff;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-counter {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 8px;
  border-radius: 12px;
  flex-shrink: 0;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  line-height: 1;
  transition: all var(--tr-fast);
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.lightbox-btn.close {
  font-size: 18px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.35);
}

.lightbox-btn.close:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.lightbox-body {
  position: relative;
  width: 100%;
  height: calc(100% - 64px);
  margin-top: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 84vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 82vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75);
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 160ms ease-out;
}

.lightbox-img.zoomed {
  cursor: zoom-out;
  max-width: 96vw;
  max-height: 94vh;
  transform: scale(1.6);
}

.lightbox-video {
  max-width: 90vw;
  max-height: 82vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.75);
  outline: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(20, 22, 28, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all var(--tr-fast);
  z-index: 15;
}

.lightbox-nav:hover {
  background: rgba(35, 38, 48, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-nav.prev {
  left: 20px;
}

.lightbox-nav.next {
  right: 20px;
}

.lightbox-nav.hidden {
  display: none;
}

/* Checklist drag & drop: the dragged row moves live and marks the placement point */
.chk-item-wrap.drag {
  opacity: 0.6;
}

.chk-item-wrap.drag .chk {
  border-style: dashed;
  border-color: var(--acc);
  background: var(--acc-bg, rgba(99, 102, 241, 0.12));
  box-shadow: 0 0 0 2px var(--acc-glow, transparent);
  cursor: grabbing;
}

/* insertion point line on the row the item is being placed next to */
.chk-item-wrap.drop-before {
  box-shadow: inset 0 2px 0 var(--acc), 0 -4px 14px -6px var(--acc-glow, transparent);
}

.chk-item-wrap.drop-after {
  box-shadow: inset 0 -2px 0 var(--acc), 0 4px 14px -6px var(--acc-glow, transparent);
}

/* =========================================================
   Live presence (who is viewing a card / editing a checklist item)
   ========================================================= */
.presence-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffffff;
  border: 2px solid var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  user-select: none;
  flex: 0 0 auto;
  text-transform: uppercase;
}

.presence-avatar.self {
  border-color: var(--acc);
}

.presence-avatar.editing {
  box-shadow: 0 0 0 2px var(--acc-glow), 0 1px 3px rgba(0, 0, 0, 0.35);
}

.presence-edit-dot {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--acc);
  font-size: 8px;
  font-style: normal;
  line-height: 10px;
  text-align: center;
}

.presence-stack {
  display: inline-flex;
  align-items: center;
}

.presence-stack .presence-avatar + .presence-avatar {
  margin-left: -8px;
}

/* modal top-left bar */
.presence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--txt-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: var(--col);
  border: 1px solid var(--line-subtle);
  align-self: flex-start;
}

.presence-bar.hidden {
  display: none;
}

.presence-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--txt);
}

.presence-live i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
  animation: presencePulse 1.8s ease-in-out infinite;
}

@keyframes presencePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.presence-names {
  color: var(--txt-muted);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* left side of a checklist row: who is editing that item */
.chk-presence {
  display: none;
  align-items: center;
  flex: 0 0 auto;
}

.chk-presence.on {
  display: inline-flex;
}

.chk-presence .presence-avatar {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.chk-presence .presence-stack .presence-avatar + .presence-avatar {
  margin-left: -7px;
}

/* avatars on the board card (visible without opening the card) */
.card-presence {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.card-presence .presence-avatar {
  width: 20px;
  height: 20px;
  font-size: 9px;
  border-color: var(--card);
}

.card-presence .presence-stack .presence-avatar + .presence-avatar {
  margin-left: -7px;
}

/* Media Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0;
  transition: outline var(--tr-fast), background var(--tr-fast);
  border-radius: var(--radius);
}

.media-grid.media-drop-zone-active {
  outline: 2px dashed var(--acc);
  outline-offset: 4px;
  background: rgba(99, 102, 241, 0.08);
}

.media-grid figure {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast), opacity var(--tr-fast), transform var(--tr-fast);
  display: flex;
  flex-direction: column;
  cursor: grab;
  position: relative;
  user-select: none;
}

.media-grid figure:active {
  cursor: grabbing;
}

.media-grid figure:hover {
  border-color: var(--line-highlight);
  box-shadow: var(--shadow-sm);
}

.media-grid figure.is-dragging-media {
  opacity: 0.35;
  border: 2px dashed var(--acc);
  transform: scale(0.96);
}

.media-grid figure.drop-target-before {
  border-left: 3px solid var(--acc) !important;
  box-shadow: -4px 0 14px rgba(99, 102, 241, 0.5) !important;
}

.media-grid figure.drop-target-after {
  border-right: 3px solid var(--acc) !important;
  box-shadow: 4px 0 14px rgba(99, 102, 241, 0.5) !important;
}

.media-cover-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-weight: 600;
  flex-shrink: 0;
  line-height: 1.3;
}

.media-drag-handle {
  cursor: grab;
  color: var(--txt-muted);
  padding: 0 3px;
  font-size: 12px;
  user-select: none;
  opacity: 0.65;
  transition: opacity var(--tr-fast);
  flex-shrink: 0;
}

.media-drag-handle:hover {
  opacity: 1;
  color: var(--txt);
}

.card.card-drop-over {
  outline: 2px dashed var(--acc) !important;
  outline-offset: 2px !important;
  background: rgba(99, 102, 241, 0.14) !important;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35) !important;
}

.media-thumb-frame {
  position: relative;
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c0e14;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
  cursor: pointer;
  overflow: hidden;
}

.media-thumb-frame img,
.media-grid img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  transition: transform var(--tr-fast);
}

.media-thumb-frame:hover img {
  transform: scale(1.04);
}

.media-thumb-frame .media-zoom-hint {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  opacity: 0;
  transition: opacity var(--tr-fast);
  pointer-events: none;
}

.media-thumb-frame:hover .media-zoom-hint {
  opacity: 1;
}

.media-grid video,
.media-thumb-frame video {
  width: 100%;
  height: 100%;
  max-height: 140px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
  background: #000000;
}

.media-grid figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--txt-secondary);
  background: var(--panel);
  border-top: 1px solid var(--line-subtle);
  min-height: 32px;
}

.media-cap-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.media-name-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.media-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--txt);
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 1px 4px;
  transition: background var(--tr-fast);
}

.media-name:hover {
  background: var(--card-hover);
  text-decoration: underline;
}

.media-rename-input {
  width: 100%;
  padding: 2px 6px;
  font-size: 11.5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--acc);
  background: var(--input-bg, #0d1117);
  color: var(--txt);
  outline: none;
  box-shadow: 0 0 0 1.5px rgba(99, 102, 241, 0.4);
}

.media-cap-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.media-action-btn {
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.2;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--txt-muted);
  cursor: pointer;
  transition: all var(--tr-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.media-action-btn:hover {
  background: var(--card-hover);
  color: var(--txt);
  border-color: var(--line);
}

.media-action-btn.danger:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.media-action-btn.media-replace-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.media-action-btn.media-cover-btn:hover {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}

.media-thumb-uploading {
  pointer-events: none;
}

.media-uploading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(11, 13, 19, 0.82);
  backdrop-filter: blur(3px);
  z-index: 5;
  color: #f3f6fc;
  font-size: 11px;
  font-weight: 500;
  gap: 8px;
}

.media-uploading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--acc, #4f46e5);
  border-radius: 50%;
  animation: media-spin 0.7s linear infinite;
}

@keyframes media-spin {
  to { transform: rotate(360deg); }
}

.media-thumb-name-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 6;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  padding: 3px 8px;
  border-radius: 5px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--tr-fast), background var(--tr-fast);
}

.media-thumb-name-badge:hover {
  background: rgba(0, 0, 0, 0.88);
  border-color: rgba(255, 255, 255, 0.35);
}



/* Comments Section */
.comment-box {
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 18px;
}

.comment-box b {
  font-size: 13.5px;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.comment-box input {
  flex: 1;
  background: var(--card);
}

#comments {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cmt {
  background: var(--card);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--txt);
}

.cmt small {
  color: var(--txt-muted);
}

/* Modal Foot */
.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.modal-foot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- 10. Settings Drawer --- */
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 24px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  animation: drawerSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.drawer h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
}

.drawer label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--txt-secondary);
}

.drawer label:has(input[type=checkbox]) {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
}

.drawer input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--acc);
}

.drawer input[type=range] {
  accent-color: var(--acc);
  padding: 0;
}

.drawer select, .drawer input[type=text] {
  width: 100%;
}

.drawer hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 8px 0;
}

.settings-data-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 4px;
}

.settings-data-tools .settings-section-title {
  grid-column: 1 / -1;
  color: var(--txt-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settings-data-tools button {
  width: 100%;
  text-align: left;
}

.settings-data-tools #sBackup {
  grid-column: 1 / -1;
}

/* --- 11. Alternative Views (List / Calendar / Timeline) --- */
.kv {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--tr-fast);
  box-shadow: var(--shadow-xs);
}

.kv:hover {
  transform: translateY(-1px);
  border-color: var(--line-highlight);
  background: var(--card-hover);
  box-shadow: var(--shadow-sm);
}

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .cal {
    grid-template-columns: repeat(2, 1fr);
  }
}

.cal div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 130px;
  padding: 10px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal div b {
  font-size: 13px;
  color: var(--txt-secondary);
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 4px;
  display: block;
}

.tl {
  border-left: 2px solid var(--line);
  margin-left: 16px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tl .kv {
  position: relative;
}

.tl .kv::before {
  content: '';
  position: absolute;
  left: -27px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--acc);
  border: 3px solid var(--bg);
}

/* --- 12. Toast & Utilities --- */
#toast {
  position: fixed !important;
  bottom: 24px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: var(--panel) !important;
  color: var(--txt) !important;
  padding: 10px 20px !important;
  border-radius: var(--radius-full) !important;
  z-index: 100 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  border: 1px solid var(--line-highlight) !important;
  box-shadow: var(--shadow-lg), 0 0 20px var(--acc-glow) !important;
  animation: toastPop 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes toastPop {
  from {
    opacity: 0;
    transform: translate(-50%, 14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.hidden {
  display: none !important;
}

/* --- 13. Real-Time Sync & User Authentication Styles --- */

/* Sync status badge */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  font-size: 11.5px;
  color: var(--txt-muted);
  user-select: none;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--txt-muted);
  transition: all var(--tr-fast);
}

.sync-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.sync-dot.offline {
  background: var(--danger-txt);
  box-shadow: 0 0 6px var(--danger-border);
}

/* User pill in topbar */
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  font-size: 12px;
  position: relative;
  cursor: pointer;
  transition: border-color var(--tr-fast);
}

.user-pill:hover {
  border-color: var(--line-highlight);
}

.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.user-role-badge.admin {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.user-role-badge.user, .user-role-badge.member {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.user-menu-btn {
  background: transparent !important;
  border: none !important;
  color: var(--txt-muted) !important;
  font-size: 10px !important;
  padding: 0 !important;
  cursor: pointer;
}

/* User context menu dropdown */
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line-highlight);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  min-width: 170px;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.user-menu-dropdown .menu-header {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--txt-muted);
  border-bottom: 1px solid var(--line-subtle);
  margin-bottom: 4px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
  transition: transform var(--tr-fast), background var(--tr-fast);
}

.profile-color-section {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-subtle);
}

.profile-color-title {
  font-size: 11px;
  color: var(--txt-muted);
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}

.profile-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--tr-fast), border-color var(--tr-fast);
}

.profile-color-swatch:hover {
  transform: scale(1.2);
  border-color: #fff;
}

.profile-color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 1.5px var(--acc);
}

.profile-color-custom {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  padding: 0;
  border: 1px dashed var(--line);
  cursor: pointer;
  background: transparent;
}

.user-menu-dropdown button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 14px;
  color: var(--txt);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--tr-fast);
}

.user-menu-dropdown button:hover {
  background: var(--card-hover);
  color: var(--acc-hover);
}

.user-menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--line-subtle);
  margin: 4px 0;
}

/* User Management Panel */
.user-create-box {
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.users-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.users-table th {
  background: var(--col);
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt-muted);
  border-bottom: 1px solid var(--line);
}

.users-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-subtle);
  color: var(--txt);
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover td {
  background: var(--card-hover);
}

.users-table .btn-act {
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt-secondary);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin-left: 6px;
}

.users-table .btn-act:hover {
  border-color: var(--line-highlight);
  color: var(--txt);
}

.users-table .btn-act.danger:hover {
  border-color: var(--danger-border);
  color: var(--danger-txt);
  background: var(--danger-bg);
}

.user-role-select {
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt);
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  outline: none;
  transition: all var(--tr-fast);
}

.user-role-select:hover,
.user-role-select:focus {
  border-color: var(--line-highlight);
}

.user-role-select.role-admin {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
  font-weight: 600;
}

.user-role-select.role-user {
  color: var(--txt-muted);
}

/* Role-based UI visibility */
body.role-user .admin-only {
  display: none !important;
}

/* Authentication Gatekeeper — Zero project/board leakage to outside visitors */
body.not-authenticated .topbar,
body.not-authenticated .app-layout,
body.not-authenticated .views,
body.not-authenticated #boardWrap,
body.not-authenticated .drawer {
  display: none !important;
}

body.not-authenticated #loginModal {
  display: flex !important;
  position: fixed;
  inset: 0;
  background: var(--bg);
  background-image: var(--bg-gradient);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  backdrop-filter: none;
}

body.not-authenticated #loginModal .modal-card {
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--line);
  background: var(--panel);
}

/* ============================================================
   Notifications System (Bell, Dropdown, Badges, Cards, Toasts)
   ============================================================ */

.notif-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.notif-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--col);
  border: 1px solid var(--line);
  color: var(--txt-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--tr-fast);
  padding: 0;
}

.notif-btn:hover {
  background: var(--card-hover);
  border-color: var(--line-highlight);
  color: var(--txt);
}

.notif-btn.active {
  background: var(--card-hover);
  border-color: #3b82f6;
  color: var(--txt);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--panel);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  pointer-events: none;
  animation: notifPulse 2s infinite;
}

.notif-badge.hidden {
  display: none !important;
}

@keyframes notifPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* Dropdown Panel */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: var(--panel);
  border: 1px solid var(--line-highlight);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notifDropIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.notif-dropdown.hidden {
  display: none !important;
}

@keyframes notifDropIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--col);
  border-bottom: 1px solid var(--line-subtle);
}

.notif-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notif-title-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: -0.01em;
}

.notif-count-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.notif-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notif-action-btn {
  background: transparent;
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-xs);
  color: var(--txt-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  cursor: pointer;
  transition: all var(--tr-fast);
}

.notif-action-btn:hover {
  background: var(--card-hover);
  color: var(--txt);
  border-color: var(--line);
}

.notif-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Tabs */
.notif-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--panel);
}

.notif-tab {
  background: transparent;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--txt-muted);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.notif-tab:hover {
  color: var(--txt);
  background: var(--col);
}

.notif-tab.active {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
}

/* Notification List */
.notif-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.notif-list::-webkit-scrollbar {
  width: 5px;
}

.notif-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

/* Individual Item */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--line-subtle);
  cursor: pointer;
  transition: background var(--tr-fast);
  position: relative;
  text-decoration: none;
  color: inherit;
}

.notif-item:hover {
  background: var(--card-hover);
}

.notif-item.unread {
  background: rgba(59, 130, 246, 0.06);
}

.notif-item.unread:hover {
  background: rgba(59, 130, 246, 0.12);
}

.notif-item-unread-dot {
  position: absolute;
  top: 14px;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.8);
}

.notif-item-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--col);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.notif-item-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notif-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.notif-item-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-time {
  font-size: 10.5px;
  color: var(--txt-muted);
  white-space: nowrap;
}

.notif-item-target {
  font-size: 11.5px;
  color: var(--txt-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-item-target b {
  color: var(--txt);
}

.notif-item-project-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 0 5px;
  border-radius: var(--radius-xs);
  background: var(--col);
  border: 1px solid var(--line-subtle);
  color: var(--txt-muted);
  margin-left: 4px;
}

.notif-item-msg {
  font-size: 11.5px;
  color: var(--txt-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  margin-top: 1px;
}

/* Empty State */
.notif-empty {
  padding: 32px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--txt-muted);
}

.notif-empty-icon {
  font-size: 26px;
  opacity: 0.7;
}

.notif-empty-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt-secondary);
}

.notif-empty-desc {
  font-size: 11.5px;
  color: var(--txt-muted);
}

/* Floating Toast Popups for Live Notifications */
.notif-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}

.notif-toast {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line-highlight);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: notifToastSlide 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.25s, transform 0.25s;
}

.notif-toast.fade-out {
  opacity: 0;
  transform: translateX(30px);
}

@keyframes notifToastSlide {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.notif-toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.notif-toast-body {
  flex: 1;
  min-width: 0;
}

.notif-toast-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--txt);
  margin-bottom: 2px;
}

.notif-toast-msg {
  font-size: 11.5px;
  color: var(--txt-secondary);
  line-height: 1.35;
  margin-bottom: 8px;
  word-break: break-word;
}

.notif-toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notif-toast-view-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: var(--radius-xs);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.notif-toast-view-btn:hover {
  background: #2563eb;
}

.notif-toast-dismiss {
  background: transparent;
  color: var(--txt-muted);
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
}

.notif-toast-dismiss:hover {
  color: var(--txt);
}

/* =========================================================
   Responsive Mobile View & Checklist Wrapping
   ========================================================= */
@media (max-width: 768px) {
  .modal {
    padding: 12px 6px;
  }

  .modal-card {
    padding: 16px 12px;
    max-height: 96vh;
    border-radius: var(--radius);
  }

  .modal-cover {
    margin: -16px -12px 14px -12px;
  }

  .modal-head {
    gap: 8px;
    margin-bottom: 12px;
  }

  #mTitle {
    font-size: 18px;
    padding: 4px 6px;
  }

  .modal-head .row {
    gap: 6px;
  }

  /* Checklist item: wrap actions onto second row so text has full width */
  .chk {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 8px 10px 6px 10px;
    gap: 6px 8px;
  }

  .chk .txt {
    flex: 1 1 calc(100% - 55px);
    max-width: calc(100% - 50px);
    min-width: 0;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .chk-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    padding-top: 6px;
    border-top: 1px solid var(--line-subtle);
    gap: 6px;
  }

  .chk-actions button {
    padding: 4px 8px;
    font-size: 12px;
  }

  .chk-cmt-btn,
  .chk-media-btn {
    padding: 3px 8px !important;
    font-size: 11.5px !important;
  }

  .chk-thread {
    margin: 4px 0 6px 6px;
    padding: 8px 10px;
  }

  .chk-media-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .chk-reply-box {
    flex-wrap: wrap;
  }

  .chk-reply-input {
    width: 100%;
    flex: 1 1 100%;
  }

  .chk-reply-btn,
  .chk-attach-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  .check-add {
    gap: 6px;
  }
}

/* Confirmation Dialog Popup */
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: threadFadeIn 140ms ease-out;
}

.confirm-dialog-overlay.hidden {
  display: none;
}

.confirm-dialog-card {
  background: var(--panel, #181b22);
  border: 1px solid var(--line-highlight, #303644);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  width: 100%;
  max-width: 380px;
  padding: 24px 22px 20px;
  text-align: center;
  animation: modalScaleIn 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-dialog-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.confirm-dialog-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--txt, #f3f6fc);
}

.confirm-dialog-msg {
  margin: 0 0 20px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--txt-secondary, #9ba3b2);
  word-break: break-word;
}

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

.confirm-dialog-actions button {
  flex: 1;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.confirm-dialog-actions .confirm-btn-cancel {
  background: var(--card, #20242e);
  color: var(--txt, #f3f6fc);
  border: 1px solid var(--line, #2c3240);
}

.confirm-dialog-actions .confirm-btn-cancel:hover {
  background: var(--card-hover, #282d3a);
  border-color: var(--line-highlight, #3b4356);
}

.confirm-dialog-actions .confirm-btn-yes {
  background: #ef4444;
  color: #ffffff;
  border: 1px solid #dc2626;
}

.confirm-dialog-actions .confirm-btn-yes:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* ============================================================
   Enhanced Toast & Undo System Styling
   ============================================================ */
#toast.app-toast,
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #151926;
  color: #f3f6fc;
  padding: 10px 18px;
  border-radius: 12px;
  z-index: 10001;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid rgba(99, 102, 241, 0.4);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: none;
  align-items: center;
  gap: 12px;
  max-width: 90vw;
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: appToastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes appToastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

#toast .toast-msg {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 480px;
}

#toast .toast-undo-btn {
  background: #4f46e5;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

#toast .toast-undo-btn:hover {
  background: #6366f1;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

#toast .toast-undo-btn:active {
  transform: translateY(0);
}

#toast .toast-close-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

#toast .toast-close-btn:hover {
  color: #f3f6fc;
}

/* Global Board & Modal Undo Action Buttons */
.undo-nav-btn {
  background: rgba(99, 102, 241, 0.12) !important;
  color: #818cf8 !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  border-radius: var(--radius-full, 9999px) !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.undo-nav-btn:hover {
  background: rgba(99, 102, 241, 0.22) !important;
  color: #a5b4fc !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}

.check-undo-btn {
  background: rgba(99, 102, 241, 0.1) !important;
  color: #818cf8 !important;
  border: 1px solid rgba(99, 102, 241, 0.25) !important;
  padding: 6px 11px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: var(--radius-sm, 6px) !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.check-undo-btn:hover {
  background: rgba(99, 102, 241, 0.2) !important;
  color: #a5b4fc !important;
  border-color: rgba(99, 102, 241, 0.45) !important;
}

/* ---- AI translation ---- */
.translate-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.translate-btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
}

.translate-btn:disabled,
.translate-btn.btn-translating {
  opacity: 0.75;
  cursor: progress;
}

/* ---- AI settings panel (administrators only) ---- */
.ai-settings-card {
  max-width: 760px;
}

.ai-settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-provider-list-wrap {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line-subtle, #272f3d);
  border-radius: var(--radius-sm, 6px);
}

.ai-provider-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.ai-provider-table th,
.ai-provider-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line-subtle, #272f3d);
  vertical-align: middle;
}

.ai-provider-table tbody tr:last-child td {
  border-bottom: none;
}

.ai-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-full, 999px);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.ai-badge.default {
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
}

.ai-badge.on {
  color: #86efac;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.35);
}

.ai-badge.off {
  color: var(--txt-muted, #94a3b8);
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
}

.ai-badge.warn {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

.ai-provider-form {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-subtle, #272f3d);
}

.ai-form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ai-field {
  flex: 1 1 200px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--txt-muted, #94a3b8);
}

.ai-field.wide {
  flex: 1 1 100%;
}

.ai-field input,
.ai-field select {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--txt);
  background: var(--input-bg, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--line, #2a3242);
  border-radius: var(--radius-sm, 6px);
}

.ai-form-toggles {
  align-items: center;
}

.ai-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt);
  cursor: pointer;
}

.ai-form-spacer {
  flex: 1 1 auto;
}




/* ============================================================
   History & Trash (shared activity log, trash restore, versions)
   ============================================================ */

.not-authenticated #btnHistory,
.not-authenticated #btnCardHistory {
  display: none !important;
}

.history-modal-card {
  max-width: 900px;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  overflow: hidden;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.history-head h3 {
  font-size: 18px;
}

.history-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.history-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--txt-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--tr-fast), border-color var(--tr-fast);
}

.history-tab:hover {
  color: var(--txt);
}

.history-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.history-trash-count {
  background: var(--danger-bg, rgba(239, 68, 68, 0.18));
  color: var(--danger-txt, #ef4444);
  border-radius: var(--radius-full);
  font-size: 10.5px;
  padding: 1px 7px;
}

.history-card-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--col);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--txt-secondary);
  margin-bottom: 12px;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.history-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-filter select {
  background: var(--col);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  min-width: 150px;
}

.history-list {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 160px;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-empty {
  text-align: center;
  color: var(--txt-muted);
  font-size: 13px;
  padding: 42px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.history-empty-icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.history-item {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius);
  padding: 11px 13px;
  transition: border-color var(--tr-fast);
}

.history-item:hover {
  border-color: var(--line-highlight);
}

.history-item-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  background: var(--col);
  border: 1px solid var(--line);
}

.history-item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.history-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  word-break: break-word;
}

.history-item-time {
  font-size: 11px;
  color: var(--txt-muted);
  white-space: nowrap;
}

.history-item-meta {
  font-size: 11.5px;
  color: var(--txt-muted);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.history-author {
  color: var(--txt-secondary);
  font-weight: 600;
}

.history-target {
  color: var(--txt-secondary);
  word-break: break-word;
}

.history-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  border: 1px solid var(--line);
  color: var(--txt-secondary);
  background: var(--col);
}

.history-action-badge.created,
.history-action-badge.added,
.history-action-badge.restored {
  color: var(--done, #10b981);
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.history-action-badge.deleted {
  color: var(--danger-txt, #ef4444);
  border-color: var(--danger-border, rgba(239, 68, 68, 0.35));
  background: var(--danger-bg, rgba(239, 68, 68, 0.1));
}

.history-action-badge.updated,
.history-action-badge.moved {
  color: var(--primary, #3b82f6);
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
}

.history-changes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 7px;
}

.history-chip {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--txt-secondary);
  background: var(--col);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  word-break: break-word;
}

.history-chip b {
  color: var(--txt-muted);
  font-weight: 700;
  margin-right: 4px;
}

.history-chip .from {
  color: var(--danger-txt, #ef4444);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.history-chip .arrow {
  color: var(--txt-muted);
  margin: 0 5px;
}

.history-chip .to {
  color: var(--done, #10b981);
}

.history-item-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item-actions button {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--col);
  color: var(--txt-secondary);
  cursor: pointer;
  transition: all var(--tr-fast);
}

.history-item-actions button:hover {
  border-color: var(--line-highlight);
  color: var(--txt);
}

.history-item-actions button.primary-act {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--primary, #3b82f6);
  font-weight: 600;
}

.history-item-actions button.primary-act:hover {
  background: rgba(59, 130, 246, 0.24);
}

.history-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-subtle);
}

.history-foot .hint {
  font-size: 11px;
  line-height: 1.4;
}

.history-trash-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-trash-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt-muted);
  margin-top: 6px;
}

.history-trash-hint {
  font-size: 11.5px;
  color: var(--txt-muted);
  font-style: italic;
}

.history-muted {
  color: var(--txt-muted);
}

.history-live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--done, #10b981);
  margin-right: 5px;
  vertical-align: middle;
}

@media (max-width: 620px) {
  .history-filters {
    flex-direction: column;
  }

  .history-filter select {
    width: 100%;
  }

  .history-modal-card {
    max-height: 94vh;
    padding: 16px;
  }

  .history-item {
    padding: 10px;
  }

  .history-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Admin-only card visibility ---- */
.card-visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt-muted, #94a3b8);
  padding: 4px 8px;
  border: 1px dashed var(--line, #2a3342);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.card-visibility-toggle input {
  accent-color: var(--primary, #3b82f6);
}

.card-visibility-toggle:hover {
  color: var(--txt, #e5e7eb);
  border-color: var(--primary, #3b82f6);
}

.card-lock-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  border-radius: 999px;
  color: #f59e0b;
  background: rgba(245, 158, 11, .14);
  border: 1px solid rgba(245, 158, 11, .35);
  vertical-align: middle;
}

.card.admin-card,
.card.locked {
  border: 1.5px solid #f59e0b;
  border-style: solid;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, .25), 0 6px 18px -12px rgba(245, 158, 11, .55);
  background-image: linear-gradient(135deg, rgba(245, 158, 11, .07), transparent 60%);
}

.card.admin-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 12px 0 0 12px;
  background: #f59e0b;
}

.card.admin-card .title-txt,
.card.locked .title-txt {
  color: var(--txt, #e5e7eb);
}

/* Locked card modal: members only see and work the shared checklist */
#modal.card-locked #mTitle,
#modal.card-locked .modal-head .row,
#modal.card-locked #toolbar,
#modal.card-locked #mDesc,
#modal.card-locked #mMedia,
#modal.card-locked .comment-box,
#modal.card-locked .modal-cover,
#modal.card-locked #mDelete {
  display: none !important;
}

#modal.card-locked .modal-head {
  padding-bottom: 4px;
}

.locked-card-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .35);
  color: var(--txt, #e5e7eb);
}

.locked-card-banner .lock-ico {
  font-size: 20px;
}

.locked-card-banner b {
  display: block;
  font-size: 13px;
}

.locked-card-banner small {
  display: block;
  font-size: 12px;
  color: var(--txt-muted, #94a3b8);
  margin-top: 2px;
}

#modal.card-admin .modal-card {
  border: 1.5px solid #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, .25), var(--shadow-lg, 0 20px 60px rgba(0,0,0,.5));
}

.chk.chk-locked .chk-media-btn,
.chk.chk-locked .chk-cmt-btn,
.chk.chk-locked .del {
  display: none !important;
}

/* =========================================================
   Notion-style docked card windows (desktop only)
   The legacy .modal markup/styles above stay untouched for mobile.
   ========================================================= */
.card-window-layer {
  position: fixed;
  z-index: 45;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  pointer-events: none;
  overflow: visible;
}

body.cw-resizing {
  cursor: col-resize;
  user-select: none;
}

.card-peek-window {
  position: relative;
  pointer-events: auto;
  z-index: 1;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 14px 0 0 14px;
  box-shadow: -14px 0 44px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  opacity: 0;
  transform: translateX(18px);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), width 0.16s ease;
}

.card-peek-window.mounted {
  opacity: 1;
  transform: translateX(0);
}

.card-peek-window.focused {
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.55);
  z-index: 2;
}

.card-peek-window.expanded {
  transition: none;
}

.card-peek-window.cw-hidden {
  display: none !important;
}

/* Left-edge resize handle */
.cw-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 9px;
  cursor: col-resize;
  z-index: 6;
  touch-action: none;
}

.cw-resize::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 46px;
  border-radius: 4px;
  background: var(--line);
  opacity: 0;
  transition: opacity 0.15s;
}

.card-peek-window:hover .cw-resize::after { opacity: 0.9; }
.cw-resize:hover::after { opacity: 1; background: var(--acc); }

/* Window header */
.cw-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--col);
  flex-shrink: 0;
}

.cw-title-label {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cw-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--txt-muted);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
}

.cw-btn:hover {
  color: var(--txt);
  border-color: var(--line-highlight);
  background: var(--card-hover);
}

.cw-close:hover {
  color: var(--danger-txt);
  border-color: rgba(239, 68, 68, 0.4);
}

.cw-translate { width: auto; padding: 0 8px; font-size: 12px; }

/* Cover + scrolling body reuse the modal internals */
.cw-cover {
  margin: 0;
  border-radius: 0;
  max-height: 220px;
  flex-shrink: 0;
}

.cw-body {
  margin: 0;
  border: none;
  border-radius: 0;
  max-width: none;
  width: 100%;
  max-height: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  box-shadow: none;
  animation: none;
  padding: 16px;
  background: var(--panel);
}

/* Window inputs mirror the #mTitle / #mStatus / #mTags modal rules */
.cw-title {
  width: 100%;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--txt);
  margin: 0;
}

.cw-title:hover { border-color: var(--line); }
.cw-title:focus { background: var(--card); border-color: var(--acc); }

.cw-status { font-weight: 600; }
.cw-tags { flex: 1; min-width: 130px; }

.cw-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cw-comments {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cw-desc { min-height: 110px; }

/* Locked (admin-only) card windows: checklist only, like the modal */
.card-peek-window.card-locked .cw-title,
.card-peek-window.card-locked .modal-head .row,
.card-peek-window.card-locked .cw-toolbar,
.card-peek-window.card-locked .cw-desc,
.card-peek-window.card-locked .cw-media,
.card-peek-window.card-locked .comment-box,
.card-peek-window.card-locked .cw-cover,
.card-peek-window.card-locked .cw-delete {
  display: none !important;
}

.card-peek-window.card-admin .cw-body {
  border: 1px solid #f59e0b;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}
