#inventory-status {
  max-width: 600px;
  margin: 20px auto;
  text-align: center;
  padding: 20px;
  background-color: var(--dark);
  border-radius: 8px;
}

#loading-message {
  font-size: 18px;
  margin-bottom: 15px;
  color: var(--pop);
}

#progress-bar {
  width: 100%;
  height: 20px;
  background-color: var(--gray);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

#progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pop), #27ae60);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 10px;
}

#progress-text {
  font-size: 14px;
  color: var(--text);
}

#inventory-summary {
  max-width: 800px;

  /* No top margin: the summary sits flush at the top of #inventory-area so its gap below the top
     bar matches the item card's (which sits flush in #item-card-outer). Bottom margin stays. */
  margin: 0 auto 18px;
  padding: 12px 16px;
  background-color: var(--dark);
  border-radius: 8px;
}

/* Profile on the left, highlight chips on the right, rarity bar below. */
.summary-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 10px;
}

.ban-alert {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: rgb(204 73 47 / 15%);
  border: 1px solid var(--error, #cc492f);
  color: var(--error, #cc492f);
  font-weight: bold;
  text-align: center;
}

.summary-profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.summary-persona {
  font-size: 15px;
  font-weight: bold;
  color: var(--text);
}

.summary-profile:hover .summary-persona {
  color: var(--pop);
}

.summary-avatar {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.summary-nameblock {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Account age from the profile feed's memberSince year, shown under the persona. */
.summary-since {
  font-size: 12px;
  color: var(--text);
  opacity: 0.55;
}
.summary-since:empty { display: none; }

.rarity-bar {
  display: flex;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  background-color: var(--gray);
}

.rarity-segment {
  height: 100%;
  min-width: 2px;
}

.rarity-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
}

.rarity-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.9;
}

.rarity-legend-item strong {
  color: var(--pop);
  font-weight: 700;
}

.rarity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.summary-highlights {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.highlight-chip {
  background-color: var(--gray);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.highlight-chip.special {
  border: 1px solid var(--pop);
}

/* Total inventory value - the headline number, tinted the same green as the per-card prices. */
.highlight-chip.value {
  color: #7fdca4;
  border: 1px solid rgb(127 220 164 / 50%);
  font-variant-numeric: tabular-nums;
}

.float-range span {
  color: var(--text);
  font-size: 14px;
}

#inventory-container {
  max-width: 1200px;
  margin: 0 auto;
}

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

/* Item container styles for web components */
inventory-item {
  display: block;
  background-color: var(--dark);
  border-radius: 8px;
  padding: 15px;

  /* Match the shadow :host: only animate the properties that actually change, not 'all'. */
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-left-color 0.3s ease, opacity 0.3s ease;
  border-left: 4px solid var(--gray);
  position: relative;
}

.control-group {
  display: flex;
  flex-direction: column;
  min-width: 150px;
}

.control-group label {
  color: var(--text);
  font-size: 14px;
  margin-bottom: 5px;
  font-weight: 500;
}

.control-group select,
.control-group input[type="number"] {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--light);
  background-color: var(--gray);
  color: var(--text);
  font-size: 14px;
}

/* Replace native widget chrome (Safari's select/stepper styling differs wildly from
   Chrome's) with one consistent look: flat fields, a custom chevron on selects, and no
   spinner buttons on the float inputs. */
.control-group select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23ecf0f1' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.control-group input[type="number"] {
  appearance: textfield;
}

.control-group input[type="number"]::-webkit-inner-spin-button,
.control-group input[type="number"]::-webkit-outer-spin-button {
  display: none;
}

/* Attribute toggle chips (★ / ST / Souvenir / Special). Independent AND filters - a
   StatTrak knife matches with both ★ and ST pressed - unlike the single-select
   dropdown they replaced. */
.attr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attr-chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--light);
  background-color: var(--gray);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.attr-chip:hover {
  border-color: var(--pop);
}

.attr-chip[aria-pressed="true"] {
  background-color: var(--pop);
  border-color: var(--pop);
  color: var(--gray);
}

.float-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.float-range input[type="number"] {
  width: 80px;
}

.control-group select:focus,
.control-group input[type="number"]:focus {
  outline: none;
  border-color: var(--pop);
  box-shadow: 0 0 0 2px rgb(46 204 113 / 20%);
}

.checkbox-group {
  display: flex;
  flex-direction: column; /* one checkbox per row, left-aligned within the column control-group */
  align-items: flex-start;
  gap: 8px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

/* Fully custom checkbox: Safari draws native ones oversized and ignores width/height,
   so opt out of native rendering entirely and draw the check with rotated borders. */
.checkbox-group input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--light);
  border-radius: 3px;
  background-color: var(--gray);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"]:checked {
  background-color: var(--pop);
  border-color: var(--pop);
}

