:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #66605a;
  --line: #d8d0c7;
  --paper: #fffdf8;
  --panel: #f6f1e8;
  --accent: #9b2f21;
  --accent-dark: #6e1f17;
  --warn: #8c5a00;
  --bad: #9b1c1c;
  --focus: #1c4f9b;
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--accent-dark);
  background: var(--accent);
  color: white;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  /* Touch targets: the Add buttons are used one-handed on a phone. */
  min-height: 2.4rem;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

/* Pressed state reads as pressed rather than merely darker. */
button:active:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(1px);
}

button.secondary {
  background: transparent;
  color: var(--accent-dark);
}

button.secondary:hover:not(:disabled) {
  background: var(--accent-dark);
  color: white;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Nothing should suggest a disabled control will respond. */
button:disabled:hover {
  background: var(--accent);
}

button.secondary:disabled:hover {
  background: transparent;
  color: var(--accent-dark);
}

/*
 * One focus treatment for everything. :focus-visible so a mouse click does not
 * leave a ring behind, but a keyboard traversal is obvious on both the
 * parchment and the white panels - the stylesheet previously had no focus
 * style at all, so keyboard users could not tell where they were.
 */
:where(button, input, select, textarea, summary, a, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 1px;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 3vw, 2rem);
  border-bottom: 2px solid var(--ink);
  background: #efe3d3;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.app-shell {
  padding: 1rem clamp(1rem, 3vw, 2rem);
}

.controls {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) minmax(12rem, 1fr) 10rem;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 0.5rem;
  transition: border-color 120ms ease;
}

input:hover:not(:disabled),
select:hover:not(:disabled) {
  border-color: var(--muted);
}

input:focus,
select:focus {
  border-color: var(--focus);
}

select:not(:disabled) {
  cursor: pointer;
}

input:disabled,
select:disabled {
  background: var(--panel);
  color: var(--muted);
  cursor: not-allowed;
}

/*
 * A locked option is a checked, disabled checkbox - equipment the entry must
 * take. It should read as settled rather than broken, so it keeps full
 * contrast and only loses its pointer.
 */
.option-row input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.option-row input[type="checkbox"]:disabled {
  cursor: default;
  opacity: 1;
}

.option-row:has(input[type="checkbox"]:disabled) {
  color: var(--muted);
}

.option-row:has(input[type="checkbox"]:not(:disabled)):hover {
  color: var(--accent-dark);
}

.status {
  min-height: 1.4rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(18rem, 0.9fr) minmax(24rem, 1.3fr);
  gap: 1rem;
  align-items: start;
}

.workspace-toolbar {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.2rem;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0.4rem 0.6rem;
}

.workspace-toolbar-line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.workspace-tabs,
.add-feedback {
  display: none;
}

.unit-browser {
  grid-column: 1;
  grid-row: 2;
}

.roster-panel {
  grid-column: 2;
  grid-row: 2;
}

.unit-browser,
.roster-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 20rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.panel-heading input {
  max-width: 16rem;
}

.unit-list,
.roster-list {
  padding: 0.75rem;
}

.category-block + .category-block {
  margin-top: 1rem;
}

.category-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  margin: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.3rem 0.35rem;
  list-style: none;
  transition: color 120ms ease, background-color 120ms ease;
}

.category-title::-webkit-details-marker,
.role-title::-webkit-details-marker {
  display: none;
}

.category-title::before,
.role-title::before {
  content: "\25b8";
  line-height: 1;
  transition: transform 120ms ease;
}

.category-block[open] > .category-title::before,
.role-block[open] > .role-title::before {
  transform: rotate(90deg);
}

.category-block[open] > .category-title {
  margin-bottom: 0.45rem;
}

.category-summary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  text-transform: none;
  white-space: nowrap;
}

.role-block + .role-block {
  margin-top: 0.7rem;
}

.role-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.4rem;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  padding: 0.25rem 0.35rem;
  list-style: none;
  text-transform: uppercase;
  transition: color 120ms ease, background-color 120ms ease;
}

.role-block[open] > .role-title {
  margin-bottom: 0.35rem;
}

.category-title:hover,
.role-title:hover {
  color: var(--accent-dark);
  background: #efe3d3;
}

.category-title:active,
.role-title:active {
  background: var(--panel);
}

.unit-row,
.roster-card {
  background: white;
  border: 1px solid var(--line);
  padding: 0.7rem;
}

.unit-row + .unit-row,
.roster-card + .roster-card {
  margin-top: 0.55rem;
}

.unit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.unit-row:hover {
  border-color: var(--accent);
  background: var(--panel);
}

