/* ── CSS Variables (Dark = default) ── */
:root, [data-theme="dark"] {
  --bg: #1a1a1a;
  --bg2: #2a2a2a;
  --bg3: #333333;
  --surface: #2a2a2a;
  --surface2: #333333;
  --border: #404040;
  --border2: #505050;
  --text: #e0e0e0;
  --text2: #aaaaaa;
  --text3: #888888;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-bg: rgba(99, 102, 241, 0.15);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --shadow: rgba(0,0,0,0.5);
  --scrollbar: #404040;
  --scrollbar-hover: #555555;

  --col-backlog: #555555;
  --wb-bg: #2a2a2a;
  --wb-dot: #505050;

  --col-todo: #3b82f6;
  --col-in_progress: #f59e0b;
  --col-review: #8b5cf6;
  --col-done: #10b981;

  --type-bug: #ef4444;
  --type-note: #f59e0b;
  --type-idea: #8b5cf6;
  --type-suggestion: #3b82f6;
  --type-todo: #10b981;
  --type-task: #6b7280;

  --priority-low: #6b7280;
  --priority-medium: #f59e0b;
  --priority-high: #ef4444;
  --priority-critical: #dc2626;
}

[data-theme="light"] {
  --bg: #f4f4f4;
  --bg2: #ffffff;
  --bg3: #e8e8e8;
  --surface: #ffffff;
  --surface2: #f0f0f0;
  --border: #e0e0e0;
  --border2: #d0d0d0;
  --text: #1a1a1a;
  --text2: #555555;
  --text3: #888888;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-bg: rgba(99, 102, 241, 0.1);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --shadow: rgba(0,0,0,0.1);
  --scrollbar: #d0d0d0;
  --scrollbar-hover: #aaaaaa;
  --wb-bg: #fafafa;
  --wb-dot: #d8d8d8;

  --col-backlog: #888888;
  --col-todo: #3b82f6;
  --col-in_progress: #f59e0b;
  --col-review: #8b5cf6;
  --col-done: #10b981;

  --type-bug: #dc2626;
  --type-note: #d97706;
  --type-idea: #7c3aed;
  --type-suggestion: #2563eb;
  --type-todo: #059669;
  --type-task: #4b5563;

  --priority-low: #6b7280;
  --priority-medium: #d97706;
  --priority-high: #dc2626;
  --priority-critical: #991b1b;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

a { color: var(--primary); text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ── Login ── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  text-align: center;
  box-shadow: 0 25px 50px var(--shadow);
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text2);
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 16px;
  outline: none;
  transition: border-color .2s;
}

.login-card input:focus {
  border-color: var(--primary);
}

.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.login-card button:hover {
  background: var(--primary-hover);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

/* ── App Layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  white-space: nowrap;
}

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

.header-center { gap: 4px; }

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.assignee-toggle {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all .2s;
}

.assignee-toggle:hover {
  color: var(--text);
  border-color: var(--border2);
}

.assignee-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.user-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: default;
  outline: none;
  opacity: 0.8;
}

/* ── Tabs ── */
.tab-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-weight: 500;
  transition: all .2s;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--border2);
}

.tab-btn.active {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Buttons ── */
.btn-primary {
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}

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

.btn-ghost {
  padding: 8px 16px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .2s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border2);
}

.btn-danger {
  padding: 8px 16px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

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

#theme-toggle {
  padding: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* ── Filter Bar ── */
#filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

#filter-bar select,
#filter-bar input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-size: 13px;
  min-width: 0;
}

#filter-bar select { cursor: pointer; }
#filter-bar select:focus,
#filter-bar input:focus { border-color: var(--primary); }

#filter-search {
  flex: 1;
  min-width: 140px;
}

/* ── Main Content ── */
main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow: auto;
}

.view.active {
  display: block;
}

/* ── Board View ── */
#board-view {
  display: none;
  padding: 20px;
  overflow: hidden;
}

#board-view.active {
  display: flex;
  gap: 16px;
}

.board-columns {
  display: flex;
  gap: 16px;
  flex: 1;
  overflow-x: auto;
  min-width: 0;
}

