/* PrimaLux mobile layout
   Loaded after the desktop visual system so small screens have one predictable
   navigation pattern, touch-sized controls and readable working surfaces. */

@media (max-width: 900px) {
  .workspace-sidebar { width: 214px; padding-left: 14px; padding-right: 14px; }
  .main-content { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 760px) {
  :root { --mobile-nav-height: 68px; }

  html, body { max-width: 100%; overflow-x: hidden; }
  body { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); }
  button, [role="button"], input, select, textarea { touch-action: manipulation; }

  /* The desktop sidebar becomes a compact mobile masthead. Project and smart
     views remain reachable as horizontal rows; primary navigation stays under
     the thumb at the bottom of the screen. */
  .app-shell { display: block; min-height: 100dvh; }
  .workspace-sidebar {
    position: relative;
    display: block;
    width: 100%;
    padding: 9px 12px 10px;
    border-right: 0;
    border-bottom: 1px solid #dfe5ee;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 5px 18px rgba(29, 42, 66, .06);
  }
  .workspace-brand {
    min-height: 39px;
    margin: 0 2px 7px;
  }
  .workspace-brand img { width: 126px; max-height: 38px; }
  .workspace-brand span { display: inline; font-size: 12px; }
  .workspace-nav {
    position: fixed;
    z-index: 18;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    margin: 0;
    padding: 6px max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
    border-top: 1px solid #dfe5ee;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -8px 24px rgba(29, 42, 66, .10);
    backdrop-filter: blur(12px);
  }
  .workspace-nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    padding: 5px 4px 4px;
    border-radius: 9px;
    font-size: 12px;
  }
  .workspace-nav-icon { font-size: 20px; }
  .workspace-project-icon { width: 19px; height: 19px; }
  .workspace-notification-icon { width: 21px; height: 21px; }
  .workspace-nav-badge { top: 2px; right: calc(50% - 27px); }

  .workspace-sidebar > .sidebar-section {
    min-width: 0;
    margin: 7px 0 0;
  }
  .workspace-sidebar .section-label { display: none; }
  .workspace-sidebar .projects-section {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .workspace-sidebar .new-project-btn {
    flex: 0 0 auto;
    width: auto;
    min-height: 38px;
    margin: 0;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: none;
  }
  .workspace-sidebar .new-project-btn span { font-size: 16px; }
  #projectList {
    display: flex;
    min-width: 0;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  #projectList::-webkit-scrollbar { display: none; }
  #projectList .project-item {
    flex: 0 0 auto;
    width: auto;
    max-width: 190px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #e1e6ee;
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
  }
  #projectList .project-item.active { border-color: #c8d8ee; background: #edf3fb; }
  #projectList .project-count { margin-left: 7px; }
  .workspace-sidebar > .sidebar-section:not(.projects-section) {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  .workspace-sidebar > .sidebar-section:not(.projects-section)::-webkit-scrollbar { display: none; }
  .workspace-sidebar .sidebar-link {
    flex: 0 0 auto;
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid #e4e8ef;
    border-radius: 8px;
    background: #f9fafc;
    font-size: 13px;
  }
  .workspace-sidebar .sidebar-link .link-count { margin-left: 4px; }
  .workspace-sidebar .sidebar-footer { display: none; }

  /* Compact project context without sacrificing readable type. */
  .main-content {
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 0 12px 22px;
    overflow: visible;
  }
  .topbar {
    position: sticky;
    z-index: 16;
    top: 0;
    height: 56px;
    margin: 0 -12px;
    padding: 0 12px;
    background: rgba(245, 247, 251, .96);
    backdrop-filter: blur(12px);
  }
  .breadcrumbs { min-width: 0; gap: 7px; }
  .breadcrumbs > span:first-child, .breadcrumbs .crumb-separator { display: none; }
  .breadcrumbs strong {
    min-width: 0;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .status-pill { flex: 0 0 auto; padding: 5px 8px; font-size: 11px; }
  .top-actions { flex: 0 0 auto; gap: 4px; }
  .account-menu-trigger { max-width: 38vw; min-height: 42px; }

  .project-heading {
    align-items: stretch;
    gap: 14px;
    padding: 18px 1px 15px;
  }
  .project-heading h1 { font-size: 24px; line-height: 1.25; }
  .project-heading p { font-size: 14px; line-height: 1.55; }
  .project-description-wrap { max-width: 100%; }
  .heading-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }
  .heading-actions button {
    width: 100%;
    min-height: 44px;
    padding: 9px 10px;
    font-size: 13px;
  }
  .heading-actions #newTaskBtn { grid-column: 1 / -1; }
  .shortcut { display: none; }

  .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .insight-card { min-height: 86px; padding: 12px 13px; }
  .insight-label { margin-bottom: 4px; font-size: 12px; }
  .insight-value { font-size: 23px; }
  .insight-meta { font-size: 11px; }

  /* Preserve the product's table abstraction on mobile. The identity columns
     stay frozen while the remaining fields are reached by horizontal swipe. */
  .board-card { border-radius: 11px; }
  .board-tabs {
    height: 56px;
    gap: 20px;
    padding: 0 14px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  .board-tabs::-webkit-scrollbar { display: none; }
  .board-tab { flex: 0 0 auto; height: 56px; min-width: 58px; font-size: 14px; }
  .board-action { display: none; }
  .board-card > .bulk-bar {
    height: 56px;
    min-height: 56px;
    padding: 8px 10px;
    gap: 7px;
    flex-wrap: nowrap;
  }
  .bulk-bar strong { width: auto; margin: 0 3px 0 0; font-size: 13px; white-space: nowrap; }
  .bulk-bar button, .bulk-bar select { min-height: 40px; height: 40px; font-size: 13px; }
  .bulk-bar .bulk-clear { margin-left: auto; background: #f7f5ff; }

  .table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .task-table { min-width: 1308px; }
  .task-table th, .task-table td { padding-left: 10px; padding-right: 10px; }
  .task-table th.check-col { width: 52px; }
  .task-table th.task-col { width: 220px; }
  .task-table th.detail-col { width: 170px; }
  .task-table th.owner-col { width: 150px; }
  .task-table th.status-col { width: 110px; }
  .task-table th.start-col, .task-table th.date-col { width: 150px; }
  .task-table th.priority-col { width: 90px; }
  .task-table th.dep-col { width: 160px; }
  .task-table th.action-col { width: 56px; }
  .task-table th:first-child,
  .task-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    width: 52px;
    min-width: 52px;
    background: #fff;
  }
  .task-table th:nth-child(2),
  .task-table td:nth-child(2) {
    position: sticky;
    left: 52px;
    z-index: 3;
    width: 220px;
    min-width: 220px;
    background: #fff;
    box-shadow: 8px 0 12px -12px rgba(34, 49, 76, .5);
  }
  .task-table thead th:first-child,
  .task-table thead th:nth-child(2) { z-index: 7; background: #f7f9fc; }
  .task-table .group-row td {
    position: static;
    width: auto;
    min-width: 0;
    box-shadow: none;
    background: #f1f0ff;
  }
  .task-table tbody tr:hover td:first-child,
  .task-table tbody tr:hover td:nth-child(2) { background: #fafaff; }
  .task-table input[type="checkbox"] { width: 18px; height: 18px; }
  .task-table input[type="checkbox"]:checked::after { left: 3px; top: 0; font-size: 12px; }
  .task-table td.check-col .drag-handle { margin-right: 4px; }
  .task-table .task-name-input { font-size: 14px; }
  .task-table .task-description-input { font-size: 13px; }
  .task-table .inline-template-picker,
  .task-table .row-delete { min-width: 38px; min-height: 38px; }
  .task-table td.status-cell .status-select-button { min-height: 38px; }
  .date-picker-trigger.date-cell { min-height: 38px; }
  .assignee-picker { min-height: 40px; }
  .table-footer { min-height: 58px; height: auto; padding: 9px 12px; gap: 12px; }
  .add-row { flex: 0 0 auto; min-height: 40px; font-size: 13px; }
  .table-hint { min-width: 0; font-size: 0; }
  .table-hint::after { content: "左右滑动查看全部列"; font-size: 12px; }
  .table-total { flex: 0 0 auto; font-size: 12px; }

  /* Secondary views keep readable cell sizes and scroll within their surface. */
  .alternate-view { min-height: 300px; }
  .flat-calendar.calendar-view { padding: 14px 12px 18px; overflow-x: auto; }
  .flat-calendar .calendar-toolbar { position: sticky; left: 0; gap: 12px; }
  .flat-calendar .calendar-toolbar h2 { font-size: 23px; }
  .flat-calendar .calendar-actions button { min-height: 42px; font-size: 13px; }
  .flat-calendar .calendar-weekdays,
  .flat-calendar .calendar-grid { min-width: 700px; }
  .flat-calendar .calendar-day { min-height: 105px; }
  .flat-calendar .calendar-task { min-height: 29px; font-size: 12px; }
  .smart-list-view { padding: 16px 10px 20px; }
  .smart-list-head h2 { font-size: 23px; }
  .smart-task-row { min-height: 66px; padding: 12px 10px; }
  .smart-task-main strong { font-size: 14px; }
  .smart-task-main small, .smart-task-due { font-size: 12px; }
  .gantt-view { padding: 14px 11px 18px; }
  .gantt-toolbar h2 { font-size: 24px; }
  .gantt-toolbar-actions select,
  .gantt-toolbar-actions .secondary-btn { min-height: 44px; font-size: 14px; }
  .gantt-scroll { -webkit-overflow-scrolling: touch; }
  .gantt-header, .gantt-row { grid-template-columns: 190px calc(var(--gantt-days) * 38px); }
  .gantt-task-label { padding-left: 10px; padding-right: 8px; }
  .gantt-task-copy strong { font-size: 14px; }
  .gantt-task-copy small { font-size: 12px; }
  .gantt-today-line { left: calc(190px + var(--today-position) * 38px); }

  /* Drawers occupy the mobile viewport and keep actions above safe areas. */
  .notification-drawer,
  .task-detail-drawer,
  .profile-drawer {
    width: 100vw;
    max-width: none;
    padding: 20px 17px calc(24px + env(safe-area-inset-bottom));
  }
  .drawer-head .icon-button,
  .profile-drawer-head .icon-button,
  .modal-head .icon-button { min-width: 42px; min-height: 42px; font-size: 22px; }
  .notification-list { overscroll-behavior: contain; }
  .notification-item { padding: 14px 1px; }
  .detail-grid { grid-template-columns: 1fr; gap: 0; }
  .detail-form input,
  .detail-form select,
  .detail-form textarea,
  .profile-form input { min-height: 44px; font-size: 16px; }
  .detail-footer { position: sticky; bottom: 0; margin: 8px -5px -12px; padding: 13px 5px 12px; background: #fff; }
  .detail-footer button { min-height: 42px; }

  /* Creation and management dialogs become bottom sheets instead of narrow
     desktop cards floating in the middle of the phone. */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .task-modal,
  .project-modal,
  .project-members-modal,
  .task-template-library-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 10px);
    margin: 0;
    padding: 20px 17px calc(18px + env(safe-area-inset-bottom));
    overflow: auto;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
  .modal-head { position: sticky; z-index: 2; top: -20px; margin: 0 -2px 18px; padding: 14px 2px 12px; background: #fff; }
  .modal-head h2 { font-size: 22px; }
  .task-modal label,
  .project-modal label,
  .project-member-form label { font-size: 13px; }
  .task-modal input,
  .task-modal select,
  .task-modal textarea,
  .project-modal input,
  .project-modal select,
  .project-modal textarea,
  .project-member-form select { min-height: 44px; font-size: 16px; }
  .form-grid, .project-member-form-grid { grid-template-columns: 1fr; gap: 0; }
  .modal-foot,
  .project-modal-foot,
  .project-members-foot,
  .task-template-library-foot { align-items: stretch; flex-direction: column; }
  .modal-foot > div,
  .project-modal-foot > div,
  .task-template-library-foot > div { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .modal-foot button,
  .project-modal-foot button,
  .project-members-foot button,
  .task-template-library-foot button { min-height: 44px; }
  .task-name-picker { grid-template-columns: 1fr; }
  .task-name-template-btn { width: 100%; min-height: 44px; font-size: 14px; }
  .task-template-library-modal .task-template-grid,
  .task-template-grid { grid-template-columns: 1fr; max-height: 42dvh; }
  .task-template-card { min-height: 70px; }
  .project-member-row { min-height: 58px; }

  /* Floating table controls use a consistent bottom-sheet position. Inline
     coordinates from desktop JS are intentionally overridden at this width. */
  .status-menu.floating-menu,
  .dependency-menu.floating-menu,
  .assignee-menu.floating-menu,
  .date-time-popover.floating-menu {
    top: auto !important;
    right: 10px !important;
    bottom: calc(var(--mobile-nav-height) + 10px + env(safe-area-inset-bottom)) !important;
    left: 10px !important;
    width: auto !important;
    max-width: none !important;
    max-height: calc(100dvh - var(--mobile-nav-height) - 30px) !important;
    transform: none !important;
    border-radius: 16px;
  }
  .floating-menu::before { display: none; }
  .status-menu.floating-menu { padding: 14px; }
  .status-option { min-height: 44px; height: 44px; font-size: 16px; }
  .dependency-menu.floating-menu .floating-menu-scroll { padding: 16px; }
  .dependency-task-row { min-height: 48px; }
  .dependency-task-name { font-size: 13px; }
  .dependency-owner-select { min-height: 38px; font-size: 13px; }
  .assignee-option { min-height: 46px; font-size: 14px; }
  .assignee-option input { width: 18px; height: 18px; }
  .date-time-picker-shell { max-height: inherit; overflow-y: auto; }
  .date-time-day { height: 36px; }
  .date-time-clock input { width: 64px; height: 42px; font-size: 16px; }
  .date-time-picker-foot button { min-height: 42px; }

  .confirm-dialog-backdrop { padding: 14px; }
  .confirm-dialog { padding: 21px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 15px; }
  .confirm-dialog-actions button { min-height: 44px; }
  .toast { bottom: calc(var(--mobile-nav-height) + 13px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 28px); text-align: center; }

  .auth-screen { align-items: flex-start; padding: max(18px, env(safe-area-inset-top)) 14px 18px; overflow-y: auto; }
  .auth-card { width: 100%; max-width: 420px; padding: 27px 22px 24px; }
  .auth-card input { min-height: 46px; font-size: 16px; }
  .auth-submit { min-height: 46px; }
}

@media (max-width: 420px) {
  .workspace-brand span { display: none; }
  .workspace-sidebar .new-project-btn { font-size: 0; width: 38px; padding: 0; }
  .workspace-sidebar .new-project-btn span { font-size: 19px; }
  #projectList .project-item { max-width: 164px; }
  .breadcrumbs strong { max-width: 39vw; }
  .account-menu-trigger > span:nth-child(2),
  .account-menu-chevron { display: none; }
  .account-menu-trigger { width: 40px; padding: 4px; }
  .project-heading h1 { font-size: 22px; }
  .heading-actions button { font-size: 12px; }
  .insight-card { min-height: 82px; padding: 11px; }
  .task-table th.task-col,
  .task-table th:nth-child(2),
  .task-table td:nth-child(2) { width: 190px; min-width: 190px; }
  .detail-footer { align-items: stretch; flex-direction: column; gap: 9px; }
  .detail-footer > div { display: grid; grid-template-columns: 1fr 1fr; }
  .detail-footer .danger-btn { width: 100%; }
  .profile-section-heading { align-items: flex-start; flex-direction: column; gap: 2px; }
  .password-rules { grid-template-columns: 1fr; }
  .date-time-picker-head { padding: 13px 14px 10px; }
  .date-time-weekdays { padding-top: 9px; }
  .date-time-days { gap: 1px; padding-bottom: 8px; }
  .date-time-day { height: 34px; }
  .date-time-clock { padding: 10px 12px; }
  .date-time-picker-foot { padding: 10px 12px 12px; }
}

@media (max-width: 360px) {
  .status-pill { display: none; }
  .breadcrumbs strong { max-width: 58vw; }
  .heading-actions { grid-template-columns: 1fr; }
  .heading-actions #newTaskBtn { grid-column: auto; }
  .table-total { display: none; }
  .date-time-clock-label { display: none; }
  .confirm-dialog-content { gap: 11px; }
  .confirm-dialog-icon { flex-basis: 38px; width: 38px; height: 38px; }
}

@media (max-width: 760px) and (orientation: landscape) and (max-height: 520px) {
  :root { --mobile-nav-height: 58px; }
  .workspace-sidebar { padding-top: 6px; padding-bottom: 7px; }
  .workspace-brand { display: none; }
  .workspace-sidebar > .sidebar-section:not(.projects-section) { display: none; }
  .workspace-nav-link { min-height: 44px; flex-direction: row; gap: 7px; }
  .modal-backdrop { align-items: center; padding: 8px; }
  .task-modal, .project-modal, .project-members-modal, .task-template-library-modal { max-height: calc(100dvh - 16px); border: 1px solid #e2e6ec; border-radius: 14px; }
}
