@layer components {
  .lane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 7rem;
    max-height: calc(100vh - 11rem);
    max-height: calc(100dvh - 11rem);
    border-radius: var(--r-3);
    background: var(--surface);
    box-shadow: var(--ring);
    transition: box-shadow var(--dur-2) var(--ease);
  }

  .lane-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
    border-radius: var(--r-3) var(--r-3) 0 0;
    background: var(--surface);
  }

  .lane-rest {
    list-style: none;
  }

  .lane-more {
    padding: var(--space-2) var(--space-3);
    color: var(--muted);
    font-size: var(--text-xs);
    cursor: pointer;
  }

  .lane-more::marker {
    content: "";
  }

  .lane-items--rest > .board-item:first-child {
    border-top: 1px solid var(--border);
  }

  .lane-dot {
    flex-shrink: 0;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: var(--r-full);
    background: var(--lane-accent, var(--border-strong));
  }

  .area-shared-badge {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--lane-accent, var(--text-muted));
    background: color-mix(in srgb, var(--lane-accent, var(--muted)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--lane-accent, var(--muted)) 35%, transparent);
    border-radius: var(--r-full);
    padding: 0.1rem 0.45rem;
    cursor: help;
  }

  .area-progress {
    flex-shrink: 0;
    margin-left: auto;
    color: var(--muted);
    font-size: var(--text-xs);
  }

  .area-progress-slot {
    flex-shrink: 0;
  }

  .chip--member {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
  }

  .chip--today {
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

  .proof-note {
    margin: var(--space-2) 0;
    padding: var(--space-2);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-1);
    background: var(--inset);
    color: var(--ink-2);
    font-size: var(--text-sm);
  }

  @media (hover: none) {
    .area-shared-badge {
      /* Tap shows the native tooltip on touch; nothing else to wire. */
      cursor: pointer;
    }
  }

  .lane:hover {
    box-shadow: var(--ring-strong), var(--shadow-1);
  }

  .lane-title.inline-input {
    flex: 1;
    min-width: 0;
    font-family: var(--font-display);
    word-spacing: var(--display-word-space);
    font-size: 1.0625rem;
    font-weight: 620;
    letter-spacing: -0.015em;
  }

  .lane-title-form {
    flex: 1;
    min-width: 0;
  }

  .worklog-lane--today .lane-head {
    flex-wrap: wrap;
    row-gap: var(--space-1);
  }

  .worklog-lane--today .lane-title-form {
    flex: 1 1 6rem;
    min-width: 6rem;
  }

  .lane-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }

  .lane-date {
    flex-shrink: 0;
    color: var(--muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }

  .lane-suggestions > summary {
    padding: var(--space-1) var(--space-3);
    color: var(--muted);
    font-size: var(--text-xs);
    cursor: pointer;
  }

  .lane-empty {
    padding: var(--space-2) var(--space-3) var(--space-3);
    color: var(--muted);
    font-size: var(--text-xs);
  }

  /* Rendered in every lane so a drag or a stream that empties one shows it without a repaint */
  .worklog-lane:has(.worklog-entry, .task-record) .lane-empty {
    display: none;
  }

  .lane-items {
    padding: var(--space-1) var(--space-2);
  }

  .lane-items > .board-item + .board-item,
  .worklog-lane-items > .board-item + .board-item {
    border-top: 1px solid var(--border);
  }

  .board-item {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    row-gap: 0;
    min-height: 1.9rem;
    padding: 0 var(--space-1) 0 var(--space-2);
    border-radius: var(--r-2);
    scroll-margin: var(--space-4);
  }

  /* Where a pulled task landed. Green, so it never reads as the blue mark
     for the row the keyboard is on. */
  .board-item.is-landed {
    animation: landed-glow 2.4s var(--ease);
  }

  @keyframes landed-glow {
    0% {
      background: color-mix(in srgb, var(--success) 26%, var(--surface));
      box-shadow: inset 4px 0 0 var(--success), 0 0 0 2px color-mix(in srgb, var(--success) 40%, transparent);
    }
    55% {
      background: color-mix(in srgb, var(--success) 14%, var(--surface));
      box-shadow: inset 4px 0 0 var(--success), 0 0 0 0 transparent;
    }
    100% {
      background: transparent;
      box-shadow: inset 0 0 0 0 transparent;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .board-item.is-landed {
      animation: none;
      background: var(--success-soft);
      box-shadow: inset 4px 0 0 var(--success);
    }
  }

  .board-item:hover,
  .board-item:focus,
  .board-item:focus-within {
    background: var(--inset);
  }

  .item-check:disabled {
    opacity: 0.45;
    cursor: default;
  }

  .board-item:focus {
    outline: none;
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  }

  .lane:focus {
    outline: none;
    box-shadow: var(--ring), 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
  }

  .board-item-body {
    display: flex;
    align-items: center;
    flex: 1 1 40%;
    min-width: 0;
    padding: var(--space-1) 0;
    color: var(--ink);
    cursor: text;
  }

  .board-item-form {
    display: flex;
    flex: 1 1 40%;
    min-width: 0;
    padding: var(--space-1) 0;
  }

  .board-item-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-sm);
  }

  #archived-areas,
  #archived-tasks {
    margin-bottom: var(--space-5);
  }

  #archived-areas .page-section-title,
  #archived-tasks .page-section-title {
    margin-bottom: var(--space-2);
  }

  .board-item.board-item--archived {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    color: var(--muted);
    font-size: var(--text-sm);
  }

  .board-item.board-item--archived .board-item-open {
    flex: 1;
    min-width: 0;
    color: var(--ink-2);
    text-decoration: none;
  }

  .board-item.board-item--archived .board-item-open:hover .board-item-title {
    text-decoration: underline;
  }

  .board-item-archived-meta {
    flex-shrink: 0;
    color: var(--muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }

  .board-item-chips {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: var(--space-1);
    flex-shrink: 1;
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
  }

  .board-item-chips > * {
    flex-shrink: 0;
  }

  .chip--area {
    max-width: 5.5rem;
    overflow: hidden;
    white-space: nowrap;
  }

  /* A row is one line: the title truncates, then the chips give way. */
  :is(.lane-items, .worklog-lane-items) > .board-item {
    flex-wrap: nowrap;
  }

  :is(.lane-items, .worklog-lane-items) > .board-item .board-item-body {
    flex: 1 1 0;
    min-width: 3rem;
  }

  .worklog-entry .board-item-title {
    white-space: nowrap;
  }

  .worklog-entry-meta {
    white-space: nowrap;
  }

  .board-item-actions {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-1);
    margin-left: auto;
  }

  .task-menu .menu-trigger {
    opacity: 1;
  }

  .task-menu-panel {
    max-height: calc(100dvh - 1rem);
    max-width: calc(100vw - 1rem);
    overflow-y: auto;
  }

  .task-menu-panel > form + form {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .task-menu-action {
    display: block;
    width: 100%;
    padding: var(--space-2);
    border: 0;
    border-radius: var(--r-2);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
  }

  .task-menu-action:hover,
  .task-menu-action:focus-visible {
    background: var(--inset);
  }

  .task-menu-destructive {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border);
  }

  /* .board-remove (the small inline delete) would otherwise win on padding,
     size and colour; Delete in the menu is a full-width row, red like the
     other destructive actions. */
  .task-menu-panel .task-menu-delete {
    padding: var(--space-2);
    color: var(--danger);
    font-size: var(--text-sm);
    line-height: inherit;
  }

  .task-menu-panel .task-menu-delete:hover,
  .task-menu-panel .task-menu-delete:focus-visible {
    background: var(--danger-soft);
    color: var(--danger);
  }

  .task-menu-panel .task-schedule { display: block; }

  .board-item-actions form {
    display: contents;
  }

  .chip {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    height: 1.15rem;
    padding: 0 var(--space-1);
    border-radius: var(--r-1);
    background: var(--inset);
    color: var(--ink-2);
    font-size: 0.6875rem;
    line-height: 1;
    white-space: nowrap;
  }

  .chip-icon {
    width: 0.7rem;
    height: 0.7rem;
    margin-right: 0.15rem;
  }

  .chip--urgent,
  .chip--review,
  .chip--settled,
  .chip--live {
    background: color-mix(in srgb, var(--chip-hue) 14%, var(--surface));
    color: color-mix(in srgb, var(--chip-hue) 70%, var(--ink));
  }

  .chip--urgent { --chip-hue: var(--danger); }
  .chip--review { --chip-hue: var(--info); }
  .chip--settled { --chip-hue: var(--success); }
  .chip--live { --chip-hue: var(--accent); }

  .chip--area {
    color: var(--muted);
  }

  .chip--area::before {
    content: "";
    flex-shrink: 0;
    width: 0.3rem;
    height: 0.3rem;
    margin-right: 0.3rem;
    border-radius: var(--r-full);
    background: var(--lane-accent, var(--border-strong));
  }

  .chip--repeat {
    color: var(--muted);
  }

  .drag-handle {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 0.65rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--border-strong);
    font-size: 0.6rem;
    letter-spacing: -0.05em;
    line-height: 1;
    cursor: grab;
    opacity: 0;
    transition: opacity var(--dur-1) var(--ease);
  }

  .lane-head:hover .menu-trigger,
  .menu[open] .menu-trigger,
  .menu-trigger:focus-visible {
    opacity: 1;
  }

  .board-item:hover .drag-handle,
  .list-item:hover .drag-handle,
  .lane-head:hover .drag-handle,
  .drag-handle:focus-visible {
    opacity: 1;
  }

  .inline-input {
    width: 100%;
    padding: var(--space-1) var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--r-2);
    background: transparent;
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 580;
  }

  .inline-input:hover {
    border-color: var(--border);
  }

  .inline-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-raised);
  }

  .menu {
    position: relative;
    flex-shrink: 0;
  }

  .menu-trigger {
    opacity: 0;
    transition: opacity var(--dur-1) var(--ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--r-2);
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: 1;
    list-style: none;
  }
}
