/* ============================================================================
   CUSTOMIZE AND SETTINGS (chat-first UI step 4, 2026-10-12) — customize.js,
   settings-layout.js
   ----------------------------------------------------------------------------
   The owner's approved Connections, Skills, Memory and Settings canvases, in
   this app's own palette and type (the owner kept both): one "Customize"
   header with tabs and counts over what Scout can reach and know, skills as
   cards filed by where they came from, notes as rows of plain sentences filed
   the same way, and Settings as a page-sized sheet of sections.

   Loaded after chat-shell.css so it wins at equal specificity. Every colour is
   a token or a mix of tokens, so the dark theme follows without a second block.

   Motion is the motion pack's: the tab ink travels in 160ms on the snap curve,
   content arrives with a 4px shift, rows stagger 18ms for the first six, and
   nothing here springs — Spending shows money, and money never bounces.
   Reduced motion makes every one of them an 80ms fade (the block at the end).
   ============================================================================ */

.cz-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- one room for three tabs --------------------------------------------
   Connections' honey for all three, so moving between the tabs is moving
   inside one place rather than walking into Library's plum.

   Since slice 4 (2026-10-29) the three panes are children of one
   #customize-view, which is the scroller, carries the padding and the honey
   band, and shows the one pane its tab names. The panes kept the scroller
   rules they had as pages of their own (style.css), so inside the room they
   stand down to plain blocks — otherwise each would scroll inside the page
   and add its 60px top a second time under the header. Three ids, to beat
   style.css's `#app.view-x #x-view` and the phone's `#connections-view`. */
#app.view-customize { --vh: var(--fill-honey); --vw: var(--honey-wash); --vi: var(--honey); }
#app #customize-view > :is(#connections-view, #skills-view, #memories-view, #automations-view) {
  display: none; flex: none; overflow: visible; padding: 0; background: none; min-height: 0;
}
#app.view-connections #customize-view > #connections-view,
#app.view-skills #customize-view > #skills-view,
#app.view-memories #customize-view > #memories-view,
#app.view-automations #customize-view > #automations-view { display: flex; }
#automations-view { flex-direction: column; gap: 12px; }

/* ---------- Automations: one card per routine ------------------------------------
   The routine's own controls are routines.js's, the same markup Goals →
   Routines draws, so only the card around them is styled here. */
.au-list { display: flex; flex-direction: column; gap: 10px; }
.au-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.au-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.au-name { font-size: 15px; font-weight: 600; }
.au-status.err { color: var(--err); }
.au-none { margin: 4px 2px; }
/* The check-in's model names are long; on a phone the select would push the
   card, and the page with it, past the right edge. */
#automations-view, .au-list, .au-row { min-width: 0; max-width: 100%; }
.au-row .gv-row { flex-wrap: wrap; min-width: 0; }
.au-row :is(select, input) { max-width: 100%; min-width: 0; }
.au-row label { min-width: 0; max-width: 100%; }

/* The panes' own titles stand down under the header: the tab names the page.
   Connections' tile-and-title goes, its purpose line being the header's
   subtitle now. The counts and the actions in the panes' heads stay. */
#customize-view #connections-view > .mv-head { display: none; }
#customize-view :is(#skills-view, #memories-view) > .mv-head h3 { display: none; }
#customize-view :is(#skills-view, #memories-view) > .mv-head { align-items: center; }

/* ---------- the header ------------------------------------------------------- */

.cz-head { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 1000px; }
.cz-title h2 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 600; }
.cz-sub { margin: 5px 0 0; color: var(--dim); font-size: var(--t-sm); max-width: 72ch; }
.cz-bar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.cz-tabs { position: relative; display: flex; gap: 2px; min-width: 0; }
.cz-tab {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 42px; padding: 11px 12px 10px;
  background: none; border: 0; border-radius: 9px 9px 0 0; font: inherit; font-size: 14px; color: var(--dim);
  cursor: pointer; white-space: nowrap; transition: color var(--dur-quick) var(--ease-snap), background var(--dur-instant) var(--ease-snap);
}
.cz-tab:hover { color: var(--text); background: color-mix(in srgb, var(--text) 4%, transparent); }
.cz-tab.on { color: var(--text); font-weight: 600; }
.cz-tab:focus-visible { outline: 2px solid color-mix(in srgb, var(--info) 55%, transparent); outline-offset: -2px; }
/* Counts beside a tab: secondary words in the body face (2026-11-17, was mono). */
.cz-n { font: 500 12px/1 var(--f-body); letter-spacing: normal; color: var(--dim); font-variant-numeric: tabular-nums; }
/* The underline is one bar that travels (customize.js measures the tab), so
   the eye follows it from the tab that was to the tab that is. Until it has
   been measured once it is drawn under the selected tab without travelling. */
