/* carvel page — the main screen's columns, the middle head and More menu.
   The projects on the left, the middle column with its head (the Inbox tab and
   the log's name) over the page it picks, using the rest of the width; an
   opened Inbox row, the crew strip under a log's head, and the top bar's More
   menu. The seats are the rail's, so the head chooses no seat. The base rules
   are Classic's instrument; the Jolly Roger themes set the same parts below. */

/* Wider than a phone the Inbox, the Topics and the log share the middle
   column's cell; the log keeps its scroll and drafts under the other two. */
@media (min-width: 720px) {
  #shell > .page-view { position: relative; inset: auto; min-height: 0; }
  /* The desk picks its seat in the rail; the header's mount stays for the
     phone width, where the rail is off the screen. */
  #readout-controls #seat-switch,
  #more-merged-button { display: none; }
  /* The Inbox is the left half of the Helm's seat now, so the seat's chat shows
     beside it; the Topics page and the Fleet still take the whole column. */
  body:not([data-page="log"]) #shell:not([data-view="inbox"]):not([data-view="merged"]) > #readout { visibility: hidden; }
  /* The page's body grows, so the talk box sits at the column's foot. */
  body[data-page="inbox"] #inbox-page,
  body[data-page="topics"] #topics-page,
  body[data-page="scoreboard"] #scoreboard-page { display: flex; flex-direction: column; }
  #shell > .page-view > .page-body { flex: 1 0 auto; width: 100%; }
  /* The box fits the column it is in, at every width the Inbox can take: the
     text keeps the free column, the Send the smallest one, and the waiting line
     a row of its own above the two. */
  .talk {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "status status" "text send";
    align-items: center;
    column-gap: 0.75rem;
  }
  .talk > .talk-status { grid-area: status; }
  .talk > .talk-text { grid-area: text; }
  .talk-send { grid-area: send; align-self: stretch; min-width: 6rem; }
}

.tab:disabled { opacity: 0.5; cursor: default; }
/* The Reckoner's tab says its seat's state with a dot, so its word stays as
   short as its neighbours': running is the signal ink, ended the dim one, and
   a project with no reckoning yet has no dot at all. The rail's Reckoner row
   draws the same state as a lamp beside its word, so it carries no dot here. */
#seat-switch .tab[data-state]:not([data-state="empty"])::after {
  content: "";
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  margin-left: 0.375rem;
  border-radius: 50%;
  vertical-align: middle;
  background: var(--glow-dim);
}
#seat-switch .tab[data-state="running"]::after { background: var(--signal-green); }
/* The Reckoner's row: its name, then its state, which a wide screen shows
   here because the header keeps the role line for a screen reader. */
.seat-reckoner-state {
  font-size: var(--fs-11, 0.6875rem);
  font-variant-numeric: tabular-nums;
  color: var(--prose-dim);
}
#middle-logs { display: inline-flex; align-items: center; gap: 0.25rem; min-width: 0; margin-left: 0.25rem; }
#middle-logs:empty { display: none; }
/* An extension's item after the tabs (the Pause). It gives way before the
   tabs do, so the head stays one row. */
