/* Page styles for the Library, Search, Ask and the component gallery (/ui). Shared pieces live in
   ui.css (components) and app.css (tokens and the shell); see docs/ui.md. Each page loads this file in
   its head block; class names carry the page's prefix (lib-, sr-, ask-, g-). */

/* ------------------------------------------------------------------ Library */
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.lib-search-wrap { position: relative; flex: 1 1 12rem; max-width: 16rem; display: flex; align-items: center; }
.lib-search-wrap > svg { position: absolute; left: 10px; color: var(--muted-foreground); pointer-events: none; }
.lib-search { width: 100%; height: 32px; padding-left: 32px; }
.lib-status .toggle-item[data-empty] { color: var(--muted-foreground); }
.lib-status .toggle-item[data-empty] .count { opacity: .6; }
.lib-facets { display: contents; }
.lib-facets .lib-chip { height: 32px; font-size: var(--text-sm); border-style: dashed; box-shadow: none; }
.lib-facets .lib-chip[aria-pressed="true"] { border-style: solid; background: var(--secondary); }
.lib-facets .lib-chip .count { font-family: var(--mono); font-size: var(--text-xs); color: var(--muted-foreground); font-weight: 400; }
.lib-toolbar [data-lib-sort] { margin-left: auto; }
.lib-note { margin: var(--space-2) 0 0; color: var(--muted-foreground); font-size: var(--text-sm); }
.lib-empty .btn[data-variant="link"] { height: auto; padding: 0; vertical-align: baseline; }
.lib-refresh { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.lib-muted, .lib-tk { color: var(--muted-foreground); font-size: var(--text-sm); }
.lib-co a { color: var(--foreground); font-weight: 600; text-decoration: none; }
.lib-tk { margin-left: .25rem; }
.lib-dist { white-space: nowrap; }
.lib-dist-h { min-width: 13rem; }
.lib-bar { position: relative; display: inline-block; vertical-align: middle; width: 8rem; height: 8px; margin-right: .5rem; }
.lib-zero { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--price); }
.lib-fill { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--muted-foreground); opacity: .55; }
.lib-fill.below { background: var(--price); opacity: 1; }
.lib-fill.capped { border-radius: 2px 0 0 2px; -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
.lib-pct { display: inline-block; min-width: 4rem; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.lib-warn { color: var(--warning); margin-left: .25rem; display: inline-flex; vertical-align: middle; }
.lib-live { display: inline-block; width: 14px; text-align: right; }
.lib-dot { width: 6px; height: 6px; color: var(--price); vertical-align: middle; }
.lib-age { color: var(--muted-foreground); }
.lib-since { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: var(--text-xs); white-space: nowrap; }
.lib-quote { display: inline-flex; vertical-align: middle; color: var(--muted-foreground); }
.lib-quote:hover, .lib-quote:focus-visible { color: var(--foreground); }
.lib-star-h { width: 40px; }
.table td.lib-star { width: 40px; padding-top: 0; padding-bottom: 0; text-align: right; }
/* empty Library or watchlist: the table's header over faded placeholder rows, the message centred on them */
.lib-empty-state { position: relative; display: grid; grid-template-rows: auto 1fr; min-height: 24rem; margin-bottom: var(--space-8); overflow: hidden; }
.lib-empty-head, .lib-ghost-row { display: grid; grid-template-columns: minmax(10rem, 2.2fr) 1fr 1fr 1fr minmax(8rem, 2fr) .6fr; column-gap: var(--space-4); align-items: center; }
.lib-empty-head { height: 40px; border-bottom: 1px solid var(--border); color: var(--muted-foreground); font-size: var(--text-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.lib-empty-head .num { text-align: right; }
.lib-empty-ghost { grid-row: 2; grid-column: 1; align-self: start; -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 85%); mask-image: linear-gradient(to bottom, #000 0%, transparent 85%); }
.lib-ghost-row { height: 49px; border-bottom: 1px solid var(--border); }
.lib-ghost-row .skel { display: block; height: 8px; width: 56%; border-radius: var(--radius-sm); background: var(--muted); }
.lib-ghost-row .skel:nth-child(n+3):not(.lib-ghost-bar) { justify-self: end; width: 48%; }
.lib-ghost-row .lib-ghost-bar { width: 72%; }
.lib-empty-body { grid-row: 2; grid-column: 1; align-self: center; justify-self: center; display: grid; justify-items: center; gap: var(--space-2);
  max-width: 30rem; padding: var(--space-10) var(--space-10); text-align: center; color: var(--muted-foreground); font-size: var(--text-base);
  background: radial-gradient(closest-side, var(--background) 72%, transparent); }
.lib-empty-body p { margin: 0; }
.lib-empty-body .empty-title { margin: var(--space-2) 0 0; color: var(--foreground); font-family: var(--sans); font-size: var(--text-md); font-weight: 600; }
.lib-empty-icon { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.lib-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-3); }
@media (max-width: 720px) {
  .lib-empty-state { min-height: 20rem; }
  .lib-empty-head, .lib-ghost-row { grid-template-columns: minmax(0, 2fr) 1fr 1fr; }
  .lib-empty-head > :nth-child(n+4), .lib-ghost-row > :nth-child(n+4) { display: none; }
}
.lib-more { margin-top: var(--space-8); }
.lib-more h3 { font-size: var(--text-sm); font-weight: 600; margin: var(--space-3) 0 var(--space-2); }
.lib-list { list-style: none; margin: 0; padding: 0; columns: 2 16rem; }
.lib-list li { padding: 2px 0; break-inside: avoid; }
@media (max-width: 640px) {
  .lib-search-wrap { max-width: none; flex-basis: 100%; }
  .lib-status { max-width: 100%; overflow-x: auto; }
  .lib-status .toggle-item { white-space: nowrap; }
  .lib-table .lib-co { white-space: normal; }
  .lib-refresh { margin-left: 0; width: 100%; justify-content: space-between; }
  .lib-table thead { display: none; }
  .lib-table, .lib-table tbody { display: block; }
  .lib-table tr { display: grid; grid-template-columns: auto auto minmax(5rem, 1fr) auto; grid-template-areas: "co co rating star" "price entry dist star"; column-gap: var(--space-3); row-gap: 2px; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
  .lib-table tr[hidden] { display: none; }
  .lib-table td, .lib-table td.num { display: block; padding: 0 !important; border: 0; text-align: left; white-space: nowrap; }
  .lib-table tr { align-items: baseline; }
  .lib-table .lib-co { grid-area: co; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .lib-table .lib-rating { grid-area: rating; justify-self: end; }
  .lib-table td.lib-star { grid-area: star; align-self: center; margin-left: var(--space-1); }
  .lib-missing tr { grid-template-areas: "co co rating star"; }
  .lib-table td.lib-age { display: none; }
  .lib-table tr > .lib-price { grid-area: price; } .lib-table tr > .lib-entry { grid-area: entry; } .lib-table tr > .lib-dist { grid-area: dist; justify-self: end; }
  .lib-table .lib-price, .lib-table .lib-entry, .lib-table .lib-pct { font-size: var(--text-xs); }
  .lib-table td[data-label]::before { content: attr(data-label) " "; color: var(--muted-foreground); font-family: var(--sans); }
  .lib-live { width: 10px; }
  .lib-bar { display: none; }
  .lib-pct { min-width: 0; }
  .lib-dist-h { min-width: 0; }
  .lib-empty td { padding: var(--space-3) 0; }
}

/* ------------------------------------------------------------------ Search */
.sr-form { margin-bottom: var(--space-4); max-width: 40rem; }
.sr-field { position: relative; }
.sr-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); display: inline-flex; pointer-events: none; }
.sr-input { padding-left: 34px; width: 100%; }
.sr-toolbar { margin-bottom: var(--space-4); overflow-x: auto; }
.sr-muted, .sr-tk { color: var(--muted-foreground); font-size: var(--text-sm); }
.sr-meta { color: var(--muted-foreground); font-size: var(--text-sm); margin: 0 0 var(--space-2); }
.sr-group { padding: var(--space-4) 0; border-top: 1px solid var(--border); }
.sr-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.sr-co { font-size: var(--text-base); font-weight: 600; margin: 0; font-family: inherit; }
.sr-co a { color: var(--foreground); text-decoration: none; }
.sr-co a:hover { text-decoration: underline; }
.sr-hit { display: block; padding: var(--space-2); margin: 0 calc(-1 * var(--space-2)); border-radius: var(--radius-md); color: var(--foreground); text-decoration: none; }
.sr-hit:hover { background: var(--muted); }
.sr-hit-t { display: block; font-size: var(--text-sm); color: var(--muted-foreground); margin-bottom: 2px; }
.sr-snip { display: block; font-size: var(--text-base); line-height: 1.5; }
.sr-snip mark { background: color-mix(in srgb, var(--warning) 28%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.sr-more { margin-top: var(--space-1); }
.sr-rest { margin-top: var(--space-4); }
.sr-foot { margin-top: var(--space-8); }
@media (max-width: 640px) { .sr-long { display: none; } .sr-scope .toggle-item { padding: 0 10px; font-size: var(--text-sm); } }

/* ------------------------------------------------------------------ Ask */
.ask-page { max-width: 44rem; margin: 0 auto; }
.ask-header { text-align: left; }
.ask-composer { position: relative; border: 1px solid var(--input); border-radius: var(--radius-xl); background: var(--background); padding: var(--space-3); padding-bottom: 52px; box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.ask-composer:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent); }
.ask-input { display: block; width: 100%; min-height: 4.5rem; resize: vertical; border: 0; outline: none; background: transparent; color: var(--foreground); font: inherit; font-size: var(--text-md); line-height: 1.5; padding: 0; }
.ask-input::placeholder { color: var(--muted-foreground); }
.ask-bar { position: absolute; right: var(--space-3); bottom: var(--space-3); left: var(--space-3); display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); }
.ask-hint { color: var(--muted-foreground); font-size: var(--text-xs); }
.ask-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1); margin-top: var(--space-3); }
.ask-examples .btn { color: var(--muted-foreground); white-space: normal; height: auto; min-height: 32px; text-align: left; }
.ask-new { text-align: center; font-size: var(--text-sm); margin-top: var(--space-3); }
.ask-thread { margin-bottom: var(--space-6); }
.ask-turn { padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.ask-q { font-weight: 600; margin: 0 0 var(--space-2); }
.ask-status { color: var(--muted-foreground); font-size: var(--text-sm); margin: 0; }
.ask-muted { color: var(--muted-foreground); }
.ask-recent { margin-top: var(--space-12); }
.ask-list { list-style: none; margin: 0; padding: 0; }
.ask-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-2); margin: 0 calc(-1 * var(--space-2)); border-radius: var(--radius-md); color: var(--foreground); text-decoration: none; }
.ask-row:hover, .ask-row.is-open { background: var(--muted); }
.ask-row-q { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-row-meta { color: var(--muted-foreground); font-size: var(--text-sm); white-space: nowrap; }
.ask-empty p { margin: 0; }
@media (max-width: 640px) { .ask-row { flex-direction: column; gap: 0; } .ask-row-q { white-space: normal; } }

/* ------------------------------------------------------------------ component gallery (/ui, local only) */
.g-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--space-6); }
.g-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.g-label { font-size: var(--text-sm); color: var(--muted-foreground); margin-bottom: var(--space-2); }
.g-swatch { display: grid; gap: 4px; font-size: var(--text-xs); }
.g-swatch i { display: block; height: 40px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.g-slider { display: grid; gap: var(--space-2); padding-top: var(--space-6); }
.g-out { font-family: var(--mono); font-size: var(--text-sm); color: var(--muted-foreground); }

/* ------------------------------------------------------------------ Price checks (staff) */
.pc-note { max-width: 28rem; text-align: right; }
.pc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-8); }
.pc-stat { padding: var(--space-4) 0; gap: 0; }
.pc-stat .card-content { padding: 0 var(--space-4); gap: 2px; }
.pc-stat p { margin: 0; }
.pc-k { color: var(--muted-foreground); font-size: var(--text-sm); }
.pc-v { font-size: 1.75rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.pc-s { color: var(--muted-foreground); font-size: var(--text-xs); }
.pc-table td { vertical-align: top; }
.pc-why { max-width: 32rem; }
.pc-kind { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: var(--text-xs); }
.pc-sym { display: flex; gap: var(--space-2); }
.pc-sym .input { width: 9rem; height: 32px; }
.pc-n { display: block; margin-top: 4px; font-size: var(--text-xs); }
.pc-change { white-space: nowrap; }
.pc-lead { margin-top: 0; }
.pc-dead { margin: var(--space-3) 0 0; padding-left: 1.2rem; font-size: var(--text-sm); }
@media (max-width: 720px) {
  .pc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-sym { flex-wrap: wrap; }
  .pc-note { text-align: left; }
}