.cz-ink {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; border-radius: 2px;
  background: var(--text); pointer-events: none;
}
.cz-head.cz-ready .cz-ink { transition: transform 160ms var(--ease-snap), width 160ms var(--ease-snap); }

/* The ask line: a request for a new chat, drawn like the chat's own box. */
.cz-ask {
  display: flex; align-items: center; gap: 9px; margin: 0 0 8px; padding: 5px 5px 5px 14px;
  width: min(380px, 100%); border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface);
  transition: border-color var(--dur-quick) var(--ease-snap), box-shadow var(--dur-quick) var(--ease-snap);
}
.cz-ask:focus-within { border-color: color-mix(in srgb, var(--text) 30%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 18%, transparent); }
.cz-ask-mark { flex: none; fill: var(--primary); }
.cz-ask input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 13.5px; outline: none; padding: 4px 0; }
.cz-ask input::placeholder { color: var(--dim); }
.cz-ask-go {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 999px;
  background: var(--text); color: var(--window); cursor: pointer; transition: transform var(--dur-instant) var(--ease-snap);
}
.cz-ask-go svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cz-ask-go:active { transform: scale(.94); }
/* Nothing to send yet: the arrow is there, greyed, so the line still reads as
   one you can send from, and it takes no press (customize.js `armGo`). */
.cz-ask-go:disabled { background: var(--line-2); color: var(--dim); cursor: default; }
.cz-ask-go:disabled:active { transform: none; }

/* ---------- Connections under the header -------------------------------------- */

#app.view-connections #connections-view { gap: 18px; }

/* ---------- Skills: cards filed by where they came from ------------------------- */