#middle-head-ext { display: inline-flex; align-items: center; flex: 0 1 auto; min-width: 0; margin-left: 0.5rem; }
#middle-head-ext[hidden] { display: none; }
#middle-head-ext > * { min-width: 0; }
#middle-head-ext .topbar-btn { max-width: 100%; }
#middle-head-ext .topbar-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.middle-log-name {
  display: inline-flex;
  align-items: baseline;
  gap: 0.375rem;
  min-width: 0;
  padding: 0 0.25rem 0 0.75rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 700;
  color: var(--signal-green);
}
.middle-log-word { font-weight: 400; color: var(--glow-dim); }
.middle-log-close { padding: 0.25rem 0.5rem; }
.middle-helm {
  height: 1.75rem;
  padding: 0 0.625rem;
  background: transparent;
  border: 1px solid var(--glow-line);
  border-radius: var(--radius, 0.25rem);
  font: inherit;
  font-size: 0.8125rem;
  color: var(--glow-dim);
  cursor: pointer;
}
.middle-helm[aria-pressed="true"] { color: var(--signal-green); border-color: var(--signal-green); }
.project .project-name { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project .project-running { margin-left: 0; }
.project-needs, .project-unread {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.project-needs { padding: 0 0.375rem; color: var(--signal-amber); font-weight: 700; border: 1px solid currentColor; }
.project-needs::before { content: ""; width: 0.5rem; height: 0.5rem; border: 2px solid currentColor; border-radius: 50%; }
.project-unread { color: inherit; }
@media (min-width: 701px) and (max-width: 900px) {
  #rail .project-unread, #rail .project-running { display: none; }
  #rail .project-needs { padding: 0 0.25rem; }
  #rail .project-needs::before { display: none; }
}
.project-unread::before { content: ""; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: currentColor; }

#topbar-more { display: inline-flex; flex: none; margin-left: auto; gap: 0.375rem; }
#topbar-more[hidden] { display: none; }
#topbar-more[aria-expanded="true"] { border-color: var(--signal-green); color: var(--signal-green); }
#topbar-more[hidden] ~ #settings-button { margin-left: auto; }
#topbar > #settings-button { margin-left: 0; }
#topbar-menu {
  right: 1rem;
  min-width: 15rem;
  max-height: calc(100dvh - 4rem);
  overflow-y: auto;
  padding: 0.375rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
}
#topbar-menu #topbar-ext { display: flex; flex-direction: column; align-items: stretch; gap: 0.25rem; margin: 0; }
#topbar-menu #topbar-ext[hidden] { display: none; }
#topbar-menu #topbar-ext > * { display: flex; gap: 0.25rem; }
#topbar-menu #topbar-ext > * > .topbar-btn { flex: 1 1 auto; width: auto; }
#topbar-menu #rigging-button { margin: 0; }
#topbar-menu .topbar-btn { min-height: 2.25rem; }
@media (max-width: 700px) {
  #topbar > #settings-button { display: inline-flex; height: 2.75rem; }
  #topbar-menu { right: 0.5rem; }
  #topbar-menu .topbar-btn { min-height: 2.75rem; }
}

.inbox-read { max-width: 46rem; margin: 0 auto; }
.inbox-read-kind { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.75rem; font-size: 0.8125rem; }
.inbox-read-title {
  margin: 0 0 0.75rem;
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
  color: var(--bone);
  outline: none;
}
.inbox-read-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0 0 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rope);
  font-size: 0.8125rem;
  color: var(--bone-3);
}
.inbox-read-meta .inbox-topic { padding: 0; background: none; border: 0; font: inherit; cursor: pointer; }
.inbox-read-body { max-width: 70ch; font-size: 1rem; line-height: 1.6; color: var(--bone); }
.inbox-read-detail { max-width: 70ch; margin: 0; font-size: 1rem; line-height: 1.6; color: var(--bone); text-wrap: pretty; }
.inbox-proofs { display: grid; gap: 1.5rem; margin-top: 1.5rem; }
.inbox-proof { margin: 0; }
.inbox-proof-open {
  display: block;
  width: 100%;
  padding: 0;
  background: var(--deck);
  border: 1px solid var(--rope);
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: zoom-in;
}
.inbox-proof-open img { display: block; width: 100%; height: auto; }
.inbox-proof-open:hover { border-color: var(--bone-3); }
.inbox-proof-name { margin-top: 0.5rem; font-family: var(--font-mono); font-size: 0.75rem; color: var(--bone-3); overflow-wrap: anywhere; }
.inbox-read .inbox-files { margin-top: 1.5rem; }

