/* settings.css: owned by stream S; linked from index.html.
   The Settings page (settings.js), the delete confirmation, and the capture
   detail's two columns and More menu. */

/* Text size: the type tokens follow --ts (settings.js, device-local). Never
   below 11px, and inputs stay 16px or more so iOS doesn't zoom into them. */
:root {
  --fs-2xs: max(11px, calc(11px * var(--ts, 1)));
  --fs-xs: max(11px, calc(12px * var(--ts, 1)));
  --fs-sm: max(11px, calc(13px * var(--ts, 1)));
  --fs-md: max(11px, calc(14px * var(--ts, 1)));
  --fs-base: max(11px, calc(15px * var(--ts, 1)));
  --fs-lg: max(16px, calc(16px * var(--ts, 1)));
  --fs-xl: calc(17px * var(--ts, 1));
  --fs-2xl: calc(18px * var(--ts, 1));
  --fs-h3: calc(20px * var(--ts, 1));
  --fs-h2: calc(24px * var(--ts, 1));
  --fs-h1: calc(30px * var(--ts, 1));
}

/* ------------------------------------------------------------ the page */
.st-page { max-width: 760px; margin: 0 auto; padding: 14px 22px 64px; animation: rise .45s var(--ease) both; }
.st-head { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 14px; }
.st-title { margin: 2px 0 0; font: 400 var(--fs-title)/1.1 var(--serif); letter-spacing: -0.015em; }
.st-body { display: flex; flex-direction: column; gap: 20px; }
.st-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-veil); overflow: hidden; }
.st-card-title { margin: 0; padding: 18px 20px 8px; font: 400 var(--fs-h3)/1.2 var(--serif); color: var(--bone); }
.st-card-head { display: flex; align-items: baseline; justify-content: space-between; padding-right: 20px; }
.st-card-head .link-btn { margin: 0; }
.st-pad { padding: 14px 20px; }
.st-fold > summary { cursor: pointer; list-style: none; }
.st-fold > summary::-webkit-details-marker { display: none; }
.st-fold > summary .st-card-title { display: flex; align-items: center; gap: 8px; }
.st-fold > summary .st-card-title::after { content: ""; width: 8px; height: 8px; border: solid var(--bone-faint); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .2s var(--ease); }
.st-fold[open] > summary .st-card-title::after { transform: rotate(45deg); }
.st-fold:not([open]) > summary .st-card-title { padding-bottom: 18px; }

.st-big { margin: 0; font: 400 var(--fs-h3)/1.25 var(--serif); color: var(--bone); overflow-wrap: anywhere; }
.st-quiet { margin: 0; color: var(--bone-dim); font-size: var(--fs-md); line-height: 1.5; }
small.st-quiet, .st-quiet small { color: var(--bone-faint); }
.st-note { margin: 0; padding: 4px 20px 16px; font-size: var(--fs-sm); color: var(--bone-faint); line-height: 1.5; }
.st-note.st-flush { padding: 10px 0 0; }
.st-kicker { margin: 14px 0 6px; font-size: var(--fs-2xs); letter-spacing: .14em; text-transform: uppercase; color: var(--bone-faint); }
.st-mono { margin: 0; font-size: var(--fs-sm); color: var(--bone); overflow-wrap: anywhere; }

.st-account { display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.st-avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--sea); color: var(--ink-0); font: 400 24px/1 var(--serif); }
.st-who { flex: 1; min-width: 0; }
.st-danger-link, .st-danger-link:hover { color: var(--rose); }
.st-danger { background: var(--rose); color: var(--ink-0); }

