/* Workbench Home UX & New World modal (Track U2).
   Loaded after style.css without modifying style.css. Uses the shell's own theme tokens
   (--bg-*, --border-*, --text-*, --brand, --brand-fg, --paper, --shadow-modal, --font-sans, --font-mono)
   so dark and light themes both stay consistent and crisp. */

/* ── 1. Home Suggestions: responsive multi-column grid with downward "More" expansion (no h-scroll) ── */

.start {
  container-type: inline-size;
}

.home-suggestions .action-grid.action-row {
  display: grid;
  grid-auto-flow: row;
  grid-auto-columns: auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 12px;
  overflow-x: visible;
  overscroll-behavior-x: auto;
  padding-bottom: 0;
}

@container (max-width: 680px) {
  .home-suggestions .action-grid.action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@container (max-width: 460px) {
  .home-suggestions .action-grid.action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── 2. Centered bottom "More" / "Less" expander for both Suggestions and Recents ── */

.start-more-foot {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.start-more-foot .start-more {
  margin-inline-start: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: hsl(var(--text-3));
  font: 500 var(--fs-ui, 13px)/1 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  transition: color .14s ease, background-color .14s ease;
}

.start-more-foot .start-more:hover,
.start-more-foot .start-more:focus-visible {
  color: hsl(var(--text-1));
  background: hsl(var(--bg-2));
}

.start-more-foot .start-more svg {
  flex: none;
  opacity: .8;
  transition: transform .16s ease, opacity .14s ease;
}

.start-more-foot .start-more:hover svg,
.start-more-foot .start-more:focus-visible svg {
  opacity: 1;
}

/* ── 3. Full-width row hover highlight (including the trailing ⋯ menu button) ── */

.start-recent > li:not(.start-group-head) {
  display: flex;
  align-items: center;
  min-width: 0;
  border-radius: 8px;
  padding-inline-end: 4px;
  transition: background-color .12s ease;
}

.start-recent > li:not(.start-group-head):hover,
.start-recent > li:not(.start-group-head):has(.row-more[aria-expanded="true"]) {
  background: hsl(var(--bg-dock));
}

:root[data-theme="light"] .start-recent > li:not(.start-group-head):hover,
:root[data-theme="light"] .start-recent > li:not(.start-group-head):has(.row-more[aria-expanded="true"]) {
  background: hsl(var(--bg-2));
}

.start-recent > li:not(.start-group-head):hover .recent-row,
.start-recent > li:not(.start-group-head):has(.row-more[aria-expanded="true"]) .recent-row {
  color: hsl(var(--text-1));
}

.start-recent > li:not(.start-group-head) .recent-row,
.start-recent > li:not(.start-group-head) .recent-row:hover,
.start-recent > li:not(.start-group-head) .recent-row:focus-visible {
  flex: 1;
  min-width: 0;
  height: 30px;
  background: transparent;
  border-radius: 8px;
}

.start-recent > li:not(.start-group-head) .row-more {
  flex: none;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--text-3));
  transition: opacity .12s ease, color .12s ease, background-color .12s ease;
}

.start-recent > li:not(.start-group-head) .row-more:hover,
.start-recent > li:not(.start-group-head) .row-more:focus-visible {
  background: hsl(var(--bg-3));
  color: hsl(var(--text-1));
}

/* ── 4. App tools toolbar: pure naked ghost icons, never filled square buttons ── */

.cagi-head [role="toolbar"] button,
[aria-label="App tools"] button {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: hsl(var(--text-3));
  transition: color .12s ease, opacity .12s ease;
}

.cagi-head [role="toolbar"] button svg,
[aria-label="App tools"] button svg {
  opacity: .82;
  transition: opacity .12s ease;
}

.cagi-head [role="toolbar"] button:hover,
.cagi-head [role="toolbar"] button:focus-visible,
[aria-label="App tools"] button:hover,
[aria-label="App tools"] button:focus-visible {
  background: transparent;
  border-color: transparent;
  color: hsl(var(--text-1));
}

.cagi-head [role="toolbar"] button:hover svg,
.cagi-head [role="toolbar"] button:focus-visible svg,
[aria-label="App tools"] button:hover svg,
[aria-label="App tools"] button:focus-visible svg {
  opacity: 1;
}

.cagi-head [role="toolbar"] button[aria-pressed="true"],
[aria-label="App tools"] button[aria-pressed="true"] {
  background: transparent;
  color: hsl(var(--text-1));
}

.cagi-head [role="toolbar"] button.text-accent,
[aria-label="App tools"] button.text-accent {
  color: hsl(var(--brand));
}

.cagi-head [role="toolbar"] button.text-accent:hover,
[aria-label="App tools"] button.text-accent:hover {
  background: transparent;
  color: hsl(var(--brand));
  opacity: .85;
}

.cagi-head [role="toolbar"] button.text-bad,
[aria-label="App tools"] button.text-bad {
  color: hsl(var(--danger));
}

/* ── 5. New World modal: calm, centered, ComputaCo-clean creation experience ── */

dialog.nw-modal {
  width: min(620px, calc(100vw - 32px));
  max-width: min(620px, calc(100vw - 32px));
  max-height: min(86dvh, 760px);
  padding: 0;
  border: 1px solid hsl(var(--border-2));
  border-radius: 16px;
  background: hsl(var(--paper));
  color: hsl(var(--text-1));
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

dialog.nw-modal:not([open]) {
  display: none;
}

dialog.nw-modal::backdrop {
  background: hsl(0 0% 0% / .52);
  backdrop-filter: blur(4px);
}

.nw-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid hsl(var(--border-1));
  flex: none;
}

.nw-head-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.nw-title {
  margin: 0;
  font: 600 var(--fs-title, 16px)/1.25 var(--font-sans);
  letter-spacing: -.015em;
  color: hsl(var(--text-1));
}

.nw-sub {
  margin: 0;
  font: 400 var(--fs-ui, 13px)/1.45 var(--font-sans);
  color: hsl(var(--text-3));
}

.nw-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: hsl(var(--text-3));
  cursor: pointer;
  transition: color .12s ease, background-color .12s ease;
}