#readout-crew { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
#readout-crew[hidden] { display: none; }
.crew-strip-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 1rem; font-size: 0.8125rem; }
#readout-crew .crew-strip-line > :is(.node-host, .node-blocker, .node-outside, .node-overlap, .node-report, .node-check, .node-drop) {
  flex-basis: auto;
  order: 0;
  margin: 0;
  padding-left: 0;
  text-align: left;
  font-size: 0.8125rem;
}
#readout-crew .crew-strip-line > :is(.node-blocker, .node-outside) { display: inline; -webkit-line-clamp: unset; }
#readout-crew .crew-strip-line > .node-report { justify-content: flex-start; }
#readout-crew .node-overlap-files { position: absolute; z-index: 5; margin-top: 0.25rem; padding: 0.5rem 0.75rem; background: var(--enamel-black); border: 1px solid var(--glow-line); }
#readout-crew .node-overlap { position: relative; }
/* --- Helmsman tools launcher inside #readout-more-drawer (web/helm-tools.js) --- */

#readout-helm-tools {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

#readout-helm-tools[hidden] {
  display: none;
}

.ht-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
}

.ht-strip-label {
  flex: none;
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.71875rem);
  color: var(--text-3);
}

.ht-empty {
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.71875rem);
  color: var(--text-3);
}

.ht-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
}

.ht-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  padding: 0.1875rem 0.5625rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.75rem);
  line-height: 1.25;
  cursor: pointer;
  transition: background var(--t-fast, 110ms) var(--ease, ease),
              border-color var(--t-fast, 110ms) var(--ease, ease),
              color var(--t-fast, 110ms) var(--ease, ease);
}

.ht-pill:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

.ht-pill[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--text);
}

.ht-pill:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.ht-scope {
  display: inline-flex;
  align-items: center;
  padding: 0 0.3125rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.65625rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

.ht-scope-global {
  background: var(--surface-3);
  color: var(--text-2);
}

.ht-scope-project {
  background: var(--accent-soft);
  color: var(--accent);
}

.ht-form-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.75rem;
  border-radius: var(--r-md, 7px);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.ht-form-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.ht-form-title-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  min-width: 0;
}

.ht-form-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm, 0.8125rem);
  font-weight: 600;
  color: var(--text);
}

.ht-form-desc {
  flex: 1 0 100%;
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.75rem);
  line-height: 1.4;
  color: var(--text-2);
}

.ht-close-btn {
  flex: none;
  min-height: 1.5rem;
  padding: 0 0.375rem;
  font-size: var(--text-xs, 0.75rem);
}

.ht-form {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.ht-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: start;
}

.ht-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.ht-field-check {
  justify-content: flex-end;
  padding-top: 1.125rem;
}

.ht-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.71875rem);
  font-weight: 500;
  color: var(--text-2);
}

.ht-req {
  color: var(--bad);
  font-weight: 600;
}

.ht-input,
.ht-select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 1.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--r-sm, 5px);
  border: 1px solid var(--line-strong);
  background: var(--surface-1);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-sm, 0.8125rem);
}

.ht-input:focus-visible,
.ht-select:focus-visible,
.ht-checkbox:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.ht-check-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--text-sm, 0.8125rem);
  color: var(--text);
}

.ht-checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.ht-help {
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.71875rem);
  color: var(--text-3);
  line-height: 1.35;
}

.ht-meta-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem;
  gap: 0.5rem 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.ht-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ht-feedback {
  margin: 0;
  padding: 0.375rem 0.625rem;
  border-radius: var(--r-sm, 5px);
  font-family: var(--font-ui);
  font-size: var(--text-xs, 0.75rem);
  line-height: 1.4;
}

.ht-feedback[data-kind="ok"] {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid color-mix(in srgb, var(--ok) 32%, transparent);
}

.ht-feedback[data-kind="error"] {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 32%, transparent);
}

#readout-crew .node-processes { max-width: 40rem; margin: 0; }

