.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-header nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.inline-form {
  display: inline;
  margin: 0;
}

#quick-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

#quick-add input[type='text'] {
  flex: 1 1 200px;
}

#quick-add details {
  flex-basis: 100%;
}

.quick-add-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.quick-add-options label {
  flex: 1 1 160px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.task-table {
  width: 100%;
  font-size: 0.9rem;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 0 0 var(--line-height);
}

.task-table th,
.task-table td {
  padding: 0.1rem 0.5ch;
  text-align: left;
  vertical-align: baseline;
}

/* The header row keeps the body's font size: with table-layout: fixed the
   column widths are read from these cells, and ch resolves per element. */
.task-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.1ch;
  color: var(--text-color-alt);
  border-bottom: var(--border-thickness) solid var(--text-color);
}

.col-done { width: 4ch; }
.col-plan { width: 14ch; }
.col-time { width: 6ch; }
.col-cost { width: 9ch; }
.col-when { width: 12ch; }

.task-section-label {
  padding-top: 0.6rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1ch;
  color: var(--text-color-alt);
}

/* With no tasks at all the header row would be the only thing left, so the
   table steps aside for a one-line empty state. */
.task-table:not(:has(.task-rows > *)) thead {
  display: none;
}

.task-table-empty {
  color: var(--text-color-alt);
}

.task-table:has(.task-rows > *) + .task-table-empty {
  display: none;
}

/* A section's label row sits in its own row group so it can disappear along
   with an empty list — the markup emits the rows group with no whitespace to
   keep :empty accurate. */
.task-section:has(+ .task-rows:empty) {
  display: none;
}

.task-item > td {
  border-bottom: 1px solid var(--text-color-alt);
}

.task-item:focus {
  outline: var(--border-thickness) solid var(--text-color);
  outline-offset: -2px;
}

.col-task {
  overflow-wrap: anywhere;
}

.col-plan,
.col-time,
.col-cost,
.col-when {
  color: var(--text-color-alt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-time,
.col-cost {
  text-align: right;
}

.task-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 1ch;
}

/* The description takes the slack so the row's controls line up down the
   right edge of the Task column and a long description wraps inside its own
   box rather than pushing them onto a second line. */
.task-description {
  flex: 1 1 0;
  min-width: 0;
}

.task-table form {
  margin: 0;
}

.complete-form {
  display: inline;
}

/* bureau boxes every <details>; these are inline affordances, not panels. */
.task-panel {
  margin: 0;
  padding: 0;
  border: none;
}

/* bureau spaces out every summary inside an open <details>, which outranks a
   plain .task-panel rule when a plan's task table sits inside one. */
.task-table .task-panel > summary {
  margin-bottom: 0;
}

.task-panel > summary::marker {
  content: none;
}

.task-panel > summary::-webkit-details-marker {
  display: none;
}

/* Row actions (Done / Notes / Edit / Delete) read as plain text links rather
   than boxed buttons, so a row keeps to one compact line. Covers <button>
   and <summary> alike, overriding bureau's boxed defaults for both. */
.row-action {
  display: inline;
  height: auto;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--text-color-alt);
  font: inherit;
  font-size: 0.8rem;
  font-weight: inherit;
  text-transform: none;
  text-decoration: underline;
  text-decoration-thickness: var(--border-thickness);
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

/* The Delete button is boxed yellow by a bureau rule keyed on .delete-form
   button, which outranks .row-action alone. */
.delete-form .row-action {
  background-color: transparent;
}

.row-action:hover,
.row-action[open] {
  background: none;
  color: var(--text-color);
}

.row-action:active {
  transform: none;
}

.row-action:focus {
  outline: var(--border-thickness) solid var(--text-color);
  outline-offset: 2px;
}

/* Marking "has notes" off the list itself keeps it honest after an htmx note
   add, which never re-renders the row. */
.notes-panel:has(.note-item) > .notes-summary {
  color: var(--text-color);
}

.notes-panel:has(.note-item) > .notes-summary::after {
  content: "\00B7";
}

/* Open panels take the whole task cell rather than squeezing in beside the
   description. */
.task-panel[open] {
  flex-basis: 100%;
}

.task-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
}

.delete-form {
  margin-bottom: 0.5rem;
}

[data-confirm][data-confirming] {
  background: var(--text-color);
  color: var(--background-color);
}

[data-confirm][data-confirming]:hover {
  background: var(--text-color-alt);
}

.notes {
  margin: 0.25rem 0 0.5rem;
}

.note-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.35rem;
}

.note-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.15rem 0 0.15rem 1.5ch;
  margin-left: 0.25ch;
  border-left: var(--border-thickness) solid var(--text-color);
}

.note-item::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 1ch;
  border-bottom: var(--border-thickness) solid var(--text-color);
}

.note-item:last-child {
  border-left: none;
}

.note-item:last-child::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 50%;
  border-left: var(--border-thickness) solid var(--text-color);
}

.note-item form {
  margin: 0;
}

.note-body {
  flex: 1 1 auto;
}

.add-note-form {
  display: flex;
  gap: 0.5rem;
  margin-left: 1.5ch;
}

.add-note-form input[type='text'] {
  flex: 1 1 auto;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  margin: 0;
}

.plan-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--line-height);
}

.plan-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: var(--border-thickness) solid var(--text-color);
  padding: 0.75rem 0;
}

.plan-item form {
  margin: 0;
}

.plan-name {
  flex: 1 1 auto;
  font-weight: var(--font-weight-medium);
}

.plan-item .plan-tasks-toggle {
  flex-basis: 100%;
}

.plan-tasks-empty {
  color: var(--text-color-alt);
}

.shortcuts-help {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  max-width: 20rem;
  background: var(--background-color);
  border: var(--border-thickness) solid var(--text-color);
  padding: 1rem;
  z-index: 100;
}

.shortcuts-help ul {
  margin-bottom: 0.75rem;
}

.auth-container {
  max-width: 28rem;
  padding-top: 3rem;
}

[role='alert'] {
  font-weight: var(--font-weight-bold);
}

[role='alert']::before {
  content: "[!] ";
}

@media (max-width: 480px) {
  /* Narrow screens drop the two least urgent columns and let the rest size to
     their content — a display: none column still eats its share of the free
     space under table-layout: fixed. */
  .task-table {
    table-layout: auto;
  }

  .col-plan,
  .col-cost {
    display: none;
  }

  .col-done,
  .col-time,
  .col-when {
    width: auto;
  }

  /* Squeeze the sized columns down to their content and hand the rest to the
     description. */
  .col-task {
    width: 99%;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .shortcuts-help {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}