.nw-close:hover,
.nw-close:focus-visible {
  background: hsl(var(--bg-2));
  color: hsl(var(--text-1));
}

.nw-body {
  padding: 18px 22px 20px;
  display: grid;
  gap: 18px;
  overflow-y: auto;
  min-height: 0;
}

.nw-section {
  display: grid;
  gap: 10px;
}

.nw-section-label {
  font: 600 var(--fs-micro, 11px)/1 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: hsl(var(--text-3));
}

.nw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 520px) {
  .nw-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.nw-card {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  height: auto;
  padding: 11px 12px;
  border: 1px solid hsl(var(--border-1));
  border-radius: 12px;
  background: hsl(var(--bg-0) / .55);
  color: hsl(var(--text-1));
  text-align: start;
  white-space: normal;
  cursor: pointer;
  transition: border-color .14s ease, background-color .14s ease, box-shadow .14s ease;
}

.nw-card:hover {
  border-color: hsl(var(--border-2));
  background: hsl(var(--bg-2));
}

.nw-card[aria-checked="true"] {
  border-color: hsl(var(--brand));
  background: hsl(var(--brand) / .08);
  box-shadow: inset 0 0 0 1px hsl(var(--brand) / .35);
}

.nw-card-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: hsl(var(--bg-2));
  color: hsl(var(--text-2));
  transition: background-color .14s ease, color .14s ease;
}

.nw-card[aria-checked="true"] .nw-card-icon {
  background: hsl(var(--brand) / .18);
  color: hsl(var(--brand));
}

