.board-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}
.board-card.board-selected > .board-card-body { border-color: var(--accent); }
.board-panel[hidden] {
  display: none;
}
.board-toolbar,
.board-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  flex: none;
}
.board-toolbar {
  border-bottom: 1px solid var(--line);
}
/* Keep the short save lock semantic/functional without flashing the toolbar. */
.board-toolbar button[data-saving='true']:disabled {
  opacity: 1;
}
.board-footer {
  border-top: 1px solid var(--line);
  font-size: 12px;
  flex-wrap: wrap;
}
.board-footer [role='status'] {
  flex: 1;
  min-width: 120px;
  color: var(--muted);
}
.board-footer button {
  min-width: 36px;
}
.board-canvas {
  flex: 1;
  min-height: 200px;
  position: relative;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
  cursor: grab;
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
}
.board-world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.board-wires {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.board-wires path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.board-wires .draft {
  stroke-dasharray: 4 5;
}
.board-wires .wire-hit {
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
  cursor: pointer;
}
.board-card {
  position: absolute;
  width: 244px;
  pointer-events: auto;
  cursor: default;
}
.board-card-body {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0 16px 16px;
  overflow: hidden;
}
.board-card-head {
  display: block;
  width: calc(100% - 26px);
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 0;
  cursor: grab;
  touch-action: none;
}
.board-dragging .board-card-head { background: var(--hover); border-radius: 5px; }
.board-manipulating, .board-manipulating * { user-select: none !important; -webkit-user-select: none !important; }
.board-manipulating { cursor: grabbing; }
.board-card-options {
  position: absolute;
  top: 4px;
  right: 5px;
  padding: 2px 8px;
  border: 0;
  background: transparent;
}
.board-card h3 {
  display: block;
  max-height: 56px;
  overflow: auto;
  font-size: 15px;
  margin: 6px 0 10px;
  overflow-wrap: anywhere;
}
.board-card p {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  overflow: auto;
}
.board-card blockquote {
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.board-image {
  width: 100%;
  height: 140px;
  object-fit: contain;
  border-radius: 5px;
}
.board-check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  font-size: 13px;
}
.board-check input {
  flex: none;
}
.board-check span {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.board-port {
  position: absolute;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  display: grid;
  place-items: center;
  touch-action: none;
  opacity: 0;
}
.board-port::after {
  content: '';
  width: 9px;
  height: 9px;
  border: 1.5px dashed var(--accent);
  border-radius: 50%;
  background: var(--surface);
}
.board-port.connected {
  opacity: 1;
  cursor: grab;
}
.board-port.connected::after {
  background: var(--accent);
  border-style: solid;
}
.board-port:hover,
.board-port:focus-visible,
.board-card:hover .board-port,
.connecting .board-port {
  opacity: 1;
  background: transparent;
}
.board-port:hover::after,
.board-port:focus-visible::after {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.board-editor {
  width: min(500px, calc(100% - 32px));
  max-height: 85dvh;
}
.board-editor input,
.board-editor textarea {
  width: 100%;
  margin-bottom: 12px;
}
.board-editor textarea {
  height: 230px;
  resize: vertical;
  font-size: 16px;
}
.board-editor small {
  display: block;
  margin-bottom: 12px;
}
.board-error {
  color: var(--danger);
  white-space: pre-wrap;
}
.board-editor button {
  margin-right: 8px;
}
.conversation-tools {
  flex-wrap: wrap;
}
.board-toggle[aria-pressed='true'] {
  background: var(--hover);
  color: var(--accent);
}
@media (pointer: coarse) {
  .board-port {
    opacity: 1;
  }
  .board-toolbar button,
  .board-footer button,
  .board-card-head,
  .board-card-options {
    min-height: 44px;
  }
  .board-card-head {
    padding-block: 12px;
  }
  .board-check {
    min-height: 32px;
  }
}
@media (max-width: 799px) {
  .conversation header {
    flex-wrap: wrap;
  }
  .conversation-tools {
    display: flex;
    flex-basis: 100%;
    order: 3;
    gap: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .conversation-tools button {
    font-size: 12px;
    padding: 6px;
    min-height: 44px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    flex: none;
    background: transparent;
    border: 0;
    padding-inline: 0;
    color: var(--accent);
  }
  .board-toolbar,
  .board-footer {
    padding-inline: 10px;
  }
}

.board-minimap {
  position: absolute; right: 12px; bottom: 12px; z-index: 4;
  width: 150px; height: 98px; min-height: 0; padding: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: crosshair; touch-action: none;
}
.board-minimap[hidden] { display: none; }
.board-minimap svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.board-minimap rect { fill: var(--accent); fill-opacity: .5; }
.board-minimap .board-map-viewport { fill-opacity: .1; stroke: var(--accent); stroke-width: 1.2; }
.board-storage { font-size: 11px; color: var(--muted); }
.board-image-open { padding: 0; border: 0; background: transparent; width: 100%; cursor: zoom-in; }
.board-image-viewer { width: min(1000px, 94vw); max-width: 94vw; max-height: 90dvh; padding: 12px; }
.board-image-viewer > img { display: block; width: 100%; max-height: 74dvh; object-fit: contain; }
.board-image-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.board-image-actions span { flex: 1; min-width: 0; max-height: 72px; white-space: pre-wrap; overflow: auto; overflow-wrap: anywhere; }
.board-image-actions a { white-space: nowrap; }
@media (max-width: 799px) {
  .board-footer { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .board-footer [role='status'] { flex-basis: 100%; }
  .board-storage { flex: 1; }
}

.board-kind-image .board-card-body { display: flex; flex-direction: column; }
.board-kind-image .board-card-head, .board-kind-image h3 { flex: none; }
.board-kind-image .board-image-open { flex: 1; min-height: 0; display: flex; padding: 0; align-items: stretch; }
.board-kind-image .board-image { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.board-kind-group .board-card-body { background: rgb(130 135 145 / 9%); border: 1px solid rgb(170 180 195 / 30%); }
.board-resize { position: absolute; right: 0; bottom: 0; width: 26px; height: 26px; padding: 0; border: 0; background: transparent; cursor: nwse-resize; touch-action: none; color: var(--muted); }

.board-image-title { display: block; max-width: 100%; min-height: 20px; padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; }
.board-image-title.empty { color: var(--muted); }

.board-kind-list .board-card-body, .board-kind-text .board-card-body, .board-kind-file .board-card-body, .board-kind-quote .board-card-body { display: flex; flex-direction: column; }
.board-card-head, .board-card h3 { flex: none; }
.board-kind-text p, .board-kind-file p, .board-kind-quote blockquote { flex: 1; min-height: 0; }
.board-file-download { display: inline-flex; align-items: center; min-height: 36px; flex: none; color: var(--accent); align-self: flex-start; text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; }
.board-kind-quote blockquote { margin: 0 0 8px; font-size: 13px; line-height: 1.4; }
.board-kind-quote .board-card-body > button:not(.board-card-head):not(.board-card-options) { flex: none; align-self: flex-start; }
.board-kind-group .board-card-head { max-height: 56px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.board-scroll { overscroll-behavior: contain; touch-action: pan-y; }
.board-scroll:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.board-tasks { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.board-tasks:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.board-task { display: flex; align-items: flex-start; min-height: 44px; gap: 4px; }
.board-task .board-check { flex: 1; min-width: 0; min-height: 44px; margin: 0; align-items: flex-start; }
.board-task .board-check input { margin-top: 14px; }
.board-task-text { display: flex; flex-direction: column; flex: 1; min-width: 0; padding: 12px 0; line-height: 1.4; }
.board-task-text > * { white-space: pre-wrap; overflow-wrap: anywhere; }
.board-task-text small { font-size: 11px; color: var(--muted); }
.board-assign { width: 40px; height: 44px; flex: none; padding: 8px; border: 0; background: transparent; }
.board-assign svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

/* Dialogs keep their actions visible; only the middle list scrolls. */
.board-checklist-editor[open], .board-assignees[open] {
  display: flex; flex-direction: column; overflow: hidden;
  box-sizing: border-box; max-height: min(760px, calc(var(--visible-height, 100dvh) - 32px));
}
.board-checklist-editor { width: min(588px, calc(100% - 32px)); height: min(680px, calc(var(--visible-height, 100dvh) - 32px)); }
.board-checklist-editor > *, .board-assignees > * { flex-shrink: 0; }
.board-checklist-editor h2, .board-assignees h2 { margin: 0 0 20px; }
.board-people, .board-task-editor-list {
  overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable;
  min-height: 0; padding: 6px 8px; box-sizing: border-box;
}
.board-checklist-editor .board-task-editor-list { flex: 1 1 auto; }
.board-assignees .board-people { flex: 1 1 auto; max-height: 40dvh; }
.board-person { margin: 0; display: flex; gap: 12px; align-items: center; min-height: 44px; padding: 4px 6px; box-sizing: border-box; border-radius: 6px; }
.board-person:hover { background: var(--hover); }
.board-person span { min-width: 0; overflow-wrap: anywhere; }
.board-person[hidden], .board-checklist-editor [hidden] { display: none; }
.board-editor input[type='checkbox'] { width: 18px; height: 18px; flex: none; margin: 0; padding: 0; }
.board-editor input[type='checkbox']:focus:not(:focus-visible) { outline: none; }
.board-editor-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.board-editor-actions button { margin: 0; }
.board-checklist-editor .board-editor-actions { border-top: 1px solid var(--line); padding-top: 12px; }
.board-error:empty { display: none; }
.board-task-caption { overflow-wrap: anywhere; max-height: 3.5em; overflow: auto; }
.board-task-section { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.board-task-section button { margin: 0; background: transparent; border-color: transparent; }
.board-task-editor { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; }
.board-task-editor-line { display: flex; align-items: flex-start; padding-left: 12px; gap: 12px; }
.board-task-editor-line input[type='checkbox'] { margin-top: 13px; }
.board-task-editor .board-task-toggle {
  flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 8px;
  margin: 0; padding: 12px 10px 12px 0; border: 0; background: transparent; border-radius: 6px;
  text-align: left; color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.4;
}
.board-task-toggle:focus-visible { outline-offset: -2px; }
.board-task-summary-content { flex: 1; min-width: 0; }
.board-task-caption-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.board-task-summary { display: block; font-size: 11px; font-weight: 400; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; margin-top: 2px; }
.board-task-chevron { flex: none; color: var(--muted); font-size: 16px; }
.board-task-details { padding: 0 12px 8px; }
.board-checklist-editor .board-task-details textarea { min-height: 64px; max-height: 160px; height: 64px; margin: 0 0 12px; resize: vertical; font: inherit; font-size: 14px; line-height: 1.45; }
.board-task-meta { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
.board-task-field { margin: 0; display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 11px; color: var(--muted); }
.board-task-field .board-task-assign, .board-task-field input {
  width: 100%; min-width: 0; margin: 0; min-height: 36px; padding: 7px 10px;
  color: var(--text); font: inherit; font-size: 13px; background: transparent; border: 1px solid var(--line); border-radius: 6px;
}
.board-task-field .board-task-assign { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.board-task-editor .board-task-remove { display: block; margin: 8px 0 0 auto; font-size: 12px; border: 0; color: var(--muted); background: transparent; }
.board-subtask-editor { margin-left: 16px; border: 0; border-left: 1px solid var(--line); border-radius: 0; }
.board-subtask-editor .board-task-toggle { font-weight: 400; }
.board-task-editor .board-add-subtask { margin: 0 12px 8px; border: 0; background: transparent; }
.board-subtask { margin-left: 18px; border-left: 1px solid var(--line); padding-left: 6px; }
.board-task-text .board-overdue { color: var(--danger, #ed9696); }
.board-tasks { padding: 0 6px 24px; box-sizing: border-box; }
/* Prefer standard colors. Gecko can parse WebKit selectors without painting their colors. */
.board-panel * { scrollbar-width: thin; scrollbar-color: #747980 var(--surface-soft); }
@supports not (scrollbar-color: #747980 #2b2d30) {
  .board-panel *::-webkit-scrollbar { width: 10px; height: 10px; background: var(--surface-soft); }
  .board-panel *::-webkit-scrollbar-track,
  .board-panel *::-webkit-scrollbar-track-piece,
  .board-panel *::-webkit-scrollbar-corner { background: var(--surface-soft); }
  .board-panel *::-webkit-scrollbar-thumb { background: #747980; background-clip: padding-box; border: 2px solid transparent; border-radius: 6px; }
  .board-panel *::-webkit-scrollbar-thumb:hover { background-color: #93989f; }
  .board-panel *::-webkit-scrollbar-thumb:active { background-color: #a2a6ac; }
  .board-panel *::-webkit-scrollbar-button { display: none; }
}
@media (max-width: 480px) {
  .board-task-meta { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .board-checklist-editor[open], .board-assignees[open] { padding: 16px; }
}
@media (pointer: coarse) {
  .board-resize { width: 44px; height: 44px; }
  .board-task-field .board-task-assign, .board-task-field input, .board-task-section button,
  .board-add-subtask, .board-task-remove { min-height: 44px; }
}