html[data-skin="jolly"] {
  & .middle-log-name { color: var(--bone); }
  & .middle-log-word { color: var(--bone-3); }
  & .middle-helm { border-radius: 999px; border-color: var(--rope); color: var(--bone-2); }
  & .middle-helm[aria-pressed="true"] { color: var(--bone); background: var(--deck-3); }
  & .project-needs { color: var(--attn); font-size: 0.8125rem; border-color: color-mix(in srgb, var(--attn) 45%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--attn) 12%, transparent); }
  & #readout-crew .node-overlap-files { background: var(--deck-2); border-color: var(--rope); border-radius: 0.375rem; }
  & .project-unread { color: var(--bone-2); font-size: 0.8125rem; }
  & #topbar-menu { background: var(--deck-2); border-color: var(--rope); border-radius: 0.625rem; }
  & #topbar-more[aria-expanded="true"] { color: var(--bone); background: var(--deck-3); border-color: var(--rope); }
  & .order-reported { color: var(--attn); }
}

/* The owner's phone keeps its slim bar at the foot: the project picker, the
   Inbox and the conversation, with Settings and the terminal in the top bar.
   The Inbox page shows at the phone width and under a coarse pointer, as on
   the desk, because a row that waits for you is what the phone must tell. */
@media (max-width: 719px) {
  /* The phone picks its views in the bar at its foot, so the head stays off
     screen even when an extension draws a chip in it. */
  body #shell[data-view="chat"] > #readout { visibility: visible !important; }
  /* One 48 px thumb bar at the top of chat views: seat switch (or elided crew
     name), compact jobs pill, contextual + New / Stop, and ⋯ opening Model,
     Effort, Merged, session actions, Helm tools and past chats. */
  html[data-skin="jolly"] #readout { padding: 0.25rem 0.75rem 0.5rem; }
  html[data-skin="jolly"] #readout-header { gap: 0.375rem; padding-bottom: 0.375rem; }
  html[data-skin="jolly"] #readout-identity,
  #readout-identity {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.375rem;
    min-height: 48px;
    min-width: 0;
  }
  #readout-controls { display: contents; }
  #chat-lamp { order: 0; flex: none; }
  html[data-skin="jolly"] #chat-name,
  #chat-name {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
  }
  #seat-switch { order: 2; flex: none; margin-right: auto; }
  #seat-switch .tab {
    height: 2.25rem;
    padding: 0 0.5rem;
    font-size: var(--text-sm);
    white-space: nowrap;
  }
  html[data-skin="jolly"] #chat-status,
  #chat-status {
    order: 3;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.125rem 0.4375rem;
    font-size: var(--text-xs, 0.71875rem);
    letter-spacing: 0.02em;
  }
  #chat-status .run-timer { display: none; }
  #chat-jobs { order: 4; flex: 0 1 auto; min-width: 0; }
  #chat-jobs[data-short] { flex: none; }
  #stop-button { order: 5; flex: none; min-height: 2.75rem; padding: 0 0.5rem; white-space: nowrap; }
  #new-chat-button { order: 6; flex: none; min-height: 2.75rem; padding: 0 0.5rem; white-space: nowrap; }
  #actions-toggle {
    order: 8;
    flex: none;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0 0.5rem;
    font-size: 1.125rem;
    line-height: 1;
  }
  /* Seat views lead with the seat tabs; crew chats lead with lamp + elided name. */
  #readout-header:not([data-chat-kind="crew"]) #readout-identity:has(#seat-switch:not([hidden])) > :is(#chat-lamp, #chat-name) {
    display: none;
  }
  #readout-header[data-chat-kind="crew"] #seat-switch { display: none; }
  #chat-id { display: none; }
  #chat-status:not([data-state="running"]):not([data-state="dead"]) { display: none; }
  /* Contextual action slot: hide disabled Stop while idle so + New takes its place. */
  #stop-button:disabled { display: none !important; }

  body :is(#chat-role, #readout-git, #readout-git-links, #readout-ext,
    #past-chats:not(.is-viewing-past), #readout-summary, #readout-crew) { display: none !important; }
  body #readout-status > :is(#readout-meter, #readout-branch) { display: none !important; }
  /* The processes line is a press the owner must reach from the phone too, and
     folded it costs one line: the strip stays when it holds one. */
  body #readout-crew:has(.node-processes) { display: flex !important; }

  /* Model and Effort fold behind ⋯ while keeping any pending/refused #model-note visible. */
  #readout-status { flex-wrap: wrap; gap: 0.25rem 0.5rem; width: 100%; }
  #readout-model { flex: 1 1 100%; flex-wrap: nowrap; gap: 0.5rem; min-width: 0; }
  #readout-model .ctl { flex: 1 1 50%; min-width: 0; }
  #readout-model .ctl > span:first-child {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    flex: none;
  }
  #readout-model .header-pick { display: flex; flex: 1 1 auto; min-width: 0; }
  #readout-model #effort-ctl { flex: 0 1 auto; }
  #readout-model .order-picker { flex: 1 1 auto; min-width: 0; max-width: none; }
  #readout-model .order-picker > button {
    width: 100%;
    min-height: 2.75rem;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #readout-model .header-effort > button { max-width: none; }
  #model-note[data-kind="wait"]:not([hidden]) { display: block; }

  #readout-header:has(#actions-toggle[aria-expanded="false"]) > #readout-status:not(:has(#model-note:not([hidden]))) {
    display: none;
  }
  #readout-header:has(#actions-toggle[aria-expanded="false"]) #readout-model {
    display: none;
  }
  #readout-header:has(#actions-toggle[aria-expanded="false"]) > #readout-more-drawer {
    display: none !important;
  }
  #readout-header:has(#actions-toggle[aria-expanded="false"]) + #past-chats.is-viewing-past .past-chats-shelf {
    display: none;
  }

  body #readout-header:has(#actions-toggle[aria-expanded="true"]) > #readout-more-drawer {
    display: flex !important;
    max-height: calc(100dvh - 18rem);
    overflow-y: auto;
    padding-bottom: 0.5rem;
  }
  body #readout-header:has(#actions-toggle[aria-expanded="true"]) > #readout-more-drawer:has(.ht-form-card) {
    padding-bottom: 2rem;
  }
  body #readout-header:has(#actions-toggle[aria-expanded="true"]) #readout-actions:not([hidden]) {
    display: flex !important;
    flex-wrap: wrap;
  }
  #readout-actions .btn { min-height: 2.75rem; padding: 0 0.625rem; }
  body #readout-header:has(#actions-toggle[aria-expanded="true"]) + #past-chats:not(:empty) {
    display: flex !important;
    max-height: 10rem;
    overflow-y: auto;
    flex: none;
  }

  .ht-fields,
  .ht-meta-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .ht-field-check {
    padding-top: 0.25rem;
  }
  .ht-input,
  .ht-select {
    min-height: 2.5rem;
    font-size: 0.9375rem;
  }
  .ht-actions .btn {
    min-height: 2.5rem;
  }
  #topbar > :is(#wordmark, #connection, #reports-pill, #relaunch-line, #binary-line, #wordmark-lamp) { display: none !important; }
  #topbar-more { margin-left: auto; }
  #topbar-ext > :not([data-panel-opener="terminal"]) { display: none !important; }
  #rigging-button { display: none !important; }
}
@media (max-width: 360px) {
  html[data-skin="jolly"] #readout { padding-inline: 0.5rem; }
  html[data-skin="jolly"] #readout-identity,
  #readout-identity { gap: 0.25rem; }
  #seat-switch .tab { padding: 0 0.375rem; font-size: var(--text-xs, 0.71875rem); }
  #stop-button, #new-chat-button { padding: 0 0.375rem; font-size: var(--text-sm); }
}
@media (pointer: coarse) {
  /* A wide touch screen keeps the middle head: it is where the Inbox and the
     Helm log are picked, and the bar at the foot belongs to the phone width. */
  body:not([data-page="log"]) #shell > #readout { visibility: visible; }
  #topbar > :is(#wordmark, #connection, #reports-pill, #relaunch-line, #binary-line, #wordmark-lamp) { display: none !important; }
  #topbar-ext > :not([data-panel-opener="terminal"]) { display: none !important; }
  #rigging-button { display: none !important; }
}

