/* The page sentence bar (SQ-002, js/sentence-bar.js): the sentence with its violet words (css/sentence-parts.css), a caret
   to type after it, the suggestions (a gentle menu under the bar on a laptop, a sheet on the keyboard on a phone), the
   assumptions line and Start over. Three kinds of word, never alike: violet (you change it; in the bar a pill with a ▾,
   SQ-028), dotted (opens the detail, .sb-dot), bold (the answer, .sp-ans). Money · Ledger tokens from pocket.css.
   SQ-028: the bar is a query card that holds only the question (a label with Undo and Start over, the sentence, a Try
   row); its hint sits outside, just above it.
   Design: docs/design/sentence-app/proto.html (.sbar, .sug). */

.sb { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 22px 18px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-sm); }
.sb:focus-within { box-shadow: var(--shadow-md), 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.sb-text { margin: 0; font: 600 25px/1.75 var(--font-sans); letter-spacing: -.025em; color: var(--text); text-wrap: pretty; cursor: text; overflow-wrap: anywhere; }
.sb-in-wrap { display: inline-block; max-width: 100%; vertical-align: baseline; position: relative; line-height: 1.5; }   /* the box and its grey word keep their own line; only the pills need the taller one (SQ-028) */
/* SQ-020: the grey completion after the caret: the typed text again, invisible, then the rest in grey, over the box */
.sb-ghost[hidden] { display: none; }
.sb-ghost { position: absolute; left: 0; top: 0; padding: 0 2px; white-space: pre; pointer-events: none; max-width: 100%; overflow: hidden; text-overflow: clip; }
.sb-gm { visibility: hidden; }
.sb-gt { color: color-mix(in srgb, var(--text-dim) 85%, transparent); font-weight: 500; }
.sb-ghost.is-jump .sb-gt { color: var(--accent); opacity: .7; }
.sb-in {
  font: inherit; letter-spacing: inherit; color: var(--text); border: 0; outline: 0; background: none; padding: 0 2px; margin: 0;
  field-sizing: content; min-width: 10ch; max-width: 100%; box-sizing: border-box; vertical-align: baseline; caret-color: var(--accent);
}
.sb-in::placeholder { color: color-mix(in srgb, var(--text-dim) 75%, transparent); font-weight: 500; }
.sb-also { margin: -2px 0 0; font: 500 13.5px/1.45 var(--font-sans); color: var(--text-mid); }
.sb-also[hidden] { display: none; }
/* the card's head: its label, then Undo and Start over at the far end */
.sb-head { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.sb-k { margin-right: auto; font: 600 11px var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim); }
.sb-head .sb-reset { height: 28px; }
/* the words you change: violet pills with a ▾ (the cards' own words keep their underline, css/sentence-parts.css) */
.sb-sent .sp-word:not(.sp-unknown), .sb-sent .sp-num {
  text-decoration: none; padding: 0 9px 0 12px; margin: 0 1px; border-radius: 12px; line-height: 1.45;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 30%, transparent);
}
.sb-sent .sp-num { padding: 0 12px; }
.sb-sent .sp-word:not(.sp-unknown)::after {
  content: "" / ""; display: inline-block; width: .3em; height: .3em; margin: 0 2px 0 .38em; vertical-align: .2em;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .7;
}
.sb-sent .sp-word[aria-expanded="true"], .sb-sent .sp-num.sp-open { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); }
@media (hover: hover) { .sb-sent .sp-word:not(.sp-unknown):hover, .sb-sent .sp-num:hover { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); } }
/* the Try row the page fills (Spending's follow-ups), under a hairline; gone while empty */
.sb-try { padding-top: 12px; border-top: 1px solid var(--border); }
.sb-try:empty { display: none; }
/* the hint: outside the card, just above it */
.sb-hint { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 -4px 4px; font: 500 13px/1.45 var(--font-sans); color: var(--text-mid); }
.sb-hint svg { flex: none; width: 15px; height: 15px; margin-top: 2px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sb-hint .sb-lg { color: var(--text-dim); }
.sb-hint .sb-v { color: var(--accent); font-weight: 600; }
.sb-hint kbd { font: 500 11px var(--font-mono); padding: 1px 6px; border-radius: 6px; background: rgb(from var(--text) r g b / .08); color: var(--text-mid); }
.sb-reset {
  all: unset; box-sizing: border-box; flex: none; height: 32px; padding: 0 11px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px;
  font: 600 12.5px var(--font-sans); color: var(--text-mid); cursor: pointer;
}
.sb-reset svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-reset:focus-visible { outline: 2px solid var(--accent); }
@media (hover: hover) { .sb-reset:hover { background: rgb(from var(--text) r g b / .07); color: var(--text); } }
.sb-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* dotted: opens the detail (an answer you can look into) */
.sb-dot {
  all: unset; cursor: pointer; text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: .22em;
  text-decoration-color: color-mix(in srgb, var(--text) 45%, transparent); border-radius: 4px;
}
.sb-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: hover) { .sb-dot:hover { text-decoration-color: var(--text); } }