#app.view-skills #skills-view { gap: 12px; }
#app.view-skills #skills-view .skills-intro { margin: 0; font-size: 12.5px; max-width: 80ch; }
#skill-list.skill-list { display: flex; flex-direction: column; gap: 10px; }
.sk-group-h, .mem-group-h {
  margin: 10px 2px 0; font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; color: var(--dim);
}
.sk-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.sk-group > .skill-card { gap: 6px; padding: 14px 14px 12px; min-height: 132px; }
.sk-top b.sk-name { font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.sk-group .sk-desc { font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sk-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.sk-foot .sk-src { border: 0; background: var(--surface-2); color: var(--dim); }
.sk-foot .sk-src.u { background: color-mix(in srgb, var(--sun) 14%, var(--surface)); color: var(--sun-ink); }
.sk-foot .mc-actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- Memory: rows of plain sentences --------------------------------------- */

#mem-list.mem-list { display: flex; flex-direction: column; gap: 8px; }
.mem-group { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
#mem-list .mem-group > .mem-card {
  flex-direction: row; align-items: flex-start; gap: 16px; padding: 12px 14px 12px 16px;
  background: transparent; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none;
}
#mem-list .mem-group > .mem-card:first-child { border-top: 0; }
.mem-card .mc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mem-card .mc-top:empty { display: none; }
#mem-list .mem-group .mc-title { font-size: 14.5px; font-weight: 500; line-height: 1.45; }
#mem-list .mem-group .mc-body { font-size: 13px; max-height: none; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#mem-list .mem-group .mc-prov { font-size: 12px; color: var(--dim); gap: 6px 8px; }
#mem-list .mem-group .mc-prov .rev { margin-left: 0; }
#mem-list .mem-group .mc-tags { display: inline-flex; gap: 5px; }
.mem-card .mc-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.mem-card .mc-side .imp { margin-left: 0; padding-top: 6px; }
#mem-list .mem-group .mc-actions { margin-top: 0; gap: 4px; }
/* Forget is a quiet word until it is meant: the design draws it as text. */
#mem-list .mem-group [data-del] { border-color: transparent; background: none; color: var(--dim); }
#mem-list .mem-group [data-del]:hover { color: var(--err); }

/* ---------- arriving ----------------------------------------------------------------
   The content under the tabs shifts 4px as it arrives; the first six rows of a
   list follow 18ms apart and the rest land together, so a long list is never
   slow. The class is on #main for one arrival only (customize.js takes it off
   again), so a list redrawn by a later read swaps in place, without replaying. */
/* The tab switch is the motion tokens' quick step on the snap curve, the
   same pair the tab's own colour change uses. */
#main.cz-in #customize-view > [role="tabpanel"] { animation: cz-arrive var(--dur-quick) var(--ease-snap) both; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card) { animation: cz-arrive 180ms var(--ease-snap) both; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card):nth-child(2) { animation-delay: 18ms; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card):nth-child(3) { animation-delay: 36ms; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card):nth-child(4) { animation-delay: 54ms; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card):nth-child(5) { animation-delay: 72ms; }
#main.cz-in :is(.conn-row, .skill-card, .mem-card):nth-child(n+6) { animation-delay: 90ms; }
@keyframes cz-arrive { from { opacity: 0; transform: translateY(4px); } }
@keyframes cz-fade { from { opacity: 0; } }

/* ---------- Settings as a sheet of sections ------------------------------------------
   Page-sized on a desktop, the whole screen on a phone. The head holds the
   title, the line under it, the search line and the ✕; the body is the list
   of sections and the one showing; Save and Cancel stay pinned at the foot,
   where they were. */

#settings.set-sheet { width: min(1080px, calc(100vw - 48px)); height: min(820px, calc(100dvh - 48px)); max-width: none; max-height: none; }
#settings.set-sheet > .settings-form { width: 100%; height: 100%; max-height: none; }
.dlg-form .dlg-head.set-head { align-items: flex-start; gap: 16px; padding: 24px 18px 18px 30px; border-bottom: 1px solid var(--line); }
.set-title { flex: 1; min-width: 0; }
.dlg-form .set-head .set-title h2 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.set-intro { margin: 5px 0 0; color: var(--dim); font-size: var(--t-sm); }
.set-intro .linklike { color: var(--text); text-underline-offset: 2px; }
.settings-form label.set-find {
  flex: none; flex-direction: row; align-items: center; gap: 8px; width: min(340px, 36vw); height: 38px; margin-top: 2px;
  padding: 0 7px 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); color: var(--dim); font-size: 13.5px;
  transition: border-color var(--dur-quick) var(--ease-snap), box-shadow var(--dur-quick) var(--ease-snap);
}
.settings-form label.set-find:focus-within { border-color: color-mix(in srgb, var(--text) 30%, var(--line-2)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 18%, transparent); }
.set-find .ic { flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
.settings-form .set-find input { flex: 1; min-width: 0; padding: 0; border: 0; border-radius: 0; background: none; font-size: 13.5px; }
.settings-form .set-find input:focus { border: 0; box-shadow: none; }
.set-find input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.set-kbd { flex: none; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); color: var(--dim); font: 500 11px/1 var(--f-body); letter-spacing: normal; }

.dlg-form .dlg-body.set-layout {
  display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: start; gap: 30px;
  padding: 20px 30px 28px; overflow-y: auto;
}
/* The body grows to the sheet's height, so Save and Cancel sit at its foot
   whatever the section's length; its two children never shrink under it (the
   phone's row of section chips was squashed to its border by the column). */
.dlg-form .dlg-body.set-layout { flex: 1 1 auto; }
.set-layout > * { flex: none; }
.set-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.set-nav-item {
  text-align: left; padding: 9px 12px; border: 0; border-radius: 9px; background: none; font: inherit; font-size: 14px;
  color: var(--text); cursor: pointer; transition: background var(--dur-instant) var(--ease-snap);
}
.set-nav-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.set-nav-item.on { background: color-mix(in srgb, var(--text) 9%, transparent); font-weight: 600; }
.set-nav-item:focus-visible { outline: 2px solid color-mix(in srgb, var(--info) 55%, transparent); outline-offset: -2px; }
#settings.set-searching .set-nav-item.on { background: none; font-weight: 400; }

.set-secs { min-width: 0; max-width: 660px; display: flex; flex-direction: column; gap: 26px; }
.set-sec { display: none; flex-direction: column; gap: 10px; }
.set-sec.on, #settings.set-searching .set-sec { display: flex; }
#settings .set-sec.set-sec-miss, #settings .set-miss { display: none; }
.set-sec-h { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.005em; }
.set-sec-sub { margin: -4px 0 2px; color: var(--dim); font-size: 13px; line-height: 1.5; }
.set-none { margin: 0; color: var(--dim); font-size: var(--t-sm); }

/* A card of rows with a hairline between them — the canvas's grouped list —
   or, for the fields that belong together (a key and its notes), a stack. */
.set-card { display: flex; flex-direction: column; padding: 2px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.set-card > * + * { border-top: 1px solid var(--line); }
.settings-form .set-card > :is(.set-row, .acct-head, .set-line) { padding: 13px 0; margin: 0; }
.set-card > :is(#month-spend, #prompt-reuse, #web-spend) { padding: 10px 0 12px; }
.set-card > #sandbox-egress { padding: 12px 0; }
.set-card.set-stack { gap: 12px; padding: 14px 16px; }
.set-card.set-stack > * + * { border-top: 0; }
.set-card.set-stack > .acct-head { padding: 0; }
.set-group-h { margin-top: 6px; }
.set-group-h .acct-label { font: 500 12px/1 var(--f-body); letter-spacing: normal; text-transform: none; color: var(--dim); }
.set-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.set-line-text { display: flex; flex-direction: column; min-width: 0; }
.set-line-name { font-size: 14px; color: var(--text); }
.settings-form .set-line .set-exp { margin-top: 2px; }
.set-line > button { flex: none; }
.set-spend-block { display: flex; flex-direction: column; gap: 10px; }

/* A section arrives with the same 4px shift a tab's content does. */
.set-sec.set-in { animation: cz-arrive 160ms var(--ease-snap) both; }

@media (max-width: 720px) {
  .cz-head { gap: 12px; }
  .cz-title h2 { font-size: 22px; }
  /* `nowrap`: a wrapping column sizes its line to the widest item, so with
     four tabs the strip took its full 468px and pushed the whole room
     sideways at 390 instead of scrolling inside itself (flows13). */
  .cz-bar { flex-direction: column-reverse; flex-wrap: nowrap; align-items: stretch; border-bottom: 0; gap: 12px; }
  .cz-tabs { border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .cz-tab { flex: none; }
  .cz-ask { width: 100%; margin: 0; }
  .sk-group { grid-template-columns: minmax(0, 1fr); }
  #mem-list .mem-group > .mem-card { flex-direction: column; gap: 8px; }
  .mem-card .mc-side { flex-direction: row-reverse; align-items: center; justify-content: space-between; width: 100%; }
  .mem-card .mc-side .imp { padding-top: 0; }

  #settings.set-sheet { width: 100%; height: 94dvh; }
  .dlg-form .dlg-head.set-head { flex-wrap: wrap; padding: 26px 12px 12px 18px; gap: 10px; }
  .dlg-form .set-head .set-title h2 { font-size: 22px; }
  .set-head .set-title { flex: 1 1 calc(100% - 60px); }
  .settings-form label.set-find { order: 3; width: 100%; margin-right: 6px; }
  .set-kbd { display: none; }
  .dlg-form .dlg-body.set-layout { display: flex; flex-direction: column; gap: 16px; padding: 12px 16px 20px; }
  .set-nav { position: static; flex-direction: row; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
  .set-nav-item { flex: none; white-space: nowrap; padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13.5px; }
  .set-nav-item.on { background: var(--text); border-color: var(--text); color: var(--window); }
  /* The door stays on the line it opens: wrapped under the text it read as a
     button for the next row (seen at 390px, 2026-10-12). */
  .set-line { gap: 10px; }
  .set-line-text { flex: 1 1 auto; }
}

/* ---------- reduced motion ---------------------------------------------------------
   The motion pack's rule six: every move becomes an 80ms fade, and nothing
   travels — the ink jumps to its tab, the rows and sections fade in place. */
@media (prefers-reduced-motion: reduce) {
  #main.cz-in #customize-view > [role="tabpanel"],
  #main.cz-in :is(.conn-row, .skill-card, .mem-card),
  .set-sec.set-in { animation: cz-fade 80ms linear both; animation-delay: 0s; }
  .cz-head.cz-ready .cz-ink { transition: none; }
  .cz-tab, .cz-ask, .cz-ask-go, .set-nav-item, .settings-form label.set-find { transition: none; }
  .cz-ask-go:active { transform: none; }
}
