/* Narrow screens (Adi, 2026-11-09: the iPhone Duo front screen with the side rail leaves the Today list
   under 300px, so titles were cut to "Searc…" next to the chip, timer, X and priority).
   When the Today list itself is under 460px wide (whatever the screen, rail or no rail), each row becomes:
     line 1: the title, up to two lines
     line 2: category chip and priority, small
     right:  the row tools (drag handle in My order, focus timer, take off today)
   The date hides; descriptions stay in roomy rows only. Works in both row views. */
body.orbit-v27 #chopList { container: chop-list / inline-size; }

@container chop-list (max-width: 459px) {
  #chopList .task-row,
  #chopList .chop-upnext .task-row {
    display: grid !important;
    grid-template-columns: 26px auto minmax(0, 1fr) auto !important;
    grid-template-areas: "check title title tools" "check desc desc tools" "check cat prio tools" !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 10px !important; row-gap: 0 !important;
    align-items: center !important;
    min-height: 0 !important; padding: 10px 0 !important;
  }
  /* Let the title, chip and priority sit straight in the row's grid. */
  #chopList .task-row .task-main,
  #chopList .task-row .task-row-meta { display: contents !important; }
  #chopList .task-row .task-main::before,
  #chopList .task-row .task-main::after { content: none !important; display: none !important; }

  #chopList .task-row > .task-check { grid-area: check; align-self: center !important; margin: 0 !important; }
  #chopList .task-row .task-title { grid-area: title; min-width: 0; margin: 0 !important; font-size: 15.5px !important; line-height: 1.3 !important; white-space: normal !important; }
  #chopList .task-row .task-title-button {
    display: -webkit-box !important; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    max-width: 100%; white-space: normal !important; overflow: hidden; text-overflow: clip; text-align: left !important; overflow-wrap: anywhere;
  }
  #chopList .task-row .task-list-description { grid-area: desc; min-width: 0; margin: 3px 0 0 !important; font-size: 13px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Line 2: chip, then priority right after it. */
  #chopList .task-row .task-list-category {
    grid-area: cat; justify-self: start; display: inline-flex !important; align-items: center;
    max-width: 150px; min-width: 0; margin: 4px 10px 0 0 !important; padding: 2px 8px !important;
    font-size: 12px !important; line-height: 1.35 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #chopList .task-row .priority-tap {
    grid-area: prio; justify-self: start; align-self: end;
    width: auto !important; min-height: 24px !important; margin: 2px 0 -2px -6px !important; padding: 2px 6px !important;
    font-size: 12px !important; justify-content: flex-start !important; gap: 5px;
  }
  #chopList .task-row .priority-tap > span:first-child { width: 7px !important; height: 7px !important; flex: 0 0 7px !important; }
  #chopList .task-row .task-added { display: none !important; }
  /* Anything else under the title ("Waiting on …", agent badges) gets its own line below, cut with "…". */
  #chopList .task-row .task-main > :not(.task-title):not(.task-list-description):not(.task-list-category) {
    grid-column: 2 / 4; justify-self: start; display: block; max-width: 100% !important; min-width: 0; margin: 5px 0 0 !important;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  #chopList .task-row .task-main > .task-state::before { display: inline-block; margin-right: 5px; vertical-align: 1px; }

  /* Right: the row tools, as one tight column-width group. */
  #chopList .task-row .chop-row-tools { grid-area: tools; align-self: center; display: inline-flex; gap: 0; margin-right: -4px; }
  #chopList .task-row .chop-row-tools > button { width: 32px; height: 36px; min-width: 32px; }
  #chopList .task-row .chop-remove { font-size: 19px; }
  #chopList .task-row .chop-drag { order: -1; }

  #chopList .task-row.task-is-done .task-list-category { opacity: .7; }

  /* Compact rows: same layout, less air, so titles still get two lines instead of being cut off. */
  body.orbit-v27[data-rows="tight"] #chopList .task-row { padding: 7px 0 !important; }
  body.orbit-v27[data-rows="tight"] #chopList .task-row .task-list-category { margin-top: 3px !important; padding: 1px 7px !important; }
}

/* Very narrow (iPhone Duo front screen, small phones): the rail gets a little slimmer, and the add button
   gets smaller and tucks closer to the corner so it covers less of the list. */
@media (max-width: 400px) {
  body.orbit-v27.sidebar-rail { --rail: 56px; --content-gutter: 12px; }
  body.orbit-v27.sidebar-rail:not(.sidebar-open) .sidebar { padding-left: 4px !important; padding-right: 4px !important; }
  body.orbit-v27 #taskFab { width: 54px; height: 54px; min-width: 54px; min-height: 54px; right: 12px !important; }
  body.orbit-v27 #taskFab .fab-plus svg { width: 24px; height: 24px; }
  /* Room under the last row so the add button never sits on top of it. */
  body.orbit-v27 #view-chop.chop-page.active { padding-bottom: 104px; }
}

/* The phone rail shows just the account initial, like the slim desktop sidebar (the name was cut off). */
body.orbit-v27.sidebar-rail:not(.sidebar-open) .account-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.orbit-v27.sidebar-rail:not(.sidebar-open) .account-button { width: 48px; justify-content: center; padding: 0; }

/* Other task lists (Tasks, categories) in compact rows on narrow screens: a long title gets a second line
   instead of being cut to a few letters, and a badge like "Needs you" drops under the title. */
@media (max-width: 420px) {
  body.orbit-v27[data-rows="tight"] .task-row:not(#chopList .task-row) .task-main { flex-wrap: wrap !important; row-gap: 4px; }
  body.orbit-v27[data-rows="tight"] .task-row:not(#chopList .task-row) .task-title { flex: 1 1 100% !important; white-space: normal !important; }
  body.orbit-v27[data-rows="tight"] .task-row:not(#chopList .task-row) .task-title-button {
    display: -webkit-box !important; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
    white-space: normal !important; overflow: hidden; text-overflow: clip;
  }
}
