@media screen {
  .row-more-actions {
    display: inline-flex;
  }

  .row-more-actions > .row-more-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    background: var(--panel);
    white-space: nowrap;
  }

  .row-more-actions > .row-more-toggle:hover,
  .row-more-actions.is-open > .row-more-toggle {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .row-more-actions > .project-interviewer-toggle {
    background: #e7f1fc;
    border-color: #b9d2ee;
    color: #294e77;
  }

  .row-more-actions > .project-interviewer-toggle:hover,
  .row-more-actions.is-open > .project-interviewer-toggle {
    background: #d6e8fa;
    border-color: #88b2de;
  }

  .row-more-actions > .project-manager-toggle {
    background: #e7f4e9;
    border-color: #b7d8bf;
    color: #305b39;
  }

  .row-more-actions > .project-manager-toggle:hover,
  .row-more-actions.is-open > .project-manager-toggle {
    background: #d6ebda;
    border-color: #88b694;
  }

  .column-move-handle,
  .column-resize-handle {
    display: none;
  }

  .projects-toolbar .project-create:not([open]) {
    display: none;
  }

  .project-search > .archive-toggle {
    white-space: nowrap;
  }

  .project-search > .archive-toggle.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
  }

  .projects-table .row-more-menu {
    position: fixed;
    z-index: 200;
    display: grid;
    gap: 4px;
    width: 230px;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    box-shadow: var(--shadow-md);
  }

  .projects-table .row-more-menu[hidden] {
    display: none;
  }

  .projects-table .row-more-menu :is(a, button) {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    min-height: 32px;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 600;
  }

  .projects-table .row-more-menu a {
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    background: var(--panel);
  }

  .projects-table .row-more-menu a:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .projects-table .row-more-menu form {
    margin: 0;
  }
  .project-action-menus {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .projects-table .project-information-menu {
    width: 360px;
    padding: 12px;
    gap: 8px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .project-information-menu p {
    margin: 0;
    line-height: 1.45;
  }

  .project-information-comment {
    white-space: pre-wrap;
  }
}

/* Desktop density is independent of the phone layout and printed documents. */
@media screen and (min-width: 768px) {
  body .topbar {
    min-height: 60px;
    padding: 6px 12px;
    gap: 8px;
  }

  body .topbar-main,
  body .topbar-account {
    gap: 8px;
  }

  .brand-mark img {
    max-width: 200px;
    max-height: 40px;
    width: auto;
    height: auto;
  }

  body .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
    min-height: calc(100vh - 60px);
  }

  body .app-shell.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  body .sidebar {
    padding: 8px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  body .side-tree > .side-link,
  body .side-section > .side-link,
  body button.side-link {
    min-height: 28px;
    padding: 5px 6px;
    font-size: 13px;
    white-space: normal;
  }

  .page {
    padding: 10px 12px;
  }

  :is(.questions-header, .projects-header, .participants-header, .status-header,
      .statistics-header, .toolbar, .rating-toolbar, .reports-toolbar,
      .admin-toolbar, .site-settings-toolbar, .site-backup-panel,
      .question-editor, .questionnaire-group-form, .question-form,
      .user-create-form, .notification-settings-form, .offline-local-panel,
      .offline-workspace, .offline-form-section) {
    padding: 8px;
    gap: 8px;
  }

  :is(.toolbar, .rating-toolbar, .reports-toolbar, .admin-toolbar,
      .site-settings-toolbar, .questionnaire-group-form, .create-question-form) {
    margin-bottom: 8px;
  }

  :is(.form-field, .question-row, .question-list, .question-list-form,
      .project-form, .participant-form, .rating-form-grid, .age-group-form,
      .template-meta-form, .offline-grid, .notifications-grid, .statistics-grid) {
    gap: 6px;
  }

  main .form-field > label {
    font-size: 12px;
  }

  main :is(input:not([type="radio"]):not([type="checkbox"]), select, textarea) {
    min-height: 30px;
  }

  .participant-form {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  }

  .project-form,
  .project-create[open] .project-create-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .project-form .project-assignment-field {
    grid-column: span 2;
  }

  .question-row-top {
    grid-template-columns: 76px 68px 80px minmax(0, 1fr);
  }

  .question-row-halves {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .question-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
  }

  .question-card-header > .question-form-title {
    margin: 0;
    white-space: nowrap;
  }

  .question-card-header > .question-row-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0;
    gap: 10px;
  }

  .question-card-header .form-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .question-card-header .form-field > label {
    white-space: nowrap;
  }

  .question-card-header .form-field > input {
    width: 60px;
    min-width: 0;
  }

  .question-card-header .inline-actions {
    align-items: center;
  }

  .rating-form-grid,
  .age-group-form {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr));
  }

  .notification-settings-form,
  .user-create-form {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  }

  .notification-extra-recipients,
  .notification-settings-actions {
    grid-column: 1 / -1;
  }

  .project-context-bar {
    flex-direction: row;
    align-items: center;
    padding: 6px 8px;
    gap: 8px;
    margin-bottom: 8px;
  }

  .project-context-bar:has([data-project-switch]) > div:first-child {
    display: none;
  }

  .project-context-bar:has([data-project-switch]) > div:first-child:has(.context-meta) {
    display: block;
  }

  .project-context-bar:has([data-project-switch]) :is(.context-label, h1) {
    display: none;
  }

  .project-context-selectors {
    margin-left: 0;
    flex: 1;
    width: auto;
    gap: 8px;
  }

  .project-context-selectors .project-switch-form {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    flex: 1 1 220px;
    width: auto;
    min-width: 0;
    max-width: 360px;
    gap: 6px;
  }

  .project-switch-form label {
    font-size: 12px;
  }

  .projects-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px;
    gap: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .projects-title-row {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .projects-title-row h1 {
    font-size: 18px;
  }

  .projects-control-row {
    display: contents;
  }

  .projects-control-row > .count {
    min-width: 30px;
    padding: 5px;
    font-size: 13px;
  }

  .project-search {
    flex: 1 1 300px;
  }

  .project-search,
  .participant-search {
    grid-template-columns: minmax(120px, 1fr) auto auto;
    min-width: 0;
    padding: 0;
    gap: 6px;
    border: 0;
    background: transparent;
  }

  .project-search:has(.archive-toggle) {
    grid-template-columns: minmax(120px, 1fr) auto auto auto;
  }

  :is(.project-search, .participant-search) .form-field {
    max-width: none;
  }

  :is(.project-search, .participant-search) label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .projects-toolbar .project-create,
  .participants-toolbar .participant-create {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .projects-toolbar .project-create[open] {
    flex: 1 1 100%;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }

  .participants-toolbar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .participants-toolbar:has(.participant-create[open]) {
    grid-template-columns: minmax(0, 1fr);
  }

  .participants-toolbar .participant-create[open] {
    padding: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
  }

  .participants-header {
    flex-wrap: wrap;
  }

  .participants-header .source {
    display: none;
  }

  .participant-table-tools,
  .participant-counts {
    gap: 4px;
  }

  .participant-count-card {
    padding: 2px 5px;
    gap: 4px;
  }

  .participants-table {
    width: 100%;
    table-layout: fixed;
  }

  .projects-table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  .projects-table.has-column-widths {
    width: var(--projects-table-width);
    table-layout: fixed;
  }

  .participants-table {
    min-width: 1060px;
  }

  :is(.projects-table, .participants-table, .age-groups-table, .rating-table,
      .users-table, .report-table) :is(th, td) {
    padding: 5px 6px;
    overflow-wrap: anywhere;
  }

  .projects-table .project-users {
    min-width: 0;
  }

  .projects-table .project-actions {
    min-width: 140px;
  }

  .projects-table .project-action-menus {
    flex-wrap: wrap;
  }

  .projects-table .status-change-form .status-select {
    width: 100%;
    max-width: none;
    height: 24px;
    min-height: 24px;
    padding-block: 0;
    padding-inline: 5px;
  }

  .projects-table:not(.has-column-widths) .status-select {
    width: auto;
    max-width: none;
  }

  .projects-table .filter-row :is(input, select) {
    width: 100%;
    min-width: 0;
    padding-inline: 4px;
  }

  .projects-table .created-cell {
    white-space: nowrap;
  }

  .projects-table:not(.has-column-widths) [data-column-key="created"] {
    width: 116px;
    max-width: 116px;
  }

  .projects-table .filter-row input[name="created_date"] {
    width: 104px;
    max-width: 100%;
    padding-inline: 2px;
  }

  .projects-table thead tr:first-child th {
    position: relative;
    padding-inline: 20px 12px;
    white-space: nowrap;
  }

  .projects-table .column-move-handle {
    display: inline-flex;
    position: absolute;
    top: 50%;
    left: 2px;
    transform: translateY(-50%);
    min-width: 16px;
    min-height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: grab;
  }

  .column-move-handle::before {
    content: "⠿";
    font-size: 16px;
  }

  .column-resize-handle {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
  }

  .column-resize-handle:hover,
  .column-resize-handle:focus-visible,
  .column-drop-target {
    background: var(--accent-soft);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
  }

  .is-resizing-columns,
  .is-resizing-columns * {
    cursor: col-resize;
    user-select: none;
  }

  .is-dragging-column {
    opacity: 0.5;
  }

  .projects-table .deadline-cell > span {
    display: inline-block;
    white-space: nowrap;
  }

  .projects-table .deadline-cell span + span {
    font-size: 12px;
  }

  .participants-table .participant-actions-inner {
    flex-wrap: nowrap;
    gap: 4px;
  }

  .participants-table :is(th, td) {
    padding-block: 2px;
    vertical-align: middle;
    line-height: 1.25;
  }

  .participants-table th a.sortable-header {
    min-height: 20px;
  }

  .participants-table .sort-icon {
    width: 14px;
    height: 14px;
    font-size: 9px;
  }

  .participants-table .participant-actions-inner a {
    min-width: 30px;
    min-height: 24px;
    padding-inline: 5px;
  }

  .participants-table .completion-badge {
    min-height: 22px;
    padding-inline: 6px;
  }

  .participants-table .participant-delete .danger-button.icon-only {
    width: 24px;
    min-width: 24px;
    min-height: 24px;
    font-size: 11px;
  }

  main .participants-table td :is(input:not([type="hidden"]), select) {
    height: 26px;
    min-height: 26px;
    padding: 2px 6px;
  }

  .participants-table .participant-date,
  .participants-table .completion-link {
    white-space: nowrap;
  }

  .participants-table :is(th, td):nth-child(1) { width: 125px; }
  .participants-table :is(th, td):nth-child(2) { width: 36px; }
  .participants-table :is(th, td):nth-child(3) { width: 140px; }
  .participants-table :is(th, td):nth-child(4) { width: 240px; }
  .participants-table :is(th, td):nth-child(5) { width: 145px; }
  .participants-table :is(th, td):nth-child(6),
  .participants-table :is(th, td):nth-child(7),
  .participants-table :is(th, td):nth-child(8) { width: 110px; }
  .participants-table :is(th, td):nth-child(9) { width: 44px; }

  .rating-table {
    width: 100%;
    min-width: 600px;
    table-layout: fixed;
  }

  .rating-table :is(th, td):nth-child(1) { width: 72px; }
  .rating-table :is(th, td):nth-child(3),
  .rating-table :is(th, td):nth-child(4) { width: 88px; }
  .rating-table :is(th, td):nth-child(5) { width: 80px; }

  .rating-table td:nth-child(2) {
    max-width: none;
    white-space: normal;
  }

  .rating-table :is(input[type="number"], textarea) {
    width: 100%;
    min-width: 0;
  }

  :is(.participant-questionnaire-table, .participant-rating-table) :is(th, td) {
    padding-block: 2px;
    line-height: 1.3;
  }

  .participant-questionnaire-table .questionnaire-answer-choice {
    align-items: center;
    line-height: 1.3;
  }

  .participant-questionnaire-table .questionnaire-answer-choice input {
    margin: 0;
  }

  .participant-questionnaire-table .questionnaire-answer-list:not(.questionnaire-answer-list-binary) {
    gap: 3px;
  }

  .participant-rating-table .rating-scale {
    min-height: 22px;
    gap: 6px;
  }

  .participant-rating-table .rating-star {
    width: 22px;
    min-height: 22px;
    font-size: 15px;
  }

  .participant-rating-table .rating-scale-value {
    min-width: 22px;
    min-height: 22px;
    font-size: 11px;
  }

  #participant-rating-feedback-form input.rating-number {
    width: calc(var(--rating-number-characters, 3) * 1ch + 30px);
    min-width: 60px;
    height: 22px;
    min-height: 22px;
    padding: 2px 6px;
    font-size: 12px;
  }

  #participant-survey-form > .participant-survey-toolbar {
    padding-right: 1px;
  }

  #participant-survey-form > .participant-survey-body {
    min-width: 0;
    padding-right: 1px;
  }

  .projects-table th a {
    flex-wrap: wrap;
    gap: 4px;
  }

  .projects-table th a > span:first-child {
    overflow-wrap: normal;
  }

  .status-header {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .status-header .source {
    font-size: 12px;
  }

  .status-table [data-status-row] > td {
    box-shadow:
      inset 0 var(--status-block-top, 0px) var(--muted),
      inset 0 var(--status-block-bottom, 0px) var(--muted);
  }

  .status-table .status-block-first {
    --status-block-top: 1px;
  }

  .status-table .status-block-last {
    --status-block-bottom: -1px;
  }

  .status-table [data-status-row] > td:first-child {
    border-left: 1px solid var(--muted);
  }

  .status-table [data-status-row] > td:last-child,
  .status-table [data-status-row] > td.requirement-count:last-child {
    border-right: 1px solid var(--muted);
  }

  .status-table .status-group-end > td,
  .status-table .status-group-end > td.requirement-count {
    border-bottom: 6px solid var(--bg);
  }

  .statistics-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .statistics-panel {
    min-width: 0;
  }

  .period-form {
    grid-template-columns: repeat(2, minmax(0, 150px)) auto;
  }

  .project-activity-panel {
    margin-top: 8px;
  }

  .project-activity-chart,
  .project-activity-chart-hours {
    min-height: 164px;
    padding: 8px;
    gap: var(--activity-chart-gap, 6px);
  }

  .project-activity-chart .activity-bar,
  .project-activity-chart-hours .activity-bar {
    grid-template-rows: 18px 112px var(--activity-hour-label-height, 18px);
    gap: 3px;
  }

  .account-summary {
    margin: 0;
    overflow-wrap: anywhere;
  }

  .authenticated-panel .button-link {
    justify-content: center;
  }
}

@media screen and (min-width: 768px) and (max-width: 1100px) {
  body .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  body .app-shell.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .question-row-top {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .question-row-top .inline-actions {
    grid-column: 1 / -1;
  }

  .project-form,
  .project-create[open] .project-create-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-form .project-assignment-field {
    grid-column: auto;
  }
}
