.board-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.board-header {
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 20px 0; background: var(--surface); border-bottom: 1px solid var(--border);
}

.board-header__title {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 32px; /* the star button's height, so tabs without it don't shift */
  h1 { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.star {
  &[aria-pressed="true"] { color: var(--brand); .icon { fill: currentColor; } }
}

.board-tabs { display: flex; align-items: center; gap: 4px; }
.board-tabs__list { display: flex; gap: 4px; min-width: 0; overflow-x: auto; }
.board-tabs__add {
  position: relative; flex: none;
  &[open] summary { background: var(--surface-2); color: var(--text); }
}
.board-tabs__form { left: 0; display: flex; gap: 6px; width: 300px; padding: 8px; }
.board-tabs__tab {
  padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--text-2); white-space: nowrap;
  &:hover { color: var(--text); }
  &[aria-current="page"] { color: var(--text); font-weight: 500; border-color: var(--brand); }
}

.toolbar {
  display: flex; align-items: center; gap: 8px; flex: none; padding: 8px 20px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
  .input { height: 32px; }
}
.toolbar__search { width: 220px; flex: none; }
.toolbar__select { width: auto; flex: none; }
.toolbar__filter {
  position: relative; display: flex; flex: none;
  &.is-active .input { padding-right: 30px; border-color: var(--accent); background-color: var(--accent-soft); }
  &.is-active :is(select, .choice__toggle) { background-image: none; }
  &.is-active input::-webkit-search-cancel-button { display: none; }
}
.toolbar__reset {
  position: absolute; top: 50%; right: 4px; translate: 0 -50%; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 6px; color: var(--text-muted);
  &:hover { color: var(--text); background: var(--surface-2); }
  .icon { width: 14px; height: 14px; }
}
.choice { position: relative; display: flex; }
.choice__toggle { display: flex; align-items: center; gap: 6px; max-width: 260px; white-space: nowrap; > :last-child { overflow: hidden; text-overflow: ellipsis; } }
.choice[open] .choice__toggle { border-color: var(--accent); }
.choice__menu { min-width: 180px; max-width: min(360px, calc(100vw - 32px)); max-height: 320px; overflow-y: auto; padding: 4px; }
.choice__option {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; cursor: pointer;
  input { position: absolute; opacity: 0; pointer-events: none; }
  &:hover, &:has(input:focus-visible) { background: var(--surface-2); }
  &:has(input:checked) { font-weight: 500; color: var(--brand-strong); }
  > span:last-child { overflow: hidden; text-overflow: ellipsis; }
}
.choice .card__kind {
  --kind: var(--success);
  &[data-kind="bug"] { --kind: var(--danger); }
  &[data-kind="feature"] { --kind: var(--accent); }
}
.toolbar__clear { flex: none; font-size: 13px; color: var(--brand-strong); }
.toolbar__spacer { flex: 1; }

.board-layout { display: flex; flex: 1; min-height: 0; }
.panel-frame { width: clamp(var(--panel-min), var(--panel-w), var(--panel-max)); }

.board {
  display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0;
  padding: 16px 20px; overflow: auto;
}

.column {
  display: flex; flex-direction: column; flex: none;
  width: var(--column-w); max-height: 100%;
  border-radius: var(--radius-lg); background: var(--column);

  --dot: var(--text-muted);
  &[data-category="in_progress"] { --dot: var(--accent); }
  &[data-category="done"] { --dot: var(--success); }
}

.column__header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.column__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.column__name { flex: 1; font-size: 13px; font-weight: 500; }
.column__count { font-size: 12px; color: var(--text-muted); &.is-over { color: var(--brand-strong); font-weight: 700; } }
.column__cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; padding: 0 8px 8px; overflow-y: auto; }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: box-shadow 0.15s, translate 0.15s;

  &[data-kind="bug"] { --kind: var(--danger); }
  &[data-kind="feature"] { --kind: var(--accent); }
  &[data-kind="task"] { --kind: var(--success); }
  &:hover { box-shadow: var(--shadow); translate: 0 -1px; }
}

