/* Enabled only for smartphone/tablet touch mode by display-mode.js. */
.touch-drag-pending {
  outline: 2px solid var(--drag-accent);
  outline-offset: 2px;
}
.touch-drag-message {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  width: max-content;
  padding: 12px 16px;
  overflow: hidden;
  border: 1px solid var(--drag-accent);
  border-radius: 12px;
  background: var(--surface, var(--canvas));
  box-shadow: 0 6px 24px #00000035;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}
.touch-drag-message.is-holding::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--drag-accent);
  animation: touch-hold-progress 340ms linear forwards;
}
@keyframes touch-hold-progress {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}
.touch-dragging,
.ticket[draggable="true"],
.lane-header:has(.column-grip) {
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.touch-drag-hint {
  display: none;
}
.touch-help-short {
  display: none;
}
@media (any-pointer: coarse) {
  .touch-drag-hint {
    display: block;
    flex-shrink: 0;
    margin: 0;
    padding: 0 18px 8px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .touch-drag-message.is-holding::after {
    width: 100%;
  }
}

/* Small screens keep board scrolling inside the workspace, not on the page. */
@media (max-width: 1024px) {
  .sidebar,
  .sidebar-toggle {
    display: none;
  }
  .board-heading h1 {
    max-width: none;
  }
  .board-heading {
    flex: 1;
    overflow: hidden;
  }
  .board-menu {
    top: 70px;
    right: 12px;
    max-height: calc(100% - 82px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .ticket-layout {
    grid-template-columns: minmax(0, 1fr) minmax(190px, 230px);
    gap: 18px;
  }
  .ticket-main-fields,
  .ticket-side-fields,
  .ticket-lower > * {
    min-width: 0;
  }
  .ticket-context .ticket-number {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .board-subheader,
  .board-header-actions {
    min-width: 0;
  }
  .board-search {
    min-width: 80px;
  }
  .board-search input {
    min-width: 0;
    width: 100%;
  }
}

@media (any-pointer: coarse) {
  /* Sixteen-pixel fields avoid focus zoom on phones. Touch never disables
     native panning; the drag gesture takes over only after a stationary hold. */
  :root
    :is(
      input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
      select,
      textarea
    ) {
    font-size: 16px;
  }
  :root
    :is(
      .button,
      .icon-button,
      .board-button,
      .board-back,
      .add-card,
      .add-list,
      .column-grip,
      .sidebar-toggle,
      .account-button,
      .sidebar-board,
      .nav-item
    ) {
    min-height: 44px;
    min-width: 44px;
  }
  .lane-header .icon-button {
    padding: 10px;
  }
  .lane-header {
    padding: 7px 8px;
  }
  .lane-header h2 {
    font-size: 14px;
  }
  .ticket h3 {
    font-size: 14px;
    line-height: 1.5;
  }
  .ticket {
    padding: 14px;
  }
  .lane {
    flex-basis: 300px;
    width: 300px;
  }
  .lanes {
    overscroll-behavior: contain;
  }
  .lane-cards {
    overscroll-behavior-y: contain;
  }
  .version-badge {
    min-height: 28px;
  }
  .board-bottom,
  .version-footer {
    padding-top: 2px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 760px) {
  .ticket-layout,
  .public-ticket .ticket-lower {
    grid-template-columns: minmax(0, 1fr);
  }
  .ticket-side-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ticket-side-fields .ticket-parent,
  .creator-info {
    grid-column: 1 / -1;
  }
  .board-filter-controls {
    flex: 1 1 auto;
  }
  .board-menu > .button {
    flex-shrink: 0;
  }
  .modal {
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }
  .modal-header {
    padding: 12px 16px;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-header h2 {
    font-size: 18px;
  }
  .form-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 600px) {
  .board-header {
    padding: 10px 12px;
    min-height: 64px;
    gap: 8px;
  }
  .board-heading h1 {
    font-size: 18px;
  }
  .board-header-actions {
    flex-shrink: 0;
    gap: 6px;
  }
  .board-header-actions
    > :is([data-action="labels"], [data-action="board-settings"]) {
    display: none;
  }
  .board-subheader {
    padding: 0 12px 8px;
    gap: 8px;
  }
  .board-subheader > span {
    flex: 1 1 100%;
  }
  .board-filter-controls {
    width: 100%;
    margin-left: 0;
    gap: 5px;
  }
  .board-filter-controls .board-search {
    flex: 1;
    min-width: 80px;
    padding: 6px;
  }
  .board-filter-button {
    flex-shrink: 0;
  }
  .lanes {
    padding-left: 12px;
    padding-right: 12px;
    gap: 12px;
  }
  .lane {
    flex-basis: min(320px, calc(100vw - 44px));
    width: min(320px, calc(100vw - 44px));
  }
  .touch-drag-hint {
    padding-left: 12px;
    padding-right: 12px;
    font-size: 10px;
  }
  .public-shell .topbar {
    flex-wrap: nowrap;
    padding: 0 12px;
    gap: 10px;
  }
  .public-shell .topbar .public-readonly {
    display: none;
  }
  .public-shell .board-header {
    align-items: center;
  }
  .public-shell .board-heading {
    flex-wrap: nowrap;
  }
  .public-shell .board-heading .role-badge {
    display: none;
  }
  .public-shell .public-filter {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 359px) {
  .ticket-side-fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .topbar {
    gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }
  .topbar .brand {
    gap: 6px;
  }
}

/* Landscape phones need vertical room for cards as well as horizontal room. */
@media (max-height: 600px) and (max-width: 1366px) and (any-pointer: coarse) {
  .sidebar,
  .sidebar-toggle,
  .workspace-name,
  .topbar-divider,
  .quiet-badge {
    display: none;
  }
  .topbar {
    height: 48px;
    padding: 0 12px;
  }
  .board-header,
  .board-header:has(.trello-update-action) {
    min-height: 52px;
    padding: 4px 12px;
    flex-wrap: nowrap;
  }
  .board-header:has(.trello-update-action) .board-heading {
    flex-basis: auto;
  }
  .board-header-actions {
    gap: 5px;
  }
  .board-header-actions
    > :is([data-action="labels"], [data-action="board-settings"]) {
    display: none;
  }
  .board-subheader {
    padding: 0 12px 4px;
    flex-wrap: nowrap;
  }
  .board-subheader > span {
    flex: 0 1 auto;
    white-space: nowrap;
  }
  .public-shell .board-subheader {
    flex-wrap: nowrap;
  }
  .public-shell .public-filter {
    flex: 1;
    width: auto;
    min-width: 0;
    min-height: 40px;
  }
  .board-filter-controls {
    flex-wrap: nowrap;
    width: auto;
    margin-left: auto;
  }
  .touch-drag-hint {
    padding: 0 12px 4px;
    font-size: 10px;
  }
  .lanes {
    padding: 0 12px 8px;
  }
  .board-menu {
    top: 54px;
    max-height: calc(100% - 62px);
  }
  .auth-art {
    display: none;
  }
  .auth-page {
    display: block;
    overflow-y: auto;
  }
  .auth-form-area {
    padding: 24px;
  }
  .modal {
    max-height: calc(100dvh - 12px);
  }
}

@media (max-height: 400px) and (max-width: 1366px) and (any-pointer: coarse) {
  .touch-drag-hint {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    left: 12px;
    max-width: calc((100% - 210px) / 2);
    padding: 0;
    font-size: 9px;
    white-space: nowrap;
  }
  .touch-help-full,
  .board-bottom > span {
    display: none;
  }
  .touch-help-short {
    display: inline;
  }
  .board-bottom {
    grid-template-columns: 1fr;
  }
  .lane {
    position: relative;
  }
  .lane-header {
    min-height: 46px;
    padding: 0 6px;
    gap: 4px;
  }
  .lane:has(> .add-card) .lane-header h2 {
    padding-right: 44px;
  }
  .lane-header .lane-count {
    display: none;
  }
  .lane > .add-card {
    position: absolute;
    top: 0;
    right: 54px;
    width: 44px;
    padding: 12px;
    gap: 0;
    font-size: 0;
    border-radius: 6px;
  }
  .lane-cards {
    padding-bottom: 8px;
  }
  .ticket {
    padding: 10px;
  }
  .ticket h3 {
    font-size: 13px;
    margin-bottom: 4px;
  }
  .lane:has(> .add-card-form:not([hidden])) {
    max-height: none;
  }
  .lane:has(> .add-card-form:not([hidden])) > .lane-cards {
    display: none;
  }
  .lane > .add-card-form {
    flex-shrink: 0;
  }
}