.checkbox-group input[type="checkbox"]:checked::after {
  content: '';
  width: 8px;
  height: 4px;
  margin-top: -2px;
  border-left: 2px solid var(--dark);
  border-bottom: 2px solid var(--dark);
  transform: rotate(-45deg);
}

/* Main layout with three-column structure */
#main-layout {
  display: flex;
  align-items: flex-start;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 20px;
  gap: 20px;
}

/* Sidebar styles */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.sidebar-content {
  background-color: var(--dark);
  border: 1px solid var(--light);
  border-radius: 8px;
  padding: 20px;
}

/* Sidebar bar: search + sort + Filters toggle. On desktop everything is shown, the
   Filters toggle is hidden, and the filter sections below stay open. */
.sidebar-bar {
  margin-bottom: 20px;
}

.search-group {
  margin-bottom: 18px;
}

.search-group input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--light);
  background-color: var(--gray);
  color: var(--text);
  font-size: 14px;
}

.search-group input[type="text"]:focus {
  outline: none;
  border-color: var(--pop);
  box-shadow: 0 0 0 2px rgb(46 204 113 / 20%);
}

.sort-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Sort field + order toggle share one row, replacing the old stacked "Order:" select. */
.sort-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

/* stylelint-disable-next-line no-descending-specificity -- the .control-group select:focus rule
   above is unrelated; this only sets the sort field's flex sizing. */
.sort-row select {
  flex: 1;
  min-width: 0;
}

/* Square button matching the select's height (via align-items: stretch) and chrome. The arrow
   points down for descending and flips to point up for ascending. */
.order-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 0;
  border: 1px solid var(--light);
  border-radius: 4px;
  background-color: var(--gray);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.order-toggle:hover {
  background-color: var(--light);
  border-color: var(--pop);
}

.order-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.25s ease;
}

.order-toggle[data-order="asc"] svg {
  transform: rotate(180deg);
}

/* The flex gap above is the spacing; without this the control margin doubles it. */
.sort-controls .control-group {
  margin-bottom: 0;
}

.filter-toggle {
  display: none;
}

.clear-filters {
  margin-top: 0; /* the control group above already provides the gap */
  width: 100%;
  padding: 9px 12px;
  border-radius: 4px;
  border: 1px solid var(--light);
  background-color: var(--gray);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.clear-filters:hover {
  background-color: var(--light);
}

.grid-status {
  margin: 0 0 15px;
  color: var(--text);
  opacity: 0.85;
  font-size: 14px;
}

.grid-status:empty {
  display: none;
}

/* Expand/collapse animates grid-template-rows (0fr <-> 1fr), which tracks the real
   content height - no max-height guess that the content must be kept under. Desktop
   leaves it open; the mobile block below collapses it. */
.sidebar-sections {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.sidebar-section {
  margin-bottom: 25px;
}

.sidebar-sections > .sidebar-section {
  overflow: hidden;
  min-height: 0;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar h4 {
  margin: 0 0 15px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.sidebar .control-group {
  margin-bottom: 15px;
  min-width: auto;
}

.sidebar .control-group:last-child {
  margin-bottom: 0;
}

.sidebar .control-group label {
  margin-bottom: 6px;
  font-size: 13px;
}

.sidebar .control-group select,
.sidebar .control-group input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}

.sidebar .float-range {
  gap: 8px;
}

.sidebar .float-range input[type="number"] {
  flex: 1;
}

.sidebar .checkbox-group {
  margin-right: 0;
}

.sidebar .checkbox-group label {
  font-size: 13px;
}

/* Content area - centered between sidebar and spacer */
.content-area {
  flex: 1;
  min-width: 0;
  max-width: 1200px;
}


/* Allow content to expand on narrower screens */
@media (width <= 1320px) {
  .content-area {
    max-width: none;
  }
}

@media (width <= 1024px) {
  #main-layout {
    flex-direction: column;

    /* The base rule's align-items: flex-start is for the row layout; in a column it
       would shrink-wrap children to their content width instead of filling the screen
       (visible on inventories where every item name is short). */
    align-items: stretch;
    max-width: none;
    padding: 0 15px;
  }
  
  /* Sticky slim bar: the collapsed sidebar (sort + Filters button) pins to the top so
     the user can re-sort and open filters (name search included) without scrolling up. */
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    max-height: none;
  }

  .content-area {
    max-width: none;
  }

  .sidebar-content {
    padding: 12px;
    box-shadow: 0 4px 12px rgb(0 0 0 / 35%);

    /* The bar is pinned to top: 0, so square its top corners - otherwise a couple pixels of
       scrolled item content show through the rounded corners above it. Bottom stays rounded. */
    border-top-left-radius: 0;
    border-top-right-radius: 0;

    /* The expanded filter panel can be taller than a phone screen; since the bar is
       sticky, anything past the viewport would be unreachable without this. */
    box-sizing: border-box;
    max-height: 100vh; /* fallback for browsers without dvh */
    max-height: 100dvh;
    overflow-y: auto;
  }

  /* iOS Safari auto-zooms the page when focusing any text control under 16px */
  .search-group input[type="text"],
  .control-group select,
  .control-group input[type="number"] {
    font-size: 16px;
  }

  .sidebar-bar {
    margin-bottom: 0;
  }

  .search-group {
    margin-bottom: 10px;
  }

  .sidebar-bar-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
  }

  .sort-section {
    flex: 1;
    margin-bottom: 0;
  }

  .sort-controls {
    flex-direction: row;
    gap: 8px;
  }

  .sort-controls .control-group {
    flex: 1;
    margin-bottom: 0;
  }

  /* The select values ("Rarity", "Descending") are self-explanatory; dropping the labels
     keeps the sticky bar short so it steals less of the viewport from the item list. */
  .sort-controls .control-group label {
    display: none;
  }

  .filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 4px;
    border: 1px solid var(--light);
    background-color: var(--gray);
    color: var(--text);
    font-size: 14px;
    font-weight: 400; /* match the sort select's weight */
    cursor: pointer;
  }

  .filter-toggle-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
  }

  .filter-toggle[aria-expanded="true"] .filter-toggle-arrow {
    transform: rotate(180deg);
  }

  /* Collapsed by default on mobile */
  .sidebar-sections {
    grid-template-rows: 0fr;
    opacity: 0;
    margin-top: 0;
  }

  .sidebar-sections.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: 15px;
  }

  .sidebar-section {
    margin-bottom: 20px;
  }

  .sidebar .control-group {
    margin-bottom: 12px;
  }

  /* The sort selects sit in the same row as the Filters toggle; a bottom margin here
     would push the flex-end-aligned toggle below the selects. (Must come after the
     .sidebar .control-group rule above, which would otherwise win.) */
  .sidebar-bar-row .control-group {
    margin-bottom: 0;
  }
}