/* A row containing the focused Add button should look reachable too. */
.unit-row:focus-within {
  border-color: var(--accent);
}

.unit-title,
.roster-title {
  font-weight: 700;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.source-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}

.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.65rem;
}

.source-status::before {
  width: 0.4rem;
  height: 0.4rem;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
  flex: 0 0 auto;
}

.source-status.sourced {
  color: #456454;
}

.source-status.sourced::before,
.source-status.book-sourced::before {
  background: currentColor;
}

.source-status.book-sourced {
  color: #596373;
}

.source-status.audit {
  color: var(--warn);
  font-weight: 700;
}

.source-status.audit::before {
  border-radius: 1px;
  background: currentColor;
}

.roster-card {
  display: grid;
  gap: 0.4rem;
}

.roster-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.roster-controls,
.option-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.roster-controls input {
  width: 5rem;
}

.options {
  display: grid;
  gap: 0.35rem;
}

.build-controls {
  display: grid;
  gap: 0.3rem;
}

.option-kind-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.75rem, 1fr));
  gap: 0.3rem;
}

.option-kind-sections:has(> .option-kind-details[open]) {
  grid-template-columns: 1fr;
}

.build-section,
.option-kind-details {
  background: #fffdfa;
  border: 1px solid var(--line);
  padding: 0.3rem;
}

.selection-summary {
  display: grid;
  gap: 0.25rem;
}