.card__cover { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; background: var(--surface-2); }

li.is-dragging { opacity: 0.4; }

.column__cards > li { position: relative; }
li:has(> .card-menu) .card__top { padding-right: 22px; }
.card-menu { position: absolute; top: 6px; right: 6px; }
li:has(> .card__cover) .card-menu { top: 6px; }
.card-menu__toggle {
  width: 26px; height: 26px; list-style: none; background: var(--surface); opacity: 0; transition: opacity 0.15s;
  &::-webkit-details-marker { display: none; }
  .icon { width: 18px; height: 18px; stroke-width: 3.5; }
}
li:hover .card-menu__toggle, .card-menu[open] .card-menu__toggle, .card-menu__toggle:focus-visible { opacity: 1; }
.card-menu[open] .card-menu__toggle { background: var(--surface-2); }
@media (hover: none) { .card-menu__toggle { opacity: 1; } }

.card-menu__panel { z-index: 30; width: 220px; padding: 4px; overflow-y: auto; }
.card-menu__label { padding: 8px 8px 4px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.card-menu__rule { margin: 4px 0; border: 0; border-top: 1px solid var(--border); }
.card-menu__item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px;
  font: inherit; font-size: 13px; text-align: left; color: var(--text); background: none; cursor: pointer;
  &:hover:not(:disabled) { background: var(--surface-2); }
  &:disabled { cursor: default; font-weight: 500; }
  .icon { width: 16px; height: 16px; color: var(--text-muted); }
  .icon:last-child:not(:first-child) { margin-left: auto; color: var(--accent); }
  .column__dot { --dot: var(--text-muted); }
  .column__dot[data-category="in_progress"] { --dot: var(--accent); }
  .column__dot[data-category="done"] { --dot: var(--success); }
}
.card-menu__sub > summary { list-style: none; &::-webkit-details-marker { display: none; } }
.card-menu__sub[open] > summary { font-weight: 500; }
.card-menu__item--nested { padding-left: 32px; }
.card-menu__item--danger { color: var(--danger); .icon { color: currentColor; } }
.card-menu__done { margin-left: auto; font-size: 12px; color: var(--success); }
.card-menu__row { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 8px 6px; }
.card-menu__chip {
  padding: 3px 8px; border: 1px solid var(--border-strong); border-radius: 999px; background: none; font: inherit; font-size: 12px; cursor: pointer;
  &:hover:not(:disabled) { background: var(--surface-2); }
  &:disabled { cursor: default; border-color: currentColor; background: var(--surface-2); }
}

.card__body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; }
.card .label { padding: 0 6px; font-size: 10px; font-weight: 500; line-height: 14px; }
.card .parent-chip + .labels { margin-top: -2px; }
.card__kind { display: inline-flex; color: var(--kind); .icon { width: 14px; height: 14px; } }
.card__meta .meta.is-done { color: var(--success); }

.card__top, .card__meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__top .key { flex: 1; }
.card__meta .priority { margin-left: auto; }
.card__meta .priority + .avatars { margin-left: 0; }
.card__title { font-weight: 500; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 599px) {
  .board-header { padding: 12px 16px 0; }
  .toolbar { padding: 8px 16px; }
  .board { gap: 8px; padding: 12px 16px; scroll-snap-type: x mandatory; scroll-padding: 16px; }
  .column { width: calc(100vw - 48px); scroll-snap-align: start; }
}

.composer { padding: 0 8px 8px; }
.composer__toggle {
  padding: 8px; border-radius: var(--radius); color: var(--text-muted);
  &:hover { color: var(--text); background: var(--surface); }
}
.composer[open] .composer__toggle { display: none; }
.composer__form { display: flex; flex-direction: column; gap: 8px; }
.composer__form textarea { height: auto; min-height: 60px; padding: 10px 12px; resize: none; field-sizing: content; font-weight: 500; }
.composer__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; .hint { margin-left: auto; } }
.composer__phase { width: auto; max-width: 100%; height: 30px; padding: 0 28px 0 8px; font-size: 12px; }

