/* A scrollable form body with actions outside that scroll area. */
#editor {
  padding: 0;
  height: min(820px, 94dvh, var(--visual-height, 94dvh));
  max-height: var(--visual-height, 94dvh);
  overflow: hidden;
}
#card-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0;
}
#card-form .dialog-head {
  flex: none;
  padding: 16px 20px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}
.editor-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 20px;
  overscroll-behavior: contain;
}
.editor-footer {
  flex: none;
  padding: 12px 20px;
  margin: 0;
  background: white;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}
.editor-help {
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}
.editor-help summary {
  padding: 6px 0;
  cursor: pointer;
}
.search-tools {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}
.search-tools .list-search {
  flex: 1;
  max-width: none;
  min-width: 0;
  margin: 0;
}
.search-tools .list-utilities {
  flex: none;
  gap: 4px;
}
.search-tools .list-utilities button {
  min-height: 45px;
}
.short-label {
  display: none;
}
.list-toolbar > .filters { flex: 1; }
.filters button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  overflow-wrap: anywhere;
}
.card-description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card .result {
  font-size: 14px;
  padding: 10px 12px;
}
.filters button {
  display: flex;
  justify-content: center;
  align-items: center;
}
.filter-count {
  flex: none;
  margin-inline-start: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.search-scope {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  margin-bottom: 8px;
}
.search-scope button {
  font-size: 13px;
  padding: 6px 8px;
}
.list-options {
  margin: 4px 0 10px;
  font-size: 14px;
}
.list-options > summary {
  cursor: pointer;
  padding: 6px 0;
  min-height: 32px;
}
.list-options.has-filter > summary {
  color: var(--green);
  font-weight: 600;
}
.list-options .field-row {
  margin-top: 8px;
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}
.quick-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.quick-dates button {
  padding: 6px 10px;
  min-height: 36px;
  font-size: 13px;
}
.card.past-due {
  border-color: #c2773c;
}
.deadline-note {
  color: #8a491a;
  font-size: 14px;
}
.card .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.card .actions > button {
  flex: 1;
  width: auto;
  min-width: 0;
}
.card .action-menu {
  flex: none;
}
.card .action-menu > summary {
  min-height: 44px;
  padding: 10px;
  list-style: none;
}
.card .action-menu[open] {
  flex-basis: 100%;
}
.card .action-menu .menu-items {
  position: static;
  min-width: 0;
  width: 100%;
  margin-top: 6px;
  box-shadow: none;
}
.card .menu-items button {
  width: 100%;
}
.card-history {
  display: grid;
  gap: 16px;
  list-style: none;
  padding: 0;
}
.card-history li {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.card-history p {
  margin: 6px 0 0;
}
@media (max-width: 700px) {
  .sidebar {
    display: none;
  }
  .main-area {
    min-height: 100dvh;
  }
  .topbar {
    padding: 4px 16px;
    min-height: 54px;
  }
  .heading {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
  }
  .heading h1 {
    font-size: 27px;
  }
  .heading > button {
    width: auto;
    flex: none;
  }
  .heading-actions { width: 100%; }
  .heading-actions button { font-size: 14px; white-space: nowrap; }
  #new-employee { padding: 10px 12px; }
  #new-card {
    flex: 1;
    padding: 10px 12px;
  }
  #new-card .wide-label {
    display: none;
  }
  #new-card .short-label {
    display: inline;
  }
  .pilot-note.compact-note {
    margin: 0 0 10px;
    font-size: 13px;
    padding: 7px 10px;
  }
  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .filters button {
    padding: 8px;
    font-size: 14px;
  }
  .card {
    padding: 16px;
    gap: 10px;
  }
  .card h3 {
    font-size: 18px;
  }
  .editor-body {
    padding: 12px 16px;
  }
  #card-form .dialog-head {
    padding: 10px 16px;
  }
  .editor-footer {
    padding: 10px 12px;
    gap: 8px;
  }
  .editor-footer button {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    white-space: normal;
  }
  .notice {
    margin-bottom: 10px;
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* Independent card heights: an expanded action menu does not stretch its neighbour. */
.card-grid {
  align-items: start;
}
.card-description {
  white-space: pre-wrap;
}
.card-description.expanded {
  display: block;
}
.description-toggle {
  align-self: flex-start;
  font-size: 14px;
  padding: 4px 0;
  min-height: 32px;
}
.next-actor {
  font-size: 14px;
  font-weight: 600;
}
.preparation-note {
  font-size: 14px;
  padding: 10px;
  background: var(--paper);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.preparation-changes {
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  margin: 12px 0;
}
.preparation-changes summary {
  cursor: pointer;
  font-weight: 600;
}
.preparation-changes p {
  overflow-wrap: anywhere;
}
.confirmation-choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: transparent;
  padding: 12px;
  border-radius: 10px;
}
.confirmation-choice input {
  width: 20px;
  height: 20px;
  flex: none;
  margin: 2px 0 0;
}
#list-options > button {
  margin: 8px 0;
}
#list-options [aria-pressed="true"] {
  border-color: var(--green);
  color: var(--green);
}
@media (max-width: 700px) {
  .topbar {
    min-height: 48px;
    padding-top: 2px;
    padding-bottom: 2px;
  }
  main#workspace {
    padding-top: 12px;
  }
  .pilot-note.compact-note {
    font-size: 12px;
    padding: 4px 8px;
    margin-bottom: 8px;
  }
  .heading {
    margin-bottom: 8px;
  }
  .list-toolbar {
    margin-bottom: 8px;
  }
  .list-options {
    margin-bottom: 4px;
  }
  #list-summary {
    margin-bottom: 8px;
    font-size: 12px;
  }
  .search-tools .list-utilities button {
    padding: 8px;
    font-size: 14px;
  }
  #editor {
    width: 100%;
    max-width: 100%;
    height: var(--viewport-height, 100dvh);
    max-height: var(--viewport-height, 100dvh);
    margin: 0;
    border-radius: 0;
    inset: var(--viewport-top, 0px) 0 auto;
  }
  #card-form .dialog-head {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .editor-footer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