/* A row that opens a page */
.st-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 20px; color: var(--bone); border-top: 1px solid var(--line); transition: background .2s var(--ease); }
.st-card > .st-account + .st-row, .st-card-title + .st-row { border-top: 0; }
.st-account + .st-row { border-top: 0; }
@media (hover: hover) { .st-row:hover { background: var(--panel-hover); } }
.st-row:active { background: var(--panel-hover); }
.st-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-row-title { font-size: var(--fs-xl); }
.st-row small { font-size: var(--fs-sm); color: var(--bone-faint); line-height: 1.4; }
.st-row-val { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--bone-dim); font-size: var(--fs-base); }
.st-chev { flex: none; width: 16px; height: 16px; fill: none; stroke: var(--bone-faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Fields */
.st-fields { display: flex; flex-direction: column; gap: 18px; }
.st-field, .st-setting { display: block; margin: 0; font-size: var(--fs-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--bone-faint); }
.st-field input[type=text], .st-field input[type=password], .st-setting input, .st-setting select, #dictSearch {
  display: block; width: 100%; margin-top: 7px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--ink-0); font-size: var(--fs-lg); letter-spacing: 0; text-transform: none; color: var(--bone);
  -webkit-appearance: none; appearance: none;
}
.st-setting select { background-image: linear-gradient(45deg, transparent 50%, var(--bone-faint) 50%), linear-gradient(135deg, var(--bone-faint) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.st-field input:focus, .st-setting input:focus, .st-setting select:focus, #dictSearch:focus { outline: 0; border-color: var(--sea-ring); }
.st-field small, .st-setting small, .st-toggle small { display: block; margin-top: 7px; font-size: var(--fs-xs); letter-spacing: 0; text-transform: none; color: var(--bone-faint); line-height: 1.45; }
.st-reset { margin: 0 0 0 8px; padding: 0; font-size: var(--fs-xs); letter-spacing: 0; text-transform: none; }
.st-size { display: flex; align-items: center; gap: 12px; margin-top: 8px; color: var(--bone-dim); }
.st-size input { flex: 1; min-height: var(--tap); margin: 0; accent-color: var(--sea); }
.st-a-small { font: 400 13px var(--serif); }
.st-a-big { font: 400 22px var(--serif); }

/* A line with a label and a control at its right */
.st-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 20px; min-height: 52px; border-top: 1px solid var(--line); }
.st-card-title + .st-line, .st-pad .st-line { border-top: 0; }
.st-line.st-flush { padding: 0; }
.st-line > span { font-size: var(--fs-lg); }
.st-line .lib-picker { padding: 0; }
.st-line .picker-btn { max-width: 100%; }

/* Switches */
.st-toggle { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 14px; margin: 0; font-size: var(--fs-base); letter-spacing: 0; text-transform: none; color: var(--bone); cursor: pointer; }
.st-toggle > span b { display: block; font-weight: 400; font-size: var(--fs-lg); }
.st-toggle small { grid-column: 1 / -1; }
.st-toggle > span small { grid-column: auto; margin-top: 3px; }
.st-toggle input[type=checkbox] {
  width: 42px; height: 24px; margin: 0; padding: 0; border-radius: var(--pill); position: relative; cursor: pointer; flex: none;
  -webkit-appearance: none; appearance: none; border: 1px solid var(--line-strong); background: var(--ink-3); transition: background .2s var(--ease), border-color .2s;
}
.st-toggle input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--bone-dim); transition: transform .2s var(--ease), background .2s; }
.st-toggle input[type=checkbox]:checked { background: var(--sea-deep); border-color: var(--sea); }
.st-toggle input[type=checkbox]:checked::after { transform: translateX(18px); background: var(--sea); }
.st-toggle input:focus-visible { outline: 2px solid var(--sea-ring); outline-offset: 2px; }
.st-toggle.st-inline { padding: 4px 0; }

/* The state of a save */
.st-status { margin: 0; min-height: 1.2em; font-size: var(--fs-sm); color: var(--bone-faint); }
.st-status.ok { color: var(--sea); }
.st-status.bad { color: var(--rose); }
.st-status:empty { min-height: 0; }
.st-err { margin: 10px 0 0; font-size: var(--fs-sm); color: var(--rose); }

/* Connection */
.st-conn { list-style: none; margin: 0; padding: 0 20px 8px; font-size: var(--fs-md); }
.st-conn li { display: flex; gap: 10px; padding: 5px 0; color: var(--bone-dim); }
.st-conn li b { width: 14px; flex: 0 0 14px; font-weight: 600; }
.st-conn li b svg { display: block; width: 14px; height: 14px; stroke-width: 2.2; }
.st-conn li.ok b { color: var(--sea); }
.st-conn li.bad b { color: var(--rose); }
.st-conn li.wait b { color: var(--moon); }
.st-conn li span small { color: var(--bone-faint); }
.st-install { margin: 4px 20px 14px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--ink-0); }
.st-install p { margin: 0; }
.st-install p + p { margin-top: 10px; }
.st-install a { color: var(--sea); font-size: var(--fs-base); }
.st-install small { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--bone-faint); }

/* Lists in a card (devices, deleted, waiting) */
.st-list p { margin: 0; font-size: var(--fs-lg); color: var(--bone); }
.st-list p + p { margin-top: 10px; }
.st-list small, .st-devices small { display: block; font-size: var(--fs-xs); color: var(--bone-faint); margin-top: 2px; }
.st-devices { list-style: none; margin: 0; padding: 0; }
.st-devices li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.st-devices li + li { border-top: 1px solid var(--line); }
.st-devices li > span { min-width: 0; overflow-wrap: anywhere; color: var(--bone); }
.st-devices .link-btn { margin: 0; flex: none; min-height: var(--tap); }

/* Pairing */
.st-pair { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.st-pair .pair-qr { margin: 4px 0; width: min(240px, 70vw); }
.st-pair .pair-qr img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); image-rendering: pixelated; }
.st-pair-go { display: flex; gap: 8px; }
.st-pair-go .btn-quiet { border: 1px solid var(--line-strong); padding: 8px 16px; }

/* Choosing a model */
.st-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 52px; padding: 10px 20px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--bone); font-size: var(--fs-lg); text-align: left; }
@media (hover: hover) { .st-opt:hover:not(:disabled) { background: var(--panel-hover); } }
.st-opt:disabled, .st-off { opacity: .6; }
.st-opt svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--sea); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.st-tag { margin-left: 6px; font-style: normal; font-size: var(--fs-xs); color: var(--sea); }