/* Settings — Models: the one home of a saved model (web/app-settings.js).
   A group names itself and says what it is for in one line, then one row per
   thing a model is saved for: its name and purpose at the left, its control at
   the right. No card sits inside the sheet's card (The sheet is one sheet):
   a project is told apart by space and a hairline, as the rest of Settings is. */
.settings-models-machine,
.settings-models-projects { display: flex; flex-direction: column; gap: 0.75rem; }
.settings-models-projects {
  gap: 0.25rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--glow-line);
}
.settings-models-group { display: flex; flex-direction: column; gap: 0.125rem; }
.settings-models-group-name {
  margin: 0;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  color: var(--paper-white);
}
.settings-models-note {
  margin: 0;
  max-width: 68ch;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.45;
  color: var(--glow-dim);
}

/* The machine's list: 155 models is a column, not a page, so the boxes live in
   a bounded field that scrolls, with the count and the save under it. A save
   keeps the button's own width, as every other Save on the sheet does. */
.settings-models-machine .helmsman-lines > .btn,
.settings-models-control .helmsman-lines > .btn,
#settings-crews .helmsman-lines > .btn { align-self: flex-start; }
.settings-field-hint {
  margin: 0;
  max-width: 68ch;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.45;
  color: var(--glow-dim);
}
#settings-models textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: var(--fs-12, 0.75rem);
}
.settings-models-control .model-rules { gap: 0.375rem; }
#settings-models .settings-used-models { display: flex; flex-direction: column; gap: 0.5rem; }
#settings-models .settings-used-models #settings-used-models {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.25rem 1rem;
  max-height: 17rem;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--glow-line);
  background: var(--ink-04);
}
#settings-models .settings-used-model { align-items: start; gap: 0.5rem; }
#settings-models .settings-used-model-spec {
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-dim);
  overflow-wrap: anywhere;
}

