  /* Header actions share one geometry, including Download links. */
  .popup-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
  .popup-header > button, .doc-dialog-head > button, .popup-header-actions > button, .popup-header-actions > a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 112px; height: 40px; min-height: 40px; box-sizing: border-box;
    padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
    font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  }
  .popup-header > button:focus-visible, .doc-dialog-head > button:focus-visible,
  .popup-header-actions > button:focus-visible, .popup-header-actions > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .ask-dialog.ask-one-line .popup-header > button:focus-visible { outline-color: var(--text); }   /* Sign out's Close: black, not green (the owner's ask; white in dark mode) */
  @media (pointer: coarse) {
    .popup-header > button, .doc-dialog-head > button, .popup-header-actions > button, .popup-header-actions > a { min-height: 44px; height: 44px; }
  }
  @media (max-width: 480px) {
    #docview-title { flex-basis: 100%; }
    .popup-header-actions { justify-content: flex-end; width: 100%; }
  }

  /* Audit fixes: headers remain visible, media tabs cannot resize the frame. */
  .popup-header, .doc-dialog-head { flex-wrap: wrap; }
  .popup-header > .panel-title, .doc-dialog-head > b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
  .doc-dialog-head > button { margin-left: auto; flex-shrink: 0; }
  #folder-upload-dialog[open] { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
  #folder-upload-dialog > .popup-header, #folder-upload-submit { flex-shrink: 0; }
  #folder-upload-dialog > .popup-content { min-height: 0; overflow-y: auto; }
  .popup-header-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
  @media (pointer: coarse) {
    .popup-small button, .popup-medium button, .popup-large button { min-height: 44px; }
    #folder-upload-dialog #folder-upload-close, #folder-upload-dialog #folder-upload-choose,
    #folder-upload-dialog #folder-upload-submit { height: 44px; min-height: 44px; }
  }
  .ask-dialog.popup-danger { border-top: 4px solid var(--error); }
  .popup-danger .popup-header .panel-title { color: var(--error); }
  .popup-danger .popup-message-body p { white-space: pre-line; }

  /* Popup action colours follow meaning in both themes. */
  :root { --popup-action-green: #147d64; --popup-action-blue: #2563eb; --popup-action-red: #b42318; }
  .popup-small .btn-primary, .popup-medium .btn-primary, .popup-large .btn-primary,
  .ask-dialog .ask-actions button:not(.ghost):not(.danger) {
    background: var(--popup-action-green); border-color: var(--popup-action-green); color: #fff;
  }
  .popup-small .btn-danger-solid, .popup-medium .btn-danger-solid, .popup-large .btn-danger-solid,
  .ask-dialog .ask-actions button.danger, .danger-dialog button.danger {
    background: var(--popup-action-red); border-color: var(--popup-action-red); color: #fff;
  }
  .popup-small .btn-danger, .popup-medium .btn-danger, .popup-large .btn-danger {
    background: var(--surface); border-color: var(--popup-action-red); color: var(--popup-action-red);
  }
  #folder-upload-dialog #folder-upload-choose {
    background: var(--popup-action-blue); border-color: var(--popup-action-blue); color: #fff;
  }
  #folder-upload-dialog #folder-upload-submit {
    background: var(--popup-action-green); border-color: var(--popup-action-green); color: #fff;
  }
  .popup-small .btn-ghost:not(.btn-danger), .popup-medium .btn-ghost:not(.btn-danger),
  .popup-large .btn-ghost:not(.btn-danger), .popup-small button.ghost, .popup-medium button.ghost {
    background: var(--surface); border-color: var(--border); color: var(--text);
  }
  .popup-small .btn-primary:hover:not(:disabled), .popup-medium .btn-primary:hover:not(:disabled),
  .popup-large .btn-primary:hover:not(:disabled), .ask-dialog .ask-actions button:hover:not(:disabled),
  .danger-dialog button.danger:hover:not(:disabled) { filter: brightness(.9); }

  /* My folder reserves a stable desktop card; only its list changes height. */
  @media (min-width: 761px) {
    [data-panel="folder"] > .panel { height: 780px; box-sizing: border-box; display: flex; flex-direction: column; }
    [data-panel="folder"] > .panel > :not(#folder-list) { flex-shrink: 0; }
    [data-panel="folder"] #folder-list { flex: 0 1 auto; min-height: 0; max-height: 416px; }
    [data-panel="folder"] #folder-bulk { min-height: 48px; box-sizing: border-box; }
    [data-panel="folder"] #folder-bulk[hidden] { display: none !important; }
  }
  #folder-upload, #mydocs-upload {
    background: var(--popup-action-green); border-color: var(--popup-action-green); color: #fff;
  }
  #folder-bulk-delete, #mydocs-delete-all, #mydrafts-delete-all {
    background: var(--surface); border-color: var(--popup-action-red); color: var(--popup-action-red);
  }
  #folder-bulk-delete:hover:not(:disabled), #mydocs-delete-all:hover:not(:disabled), #mydrafts-delete-all:hover:not(:disabled) {
    background: var(--popup-action-red); color: #fff;
  }

  /* Management submenu actions are neutral; deletion stays red. */
  .mydocs-actions { justify-content: flex-end; }
  [data-panel="mydocs"] #mydocs-upload,
  [data-panel="mydocs"] .back-to-folder,
  [data-panel="mydocs"] .doc-open {
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; font-size: 13px; min-height: 36px; padding: 0 12px;
    display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  }
  .back-to-folder { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 7px 12px; border-radius: 8px; text-decoration: none; }
  #mydocs-slot .doc-row .status {
    width: 112px; min-height: 36px; box-sizing: border-box; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    text-align: center; font-size: 12px; border-radius: 8px; flex-shrink: 0;
  }
  [data-panel="mydocs"] .doc-open { width: 128px; box-sizing: border-box; }
  #mydocs-slot .doc-title-status { align-items: center; }

  #mydocs-slot .doc-row .doc-delete {
    min-height: 36px; padding: 0 12px; border: 1px solid var(--popup-action-red);
    border-radius: 8px; background: var(--surface); color: var(--popup-action-red);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
  }
  #mydocs-slot .doc-row .doc-delete:hover:not(:disabled) { background: var(--popup-action-red); color: #fff; }

  #folder-list .btn-danger { border-color: var(--popup-action-red); color: var(--popup-action-red); background: var(--surface); }
  #folder-list .btn-danger:hover:not(:disabled) { background: var(--popup-action-red); color: #fff; }
  #mydocs-slot .doc-action-placeholder { display: block; width: 128px; }

  /* Status belongs to its own column, centred with the row actions. */
  #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr) 128px 128px auto; align-items: center; }
  #mydocs-slot .doc-row .status, #mydocs-slot .doc-row .doc-open {
    width: 128px; height: 36px; min-height: 36px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; text-align: center;
    margin: 0; padding: 0 8px; line-height: normal;
  }
  @media (max-width: 640px) {
    #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr) auto; }
    #mydocs-slot .doc-row.in-mydocs > .status { grid-column: 2; }
    #mydocs-slot .doc-row.in-mydocs > .doc-open,
    #mydocs-slot .doc-row.in-mydocs > .doc-action-placeholder { grid-column: 2; }
    #mydocs-slot .doc-row.in-mydocs > .doc-delete { grid-column: 3; }
  }
  .mydocs-legend { background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
  .mydocs-legend p { margin: 4px 0; }
  #mydocs-slot .doc-row .status { font-size: 11.5px; white-space: normal; }
  .artifact-legend-toggle .arr, .mydocs-legend-toggle .arr { color: #5b80ef; margin-left: 6px; }

  /* Compact artifact row actions; headers and popup actions keep their sizing. */
  #folder-list .folder-row .acts > button,
  [data-panel="chats"] .mine-row .acts > button,
  [data-panel="speeches"] .mine-row .acts > button,
  #gallery-grid .gallery-card .acts > button,
  #drafts-body .draft-acts > button,
  #mydocs-slot .doc-row .doc-open,
  #mydocs-slot .doc-row .doc-delete {
    width: auto; min-width: 0; height: 32px; min-height: 32px;
    padding: 0 10px; font-size: 12px; line-height: normal;
    box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  }
  #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr) 128px auto auto; }
  @media (max-width: 640px) {
    #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr) auto; }
  }
  @media (pointer: coarse) {
    #folder-list .folder-row .acts > button,
    [data-panel="chats"] .mine-row .acts > button,
    [data-panel="speeches"] .mine-row .acts > button,
    #gallery-grid .gallery-card .acts > button,
    #drafts-body .draft-acts > button,
    #mydocs-slot .doc-row .doc-open,
    #mydocs-slot .doc-row .doc-delete { height: 44px; min-height: 44px; }
  }

  /* Row actions stay at the right edge; row sizing never targets headers. */
  #folder-list .folder-row .acts,
  [data-panel="chats"] .mine-row .acts,
  [data-panel="speeches"] .mine-row .acts,
  #gallery-grid .gallery-card .acts,
  #drafts-body .draft-row .draft-acts {
    justify-content: flex-end; align-items: flex-end; justify-self: end;
  }
  #mydocs-slot .doc-row .doc-open,
  #mydocs-slot .doc-row .doc-delete { justify-self: end; }

  #drafts-body .draft-acts { flex-direction: row; flex-wrap: wrap; align-content: center; }
  /* Artifact menus are neutral; deletion is the only caution colour. */
  #folder-upload { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
  #folder-list .folder-row .acts > button,
  [data-panel="chats"] .mine-row .acts > button,
  [data-panel="speeches"] .mine-row .acts > button,
  #drafts-body .draft-acts > button,
  #mydocs-slot .doc-row .doc-open,
  #mydocs-slot .doc-row .doc-delete { width: 100px; min-width: 100px; }
  [data-panel="chats"] .mine-row .acts > .btn-danger,
  [data-panel="speeches"] .mine-row .acts > .btn-danger,
  #drafts-body .draft-acts > .btn-danger { color: var(--popup-action-red); border-color: var(--popup-action-red); background: var(--surface); }
  #mydocs-slot .doc-row .status {
    background: transparent; border: 0; border-radius: 0; color: var(--text-muted);
    font-weight: 500; height: auto; min-height: 0;
  }
  #mydocs-slot .doc-row .status.pending { color: #805900; }
  #mydocs-slot .doc-row .status.approved { color: var(--accent); }
  #mydocs-slot .doc-row .status.rejected { color: var(--popup-action-red); }

  #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr) 128px auto; }
  #mydocs-slot .doc-acts, #gallery-grid .gallery-card .acts {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center;
  }
  #mydocs-slot .doc-acts { max-width: 530px; justify-self: end; }
  #mydocs-slot .doc-acts > button, #gallery-grid .gallery-card .acts > button {
    width: 100px; min-width: 100px; height: 32px; min-height: 32px; padding: 0 10px;
    font-size: 12px; box-sizing: border-box;
  }
  #mydocs-slot .doc-acts > .btn-danger, #gallery-grid .gallery-card .acts > .btn-danger {
    color: var(--popup-action-red); border-color: var(--popup-action-red); background: var(--surface);
  }
  @media (max-width: 1000px) {
    #mydocs-slot .doc-row.in-mydocs { grid-template-columns: auto minmax(0, 1fr); }
    #mydocs-slot .doc-row.in-mydocs > .status, #mydocs-slot .doc-row.in-mydocs > .doc-acts { grid-column: 2; justify-self: end; }
  }
  @media (pointer: coarse) {
    #mydocs-slot .doc-acts > button, #gallery-grid .gallery-card .acts > button { height: 44px; min-height: 44px; }
  }

  /* Image cards reserve space for the two compact actions on one line. */
  #gallery-grid.gallery-grid.large { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }
  #gallery-grid .gallery-card .acts { flex-wrap: nowrap; flex-direction: row; }

  /* Artifact management selection menus use the shared neutral surface. */
  [data-panel="gallery"] .gallery-selbar,
  [data-panel="mydocs"] .gallery-selbar,
  [data-panel="chats"] .gallery-selbar,
  [data-panel="speeches"] .gallery-selbar {
    background: var(--surface-alt); color: var(--text-muted);
  }
  .gallery-selbar span { color: var(--text-muted); }
  .gallery-selbar > button, #gallery-clear-date, #gallery-more {
    min-height: 36px; padding: 0 12px; font-size: 13px; box-sizing: border-box;
    border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  }
  .gallery-selbar > button { min-width: 128px; }
  .gallery-selbar > .btn-ghost {
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
  }
  .gallery-selbar > .btn-danger-solid {
    background: var(--surface); color: var(--popup-action-red); border: 1px solid var(--popup-action-red);
  }
  .gallery-selbar > .btn-danger-solid:hover:not(:disabled) {
    background: var(--popup-action-red); color: #fff;
  }
  @media (pointer: coarse) {
    .gallery-selbar > button, #gallery-clear-date, #gallery-more { min-height: 44px; }
  }

  /* My images uses icon-sized previews rather than large image tiles. */
  #gallery-grid.gallery-grid.large { grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); }
  #gallery-grid .gallery-card { align-items: flex-end; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
  #gallery-grid .gallery-card .thumb { width: 64px; height: 64px; align-self: center; flex: none; }
  #gallery-grid .gallery-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
  /* The preview name and details follow the image; actions form its footer. */
  #image-viewer .viewer-box.popup-large {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  }
  #image-viewer .viewer-side { overflow: visible; max-height: none; gap: 6px; }
  #image-viewer .viewer-prompt { margin: 0; }
  #image-viewer #viewer-meta { margin: 0; }
  #image-viewer .viewer-actions { justify-content: flex-end; margin-top: 8px; }
  #image-viewer .viewer-actions > button {
    width: 112px; min-width: 112px; height: 40px; min-height: 40px;
    padding: 0 12px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  }
  @media (pointer: coarse) { #image-viewer .viewer-actions > button { height: 44px; min-height: 44px; } }

  .artifact-management { min-height: 680px; }
  .artifact-management > .result-head { display:flex; align-items:center; gap:8px; }
  .artifact-menu { display:flex; justify-content:flex-end; gap:8px; padding:8px 12px; background:var(--surface-alt); border-radius:10px; margin:12px 0; }
  .artifact-management .artifact-menu button { min-height:36px; padding:0 12px; background:var(--surface); color:var(--text); border:1px solid var(--border); }
  .artifact-management .btn-danger { color:var(--popup-action-red); border-color:var(--popup-action-red); }
  .artifact-management > input[type="search"] { width:100%; margin:0 0 10px; }
  .artifact-date { display:flex; align-items:end; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
  .artifact-date label { display:flex; flex-direction:column; gap:4px; }
  .artifact-selection { display:flex; align-items:center; justify-content:space-between; padding:8px 0; }
  .artifact-rows { max-height:416px; overflow:auto; }
  .artifact-row { display:grid; grid-template-columns:auto minmax(0,1fr) 128px auto; align-items:center; gap:10px; padding:9px 10px; border:1px solid var(--border); background:var(--surface-alt); min-height:52px; box-sizing:border-box; }
  .artifact-name { min-width:0; } .artifact-name > div:first-child { font-weight:600; overflow-wrap:anywhere; }
  .artifact-state { text-align:center; font-size:12px; color:var(--text-muted); }
  .artifact-actions { display:flex; gap:6px; justify-content:flex-end; }
  .artifact-actions > button { width:100px; height:32px; min-height:32px; padding:0 10px; font-size:12px; }
  .artifact-preview-title { font-size:16px; font-weight:600; overflow-wrap:anywhere; }
  .artifact-preview { display:flex; flex-direction:column; gap:12px; }
  .artifact-preview:not([open]) { display:none; }
  .artifact-preview > .hint { margin:0; flex:none; }
  .artifact-preview-menu { display:flex; align-items:center; gap:6px; min-height:40px; flex:none; }
  .artifact-preview-menu > button { height:40px; padding:0 14px; }
  .artifact-preview-menu > button.active { background:var(--accent-soft); border-color:var(--accent); }
  .artifact-preview-content { flex:1; min-height:0; overflow:auto; border:1px solid var(--border); border-radius:10px; padding:12px; }
  .artifact-preview-content iframe { width:100%; height:100%; min-height:350px; border:0; }
  .artifact-preview-content img { display:block; max-width:100%; max-height:100%; object-fit:contain; margin:auto; }
  @media(max-width:760px) { .artifact-row { grid-template-columns:auto minmax(0,1fr); } .artifact-state,.artifact-actions { grid-column:2; justify-self:end; } .artifact-actions { flex-wrap:wrap; } }
  @media(pointer:coarse) { .artifact-actions > button { height:44px; min-height:44px; } }

  #folder-list .folder-row[data-type="video"], #folder-list .folder-row[data-type="image"] { grid-template-columns: 52px 36px minmax(0,1fr) auto; }
  #folder-list .folder-thumbnail { width:36px; height:36px; padding:0; border:1px solid var(--border); border-radius:6px; overflow:hidden; background:var(--surface-alt); cursor:pointer; }
  #folder-list .folder-thumbnail img { width:100%; height:100%; object-fit:cover; display:block; }
  @media(max-width:760px) { #folder-list .folder-row[data-type="video"], #folder-list .folder-row[data-type="image"] { grid-template-columns:44px 36px minmax(0,1fr); } }

  .artifact-row[data-type="video"], .artifact-row[data-type="image"] { grid-template-columns:auto 36px minmax(0,1fr) 128px auto; }
  .artifact-thumbnail { width:36px; height:36px; padding:0; border:1px solid var(--border); border-radius:6px; overflow:hidden; background:var(--surface-alt); cursor:pointer; }
  .artifact-thumbnail img { width:100%; height:100%; object-fit:cover; display:block; }
  @media(max-width:760px) {
    .artifact-row[data-type="video"], .artifact-row[data-type="image"] { grid-template-columns:auto 36px minmax(0,1fr); }
    .artifact-row[data-type="video"] .artifact-state, .artifact-row[data-type="video"] .artifact-actions, .artifact-row[data-type="image"] .artifact-state, .artifact-row[data-type="image"] .artifact-actions { grid-column:3; }
  }

  /* One shared search row: name first, inclusive date range second. */
  .artifact-search-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; align-items:end; margin:12px 0; }
  .artifact-name-search { display:flex; flex-direction:column; gap:6px; min-width:0; font-size:13px; }
  .artifact-name-search input { width:100%; min-width:0; box-sizing:border-box; height:40px; }
  .artifact-search-row .artifact-date { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto; gap:8px; margin:0; align-items:end; }
  .artifact-search-row .artifact-date label { min-width:0; gap:6px; font-size:12px; }
  .artifact-search-row .artifact-date input { min-width:0; width:100%; height:40px; box-sizing:border-box; padding:0 6px; }
  .artifact-search-row .artifact-date button { height:40px; min-height:40px; padding:0 10px; white-space:nowrap; }
  @media(max-width:1000px) { .artifact-search-row { grid-template-columns:minmax(0,1fr); } }
  @media(max-width:440px) { .artifact-search-row .artifact-date { grid-template-columns:minmax(0,1fr) minmax(0,1fr); } .artifact-search-row .artifact-date button { grid-column:1 / -1; justify-self:end; } }

  .artifact-heading { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; min-width:0; }
  .artifact-heading > .panel-title { margin:0; flex:none; }
  .artifact-heading > .hint { margin:0; font-size:12px; font-weight:400; }
  .artifact-management > .result-head { margin-bottom:8px; flex-wrap:wrap; }
  .artifact-management > .artifact-menu { margin-top:0; }
  @media(max-width:760px) { .artifact-heading { flex:1 1 100%; } }

  /* Denser management rows without shrinking text, thumbnails or controls. */
  .artifact-row { padding:5px 10px; min-height:46px; }
  .artifact-rows .artifact-row + .artifact-row { border-top:0; }
  @media(pointer:coarse) { .artifact-row { min-height:54px; } }

  /* Folder management uses the exact service Legend presentation. */
  .artifact-management .legend-toggle,
  .result-head .artifact-legend-toggle,
  .result-head .mydocs-legend-toggle {
    display:inline-flex; align-items:center; gap:6px;
    border:1px solid var(--border); background:var(--surface-alt); color:var(--text-muted);
    border-radius:8px; padding:6px 10px; font-size:12px; font-weight:400;
    text-decoration:none; min-height:0; height:auto; width:auto;
  }
  .artifact-management .legend-toggle:hover,
  .result-head .artifact-legend-toggle:hover,
  .result-head .mydocs-legend-toggle:hover { border-color:var(--border-strong); color:var(--text); }
  .artifact-management .legend-toggle .arr,
  .result-head .artifact-legend-toggle .arr,
  .result-head .mydocs-legend-toggle .arr { margin-left:0; }

  .artifact-more { display:block; align-self:flex-end; margin:6px 0 0 auto; padding:0;
    color:#365ac4; font-size:12px; font-weight:600; text-decoration:underline; background:none; border:0; cursor:pointer; }
  .artifact-more[hidden] { display:none !important; }
  /* the My folder tab inside a service: its note on the left, "19 more" on the right, under the list */
  .svc-input .in-foot .fp-foot { display:flex; align-items:flex-start; gap:10px; }
  .svc-input .in-foot .fp-foot .limit-line { flex:1; min-width:0; }
  .svc-input .in-foot .fp-foot .fp-more { flex:none; margin:6px 0 0 auto; }
  .svc-input .in-foot .fp-foot .fp-open { flex:none; margin:6px 0 0 0; }   /* "Select from image folder", left, level with "N more" */
  .artifact-more span { color:var(--ui-arrow); }
  [data-panel="folder"] > .panel > .artifact-more { flex:none; }

  #folder-filter { display:flex; flex-wrap:wrap; align-items:center; }
  #folder-filter #folder-search-clear { margin-left:auto; flex:none; background:var(--surface); border:1px solid var(--border); color:var(--text); padding:6px 10px; }

  /* Status and next action use the same dimensions in the legend and My services. */
  .lg-service-states .status, .lg-service-states .req-btn,
  #services-list .service-row .title > .status, #services-list .req-actions > .req-btn {
    width:196px; min-width:196px; height:36px; min-height:36px; padding:0 10px;
    box-sizing:border-box; display:inline-flex; align-items:center; justify-content:center;
    text-align:center; line-height:normal; margin-top:0;
  }
  #services-list .service-row .title > .status { margin-left:auto; flex:none; }
  @media(pointer:coarse) {
    .lg-service-states .status, .lg-service-states .req-btn,
    #services-list .service-row .title > .status, #services-list .req-actions > .req-btn { height:44px; min-height:44px; }
  }

  .legend-contents { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0 24px; }
  .legend-contents a { padding:6px 10px; border:1px solid var(--border); border-radius:8px; background:var(--surface-alt); font-size:12px; }
  .legend-section { scroll-margin-top:16px; padding-bottom:20px; margin-bottom:20px; border-bottom:1px solid var(--border); }
  .legend-section:last-child { border-bottom:0; margin-bottom:0; }
  .legend-section > h3 { margin-top:0; }
  .legend-section > .lg-note { margin:0 0 12px; }
  .legend-section .wire + .lab-table-wrap { margin-bottom:24px; }

  .legend-section-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 12px; }
  .legend-section-head h3 { margin:0; font-size:16px; white-space:nowrap; }
  .legend-back-top { font-size:12px; white-space:nowrap; margin-left:auto; }
  #site-legend-top { scroll-margin-top:16px; }
  @media(max-width:440px) { .legend-section-head h3 { font-size:14px; } .legend-back-top { font-size:11px; } }

  /* One compact contents bar rather than separate pills. */
  .legend-contents {
    display:flex; flex-wrap:nowrap; gap:0; align-items:stretch; overflow-x:auto;
    padding:3px; border:1px solid var(--border); border-radius:8px;
    background:var(--surface-alt); scrollbar-width:thin;
  }
  .legend-contents a {
    flex:1 0 auto; white-space:nowrap; text-align:center; font-size:11px;
    padding:7px 8px; border:0; border-radius:0; background:none; text-decoration:none;
  }
  .legend-contents a + a { border-left:1px solid var(--border); }
  .legend-contents a:hover, .legend-contents a:focus-visible { background:var(--surface); text-decoration:underline; }

  /* History and normal result footers share one column instead of creating
     an implicit second column when both occupy the footer row. */
  .svc-result { grid-template-columns:minmax(0,1fr); }
  .svc-result > .panel-title,
  .svc-result > .result-title-row,
  .svc-result > .result-top,
  .svc-result > .result-body,
  .svc-result > .result-foot,
  .svc-result > .history-footer { grid-column:1; min-width:0; }


  .about-question { font-size:18px; font-weight:600; margin:6px 0 14px; color:var(--text); }
  .lab .legend-section .lg-note { margin:8px 0 12px; }
  .legend-section h4 { font-size:14px; margin:18px 0 8px; }
  #home-lab-top { scroll-margin-top:16px; }

  /* Distinct About menu accents: guide green, home lab blue. */
  #site-legend-top a { color:var(--accent-strong); }
  #home-lab-top a { color:#365ac4; }
  #home-lab-operations { border-bottom:0; margin-bottom:0; padding-bottom:8px; }   /* the last section */
  .lab-snake { list-style:none; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:28px 30px; padding:0; margin:16px 0 24px; }
  .lab-snake li { grid-row:var(--flow-row); grid-column:var(--flow-col); position:relative; display:flex; align-items:flex-start; gap:8px; padding:12px; border:1px solid var(--border); border-radius:10px; background:var(--surface-alt); font-size:12.5px; }
  .lab-snake .flow-number { flex:none; color:var(--accent-strong); font-weight:700; }
  .lab-snake li::after { position:absolute; color:var(--text-faint); font-size:20px; }
  .lab-snake li.forward::after { content:"→"; right:-24px; top:calc(50% - 14px); }
  .lab-snake li.reverse::after { content:"←"; left:-24px; top:calc(50% - 14px); }
  .lab-snake li.turn::after { content:"↓"; bottom:-29px; left:calc(50% - 7px); }
  @media(max-width:640px) {
    .lab-snake { grid-template-columns:minmax(0,1fr); gap:28px; }
    .lab-snake li { grid-row:auto; grid-column:1; }
    .lab-snake li:not(.last)::after { content:"↓"; top:auto; right:auto; bottom:-29px; left:calc(50% - 7px); }
  }

  [data-panel="legend"] .legend-back-top { color:var(--accent-strong); }
  [data-panel="lab"] .legend-back-top { color:#365ac4; }
  .sum1-avatar-title { text-transform:none; letter-spacing:normal; }
  #home-lab-stack-map .pmap-layer { margin-inline:0; }

  /* Both About guides use the same blue navigation accent. */
  #site-legend-top a, #home-lab-top a,
  [data-panel="legend"] .legend-back-top,
  [data-panel="lab"] .legend-back-top { color:#365ac4; }

  /* A stable desktop anchor, independent of the currently displayed form. */
  .page:not(.in-studio):not(.lobby-stack) #ask-guest { min-height:384px; }

  /* Project and closing quote are sign-in content, not setup sidebar cards.
     Keep this scoped to onboarding so normal sign-in restores both. */
  .page.onboarding #project-card, .page.onboarding #comments-card,
  .page.onboarding #quote-card { display:none !important; }
  /* My services: keep access labels with their names, actions on the right. */
  #services-list .service-row .title > .status {
    margin-left:0; flex:none; width:auto; min-width:0;
    height:auto; min-height:28px; padding:5px 10px;
    line-height:normal; text-align:center;
  }
  @media(pointer:coarse) {
    #services-list .service-row .title > .status { height:auto; min-height:28px; }
  }
  @media(max-width:600px) {
    #services-list .req-actions > .req-btn { width:auto; min-width:0; }
  }
  .services-header { display:flex; justify-content:space-between; align-items:center; gap:12px; }
  .services-heading { display:flex; align-items:center; flex-wrap:wrap; gap:12px; }
  .result-head.bk-header { justify-content:flex-start; flex-wrap:wrap; gap:16px; }
  .bk-window { align-items:center; gap:8px; font-size:12px; font-weight:600; color:var(--text); }
  .bk-window:not([hidden]) { display:inline-flex; }
  .bk-window::before { content:''; width:8px; height:8px; flex:none; border-radius:50%; background:var(--text-faint); }
  .bk-window.open::before { background:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
  .service-row .access-label { font-size:12px; font-weight:400; color:var(--text-muted); text-decoration:underline; text-underline-offset:3px; text-decoration-thickness:1px; }

  .folder-settings { margin-bottom: 18px; }
  .msg-view .message-actions { align-items: flex-start; flex-wrap: nowrap; }
  .message-file-action { margin-right: auto; min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
  .message-filename { max-width: 100%; overflow-wrap: anywhere; }
  .message-download { display: block; margin-top: 8px; overflow-wrap: anywhere; }
  #msg-file-dialog .actions { display: flex; justify-content: space-between; margin-top: 14px; }
  #msg-file-dialog #msg-file-choose {
    align-self: flex-end; margin-left: auto; width: 112px; height: 40px; padding: 0 12px;
    box-sizing: border-box; font-size: 13px; font-weight: 600; border-radius: 8px;
    background: var(--popup-action-blue); border: 1px solid var(--popup-action-blue); color: #fff;
  }
  #msg-file-dialog #msg-file-choose:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
  @media (max-width: 440px) {
    .showcase .showcase-now-label { gap: 6px; font-size: 9px; letter-spacing: 0; white-space: nowrap; }
    .showcase-legend { gap: 7px; font-size: 9px; }
    .showcase-legend span { gap: 3px; }
    .msg-view .message-actions { gap: 6px; }
    .message-actions button { padding-left: 8px; padding-right: 8px; font-size: 12px; }
  }

  .item-image { position:relative; width:fit-content; max-width:100%; margin:auto; }
  .item-image img { display:block; max-width:100%; height:auto; }
  .item-image svg { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
  .item-results ol { margin:12px 0; padding-left:24px; }
  .draft-compose[open], .draft-compose form { display:flex; flex-direction:column; gap:12px; min-height:0; }
  .draft-compose .popup-content { overflow-y:auto; }
  .draft-compose textarea { width:100%; min-height:240px; box-sizing:border-box; }
  .draft-compose input { width:100%; box-sizing:border-box; }
  .draft-compose .popup-actions { display:flex; justify-content:flex-end; gap:8px; }

  /* Match saved-artifact tiles to the main-menu service palette. */
  .kind-tile { color:#1f2937; }
  .folder-row[data-type="chat"] .kind-tile { background:linear-gradient(135deg,#fde563,#d7c354); }
  .folder-row[data-type="talk"] .kind-tile { background:linear-gradient(135deg,#fdc489,#d7a774); }
  .folder-row[data-type="image"] .kind-tile { background:linear-gradient(135deg,#65e393,#56c17d); }
  .folder-row[data-service="rag_chat"] .kind-tile,.folder-row[data-type="document"] .kind-tile,.folder-row[data-type="draft"] .kind-tile { background:linear-gradient(135deg,#f687c1,#d173a4); }
  .folder-row[data-type="video"] .kind-tile { background:linear-gradient(135deg,#f16060,#cd5252); }
  #intro-card,#ask-guest,#login-form { padding-bottom:14px; }
  .landing-cta { display:flex;align-items:center;justify-content:center;text-align:center;min-height:40px;font-size:13px;line-height:1.4;font-weight:700 !important;margin-top:auto;text-decoration:underline;text-underline-offset:2px;flex-shrink:0; }
  #login-form .login-new { text-align:center;margin-top:auto; }
  #home-card .login-new { text-align:center;margin-top:auto; }   /* Sign out where New here? is on the sign-in box */
  #login-form .login-new .landing-cta, #home-card .login-new .landing-cta { width:100%; }
  .landing-cta.cta-gold { color:#896100; }
  .landing-cta.cta-green { color:#087c58; }
  .landing-cta.cta-blue { color:#315bb5; }
  :root[data-theme="dark"] .cta-gold { color:#edc85b; }
  :root[data-theme="dark"] .cta-green { color:#6cddb5; }
  :root[data-theme="dark"] .cta-blue { color:#a8c2ff; }
  @media(prefers-color-scheme:dark){:root:not([data-theme="light"]) .cta-gold{color:#edc85b;}:root:not([data-theme="light"]) .cta-green{color:#6cddb5;}:root:not([data-theme="light"]) .cta-blue{color:#a8c2ff;}}


  .announcement-banner { grid-column:1 / -1;order:-1;min-width:0;min-height:32px;box-sizing:border-box;padding:6px 12px;background:#92749B;color:#fff;border-radius:8px;text-align:center;font-size:13px;font-weight:400;line-height:20px;white-space:nowrap;overflow-x:auto;scrollbar-width:thin; }
  .landing-cta { display:block;min-height:0;line-height:1.4;padding-top:4px; }
  #intro-card .intro-words { margin-top:auto; }
  #intro-card .intro-words .landing-cta { display:block;margin:0; }
  /* three columns: the words centred between the video and the link, the link at the foot with the others */
  .page:not(.lobby-stack) #intro-card .intro-words { margin-top:-10px;flex:1;display:flex;flex-direction:column; }   /* -10px: the card's own gap under the video, so the space above the words equals the space below */
  .page:not(.lobby-stack) #intro-card .intro-words::before { content:"";margin-bottom:auto; }
  .page:not(.lobby-stack) #intro-card .intro-words .landing-cta { margin-top:auto; }
  .page:not(.in-studio):not(.lobby-stack) #ask-guest .ag-answer { min-height:0; }
  #to-signup.cta-blue { color:#315bb5; }
  #recruit-open.cta-green { color:#087c58; }
  #intro-card .cta-gold { color:#896100; }
  :root[data-theme="dark"] #to-signup.cta-blue { color:#a8c2ff; }
  :root[data-theme="dark"] #recruit-open.cta-green { color:#6cddb5; }
  :root[data-theme="dark"] #intro-card .cta-gold { color:#edc85b; }
  @media(prefers-color-scheme:dark){:root:not([data-theme="light"]) #to-signup.cta-blue{color:#a8c2ff;}:root:not([data-theme="light"]) #recruit-open.cta-green{color:#6cddb5;}:root:not([data-theme="light"]) #intro-card .cta-gold{color:#edc85b;}}

  /* x is the existing 16px gap before the closing cards. Horizontal gaps stay unchanged. */
  .page .announcement-banner { min-height:8px;height:8px;padding:0;border-radius:999px;font-size:0;line-height:0;overflow:hidden; }
  .page .announcement-banner.has-message { min-height:24px;height:24px;padding:2px 12px;font-size:13px;line-height:20px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none; }
  .announcement-banner::-webkit-scrollbar { display:none; }
  .page { --landing-space:16px;padding-top:calc(var(--landing-space) / 4); }
  .announcement-banner { margin-bottom:calc(var(--landing-space) / 4 - var(--landing-space) / 3); }
  .page.in-studio { row-gap:calc(var(--landing-space) / 3); }
  .page:not(.in-studio):not(.onboarding) { row-gap:calc(var(--landing-space) / 3); }
  .page:not(.in-studio):not(.onboarding) .announcement-banner { margin-bottom:calc(var(--landing-space) / 4 - var(--landing-space) / 3); }
  .page:not(.in-studio):not(.onboarding) .lobby-left,
  .page:not(.in-studio):not(.onboarding) .lobby-center,
  #page:not(.in-studio):not(.onboarding) .signup-layout { row-gap:calc(var(--landing-space) / 2); }
  .page:not(.in-studio):not(.onboarding) #connect-card,
  .page:not(.in-studio):not(.onboarding) #soon-card,
  .page:not(.in-studio):not(.onboarding) #quote-card { margin-top:calc(var(--landing-space) / 2); }