.board-column {
  flex: 1;
  min-width: 180px;
  max-width: 260px;
  background: var(--surface2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.board-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.column-count {
  background: var(--bg3);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.board-column-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  min-height: 80px;
  transition: background .2s;
}

.board-column-body.drag-over {
  background: var(--primary-bg);
  border-radius: 8px;
}

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: grab;
  transition: box-shadow .2s, border-color .2s;
  user-select: none;
}

.board-card:hover {
  border-color: var(--border2);
  box-shadow: 0 4px 12px var(--shadow);
}

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

.board-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px dashed var(--border);
  background: transparent;
  min-height: 48px;
  transition: all .2s;
}

.board-card-add:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.card-add-icon {
  font-size: 22px;
  font-weight: 600;
  color: var(--text3);
  line-height: 1;
  transition: color .2s;
}

.board-card-add:hover .card-add-icon {
  color: var(--primary);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-title {
  font-weight: 500;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-assignee {
  font-size: 12px;
  color: var(--text2);
}

.card-tags {
  display: flex;
  gap: 4px;
  align-items: center;
}

.card-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.card-chat-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--text3);
  font-size: 16px;
  line-height: 1;
  margin-left: 2px;
  transition: color .3s;
}

.card-chat-indicator .material-icons-outlined {
  font-size: 16px;
}

.card-chat-indicator.unread {
  color: #f59e0b;
  animation: chat-pulse 2s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.card-topic {
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Badge System ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-type {
  color: #fff;
}

.badge-type.bug { background: var(--type-bug); }
.badge-type.note { background: var(--type-note); }
.badge-type.idea { background: var(--type-idea); }
.badge-type.suggestion { background: var(--type-suggestion); }
.badge-type.todo { background: var(--type-todo); }
.badge-type.task { background: var(--type-task); }

.badge-priority {
  background: transparent;
  border: 1px solid;
}

.badge-priority.low { color: var(--priority-low); border-color: var(--priority-low); }
.badge-priority.medium { color: var(--priority-medium); border-color: var(--priority-medium); }
.badge-priority.high { color: var(--priority-high); border-color: var(--priority-high); }
.badge-priority.critical { color: var(--priority-critical); border-color: var(--priority-critical); }

.badge-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
  color: #fff;
}

.badge-status.backlog { background: var(--col-backlog); }
.badge-status.todo { background: var(--col-todo); }
.badge-status.in_progress { background: var(--col-in_progress); }
.badge-status.review { background: var(--col-review); }
.badge-status.done { background: var(--col-done); }

/* ── List View ── */
#list-view {
  padding: 0;
}

#list-view.active {
  display: block;
}

.item-table {
  width: 100%;
  border-collapse: collapse;
}

.item-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  border-bottom: 2px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  z-index: 1;
}

.item-table th:hover {
  color: var(--text);
}

.item-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

.item-table tr {
  cursor: pointer;
  transition: background .15s;
}

.item-table tr:hover {
  background: var(--surface2);
}

.table-title {
  font-weight: 500;
}

.table-tags {
  display: flex;
  gap: 4px;
}

.table-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.table-topics {
  font-size: 12px;
  color: var(--text2);
}

.table-actions {
  display: flex;
  gap: 4px;
}

.table-actions button {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all .2s;
}

.table-actions button:hover {
  color: var(--text);
  border-color: var(--border2);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 1000;
  overflow-y: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 25px 60px var(--shadow);
  overflow: hidden;
}

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

.modal-header h2 {
  font-size: 18px;
}

.modal-close {
  padding: 4px 12px;
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  border-radius: 6px;
  transition: all .2s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--bg3);
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

/* ── Item Detail (view mode) ── */
.item-detail-title {
  font-size: 20px;
  margin-bottom: 16px;
}

.item-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.item-detail-description {
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.item-detail-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.info-label {
  color: var(--text2);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.item-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}

.item-detail-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

/* ── Comments ── */
.comments-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

.comment {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
}

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

.comment-author {
  font-weight: 600;
  font-size: 13px;
}

.comment-date {
  font-size: 12px;
  color: var(--text3);
}

.comment-body {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.comment-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comment-form input,
.comment-form textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  min-height: 40px;
}

.comment-form textarea {
  min-height: 80px;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: var(--primary);
}

.comment-form button {
  align-self: flex-end;
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.comment-form button:hover {
  background: var(--primary-hover);
}

/* ── Item Form (edit/create mode) ── */
.item-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-group-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.form-group-inline label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  min-width: 70px;
  flex-shrink: 0;
}

.form-group-inline .tags-selector {
  padding: 4px 0;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
}

.item-form input,
.item-form select,
.item-form textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  line-height: normal;
}