/* A project is one group: its name, a hairline, then its rows. */
.settings-models-list { display: flex; flex-direction: column; }
.settings-models-project {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.875rem 0 0.375rem;
  border-top: 1px solid var(--glow-line);
  border-radius: 6px;
}
.settings-models-project:first-child { border-top: 0; }
.settings-models-project-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.125rem 0.625rem; }
.settings-models-project-name {
  margin: 0;
  font-family: var(--font-label);
  font-size: var(--fs-13, 0.8125rem);
  font-weight: 700;
  color: var(--paper-white);
  overflow-wrap: anywhere;
}
.settings-models-project-name:focus-visible { outline: 1px solid var(--signal-green); outline-offset: 2px; }
.settings-models-project-path {
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-faint);
  overflow-wrap: anywhere;
}

.settings-models-row { display: flex; flex-direction: column; gap: 0.375rem; }
.settings-models-what { display: flex; flex-direction: column; gap: 0.125rem; }
.settings-models-row-name {
  margin: 0;
  font-family: var(--font-label);
  font-size: var(--fs-10, 0.625rem);
  letter-spacing: var(--track, 0.1em);
  color: var(--prose-dim);
  text-transform: var(--caps, uppercase);
}
.settings-models-for {
  margin: 0;
  max-width: 44ch;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.45;
  color: var(--glow-dim);
}
.settings-models-control { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
/* The row names the field, so the control's own label is kept for a screen
   reader and not read twice: two names for one field is what the owner saw. */
.settings-models-control .field-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The saved list as chips: the first ticked model is the fallback a lite order
   starts on, so it says the word "default" instead of wearing a colour. */
.settings-models-lite { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-model-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.settings-model-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  max-width: 100%;
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--rope);
  border-radius: 999px;
  background: var(--ink-04);
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  line-height: 1.6;
  color: var(--prose-dim);
  overflow-wrap: anywhere;
  transition: border-color 160ms ease-out, background-color 160ms ease-out, color 160ms ease-out;
}
.settings-model-chip:hover { border-color: var(--glow-line); background: var(--ink-08); color: var(--bone-2); }
.settings-model-chip.is-default { border-color: color-mix(in srgb, var(--bone) 50%, var(--rope)); background: var(--ink-08); color: var(--bone); }
.settings-model-mark {
  padding-left: 0.375rem;
  border-left: 1px solid color-mix(in srgb, var(--bone) 25%, transparent);
  font-family: var(--font-label);
  font-size: var(--fs-9, 0.5625rem);
  letter-spacing: var(--track, 0.1em);
  text-transform: var(--caps, uppercase);
  color: var(--prose-faint);
}
.settings-model-more {
  padding: 0.125rem 0.5rem;
  border: 1px dashed var(--rope);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-faint);
  cursor: help;
}
.settings-model-none {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border: 1px dashed var(--rope);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: var(--fs-11, 0.6875rem);
  color: var(--prose-faint);
}
/* The empty state names the server's own default, so an unset list is not a
   blank and not a guess. */