.nw-card-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.nw-card-title {
  font: 500 var(--fs-ui, 13px)/1.3 var(--font-sans);
  color: hsl(var(--text-1));
  display: flex;
  align-items: center;
  gap: 6px;
}

.nw-card-tag {
  font: 600 var(--fs-micro, 11px)/1 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 4px;
  background: hsl(var(--bg-2));
  color: hsl(var(--text-3));
}

.nw-card-desc {
  font: 400 var(--fs-caption, 12px)/1.4 var(--font-sans);
  color: hsl(var(--text-3));
}

.nw-field {
  display: grid;
  gap: 6px;
}

.nw-label {
  font: 500 var(--fs-ui, 13px)/1.2 var(--font-sans);
  color: hsl(var(--text-2));
}

.nw-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid hsl(var(--border-2));
  border-radius: 10px;
  background: hsl(var(--bg-0));
  color: hsl(var(--text-1));
  font: 400 var(--fs-ui, 13px)/1 var(--font-sans);
  transition: border-color .14s ease, box-shadow .14s ease;
}

.nw-input:hover {
  border-color: hsl(var(--text-4));
}

.nw-input:focus {
  border-color: hsl(var(--brand));
  box-shadow: 0 0 0 3px hsl(var(--brand) / .16);
}

.nw-input-mono {
  font: 400 var(--fs-caption, 12px)/1 var(--font-mono);
}

.nw-path-hint {
  font: 400 var(--fs-caption, 12px)/1.4 var(--font-mono);
  color: hsl(var(--text-3));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nw-advanced {
  border-top: 1px solid hsl(var(--border-1));
  padding-top: 12px;
}

.nw-advanced summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  font: 500 var(--fs-ui, 13px)/1.4 var(--font-sans);
  color: hsl(var(--text-3));
  user-select: none;
  transition: color .12s ease;
}

.nw-advanced summary::-webkit-details-marker {
  display: none;
}

.nw-advanced summary:hover {
  color: hsl(var(--text-1));
}

.nw-advanced summary svg {
  transition: transform .16s ease;
}

.nw-advanced[open] summary svg {
  transform: rotate(90deg);
}

.nw-advanced-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: hsl(var(--bg-0) / .5);
  border: 1px solid hsl(var(--border-1));
}

.nw-browse-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nw-browse-row .nw-input {
  flex: 1;
  min-width: 0;
}

.nw-browse-btn {
  flex: none;
  height: 36px;
  padding: 0 12px;
  border: 1px solid hsl(var(--border-2));
  border-radius: 10px;
  background: transparent;
  color: hsl(var(--text-2));
  font: 500 var(--fs-ui, 13px)/1 var(--font-sans);
}

.nw-browse-btn:hover {
  background: hsl(var(--bg-2));
  color: hsl(var(--text-1));
}

.nw-bounds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nw-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: hsl(var(--danger) / .1);
  color: hsl(var(--danger));
  font: 400 var(--fs-ui, 13px)/1.45 var(--font-sans);
}

.nw-error:empty {
  display: none;
}

.nw-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid hsl(var(--border-1));
  background: hsl(var(--bg-1) / .65);
  flex: none;
}

.nw-foot button {
  height: 34px;
  padding: 0 16px;
  border-radius: 9px;
  font: 500 var(--fs-ui, 13px)/1 var(--font-sans);
}

.nw-foot button.nw-cancel {
  border: 0;
  background: transparent;
  color: hsl(var(--text-2));
}

.nw-foot button.nw-cancel:hover {
  background: hsl(var(--bg-2));
  color: hsl(var(--text-1));
}

.nw-foot button.nw-submit {
  background: hsl(var(--brand));
  color: hsl(var(--brand-fg));
  border: 0;
  font-weight: 600;
}

.nw-foot button.nw-submit:hover {
  opacity: .92;
  background: hsl(var(--brand));
  color: hsl(var(--brand-fg));
}

.nw-foot button.nw-submit:disabled {
  opacity: .45;
  pointer-events: none;
}