.item-form textarea {
  min-height: 120px;
  resize: vertical;
}

.item-form input:focus,
.item-form select:focus,
.item-form textarea:focus {
  border-color: var(--primary);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.tags-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

.tag-checkbox {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  transition: all .2s;
  user-select: none;
}

.tag-checkbox:hover {
  border-color: var(--border2);
}

.tag-checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.tag-checkbox:has(input[type="radio"]) {
  background: var(--bg3);
}

.tag-checkbox:has(input[type="radio"]:checked) {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.tag-checkbox.type-bug:has(input[type="radio"]:checked) { background: var(--type-bug); color: #fff; border-color: var(--type-bug); }
.tag-checkbox.type-note:has(input[type="radio"]:checked) { background: var(--type-note); color: #fff; border-color: var(--type-note); }
.tag-checkbox.type-idea:has(input[type="radio"]:checked) { background: var(--type-idea); color: #fff; border-color: var(--type-idea); }
.tag-checkbox.type-suggestion:has(input[type="radio"]:checked) { background: var(--type-suggestion); color: #fff; border-color: var(--type-suggestion); }
.tag-checkbox.type-todo:has(input[type="radio"]:checked) { background: var(--type-todo); color: #fff; border-color: var(--type-todo); }
.tag-checkbox.type-task:has(input[type="radio"]:checked) { background: var(--type-task); color: #fff; border-color: var(--type-task); }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

#new-tag-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

#new-tag-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

#new-tag-row input:focus {
  border-color: var(--primary);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text3);
  text-align: center;
}

.empty-state p {
  font-size: 15px;
  margin-top: 8px;
}

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text3);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  #board-view.active {
    overflow-y: auto;
    flex-direction: column;
  }

  .board-columns {
    flex-wrap: wrap;
  }

  .board-column {
    max-width: none;
  }

  .chat-panel {
    min-width: 0;
    width: 100%;
    max-width: none;
    max-height: 40vh;
  }

  header h1 { font-size: 15px; }
  .tab-btn { padding: 6px 12px; font-size: 13px; }
  #filter-bar { padding: 8px 12px; }
  #filter-bar select, #filter-bar input { font-size: 12px; padding: 6px 8px; }
}

/* ── Whiteboard View ── */
#whiteboard-view {
  padding: 0;
  overflow: hidden;
  position: relative;
}

#whiteboard-view.active {
  display: block;
}

#wb-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wb-bg);
  position: relative;
  cursor: default;
}

#wb-board {
  width: 10000px;
  height: 10000px;
  position: absolute;
  background-image:
    radial-gradient(circle, var(--wb-dot) 1px, transparent 1px);
  background-size: 40px 40px;
}

.wb-card {
  position: absolute;
  min-width: 180px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 8px var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.wb-card:hover {
  box-shadow: 0 6px 20px var(--shadow);
  border-color: var(--primary);
  z-index: 9999;
}

.wb-card:active {
  cursor: grabbing;
  box-shadow: 0 8px 28px var(--shadow);
}

.wb-card-clickable {
  cursor: pointer;
}

.wb-card-del {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.wb-card:hover .wb-card-del {
  display: flex;
}

.wb-card-body {
  padding: 12px 14px;
}

.wb-card-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  margin-bottom: 4px;
}

.wb-card-desc {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ── Tracker Cards (items from kanban) ── */

.wb-card-tracker {
  min-width: 220px;
}

.wb-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.wb-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.wb-card-assignee {
  font-size: 11px;
  color: var(--text2);
}

.wb-card-tags {
  display: flex;
  gap: 4px;
  align-items: center;
}

.wb-tracker-status {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 8px;
  color: #fff;
  line-height: 1.4;
}

.wb-tracker-status.backlog { background: var(--col-backlog); }
.wb-tracker-status.todo { background: var(--col-todo); }
.wb-tracker-status.in_progress { background: var(--col-in_progress); }
.wb-tracker-status.review { background: var(--col-review); }
.wb-tracker-status.done { background: var(--col-done); }

/* ── Link Cards ── */

.wb-link-loading {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.wb-link-thumb {
  width: 80px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg3);
}

.wb-link-info {
  min-width: 0;
  flex: 1;
}

.wb-link-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.wb-link-desc {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wb-link-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.wb-link-icon {
  flex-shrink: 0;
  font-size: 12px;
}

.wb-link-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Image Cards ── */

.wb-card-image {
  padding: 0;
  background: var(--bg3);
  overflow: hidden;
}

.wb-image {
  display: block;
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: 10px 10px 0 0;
  pointer-events: none;
}

.wb-image-caption {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text2);
  text-align: center;
}

/* ── Video Cards (YouTube) ── */

.wb-card-link.wb-video-card {
  padding: 0;
  overflow: hidden;
  width: 360px;
}

.wb-video-container {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  background: #000;
  cursor: pointer;
}

.wb-video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.wb-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  z-index: 2;
  padding-left: 4px;
}

.wb-video-play:hover {
  background: rgba(255,0,0,0.9);
  transform: translate(-50%, -50%) scale(1.1);
}

.wb-video-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

.wb-video-container.playing .wb-video-iframe {
  pointer-events: auto;
}

.wb-video-title {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Add Button & Menu ── */

#wb-add-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 2147483647;
  transition: transform 0.15s, box-shadow 0.15s;
}

#wb-add-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px var(--shadow);
}

