/* Raid assignments in the dashboard: the editor of a layout or a raid's copy
   (app/assignments/assignment-editor.js) with its page rail, table cards, people
   tray and rule and link dialogs, and the Templates page's list of layouts. It
   builds on plan.css (toolbar, chips, move bar, drag ghost). The label parts
   (marker, linked name) are shared with the member page, which links this file
   too. */

/* Labels */
.as-label {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
}

.as-marker,
.as-glyph,
.as-label .wow-icon {
  flex: none;
}

.as-glyph {
  color: var(--text-secondary);
}

/* The row note sits on its own line under the label; a long word wraps. */
.as-row-note {
  flex-basis: 100%;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.as-table-note {
  display: block;
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
}

p.as-table-note {
  margin: -6px 0 10px;
}

/* A table's color: the title in it, and a left stripe unless the table turned it off. */
[data-color="red"] {
  --as-table-color: var(--table-red);
}

[data-color="orange"] {
  --as-table-color: var(--table-orange);
}

[data-color="yellow"] {
  --as-table-color: var(--table-yellow);
}

[data-color="green"] {
  --as-table-color: var(--table-green);
}

[data-color="blue"] {
  --as-table-color: var(--table-blue);
}

[data-color="purple"] {
  --as-table-color: var(--table-purple);
}

/* Square left corners, so the stripe runs straight down the card. */
.as-card[data-stripe] {
  border-left: 3px solid var(--as-table-color);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.as-card[data-color] .as-card-title,
.as-card[data-color] .as-title-field input {
  color: var(--as-table-color);
}

.as-link-row,
.as-open {
  color: var(--text-muted);
  font-weight: 400;
}

.as-link.is-removed {
  color: var(--text-muted);
  font-style: italic;
}

/* Name, toolbar and status */
.as-name-field,
.as-page-name {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.as-name-field {
  max-width: 420px;
  margin: 0 0 18px;
}

.as-publish {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.as-published {
  font-size: 12px;
  color: var(--text-secondary);
}

.as-status-why {
  display: block;
  font-size: 11px;
}

.plan-status .text-button {
  margin: 0;
  min-height: 24px;
}

.as-summary {
  margin: -4px 0 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.as-summary:empty {
  display: none;
}

/* The raid toolbar: fill actions on the left, publishing on the right. */
.as-toolbar-fill,
.as-toolbar-publish {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.as-toolbar-publish {
  margin-left: auto;
}

/* Pages: the rail right of the page, People left of it in raid mode */
.as-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  grid-template-areas: "page rail";
  gap: 18px;
  align-items: start;
}

.as-editor.has-tray {
  grid-template-columns: 270px minmax(0, 1fr) 190px;
  grid-template-areas: "tray page rail";
}

.as-rail {
  grid-area: rail;
  position: sticky;
  top: 12px;
  display: grid;
  gap: 6px;
}

.as-rail-tab {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.as-rail-tab small {
  flex: none;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.as-rail-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.as-rail-tab:focus-visible,
.as-rule-chip:focus-visible,
.as-tray-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.as-rail-tab[aria-current="true"] {
  border-color: var(--accent);
  background: var(--nav-selected);
  color: var(--text-primary);
}

.as-page-select {
  grid-area: select;
  display: none;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.as-page {
  grid-area: page;
  min-width: 0;
}

.as-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-bottom: 14px;
}

.as-page-head.is-editing {
  align-items: end;
}

.as-page-name input {
  min-width: 220px;
}

.as-page-title {
  margin: 0;
  font-size: 20px;
}

.as-tools {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

/* Table cards */
.as-cards {
  display: grid;
  gap: 14px;
}

.as-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.as-card-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.as-card-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.as-title-field {
  flex: 1;
  min-width: 0;
}

.as-title-field input {
  width: 100%;
  font-weight: 600;
}

.as-rows {
  display: grid;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

/* Without an add-row button after it, the card's padding is the space below. */
.as-rows:last-child {
  margin-bottom: 0;
}

.as-rows:last-child > .as-row:last-child {
  padding-bottom: 0;
}

.as-row {
  display: grid;
  grid-template-columns: minmax(120px, 26%) minmax(0, 1fr);
  gap: 8px 14px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.as-row:first-child {
  padding-top: 0;
  border-top: 0;
}

/* One grid for every row: marker | label | link | actions, so labels share a width. */
.as-row.is-editing {
  grid-template-columns: auto minmax(0, 1fr) 13rem auto;
  align-items: center;
}

.as-row.is-editing .as-row-slots {
  grid-column: 1 / -1;
}

.as-marker-cell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.as-link-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 12px;
}

.as-link-cell .as-linked {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-link-cell .text-button {
  flex: none;
  white-space: nowrap;
}

.as-row-actions,
.as-card-head .as-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 0;
}

.as-card-head .as-tools {
  margin-left: auto;
}

.as-row-menu > summary,
.as-table-menu > summary {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
}

.as-row-menu > summary:hover,
.as-row-menu[open] > summary,
.as-table-menu > summary:hover,
.as-table-menu[open] > summary {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.as-row-menu > summary:focus-visible,
.as-table-menu > summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.as-phone-only {
  display: none;
}

/* A menu item that can't be used says why under its name. */
.as-row-menu > div button:disabled,
.as-table-menu > div button:disabled {
  color: var(--text-muted);
  cursor: default;
}

.as-row-menu > div button:disabled:hover,
.as-table-menu > div button:disabled:hover {
  background: none;
}

.as-menu-reason {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.as-table-menu > div {
  min-width: 220px;
}

/* Color: the six swatches and None, two to a line. */
.as-swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 2px 0;
  padding: 4px 0;
  border-block: 1px solid var(--border);
}

.as-menu-label {
  grid-column: 1 / -1;
  padding: 2px 11px;
  font-size: 11px;
  color: var(--text-muted);
}

.as-table-menu .as-swatches button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.as-table-menu .as-swatches button[aria-pressed="true"] {
  background: var(--nav-selected);
  color: var(--accent);
}

.as-swatch {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--as-table-color);
}

.as-swatch.is-none {
  border: 1px dashed var(--text-muted);
  background: none;
}

/* The side stripe's on/off under the colors, drawn as a checkbox. */
.as-table-menu .as-stripe-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
  border-bottom: 1px solid var(--border);
}

.as-stripe-toggle::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border: 1px solid var(--text-muted);
  border-radius: 3px;
}

.as-stripe-toggle[aria-pressed="true"]:not(:disabled)::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.5-5' fill='none' stroke='%23111' stroke-width='1.8'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.as-stripe-toggle .as-menu-reason {
  flex-basis: 100%;
  padding-left: 20px;
}

/* The row's marker and icon button, with a faint "+" while it has neither. One width
   for every row, so the labels beside it line up. */
.as-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 52px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
}

.as-icon-button:hover,
.as-icon-button[aria-expanded="true"] {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

.as-icon-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.as-icon-empty {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  opacity: 0.7;
}

/* The marker and icon picker and the page chooser: a popover beside their button. */
.as-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 7;
  /* Nine 36 px choices to a line: None and the eight markers fit on one. */
  width: 390px;
  max-height: min(70vh, 480px);
  overflow-y: auto;
  padding: 8px 10px 10px;
  border: 1px solid var(--border-hover);
  border-radius: 9px;
  background: var(--bg-elevated);
  box-shadow: 0 14px 34px rgb(0 0 0 / 40%);
  font-weight: 400;
}

.as-copy-chooser {
  right: 0;
  left: auto;
  width: 260px;
}

.as-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.as-pick-group h3 {
  margin: 8px 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.as-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 36px);
  gap: 4px;
}

.as-pick {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  cursor: pointer;
}

.as-pick:hover {
  background: var(--bg-hover);
}

.as-pick[aria-pressed="true"] {
  border-color: var(--border-warm);
  background: var(--nav-selected);
}

.as-pick:focus-visible,
.as-page-choice:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.as-pick-none {
  font-size: 10px;
  color: var(--text-muted);
}

.as-pick-more {
  grid-column: span 2;
  width: auto;
  font-size: 11px;
  color: var(--text-secondary);
}

.as-page-choices {
  display: grid;
  margin-top: 6px;
}

.as-page-choice {
  padding: 9px 11px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-primary);
  font-size: 12px;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.as-page-choice:hover:not(:disabled) {
  background: var(--bg-hover);
}

.as-page-choice:disabled {
  color: var(--text-muted);
  cursor: default;
}

.as-page-choice small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
}

/* A note field under the label (or the table's title), once the note is added. */
.as-note-field {
  grid-column: 2 / 4;
  min-width: 0;
}

.as-note-field input {
  width: 100%;
  min-height: 32px;
  font-size: 12px;
}

.as-table-note-field {
  display: block;
  margin: -4px 0 10px;
}

/* On phones the link cell is hidden, so its text moves to the line above the spots. */
.as-link-note {
  display: none;
}

.as-row-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  padding-top: 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.as-text-field {
  flex: 1 1 160px;
}

.as-text-field input {
  width: 100%;
}

.as-linked {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
}

.as-link-button {
  margin-top: 0;
}

.as-row-slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.as-rule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-rule-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px dashed var(--border-hover);
  border-radius: 7px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.as-rule-chip span {
  font-weight: 700;
  color: var(--text-muted);
}

.as-rule-icons {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.as-rule-icon {
  position: relative;
  display: inline-flex;
}

.as-rule-icon img {
  border-radius: 4px;
}

/* An "off" mark in the corner of an off spec entry's icon. */
.as-rule-off-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  padding: 0 3px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  text-transform: uppercase;
}

.as-rule-chip:hover {
  border-color: var(--accent-border);
  background: var(--bg-elevated);
}

.as-slot-count {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.as-add-table {
  margin-top: 14px;
}

/* Spots */
/* A row's spots in even columns, so they line up from row to row (a lone spot
   takes the width), and the "+" beside them at the bottom. A phone has room for
   one spot a line. */
.as-row-people {
  display: flex;
  gap: 6px;
  align-items: end;
  min-width: 0;
}

/* align-items: start, so a spot's open menu doesn't stretch the spots beside it. */
.as-spots {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: start;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-spot {
  display: grid;
  gap: 4px;
  min-width: 0;
}

/* A row with several spots numbers them, as the member page does: a small badge on
   the chip's corner, so it takes none of the name's room. */
.as-spots.is-numbered {
  counter-reset: spot;
}

.as-spots.is-numbered > .as-spot:not(.as-spot-add) {
  position: relative;
  counter-increment: spot;
}

.as-spots.is-numbered > .as-spot:not(.as-spot-add)::before {
  content: counter(spot) / "";
  position: absolute;
  top: -5px;
  left: -5px;
  z-index: 1;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border: 1px solid var(--border-hover);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

.as-empty {
  gap: 8px;
}

.as-empty small {
  margin-left: auto;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-empty .as-rule-icon img {
  width: 16px;
  height: 16px;
}

.as-empty.is-selected,
.as-add-spot.is-selected {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* The "+" beside a row's spots: a small square, not a spot of its own. */
.as-spot.as-spot-add {
  flex: none;
}

/* plan.css comes later and sizes open spots' text. */
.as-spot-add .as-add-spot {
  justify-content: center;
  width: 44px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.as-auto {
  color: var(--text-muted);
}

.as-chip.is-gone {
  border-color: var(--warning-border);
}

.as-chip.is-gone .signup-name {
  text-decoration: line-through;
}

.as-hint,
.as-gone {
  margin: 0;
  font-size: 11px;
  color: var(--warning);
}

.as-gone .text-button {
  margin: 0 0 0 6px;
  min-height: 28px;
}

.as-spot-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* The spot's target marker: a line of its own under the menu's buttons. */
.as-spot-menu .as-marker-choices {
  flex-basis: 100%;
  margin-top: 2px;
}

/* The rule dialog's marker line, above the fill order. */
.as-rule-marker {
  margin: 14px 0 12px;
}

.as-rule-marker .as-rule-group {
  margin-top: 0;
}

/* People tray: the header, search and filters stay put, and only the list of people scrolls. */
.planner .as-tray {
  grid-area: tray;
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

/* plan.css comes later and sets the pool's chips in columns. */
.planner .as-tray .chip-list {
  grid-template-columns: minmax(0, 1fr);
}

.as-tray-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.as-tray .roster-count {
  margin-left: 0;
}

.as-tray-title {
  margin: 0;
  font-size: 15px;
}

.as-tray-close,
.as-tray-handle,
.as-tray-toggle {
  display: none;
}

.as-tray-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.as-people-filter,
.planner .as-tray .as-tray-note {
  flex: none;
  margin: 0;
}

/* Search, then the role toggles and Unplaced in one row as wide as it. */
.as-people-filter {
  display: grid;
  gap: 8px;
}

.as-people-filter .search-label input {
  width: 100%;
  box-sizing: border-box;
}

.as-people-toggles {
  display: flex;
  align-items: center;
  gap: 6px;
}

.as-people-toggles button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.as-people-toggles button[aria-pressed="true"] {
  background: var(--nav-selected);
  border-color: var(--border-warm);
  color: var(--accent);
}

.as-people-toggles button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.as-people-toggles .as-people-role {
  flex: 1 1 0;
  min-width: 32px;
  padding: 0;
}

.as-people-unplaced {
  flex: none;
}

/* The scrolling part. The 2px inset keeps focus rings clear of its clipped edges. */
.as-people-groups {
  display: grid;
  flex: 0 1 auto;
  align-content: start;
  gap: 12px;
  min-height: 0;
  margin: -2px;
  padding: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.as-tray .plan-pool-group h3 {
  align-items: center;
}

/* Icons | name over spec | spot count, so the columns line up down the list. A shade lighter
   than the tray, so each row's edge lines up with the search box above it. */
.as-tray .plan-chip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  background: var(--bg-card);
}

.as-tray .plan-chip:not(.is-selected):hover {
  background: var(--bg-hover);
}

.as-tray .signup-name,
.as-tray .signup-text small {
  white-space: normal;
  overflow-wrap: anywhere;
}

.as-tray .as-spot-count {
  margin-left: 0;
}

.as-spot-count {
  flex: none;
  min-width: 22px;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
}

/* Rule, link, new table and new layout dialogs */
.as-dialog {
  max-width: 640px;
}

.as-dialog h2 {
  font-size: 20px;
}

/* Add table: its kind and color as chips, then the side stripe. */
.as-table-fieldset {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.as-table-fieldset legend {
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.as-table-fieldset .choice-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  margin-top: 8px;
}

.as-table-form label.choice {
  display: flex;
}

.as-table-form label.choice:has(input:disabled) {
  cursor: default;
  opacity: 0.6;
}

.as-table-fieldset .as-color-grid {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.as-color-grid label.choice > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.as-stripe-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.as-stripe-field small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.as-stripe-field:has(input:disabled) {
  cursor: default;
  opacity: 0.6;
}

.as-rule-list {
  display: grid;
  gap: 8px;
  margin: 16px 0 8px;
  padding: 0;
  list-style: none;
}

.as-rule-entry {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.as-rule-number {
  font-weight: 700;
  color: var(--text-muted);
}

.as-rule-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.as-rule-off {
  font-size: 12px;
  white-space: nowrap;
}

.as-rule-empty,
.as-rule-summary {
  font-size: 12px;
  color: var(--text-secondary);
}

.as-rule-empty {
  margin: 16px 0 8px;
}

.as-rule-summary {
  margin: 8px 0 12px;
}

.as-rule-limit {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.as-rule-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.as-rule-tabs button {
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.as-rule-tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--text-primary);
}

.as-rule-tabs button:focus-visible,
.as-rule-pick:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.as-rule-panel {
  max-height: min(42vh, 360px);
  margin-bottom: 12px;
  overflow-y: auto;
}

.as-rule-group {
  margin: 10px 0 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.as-rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}

.as-rule-pick {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 64px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 11px;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.as-rule-pick img {
  border-radius: 5px;
}

.as-rule-pick:hover:not(:disabled) {
  border-color: var(--accent-border);
  background: var(--bg-elevated);
}

.as-rule-pick[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.as-rule-pick:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* The Templates page's Assignment layouts tab */
.as-layout-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-layout-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.as-layout-item h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.as-layout-item h3 a {
  color: var(--text-primary);
  text-decoration: none;
}

.as-layout-item h3 a:hover {
  color: var(--accent);
}

.as-layout-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Narrower screens: the rail becomes a select above the tables, People stays beside them. */
@media (max-width: 1100px) {
  .as-editor {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "select"
      "page";
  }

  .as-editor.has-tray {
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "tray select"
      "tray page";
  }

  .as-rail {
    display: none;
  }

  .as-page-select {
    display: grid;
    max-width: 360px;
  }
}

/* Phones: one column, and the tray is a sheet at the bottom of the screen. */
@media (max-width: 760px) {
  .as-editor.has-tray {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "select"
      "page";
  }

  .as-page-select {
    max-width: none;
  }

  /* Fill actions are a row of equal buttons, publishing a row of its own. */
  .as-toolbar.plan-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .as-toolbar-fill {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }

  .as-toolbar .as-toolbar-fill > * {
    width: 100%;
    min-width: 0;
  }

  .as-toolbar .as-toolbar-fill .button,
  .as-toolbar .as-toolbar-fill .action-menu > summary {
    width: 100%;
    min-width: 0;
    padding-inline: 6px;
    justify-content: center;
  }

  /* The menus open across the whole group, so none runs past the screen's edge. */
  .as-toolbar-fill {
    position: relative;
  }

  .as-toolbar-fill .action-menu {
    position: static;
  }

  .as-toolbar .as-toolbar-fill .action-menu > div {
    right: 0;
    left: 0;
    min-width: 0;
  }

  /* Left-aligned under Published: the planner's narrow toolbar centres every row. */
  .as-toolbar .as-toolbar-publish {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .as-toolbar .as-toolbar-publish .button {
    width: auto;
  }

  .as-toolbar .as-publish {
    flex-basis: 100%;
  }

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

  /* Line one: marker, label, menu. Line two: the spots. */
  .as-row.is-editing {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .as-row.is-editing .as-link-cell,
  .as-row-tools,
  .as-card-head .as-table-tools {
    display: none;
  }

  .as-row-menu > div .as-phone-only,
  .as-table-menu > div .as-phone-only {
    display: block;
  }

  .as-note-field {
    grid-column: 1 / -1;
  }

  /* The choosers become a sheet along the bottom of the screen. */
  .as-popover,
  .as-copy-chooser {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    width: auto;
    max-height: 70vh;
    padding: 10px 16px 16px;
    border-radius: 12px 12px 0 0;
  }

  /* Nine 36 px choices and their gaps need 356 px: the picker's sheet keeps less side room. */
  .as-popover {
    padding-inline: 8px;
  }

  .as-row.is-editing .as-link-note:not(:empty) {
    display: block;
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--text-secondary);
  }

  .as-page-name input {
    min-width: 0;
  }

  .planner .as-tray {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    padding: 0;
    border-radius: 14px 14px 0 0;
    background: var(--bg-elevated);
    box-shadow: 0 -10px 30px rgb(0 0 0 / 45%);
    overflow: hidden;
    transition: transform 0.2s ease;
  }

  /* Closed, the sheet is one bar to tap; open, it has a handle and a header. */
  .as-tray[data-open="false"] :is(.as-tray-handle, .as-tray-head, .as-tray-body) {
    display: none;
  }

  .as-tray[data-open="true"] .as-tray-toggle {
    display: none;
  }

  .as-tray-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    border: 0;
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
  }

  /* The handle and header slide the sheet down, so the browser mustn't scroll on them. */
  .as-tray-handle {
    display: block;
    flex: none;
    height: 14px;
    cursor: grab;
    touch-action: none;
  }

  .as-tray-handle::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--border-hover);
  }

  .as-tray-head {
    flex: none;
    padding: 4px 14px 8px;
    touch-action: none;
  }

  .as-tray-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0 -10px 0 auto;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }

  .as-tray-close:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }

  .as-tray-body {
    padding: 0 14px 14px;
  }

  /* The sheet is the shade the counts usually use. */
  .as-tray .roster-count {
    background: var(--bg-hover);
  }

  /* Like the header, the search and filters slide the sheet rather than the page behind it. */
  .as-people-filter,
  .as-tray-note {
    touch-action: none;
  }

  /* The move bar stays at the top here: the tray holds the bottom of the screen. */
  .planner.assignments .plan-movebar {
    position: sticky;
    top: 8px;
    right: auto;
    bottom: auto;
    left: auto;
  }

  .planner.assignments:has(.as-tray) {
    padding-bottom: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .planner .as-tray {
    transition: none;
  }
}
