/* CR-1201: the market tree in the Keep stocked list editor. Nested groups indent; a group's items sit in a stacked table at phone width. */
.keep-market { margin: var(--s2) 0; }
.keep-market-group { border-left: 2px solid var(--line); margin: var(--s1) 0 var(--s1) var(--s2); padding-left: var(--s2); }
.keep-market-group > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); }
.keep-market-tick { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 600; }
.keep-market-items table input, .keep-market-items table select { max-width: 100%; box-sizing: border-box; }
.keep-market-items table input[type="number"] { width: 7em; min-height: 44px; }
.keep-market-items table select { min-height: 44px; }

/* CR-1209: the folded tree. An arrow opens a group; the tick is a real box; a match from the search is marked. */
.keep-node-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); }
.keep-arrow { min-width: 44px; min-height: 44px; background: none; border: 0; cursor: pointer; font-size: 1.1em; }
.keep-arrow[hidden] { display: none; }
.keep-node-row button.small { min-height: 44px; }
.keep-found { margin: var(--s1) 0; }
.keep-market-items tr.match { outline: 2px solid var(--accent, currentColor); }
.keep-search, .keep-market input[type="search"] { min-height: 44px; max-width: 100%; box-sizing: border-box; }

/* CR-1209: the footer bar of an edit. Alert and Save sit together at the bottom of the screen while a list is edited. */
.keep-footer { position: sticky; bottom: 0; z-index: var(--layer-sticky); background: var(--card, var(--bg)); border-top: 1px solid var(--line); padding: var(--s2); margin-top: var(--s2); }
.keep-footer-buttons { display: flex; flex-wrap: wrap; gap: var(--s2); }
.keep-footer-buttons button { min-height: 44px; }
.keep-footer input, .keep-footer select, .keep-grid input[type="number"], .keep-grid select { min-height: 44px; max-width: 100%; box-sizing: border-box; }
.keep-grid input[type="number"] { width: 8em; }
.keep-note { display: block; }

/* CR-1622: the market window. Two panes at 1280 px; one level at a time with a bottom sheet at phone width. Indents and sizes are set from script with style.setProperty (no inline styles). */
.km-window { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: var(--s2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s2); min-height: 560px; }
.km-left { display: flex; flex-direction: column; min-width: 0; gap: var(--s1); }
.km-search { display: flex; align-items: end; gap: var(--s1); }
.km-search .field { flex: 1; min-width: 0; }
.km-tabs { display: flex; gap: var(--s1); }
.km-tab, .km-several, .km-clear, .km-back { min-height: 44px; }
.km-tab[aria-selected="true"] { font-weight: 700; border-bottom: 2px solid var(--accent); }
.km-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.km-start { display: inline-flex; align-items: center; gap: var(--s1); }
.km-start input { width: 6em; min-height: 44px; max-width: 100%; box-sizing: border-box; }
.km-scroll { position: relative; overflow-y: auto; overflow-x: hidden; height: 420px; border: 1px solid var(--line); border-radius: var(--radius); }
.km-sizer { position: relative; width: 100%; }
.km-row { position: absolute; left: 0; right: 0; box-sizing: border-box; display: flex; align-items: center; gap: var(--s1); padding-right: var(--s2); overflow: hidden; cursor: pointer; }
.km-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.km-row.picked { background: var(--sunk); }
.km-note { cursor: default; flex-wrap: wrap; }
.km-chev { width: 16px; text-align: center; flex: none; }
.km-name { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.km-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.km-hidden { white-space: normal !important; }
.km-mark { flex: none; }
.km-onlist { font-weight: 600; }
.km-tick { width: 24px; height: 24px; flex: none; }
.km-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--sunk); border-radius: var(--radius-sm); font-size: 0.7em; overflow: hidden; color: var(--muted); }
.km-icon-32 { width: 32px; height: 32px; }
.km-icon-64 { width: 64px; height: 64px; }
.km-icon img { display: block; }
.km-detail { min-width: 0; padding: var(--s1); }
.km-head { display: flex; gap: var(--s2); align-items: center; }
.km-head h3 { margin: 0; }
.km-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--s2); margin: var(--s2) 0; }
.km-facts dt { color: var(--muted); }
.km-facts dd { margin: 0; }
.km-detail input[type="number"], .km-detail select, .km-detail button { min-height: 44px; max-width: 100%; box-sizing: border-box; }
.km-paste { margin: var(--s2) 0; }
.km-paste summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.km-nav { display: flex; align-items: center; gap: var(--s2); }
.km-nav[hidden], .km-back[hidden], .km-crumb[hidden] { display: none; }
.km-crumb { margin: 0; overflow-wrap: anywhere; }
.keep-count { margin: 0 0 var(--s1); min-height: 1.2em; }
.km button.link { min-height: 44px; }

@media (max-width: 640px) {
  .km-window { display: block; padding: var(--s1); min-height: 0; }
  .km-scroll { height: 50vh; }
  .km-detail { display: none; }
  .km-detail.open { display: block; position: fixed; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow-y: auto; z-index: var(--layer-sticky); background: var(--surface); border-top: 2px solid var(--line); padding: var(--s2); box-sizing: border-box; }
  .km-chev { text-align: right; order: 5; }
}
.km-back { flex: none; white-space: nowrap; }
.km-icon { position: relative; }
.km-icon img { position: absolute; inset: 0; }
.km-letters[hidden] { display: none; }

/* The review of CR-1622: 44 px rows and in-row buttons on every width, a 44 px tick, and one column where two panes would squeeze the detail. */
.km-row button { min-height: 44px; }
.km-tick { min-width: 44px; min-height: 44px; }
.km-groupset { min-height: 44px; }
.km-groupset[hidden] { display: none; }
@media (max-width: 900px) { .km-window { grid-template-columns: 1fr; } }