.build-heading,
.group-heading {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.grouped-options {
  display: grid;
}

.magic-search {
  display: grid;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.15rem;
}

.magic-search label {
  color: var(--accent-dark);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.magic-search-results,
.group-item-list {
  display: grid;
  gap: 0.25rem;
  padding: 0.15rem;
}

.magic-search-results {
  max-height: min(24rem, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.magic-search-results[hidden],
.grouped-options[hidden] {
  display: none;
}

.magic-search-status {
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.15rem;
}

.group-item-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  background: white;
}

button.group-item-details {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0.45rem;
  text-align: left;
}

button.group-item-details:hover:not(:disabled) {
  background: var(--panel);
  color: var(--accent-dark);
}

.group-item-result-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.group-item-result-name {
  font-weight: 700;
}

.group-item-result-category {
  font-size: 0.78rem;
  color: var(--accent-dark);
  font-weight: 700;
  text-transform: uppercase;
}

button.group-item-equip {
  align-self: stretch;
  border-width: 0 0 0 1px;
  border-color: var(--line);
  padding: 0.4rem 0.65rem;
}

.group-item-included {
  align-self: center;
  padding: 0.4rem 0.65rem;
}

.option-group {
  border-top: 1px solid var(--line);
}

.option-group:first-child {
  border-top: 0;
}

.option-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.55rem 0.15rem;
  transition: color 120ms ease, background-color 120ms ease;
}

.option-group > summary:hover {
  color: var(--accent-dark);
  background: var(--panel);
}

.option-group[open] > summary {
  border-bottom: 1px solid var(--line);
}

.option-kind-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.15rem;
  transition: color 120ms ease, background-color 120ms ease;
}

.option-kind-details > summary > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-kind-count {
  flex: 0 0 auto;
}

.option-kind-details > summary:hover,
.reference-details summary:hover {
  color: var(--accent-dark);
  background: var(--panel);
}

.selected-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.item-chip {
  display: inline-flex;
  overflow: hidden;
  border-color: var(--line);
  border-style: solid;
  border-width: 1px;
  background: #efe3d3;
}

button.item-chip-details,
button.item-chip-remove {
  min-height: 2.4rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
}

button.item-chip-details {
  padding: 0.2rem 0.4rem;
}

button.item-chip-remove {
  min-width: 2.4rem;
  border-left: 1px solid var(--line);
  padding: 0.2rem 0.45rem;
  font-family: Arial, sans-serif;
  font-size: 1.05rem;
}

button.item-chip-details:hover:not(:disabled),
button.item-chip-remove:hover:not(:disabled) {
  background: var(--accent-dark);
  color: white;
}

.restriction-dot {
  color: var(--warn);
  font-size: 0.78rem;
  font-weight: 700;
}

.option-row {
  color: var(--muted);
}

.option-row input[type="checkbox"] {
  width: auto;
}

.profiles {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.reference-details {
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
}

.reference-details summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.2rem 0.15rem;
  transition: color 120ms ease, background-color 120ms ease;
}

.source-refs {
  display: grid;
  gap: 0.25rem;
  border-top: 1px solid var(--line);
  padding-top: 0.55rem;
}

.source-link {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.profile-table {
  width: 100%;
  border-collapse: collapse;
  background: #fffdfa;
}

.profile-table th,
.profile-table td {
  border: 1px solid var(--line);
  padding: 0.25rem 0.35rem;
  text-align: left;
}

.item-card-dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-width: none;
  max-height: calc(100vh - 1.5rem);
  max-height: calc(100dvh - 1.5rem);
  margin: auto;
  overflow: auto;
  border: 2px solid var(--ink);
  background: #fffdf8;
  color: var(--ink);
  padding: 0;
  box-shadow: 0 1rem 3rem rgb(23 23 23 / 35%);
}

.item-card-dialog::backdrop {
  background: rgb(23 23 23 / 58%);
}

.item-card {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding: clamp(1rem, 4vw, 1.6rem);
}

button.item-card-close {
  position: absolute;
  z-index: 1;
  top: 0.5rem;
  right: 0.5rem;
  display: grid;
  width: 2.4rem;
  min-height: 2.4rem;
  place-items: center;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 1.35rem;
}

button.item-card-close:hover:not(:disabled) {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: white;
}

.item-card-topline {
  display: flex;
  min-height: 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding-right: 2.55rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.item-card-category {
  color: var(--accent-dark);
}

.item-card-cost {
  flex: 0 0 auto;
}

.item-card-title {
  margin: 0;
  border-bottom: 4px solid var(--ink);
  padding-bottom: 0.45rem;
  font-size: clamp(1.55rem, 7vw, 2.35rem);
  line-height: 1;
}

.item-card-description {
  font-size: 1rem;
  line-height: 1.5;
}

.item-card-description p {
  margin: 0;
  white-space: pre-line;
}

.item-card-description p + p {
  margin-top: 0.75rem;
}

.item-card-profiles {
  overflow-x: auto;
}

.item-card-maximum {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.item-card-sources {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding-top: 0.45rem;
  font-size: 0.82rem;
}

.item-card-sources summary {
  cursor: pointer;
  font-weight: 700;
}

.item-card-sources .source-link {
  overflow-wrap: anywhere;
}

.item-card-footer {
  display: grid;
  gap: 0.8rem;
  border-top: 2px solid var(--ink);
  padding-top: 0.75rem;
}

.item-card-restrictions {
  text-align: center;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.35;
  text-transform: uppercase;
}

.item-card-equip {
  min-width: 6rem;
  justify-self: end;
}

.totals {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.composition-heading {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.1;
}

.composition-heading strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.composition-summary table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.composition-summary th,
.composition-summary td {
  padding: 0.08rem 0.25rem;
}

.composition-summary th {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composition-summary thead {
  color: var(--muted);
  font-size: 0.7rem;
}

.composition-summary thead th:not(:first-child),
.composition-summary td {
  text-align: right;
}

.composition-summary thead th:nth-child(2) {
  width: 4rem;
}

.composition-summary thead th:nth-child(3),
.composition-summary thead th:nth-child(4) {
  width: 5rem;
}

.composition-summary thead th:nth-child(5) {
  width: 5.5rem;
}

.composition-summary tbody tr + tr {
  border-top: 1px solid var(--line);
}

.composition-row-outside {
  background: #fff0f0;
  color: var(--bad);
}

.composition-status {
  display: inline-grid;
  width: 1em;
  height: 1em;
  place-items: center;
  margin-right: 0.15rem;
  border-radius: 50%;
  font-family: Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.composition-row-outside .composition-status {
  background: var(--bad);
  color: white;
}

.warnings {
  padding: 0.75rem 0.75rem 0;
}

.warning {
  border-left: 4px solid var(--warn);
  background: #fff5dc;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.45rem;
}

.warning.error {
  border-left-color: var(--bad);
  background: #fff0f0;
}

.print-view {
  display: none;
}

.attribution {
  color: var(--muted);
  padding: 1rem clamp(1rem, 3vw, 2rem) 2rem;
  font-size: 0.9rem;
}

/*
 * Links are the one interactive type the first pass missed. Source references
 * appear on cards over white and parchment, and the attribution sits on the
 * paper footer, so the hover has to read on all three: underline carries it
 * where colour alone would be marginal against the muted footer text.
 */
a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color 120ms ease, background-color 120ms ease;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

a:active {
  color: var(--accent-dark);
}

.attribution a {
  color: var(--accent-dark);
}

.attribution a:hover {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  button:active:not(:disabled) {
    transform: none;
  }
}

@media (max-width: 860px) {
  .roster-topline {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace-toolbar {
    position: sticky;
    z-index: 10;
    top: 0;
    gap: 0.2rem;
    padding: 0.25rem;
  }

  .workspace-toolbar-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 0.75rem;
    align-items: center;
  }

  .workspace-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button.workspace-tab {
    min-height: 2.4rem;
    border-color: var(--accent-dark);
    background: transparent;
    color: var(--accent-dark);
    padding: 0.35rem 0.75rem;
  }

  button.workspace-tab + button.workspace-tab {
    border-left: 0;
  }

  button.workspace-tab:hover:not(:disabled) {
    background: #efe3d3;
  }

  button.workspace-tab[aria-selected="true"] {
    background: var(--accent);
    color: white;
  }

  button.workspace-tab[aria-selected="true"]:hover:not(:disabled) {
    background: var(--accent-dark);
  }

  .totals {
    font-size: 0.9rem;
  }

  .add-feedback {
    display: block;
    height: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .add-feedback:not(:empty) {
    height: auto;
    margin-top: 0.35rem;
  }

  .unit-browser,
  .roster-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .workspace-panel-inactive {
    display: none;
  }

  .composition-summary table {
    font-size: 0.72rem;
  }

  .composition-summary th,
  .composition-summary td {
    padding: 0.05rem 0.15rem;
  }

  .composition-summary thead th:nth-child(2) {
    width: 2.4rem;
  }

  .composition-summary thead th:nth-child(3) {
    width: 3.2rem;
  }

  .composition-summary thead th:nth-child(4) {
    width: 3rem;
  }

  .composition-summary thead th:nth-child(5) {
    width: 4.2rem;
  }
}

@media (max-width: 600px) {
  .app-header {
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
  }

  .app-header > div:first-child {
    min-width: 0;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: clamp(0.95rem, 4vw, 1.05rem);
    line-height: 1.1;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 0.35rem;
  }

  .header-actions button,
  .unit-row button {
    min-height: 2.75rem;
  }

  .header-actions button {
    padding: 0.35rem 0.55rem;
  }

  .app-shell {
    padding: 0.55rem 0.75rem;
  }

  .controls {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(5.1rem, 0.75fr);
    gap: 0.4rem;
    margin-bottom: 0.55rem;
  }

  .controls label {
    min-width: 0;
    gap: 0.15rem;
    font-size: 0.7rem;
    line-height: 1.1;
  }

  .controls input,
  .controls select {
    min-width: 0;
    min-height: 2.75rem;
    padding: 0.4rem;
    font-size: 1rem;
  }

  .status:empty {
    min-height: 0;
    margin-bottom: 0;
  }

  .panel-heading {
    gap: 0.6rem;
    padding: 0.55rem;
  }

  .panel-heading input {
    min-height: 2.75rem;
  }

  .unit-list,
  .roster-list {
    padding: 0.55rem;
  }

  .category-block + .category-block {
    margin-top: 0.7rem;
  }

  .unit-row {
    gap: 0.5rem;
    padding: 0.35rem;
  }

  .unit-row + .unit-row {
    margin-top: 0.35rem;
  }

  .unit-row > div {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
    align-content: center;
    gap: 0.1rem 0.55rem;
  }

  .unit-row .unit-title {
    flex: 0 0 100%;
    line-height: 1.15;
  }

  .unit-row .meta {
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .unit-row .source-status {
    align-self: center;
    font-size: 0.68rem;
  }

  .unit-row button {
    align-self: center;
    padding: 0.35rem 0.65rem;
  }
}

@media (max-width: 340px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls label:first-child {
    grid-column: 1 / -1;
  }
}

@media print {
  body {
    background: white;
    color: black;
  }

  .no-print,
  .attribution {
    display: none !important;
  }

  .app-shell {
    padding: 0;
  }

  .status,
  .workspace {
    display: none;
  }

  .print-view {
    display: block;
  }

  .print-view h1 {
    font-size: 20pt;
    border-bottom: 2px solid black;
    padding-bottom: 0.25rem;
  }

  .print-summary,
  .print-unit,
  .print-warning {
    break-inside: avoid;
  }

  .print-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin: 0.6rem 0 1rem;
    font-size: 10pt;
  }

  .print-unit {
    border-top: 1px solid black;
    padding: 0.35rem 0;
    font-size: 10pt;
  }

  .print-unit strong {
    font-size: 11pt;
  }

  .print-warning {
    border: 1px solid black;
    padding: 0.25rem;
    margin: 0.25rem 0;
    font-size: 9pt;
  }
}