/* suggestions while typing: a gentle-tier menu under the bar */
.sb-sug {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 60; box-sizing: border-box; padding: 6px;
  max-height: min(420px, 60vh); overflow: auto; overscroll-behavior: contain; border-radius: 14px;
  background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-lg); font: 500 14px/1.35 var(--font-sans); letter-spacing: 0;
}
[data-theme="light"] .sb-sug { background: var(--surface); }
.sb-sug[hidden] { display: none; }
.sb-hd { font: 600 10.5px var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--text-dim); padding: 8px 10px 4px; }
.sb-pre { display: flex; gap: 10px; align-items: baseline; padding: 9px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; line-height: 1.45; }
.sb-pre .sb-k { flex: none; font: 600 10.5px var(--font-mono); color: var(--bg); background: var(--accent); padding: 3px 7px; border-radius: 6px; }
.sb-pre-t { min-width: 0; }
.sb-st { margin-left: auto; flex: none; font: 500 12px var(--font-mono); color: var(--text-dim); text-align: right; }
.sb-opt { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 38px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.sb-opt[aria-selected="true"] { background: rgb(from var(--text) r g b / .09); }
@media (hover: hover) { .sb-opt:hover { background: rgb(from var(--text) r g b / .06); } }
.sb-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-l { font-weight: 600; }
.sb-t small { margin-left: 8px; font-size: 12px; color: var(--text-dim); }
.sb-ic { width: 22px; height: 22px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 16%, transparent); position: relative; }
.sb-ic::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--accent); }
.sb-ic-merchant::after, .sb-ic-brand::after { border-radius: 2px; }
.sb-ic-time::after, .sb-ic-month::after { inset: 6px 7px; border-radius: 1px; }
.sb-ic-by::after, .sb-ic-as::after, .sb-ic-order::after { inset: 7px 5px; border-radius: 1px; background: var(--text-mid); }
.sb-empty { padding: 12px 10px; font-size: 13px; color: var(--text-dim); }
.sb-keys { display: flex; gap: 12px; padding: 6px 10px 2px; font: 500 11px var(--font-mono); color: var(--text-dim); }

@media (max-width: 768px) {
  .sb { padding: 14px 16px 16px; border-radius: 20px; }
  .sb-text { font-size: 20px; line-height: 1.7; }
  .sb-lg, .sb-keys { display: none; }
  .sb-reset, .sb-head .sb-reset { height: 40px; }
  /* a sheet on top of the keyboard: js/sentence-bar.js sets bottom from the visual viewport */
  .sb-sug { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; max-height: 58vh; border-radius: 22px; z-index: 700; padding: 8px; }   /* over the floating tab bar */
  .sb-opt { min-height: 48px; font-size: 16px; }
}

/* SQ-021: the × on the word you're on, the undo offer, the shortcuts list (?) */
.sb-x {
  all: unset; box-sizing: border-box; position: absolute; z-index: 3; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-sm); cursor: pointer;
}
.sb-x[hidden] { display: none; }
.sb-x svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .sb-x:hover { background: var(--accent-fill); color: var(--on-accent); } }
.sb-undo-wrap { flex: none; display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px var(--font-sans); color: var(--text-mid); }
.sb-undo-wrap[hidden] { display: none; }
.sb-undo { all: unset; box-sizing: border-box; height: 32px; padding: 0 12px; border-radius: 999px; font: 600 12.5px var(--font-sans); color: var(--accent-hi, var(--accent)); background: rgb(from var(--accent) r g b / .12); cursor: pointer; }
.sb-undo:focus-visible, .sb-keys-btn:focus-visible, .sb-help-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sb-keys-btn { all: unset; cursor: pointer; font: inherit; color: var(--accent-hi, var(--accent)); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.sb-help {
  position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: min(420px, 100%); box-sizing: border-box; padding: 16px 18px 12px;
  border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-md); border: 1px solid var(--border);
}
.sb-help[hidden] { display: none; }
.sb-help-h { margin: 0 0 10px; font: 600 14px var(--font-sans); color: var(--text); }
.sb-help dl { margin: 0; display: grid; gap: 6px; }
.sb-help dl > div { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: baseline; }
.sb-help dt { font: 500 12px var(--font-sans); color: var(--text-mid); }
.sb-help dd { margin: 0; font: 500 13px/1.4 var(--font-sans); color: var(--text); }
.sb-help kbd { font: 500 11px var(--font-mono); padding: 1px 6px; border-radius: 6px; background: rgb(from var(--text) r g b / .08); color: var(--text-mid); }
.sb-help-x { all: unset; box-sizing: border-box; margin-top: 10px; height: 32px; padding: 0 12px; border-radius: 999px; font: 600 12.5px var(--font-sans); color: var(--text-mid); cursor: pointer; }
@media (prefers-reduced-motion: no-preference) { .sb-undo-wrap:not([hidden]) { animation: sb-pop .18s ease-out; } }
@keyframes sb-pop { from { opacity: 0; transform: translateY(2px); } }
@media (max-width: 768px) { .sb-undo, .sb-help-x { height: 48px; padding: 0 16px; } }   /* a thumb's size on a phone */