.wb-add-menu {
  position: absolute;
  bottom: 76px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px var(--shadow);
  z-index: 2147483647;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wb-add-menu-item {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s;
}

.wb-add-menu-item:hover {
  background: var(--surface2);
}

.wb-add-menu-item + .wb-add-menu-item {
  border-top: 1px solid var(--border);
}

/* ── File Drop Indicator ── */

#wb-viewport.wb-drag-over {
  background: var(--primary-bg) !important;
}

#wb-viewport.wb-drag-over::after {
  content: 'Drop image here';
  position: absolute;
  inset: 20px;
  border: 3px dashed var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(0,0,0,0.15);
  z-index: 2147483647;
  pointer-events: none;
}

@media (max-width: 600px) {
  header { padding: 0 12px; flex-wrap: wrap; height: auto; min-height: 52px; gap: 4px; }
  .header-center { order: 3; width: 100%; justify-content: center; }
  .modal { margin: 20px 10px; }
  .form-row { flex-direction: column; gap: 14px; }
}

/* ── Selection & Edit Icon ── */

.board-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg), 0 4px 12px var(--shadow);
}

.card-edit-btn, .wb-card-edit-btn {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  flex-shrink: 0;
  transition: background .15s, color .15s;
  line-height: 1;
}

.board-card:hover .card-edit-btn,
.wb-card-tracker:hover .wb-card-edit-btn {
  display: inline-flex;
}

.card-edit-btn .material-symbols-outlined,
.wb-card-edit-btn .material-symbols-outlined {
  font-size: 16px;
}

.card-edit-btn:hover, .wb-card-edit-btn:hover {
  background: var(--bg3);
  color: var(--primary);
}

.wb-card-tracker.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-bg), 0 6px 20px var(--shadow);
}

/* ── Chat Panel ── */

.chat-panel {
  width: 340px;
  min-width: 300px;
  max-width: 380px;
  background: var(--surface2);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  max-height: 100%;
}

.chat-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  padding: 14px 16px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  line-height: 1;
  transition: color .15s;
}

.chat-back-btn .material-symbols-outlined {
  font-size: 20px;
}

.chat-back-btn:hover {
  color: var(--primary);
}

.chat-header-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
  display: inline-block;
  vertical-align: bottom;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.chat-empty, .chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text3);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
}

.chat-bubble-self {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-other {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble-author {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-bubble-self .chat-bubble-author {
  color: rgba(255,255,255,0.75);
}

.chat-bubble-other .chat-bubble-author {
  color: var(--primary);
}

.chat-bubble-body {
  white-space: pre-wrap;
}

.chat-bubble-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  text-align: right;
}

.chat-bubble-self .chat-bubble-time {
  color: rgba(255,255,255,0.6);
}

.chat-input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: relative;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  resize: none;
  outline: none;
  max-height: 80px;
  font-family: inherit;
  line-height: 1.4;
}

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

.chat-emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
  padding: 0;
}

.chat-emoji-btn:hover {
  background: var(--bg3);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: opacity .2s;
}

.chat-send-btn:active {
  opacity: 0.7;
}

.emoji-picker {
  position: absolute;
  bottom: 100%;
  left: 12px;
  margin-bottom: 4px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .15s;
  padding: 0;
}

.emoji-btn:hover {
  background: var(--bg3);
}
