/* Nomios web UI: the Done, Settings and Runs panels and the model choice of the Solve step (split from
   tasks.css and modal.css, which had reached their size limit). Design system: docs/design/DESIGN_SYSTEM.md. Its layer sits right after `tasks`, so
   the cascade is exactly what it was when these rules lived at the end of that file. */

@layer pages {
  /* --- The Done page: tabs, the lists and the typed confirmation of a deletion for good. --------- */
  .tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-block: var(--space-4);
  }

  .tab {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    color: var(--color-text);
    text-decoration: none;
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
  }

  .tab .count {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .tab.is-current {
    background: color-mix(in srgb, var(--color-accent) 22%, var(--glass-raised-bg));
    border-color: var(--color-accent);
  }

  .done-list {
    display: grid;
    gap: var(--space-3);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
  }

  .done-row {
    --project: var(--color-border-strong);
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-inline-start: 3px solid var(--project);
    border-radius: var(--radius-md);
  }

  .done-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2) var(--space-3);
    min-width: 0;
  }

  .done-main .note {
    flex: 1 1 100%;
    margin: 0;
  }

  .done-title {
    font-weight: 650;
    overflow-wrap: anywhere;
  }

  .done-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .done-actions form,
  .purge-form {
    margin: 0;
  }

  .purge-inline {
    flex: 1 1 100%;
  }

  .purge-inline > summary {
    display: inline-flex;
    cursor: pointer;
    list-style: none;
  }

  .purge-inline > summary::-webkit-details-marker {
    display: none;
  }

  .purge-form {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding: var(--space-4);
    background: color-mix(in srgb, var(--status-failed) 10%, var(--color-sunken));
    border: 1px solid color-mix(in srgb, var(--status-failed) 55%, transparent);
    border-radius: var(--radius-md);
  }

  .purge-form p {
    margin: 0;
  }

  .project-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: var(--space-3);
    align-items: end;
    margin-top: var(--space-3);
    padding: var(--space-4);
    background: var(--color-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .project-form input[type="color"] {
    width: 100%;
    height: 2.5rem;
    padding: 0.15rem;
  }

  .swatch {
    flex: none;
    width: 0.9rem;
    height: 0.9rem;
    align-self: center;
  }

  .new-project {
    margin-block: var(--space-4) var(--space-3);
  }

  /* Edit and Delete sit side by side; the one that is open takes the whole row for its form. */
  .done-actions > .purge-inline {
    flex: 0 1 auto;
  }

  .done-actions > .purge-inline[open] {
    flex: 1 1 100%;
  }

  /* --- The Settings page: read-only cards. -------------------------------------------------- */
  .settings-card {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .settings-card h2,
  .settings-card p {
    margin: 0;
  }

  /* A table that is wider than its card (longer words, a phone) scrolls inside it. */
  .table-scroll {
    overflow-x: auto;
    max-width: 100%;
  }

  .settings-table {
    width: 100%;
    border-collapse: collapse;
  }

  .settings-table caption {
    margin-bottom: var(--space-2);
    text-align: start;
    overflow-wrap: anywhere; /* a key such as [claude_profiles.<name>] must not widen the table */
  }

  .settings-table th,
  .settings-table td {
    padding: var(--space-2) var(--space-3);
    text-align: start;
    border-bottom: 1px solid var(--color-border);
  }

  .settings-table thead th {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
  }

  .settings-list,
  .settings-chips {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .settings-chips {
    grid-template-columns: repeat(auto-fill, minmax(6rem, max-content));
  }

  /* The TrackingTime card of Settings: a status dot and a word, never colour alone. */
  /* The Operations card: euros first, the dollars small behind them. */
  .ops-usd {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
  }

  /* The "Connect Claude Code" card: the manual steps and the settings block. */
  #connect-claude,
  .connect-manual,
  .connect-steps {
    min-width: 0;
  }

  .connect-manual {
    margin-top: var(--space-3);
  }

  .connect-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin: var(--space-3) 0 0;
    padding-inline-start: var(--space-5);
  }

  .connect-steps > li {
    min-width: 0;
  }

  .connect-steps p {
    margin: 0 0 var(--space-2);
  }

  .connect-code,
  .connect-snippet {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
  }

  .connect-snippet {
    max-width: 100%;
    margin: 0 0 var(--space-2);
    padding: var(--space-3);
    overflow-x: auto;
    white-space: pre;
    background: var(--color-column);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
  }

  .tt-state {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
  }

  .tt-state .dot {
    flex: none;
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 50%;
    background: var(--status-neutral);
  }

  .tt-connected .dot {
    background: var(--status-succeeded);
  }

  .tt-ended .dot {
    background: var(--status-awaiting);
  }

  /* One person's on/off switch: a label and a submit button that works without a script. ------ */
  .switch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    margin: 0;
  }

  .switch-row > span:first-of-type {
    flex: 1 1 16rem;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 600;
  }

  .switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 2.75rem;
    padding: var(--space-1) var(--space-4) var(--space-1) var(--space-2);
  }

  .switch-track {
    display: inline-flex;
    align-items: center;
    flex: none;
    width: 2.75rem;
    height: 1.5rem;
    padding: 2px;
    background: var(--color-sunken);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-pill);
  }

  .switch-thumb {
    width: 1.1rem;
    height: 1.1rem;
    background: var(--color-text-muted);
    border-radius: var(--radius-pill);
  }

  .switch.is-on .switch-track {
    background: var(--color-accent);
    border-color: var(--color-accent);
  }

  .switch.is-on .switch-thumb {
    transform: translateX(1.2rem);
    background: var(--color-accent-contrast);
  }

  .switch-state {
    min-width: 2.5ch;
    text-align: start;
  }

  @media (prefers-reduced-motion: no-preference) {
    .switch-track {
      transition: background-color var(--dur-fast) var(--ease-standard);
    }

    .switch-thumb {
      transition:
        transform var(--dur-fast) var(--ease-spring),
        background-color var(--dur-fast) var(--ease-standard);
    }
  }

  /* The panel measures itself: two columns only when it is wide enough for both, one otherwise
     (the width of the window is not the width of the panel: the sidebar and padding come off). */
  .new-run {
    container: new-run / inline-size;
  }

  .new-run-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4) var(--space-6);
  }

  @container new-run (min-width: 56rem) {
    .new-run-grid {
      grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    }
  }

  /* Orders: a table while the section is wide, one block per order when it is not. A word that
     cannot break (a file name) wraps anywhere instead of widening the table. */
  .orders {
    container: orders / inline-size;
    min-width: 0;
  }

  .orders th,
  .orders td {
    overflow-wrap: anywhere;
  }

  .orders td code,
  .orders .order-go button {
    white-space: nowrap;
  }

  @container orders (max-width: 40rem) {
    .orders thead {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0 0 0 0);
    }

    .orders table,
    .orders tbody,
    .orders th,
    .orders td {
      display: block;
    }

    .orders tr {
      display: grid;
      gap: var(--space-1);
      padding: var(--space-3) 0;
    }

    .orders tbody tr + tr {
      border-top: 1px solid var(--color-border);
    }

    .orders tbody tr + tr > * {
      border-top: 0;
    }

    .orders th,
    .orders td {
      padding: 0;
    }

    .orders td[data-label]::before {
      content: attr(data-label) ": ";
      color: var(--color-text-muted);
    }

    .orders .order-go {
      margin-top: var(--space-1);
    }
  }

  /* The model of a Solve: Claude (the standard) named in one line; the other models, with a search,
     behind one click. A row is a native radio with its label, hint, provider and price class. */
  .model-pick {
    display: grid;
    gap: var(--space-2);
  }

  .model-current {
    font-weight: 600;
  }

  .model-more > summary {
    display: inline-flex;
    cursor: pointer;
  }

  .model-search {
    display: grid;
    gap: var(--space-1);
    margin-block: var(--space-2);
  }

  .model-search label {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .model-list {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .model-list > legend {
    padding: 0;
    margin-bottom: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-muted);
  }

  /* A long list (hundreds of models) scrolls inside its own box, so the question and the Start
     button stay where they are; the wheel at its end does not carry on into the window. */
  .model-scroll {
    display: grid;
    gap: var(--space-3);
    max-height: min(24rem, 50dvh);
    padding-inline-end: var(--space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .model-group {
    display: grid;
    gap: var(--space-2);
  }

  .model-group[hidden],
  .model-row[hidden] {
    display: none;
  }

  .model-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }

  .model-row:has(input:checked) {
    border-color: var(--color-accent);
    background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  }

  .model-row:has(input:focus-visible) {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
  }

  .model-row input {
    margin-top: 0.2em;
  }

  .model-text {
    display: grid;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .model-name {
    font-weight: 600;
  }

  .model-hint,
  .model-meta {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .model-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
  }

  .model-price {
    letter-spacing: 0.05em;
    color: var(--color-text);
  }

  /* --- The Tools pages (U61): the list and the start form built from a tool's schema. ----------- */
  .tool-cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  @media (min-width: 48rem) {
    .tool-cards {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  .tool-card {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--glass-raised-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }

  .tool-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
  }

  .tool-card-name {
    margin: 0;
    font-size: var(--text-lg);
    overflow-wrap: anywhere;
  }

  .tool-card-hint,
  .tool-card-meta,
  .tool-card-actions {
    margin: 0;
  }

  .tool-card-hint {
    color: var(--color-text-muted);
  }

  .tool-ready {
    margin-inline-end: var(--space-2);
    font-weight: 600;
    color: var(--status-succeeded);
  }

  .tool-ready.is-busy {
    color: var(--status-awaiting);
  }

  .tool-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
  }

  .tool-form {
    display: grid;
    gap: var(--space-4);
    max-width: 40rem;
  }

  .tool-field {
    display: grid;
    gap: var(--space-2);
  }

  .tool-field.has-error input,
  .tool-field.has-error select {
    border-color: var(--status-failed);
  }

  .tool-group {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .tool-group legend {
    padding: 0;
    margin-bottom: var(--space-1);
  }

  .tool-hint {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .tool-choice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 2.75rem;
  }

  .tool-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
  }

  .tool-presets .btn {
    min-height: 2.75rem;
  }

  .tool-rules {
    display: grid;
    gap: var(--space-1);
    margin: 0;
    padding-inline-start: var(--space-5);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  .tool-live {
    min-height: 1.25rem;
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-link);
  }

  .tool-form .btn:disabled {
    color: var(--color-text-muted);
    background: var(--glass-raised-bg);
    border-color: var(--color-border-strong);
    cursor: not-allowed;
  }

  .tool-more {
    display: grid;
    gap: var(--space-3);
  }

  .tool-more summary {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
  }

  /* --- A tool run's progress and result files (U61 part 2b). ------------------------------------ */
  .tool-progress,
  .tool-results {
    display: grid;
    gap: var(--space-2);
  }

  .tool-progress-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2);
    margin: 0;
  }

  .tool-progress-percent {
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
  }

  .tool-progress-bar {
    width: 100%;
    max-width: 40rem;
    height: 0.75rem;
    accent-color: var(--color-accent);
  }

  .tool-upload-progress {
    width: 100%;
    max-width: 40rem;
    height: 0.75rem;
    accent-color: var(--color-accent);
  }

  .tool-upload-progress[hidden] {
    display: none;
  }

  .tool-field input[type="file"] {
    width: 100%;
    max-width: 40rem;
    padding: var(--space-2);
    color: var(--color-text);
    font: inherit;
  }

  .tool-field input[type="file"]::file-selector-button {
    margin-right: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--glass-raised-bg);
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
  }

  .tool-files {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .tool-file {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
  }

  .tool-file-name {
    font-weight: 600;
    overflow-wrap: anywhere;
  }
}