.board-tabs__divider { flex: none; align-self: center; width: 1px; height: 18px; margin: 0 4px; background: var(--border-strong); }

.gantt-page { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; padding: 16px 20px; overflow: auto; }
.gantt {
  /* flex: none: keep the chart's full height so .gantt-page scrolls labels and bars together (it shrank and clipped) */
  display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); flex: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.gantt__labels { display: flex; flex-direction: column; border-right: 1px solid var(--border); font-size: 13px; }
.gantt__labels-head { height: var(--gantt-header); border-bottom: 1px solid var(--border); }
.gantt__label {
  display: flex; align-items: center; gap: 6px; height: var(--gantt-row); padding: 0 12px; min-width: 0;
  a { display: flex; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; &:hover { color: var(--brand-strong); } }
  &.is-done a { color: var(--text-muted); text-decoration: line-through; }
}
.gantt__label--phase { font-weight: 600; background: var(--surface-2); }
.gantt__scroll { position: relative; overflow-x: auto; overflow-y: hidden; } /* horizontal only: a vertical scroll here moved bars away from their labels */
.gantt__tip {
  position: absolute; padding: 3px 8px; border-radius: var(--radius); font-size: 12px; white-space: nowrap; pointer-events: none;
  background: var(--text); color: var(--surface); box-shadow: var(--shadow);
}
.gantt__chart { display: block; font-size: 11px; }
.gantt__row { fill: transparent; &:nth-of-type(even) { fill: color-mix(in srgb, var(--surface-2) 50%, transparent); } }
.gantt__row--phase { fill: var(--surface-2); }
.gantt__grid { stroke: var(--border); }
.gantt__week { fill: var(--text-muted); }
.gantt__month { fill: var(--text-2); font-weight: 500; font-size: 12px; }
.gantt__phase { opacity: 0.55; }
.gantt__bar {
  fill: var(--text-muted);
  &.is-done { opacity: 0.4; }
  &.is-overdue { stroke: var(--danger); stroke-width: 2; }
  &:hover { filter: brightness(1.1); }
  &.is-editable { touch-action: none; }
}
.gantt__note { fill: var(--text-muted); font-style: italic; &.is-warning { fill: var(--warning); font-style: normal; } }
.gantt__today { stroke: var(--brand); stroke-width: 2; stroke-dasharray: 4 3; }

.view-toggle { display: inline-flex; flex: none; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.view-toggle__option {
  display: grid; place-items: center; width: 28px; height: 26px; border: 0; border-radius: 6px; color: var(--text-muted); background: none; cursor: pointer;
  .icon { width: 16px; height: 16px; }
  &:hover { color: var(--text); }
  &[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }
}

.board-table { display: none; flex: 1; min-width: 0; padding: 16px 20px; overflow: auto; }
html[data-board-view="table"] {
  .board { display: none; }
  .board-table { display: block; }
}
.board-table {
  .table { border-radius: var(--radius-lg); }
  td { padding-block: 8px; }
  .key { white-space: nowrap; }
  .table__title { display: inline-block; max-width: 48ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  .card__kind[data-kind="bug"] { --kind: var(--danger); }
  .card__kind[data-kind="feature"] { --kind: var(--accent); }
  .card__kind[data-kind="task"] { --kind: var(--success); }
  tbody { --dot: var(--text-muted); }
  tbody[data-category="in_progress"] { --dot: var(--accent); }
  tbody[data-category="done"] { --dot: var(--success); }
}
.board-table .board-table__group th {
  font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); background: var(--column);
  .column__dot { display: inline-block; margin-right: 8px; }
  .count { margin-left: 4px; font-weight: 400; color: var(--text-muted); }
}
.board-table tbody:not(:first-of-type) .board-table__group th { border-top: 1px solid var(--border); }