/* What the models know */
.st-built { display: flex; flex-direction: column; gap: 6px; }
.st-info > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--sea); }
.st-info-body { margin-top: 10px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--ink-0); font-size: var(--fs-md); }
.st-info-body p { margin: 0 0 8px; }
.st-info-body small { display: block; color: var(--bone-dim); }
.st-wide { width: 100%; padding: 14px 20px; font-size: var(--fs-lg); }
.st-text > summary { display: flex; align-items: center; gap: 12px; padding: 14px 20px; cursor: pointer; list-style: none; border-top: 1px solid var(--line); }
.st-text:first-child > summary { border-top: 0; }
.st-text > summary::-webkit-details-marker { display: none; }
.st-text[open] .st-chev { transform: rotate(90deg); }
.st-text-body { padding: 0 20px 16px; }
.st-pre { margin: 10px 0 0; max-height: 420px; overflow: auto; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ink-0); font: 400 var(--fs-xs)/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere; }
.st-box { list-style: none; margin: 0 0 6px; padding: 4px 14px; max-height: 300px; overflow: auto; border-radius: var(--radius-sm); background: var(--ink-0); }
.st-box li { padding: 10px 0; }
.st-box li + li { border-top: 1px solid var(--line); }
.st-box b { display: block; font-weight: 400; font-size: var(--fs-lg); color: var(--bone); overflow-wrap: anywhere; }
.st-box small { display: block; margin-top: 3px; font-size: var(--fs-sm); color: var(--bone-dim); line-height: 1.45; overflow-wrap: anywhere; }
.st-sources { max-height: 560px; }
.st-what { margin-top: 6px; font-size: var(--fs-sm); }
.st-src-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 6px; font-size: var(--fs-md); }
.st-src-links a { color: var(--sea); min-height: 32px; display: inline-flex; align-items: center; }
.st-src-links .lib-picker { padding: 0; }

/* The delete confirmation */
.st-confirm { width: min(440px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--ink-1); color: var(--bone); box-shadow: 0 40px 80px -20px rgba(0,0,0,.8); }
.st-confirm::backdrop { background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.st-confirm h3 { margin: 0 0 10px; font: 400 var(--fs-h2)/1.2 var(--serif); }
.st-confirm-msg { margin: 0 0 14px; line-height: 1.55; color: var(--bone-dim); font-size: var(--fs-base); }
.st-confirm-go { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 559px) {
  .st-page { padding: 8px 16px calc(var(--tabbar) + 48px); }
  .st-row-val { max-width: 40%; }
}

/* ------------------------------------------------- capture detail: columns */
/* The reading and the pipeline go beside the capture when there is room,
   below it when there is not (native PageColumns). */
#detailPane { container-type: inline-size; container-name: cap; }
.detail-cols { display: block; }
.detail-side { display: block; }
@container cap (min-width: 900px) {
  #detailPane .detail-inner { max-width: 1160px; }
  #detailPane .detail-top { max-width: 1160px; }
  #detailPane .detail-cols { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); gap: 0 40px; align-items: start; }
  #detailPane .detail-side { position: sticky; top: 8px; }
  #detailPane .detail-composer .composer { max-width: 760px; margin-left: max(24px, calc((100% - 1160px) / 2 + 24px)); }
}

/* Delete lives in a More menu at the top of a capture */
.det-more { position: relative; margin-left: 12px; }
.det-more > summary { list-style: none; cursor: pointer; width: var(--tap); height: 34px; display: grid; place-items: center; border-radius: var(--pill); color: var(--bone-dim); font-size: 22px; line-height: 1; }
.det-more > summary::-webkit-details-marker { display: none; }
@media (hover: hover) { .det-more > summary:hover { color: var(--bone); background: var(--panel-hover); } }
.det-menu { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 200px; padding: 6px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--ink-2); box-shadow: 0 20px 40px -10px rgba(0,0,0,.7); }
.det-menu button { display: block; width: 100%; min-height: var(--tap); padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left; font-size: var(--fs-md); color: var(--bone); }
.det-menu button.danger { color: var(--rose); }
@media (hover: hover) { .det-menu button:hover { background: var(--panel-hover); } }
.fig-label { margin: 6px 0 0; font-size: var(--fs-xs); color: var(--bone-faint); }
.where-went a { font: 400 var(--fs-2xl)/1.3 var(--serif); color: var(--bone); }

/* A capture row's Delete: on hover or focus with a mouse, always there on touch. */
.entry-row { position: relative; }
.entry-delete {
  position: absolute; top: 8px; right: 6px; width: 36px; height: 36px; padding: 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--bone-faint, currentColor); opacity: 0;
}
.entry-delete svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.entry-row:hover .entry-delete, .entry-delete:focus-visible { opacity: .8; }
.entry-delete:hover { color: var(--rose, #e29a9a); opacity: 1; }
@media (hover: none) { .entry-delete { opacity: .55; } }
.q-talk-box { margin-top: 12px; }