.settings-model-fallback {
  max-width: 52ch;
  font-family: var(--font-sans);
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.45;
  color: var(--glow-dim);
}

.settings-models-choose { display: flex; flex-direction: column; align-items: flex-start; }
.settings-models-choose > summary {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.75rem;
  padding: 0.125rem 0.625rem 0.125rem 0.375rem;
  border: 1px solid var(--rope);
  border-radius: 6px;
  font-family: var(--font-label);
  font-size: var(--fs-12, 0.75rem);
  color: var(--bone-2);
  cursor: pointer;
  list-style: none;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out;
}
.settings-models-choose > summary::-webkit-details-marker { display: none; }
.settings-models-choose > summary::before {
  content: "▸";
  display: inline-block;
  color: var(--prose-dim);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
.settings-models-choose[open] > summary::before { transform: rotate(90deg); }
.settings-models-choose > summary:hover { border-color: var(--glow-line); background: var(--ink-08); color: var(--bone); }
.settings-models-choose > summary:focus-visible { outline: 1px solid var(--signal-green); outline-offset: 2px; }
.settings-models-slot { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; padding-top: 0.625rem; }
.settings-models-slot .ap-models-settings { display: flex; flex-direction: column; gap: 0.5rem; }

/* One authored moment: the group a Projects press sent the owner to takes a
   ring that settles, so the eye lands where the press pointed. */
@keyframes settings-model-land {
  from { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bone) 22%, transparent); }
  to { box-shadow: inset 0 0 0 1px transparent; }
}
.settings-models-project.is-target { animation: settings-model-land 900ms cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* The Projects block's echo: what is saved for this project, and the way to
   the one place it is saved. Read-only, so it wears no field's shape. */
.settings-project-models { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.settings-project-models-line {
  margin: 0;
  max-width: 60ch;
  font-size: var(--fs-12, 0.75rem);
  line-height: 1.45;
  color: var(--glow-dim);
}

/* Wide: the purpose sits beside its control, so a project reads down its two
   columns and the eye never crosses a full line of prose to reach a field. */
@container settings (min-width: 40rem) {
  .settings-models-row {
    display: grid;
    grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr);
    align-items: start;
    gap: 0.25rem 2rem;
  }
  .settings-models-row + .settings-models-row { padding-top: 0.375rem; }
}

@media (max-width: 700px) {
  #settings-models .btn, .settings-project-models .btn { min-height: 44px; }
  .settings-models-choose > summary { min-height: 44px; }
  #settings-models textarea { min-height: 5.5rem; }
  #settings-models .settings-used-models #settings-used-models { grid-template-columns: minmax(0, 1fr); max-height: 15rem; }
  .settings-models-project { padding-top: 0.75rem; }
  .settings-models-control .settings-review-model .settings-review-input { flex-basis: 100%; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .settings-models-project.is-target {
    animation: none;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bone) 22%, transparent);
  }
  .settings-models-choose > summary::before,
  .settings-model-chip,
  .settings-models-choose > summary { transition: none; }
}