@media (width <= 768px) {
  .content-area {
    padding: 0;
  }

  #inventory-grid {
    grid-template-columns: 1fr;
  }
  
  /* Tighten the summary on mobile so the actual inventory items are
     reachable with much less scrolling. No top margin, matching the item card's flush top. */
  #inventory-summary {
    margin: 0 auto 12px;
    padding: 10px 12px;
  }

  .summary-top {
    margin-bottom: 8px;
  }

  .rarity-legend {
    font-size: 11px;
    gap: 4px 12px;
    margin-top: 10px;
  }

  .highlight-chip {
    font-size: 11px;
    padding: 3px 10px;
  }

  .sidebar h4 {
    font-size: 13px;
  }
}

/* Dual-thumb range slider styles. The track shows the same wear-zone gradient as the
   per-item float bars; the portions outside the selected range are dimmed by two
   overlay elements (widths set in % by updateSliderVisual), exactly like the
   .float-bar-dim overlays on the item cards. */
.float-slider-container {
  margin-bottom: 10px;
  padding: 10px 0;
}

.float-slider-track {
  position: relative;
  height: 6px;
  border-radius: 3px;
  margin: 0 10px;
  background: linear-gradient(90deg, #2ecc71 0 7%, #82c91e 7% 15%, #f1c40f 15% 38%, #e67e22 38% 45%, #e74c3c 45% 100%);
}

.float-slider-dim {
  position: absolute;
  top: 0;
  height: 100%;
  background-color: rgb(15 29 42 / 70%);
  pointer-events: none;
}

.float-slider-dim:first-child {
  left: 0;
  border-radius: 3px 0 0 3px;
}

.float-slider-dim:nth-child(2) {
  right: 0;
  border-radius: 0 3px 3px 0;
}

.float-slider-track input[type="range"] {
  position: absolute;
  width: 100%;
  height: 6px;
  background: none;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
  appearance: none;
}

/* Neutral thumbs so they read as handles over the colored gradient */
.float-slider-track input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background-color: var(--text);
  border: 2px solid var(--dark);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  position: relative;
  z-index: 2;
}

.float-slider-track input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background-color: var(--text);
  border: 2px solid var(--dark);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  position: relative;
  z-index: 2;
}

.float-slider-track input[type="range"]::-webkit-slider-thumb:hover {
  background-color: #fff;
}

.float-slider-track input[type="range"]::-moz-range-thumb:hover {
  background-color: #fff;
}

.float-slider-track input[type="range"]::-webkit-slider-thumb:active {
  background-color: #c8d0d4;
}

.float-slider-track input[type="range"]::-moz-range-thumb:active {
  background-color: #c8d0d4;
}

/* Ensure min slider is on top so it's grabbed first when thumbs overlap */
#float-slider-min {
  z-index: 2;
}

#float-slider-max {
  z-index: 1;
}