.confirmation-choice {
  flex-direction: row;
}
@media (max-height: 500px) and (pointer: coarse) {
  .sidebar {
    display: none;
  }
  .main-area {
    margin-left: 0;
  }
  .topbar {
    min-height: 48px;
  }
  #editor {
    width: 100%;
    max-width: 100%;
    height: var(--viewport-height, 100dvh);
    max-height: var(--viewport-height, 100dvh);
    margin: 0;
    border-radius: 0;
    inset: var(--viewport-top, 0px) 0 auto;
  }
}

/* Internal workflow: one visible decision before optional details. */
.secondary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.execution-dialog {
  width: min(720px, calc(100% - 24px));
  max-height: var(--visual-height, 90dvh);
}
#execution-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
#execution-body h4 {
  margin-top: 8px;
}
#execution-action:empty {
  display: none;
}
#execution-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
#execution-form .actions {
  position: sticky;
  bottom: 0;
  background: var(--paper, #fff);
  padding: 8px 0;
}
#execution-body .card-history {
  padding-left: 22px;
}
@media (max-width: 700px) {
  .pilot-note.compact-note {
    font-size: 11px;
    margin: 2px 0 6px;
  }
  .heading {
    margin-bottom: 4px;
  }
  .list-options {
    margin: 4px 0;
  }
  #list-summary {
    margin: 4px 0;
  }
  .card {
    gap: 8px;
  }
  .card > * {
    order: 4;
  }
  .card > .card-top {
    order: 0;
  }
  .card > h3 {
    order: 1;
  }
  .card > .next-actor {
    order: 2;
  }
  .card > .actions {
    order: 3;
  }
  .card-description {
    -webkit-line-clamp: 2;
  }
  .card-description.expanded {
    -webkit-line-clamp: unset;
  }
  .card-meta {
    margin-top: 0;
    padding-top: 8px;
  }
  .execution-dialog {
    width: 100%;
    height: var(--viewport-height, 100dvh);
    max-height: var(--viewport-height, 100dvh);
    max-width: 100%;
    margin: var(--viewport-top, 0px) 0 0;
    border-radius: 0;
    padding: 12px;
  }
  .execution-dialog .dialog-head {
    position: sticky;
    top: -12px;
    background: var(--paper, #fff);
    z-index: 2;
    padding: 8px 0;
  }
  #execution-form .actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .pilot-note.compact-note {
    padding: 2px 6px;
    font-size: 11px;
  }
  .list-toolbar {
    margin-bottom: 4px;
  }
  main#workspace {
    padding-top: 8px;
  }
}
#execution-body h4 {
  margin: 4px 0 0;
}
#execution-body > p {
  margin: 0;
}
#execution-form > .muted {
  margin-top: 10px;
}

#cards-view > .heading { flex-wrap: wrap; }
.heading-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.voice-dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(var(--viewport-height, 100dvh) - 24px); overflow: auto; }
.voice-body { display: grid; gap: .8rem; min-width: 0; }
.voice-body input, .voice-body textarea, #voice-preview { width: 100%; max-width: 100%; min-width: 0; }
.voice-file-label { overflow-wrap: anywhere; }
#voice-send { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
#voice-send.is-loading { opacity: 1; cursor: progress; }
#voice-send.is-loading::before {
 content: "";
 width: 18px; height: 18px; flex-shrink: 0;
 border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
 animation: voice-spin .8s linear infinite;
}
@keyframes voice-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
 #voice-send.is-loading::before { animation: none; }
}
#voice-result { display: grid; gap: .8rem; }
#voice-result[hidden] { display: none; }
@media (max-width: 480px) {
 .heading { flex-wrap: wrap; gap: .5rem; }
 .heading-actions { justify-content: flex-start; }
 .voice-dialog { margin: 0; width: 100vw; max-width: 100vw; max-height: var(--viewport-height, 100dvh); height: var(--viewport-height, 100dvh); border-radius: 0; }
 .voice-body .actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
 #new-voice .voice-button-label { display: none; }
 #new-voice { width: 40px; min-width: 40px; padding: 10px; }
 .heading-actions { flex-wrap: nowrap; }
}

.context-help { font-size: 13px; font-weight: 500; text-align: left; text-decoration: underline; text-underline-offset: 3px; border-color: transparent; min-height: 44px; padding: 8px; max-width: 100%; overflow-wrap: anywhere; }
.context-help:hover { border-color: var(--line); }
#recoveries { margin-bottom: 12px; }
