*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --sticky-header-height: 96px;
  --page-bg: #f4f6f8;
  --sidebar-width-left: 240px;
  --sidebar-width-right: 280px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: #1a1a1a;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.sticky-search-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--page-bg);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.sticky-search-header__inner {
  padding-top: 1rem;
  padding-bottom: 0.75rem;
}

.sticky-search-header--compact .subtitle {
  display: none;
}

.sticky-search-header--compact .header h1 {
  font-size: 1.15rem;
  margin-bottom: 0;
}

.sticky-search-header--compact .mode-bar {
  margin-bottom: 0.65rem;
}

.content-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width-left) minmax(0, 1fr) var(--sidebar-width-right);
  gap: 1rem;
  align-items: start;
  padding-top: 1rem;
  padding-bottom: 3rem;
}

.left-sidebar,
.right-sidebar {
  position: sticky;
  top: calc(var(--sticky-header-height) + 12px);
  align-self: start;
  max-height: calc(100vh - var(--sticky-header-height) - 24px);
  overflow: auto;
}

.results-feed {
  min-width: 0;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0 0 0.75rem;
  color: #555;
}

.mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.mode-bar__divider {
  width: 1px;
  height: 1.5rem;
  margin: 0 0.15rem;
  background: #d4d4d4;
}

.mode-button {
  padding: 0.55rem 1rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.mode-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.mode-button--active,
.mode-button--sort[aria-pressed="true"] {
  background: #1a5fb4;
  border-color: #1a5fb4;
  color: #fff;
}

.enrich-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: #444;
  font-size: 0.95rem;
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-form input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

.source-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid #d8dde3;
  border-radius: 10px;
  background: #fff;
}

.source-filter__legend {
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
  padding: 0 0 0.35rem;
  margin-bottom: 0.25rem;
  width: 100%;
}

.source-filter__list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.source-filter__item {
  --source-accent: #cbd5e1;
  display: flex;
  position: relative;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.35rem 0.4rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.source-filter__item::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 50%;
  width: 0.5rem;
  height: 1.15rem;
  border-top: 2px solid var(--source-accent);
  border-bottom: 2px solid var(--source-accent);
  border-left: 2px solid var(--source-accent);
  border-radius: 8px 0 0 8px;
  transform: translateY(-50%);
  opacity: 0.95;
}

.source-filter__item:hover {
  background: #f1f5f9;
}

.source-filter__item--all {
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.25rem;
  padding-left: 0.35rem;
  padding-bottom: 0.55rem;
}

.source-filter__item--all::before {
  display: none;
}

.source-filter__item input {
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.source-filter__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-filter__logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.source-filter__item--junora {
  --source-accent: #e83e7f;
  border: 1px solid transparent;
}

.source-filter__item--junora:hover {
  background: #eef4f7;
}

.source-filter__item--junora.source-filter__item--selected {
  border-color: #bfd0da;
  background: #f6f4ee;
  box-shadow: inset 0 0 0 1px rgba(0, 54, 83, 0.08);
}

.source-filter__item--klaravik {
  --source-accent: #d21f3c;
}

.source-filter__item--kronofogden {
  --source-accent: #214e9d;
}

.source-filter__item--auctionet {
  --source-accent: #7a0f14;
}

.source-filter__item--psauction {
  --source-accent: #f39c12;
}

.source-filter__item--blinto {
  --source-accent: #1f4f8f;
}

.source-filter__item--budi {
  --source-accent: #0ea5a4;
}

.source-filter__item--netauktion {
  --source-accent: #475569;
}

.source-filter__item--tradera {
  --source-accent: #006aa7;
}

.source-filter__logo--on-dark {
  padding: 2px;
  border-radius: 4px;
  background: #1f2933;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.25rem 0.55rem 0.25rem 0.35rem;
  border: 1px solid #dde3ea;
  border-radius: 999px;
  background: #f8fafc;
}

.source-badge--compact {
  padding: 0.15rem 0.4rem 0.15rem 0.25rem;
}

.source-badge--text-only {
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

.source-badge--junora {
  border-color: #c7d7de;
  background: linear-gradient(135deg, #f6f4ee 0%, #eef4f7 100%);
}

.source-badge--junora .source-badge__label,
.source-badge--junora.source-badge--text-only {
  color: #003653;
}

.source-badge__logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.source-badge__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lot-card__top {
  margin-bottom: 0.55rem;
}

.results-sentinel {
  height: 1px;
}

.results-footer {
  padding: 0.75rem 0 0.25rem;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}

.search-form button {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: #1a5fb4;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.search-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-help-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  background: #5b3aa8;
  white-space: nowrap;
}

.ai-help-button__icon {
  font-size: 0.95rem;
  line-height: 1;
  flex-shrink: 0;
}

.ai-help-button__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.ai-help-button__label--short {
  display: none;
}

.sticky-search-header--compact .ai-help-button__label--full {
  display: none;
}

.sticky-search-header--compact .ai-help-button__label--short {
  display: inline;
}

.sticky-search-header--compact .ai-help-button {
  gap: 0.3rem;
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

.sticky-search-header--compact .ai-help-button__icon {
  font-size: 0.85rem;
}

.ai-help-panel {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d8dde3;
  border-radius: 8px;
  background: #f8fafc;
}

.ai-help-panel[hidden],
#status[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.ai-help-panel__title {
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
}

.sticky-search-header--compact .ai-help-panel:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.sticky-search-header--compact .ai-help-panel__title {
  margin: 0;
  font-size: 0.8rem;
}

.sticky-search-header--compact .ai-help-panel__title::after {
  content: ":";
}

.sticky-search-header--compact .ai-help-panel__list {
  gap: 0.35rem;
}

.sticky-search-header--compact .ai-help-panel__item {
  padding: 0.28rem 0.5rem;
}

.ai-help-panel__status {
  margin: 0;
  font-size: 0.875rem;
  color: #64748b;
  font-style: italic;
}

.ai-help-panel__status--error {
  color: #b42318;
  font-style: normal;
}

.ai-help-panel__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-help-panel__list--compact {
  gap: 0.35rem;
}

.ai-help-panel__item {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 0.4rem 0.65rem;
  border: 1px solid #c7d2e0;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.ai-help-panel__list--compact .ai-help-panel__item {
  padding: 0.3rem 0.55rem;
}

.ai-help-panel__item:hover {
  border-color: #5b3aa8;
  background: #f3effb;
}

.ai-help-panel__item--selected {
  border-color: #5b3aa8;
  background: #ede9fe;
  box-shadow: inset 0 0 0 1px #5b3aa8;
}

.ai-help-panel__swedish {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1f2933;
}


.search-history {
  padding: 0.75rem;
  border: 1px solid #d8dde3;
  border-radius: 10px;
  background: #fff;
}

.search-history__title {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #334155;
}

.search-history__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.search-history__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.5rem 0.55rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
}

.search-history__item:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.search-history__query {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  word-break: break-word;
}

.search-history__original {
  font-size: 0.75rem;
  color: #64748b;
}

.search-history__empty {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.status {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
}

.status--loading {
  background: #e8f0fe;
  color: #1a5fb4;
}

.status--error {
  background: #fde8e8;
  color: #b42318;
}

.status--empty {
  background: #f3f4f6;
  color: #555;
}

.results-sentinel {
  width: 100%;
  height: 1px;
}

.results {
  display: grid;
  gap: 1rem;
}

.lot-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
}

.lot-card--junora {
  border-color: #d9e2e8;
  box-shadow: inset 4px 0 0 #e83e7f;
}

.lot-card__image-wrapper {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  overflow: hidden;
  align-self: start;
}

.lot-card__image-wrapper--placeholder {
  color: #666;
  font-size: 0.875rem;
}

.lot-card__image-wrapper--clickable {
  cursor: pointer;
}

.lot-card__image-wrapper--clickable:hover {
  filter: brightness(0.96);
}

.lot-card__image-wrapper--clickable:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.lot-card__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  display: block;
}

.lot-card__body {
  padding: 1rem 1rem 1rem 0;
}

.lot-card__title {
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

.lot-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem 1rem;
  margin: 0 0 1rem;
}

.lot-card__meta div {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.lot-card__meta dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
}

.lot-card__meta dd {
  margin: 0;
  font-weight: 500;
}

.lot-card__place--pending {
  color: #6b5a2e;
}

.lot-card__place--pending .lot-card__place-note {
  font-weight: 400;
  color: #9a7b2f;
}

.lot-card__place--missing {
  color: #888;
  font-style: italic;
}

.lot-card__open {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.lot-card__open:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #1a5fb4;
}

.lot-card__open-icon {
  flex-shrink: 0;
  opacity: 0.75;
}

.lot-card__gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.lot-card__extras {
  margin-bottom: 0.75rem;
}

.lot-card__extras-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lot-card__extra-button {
  border: 1px solid #c9d4e3;
  background: #f7faff;
  color: #1a3f66;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.lot-card__extra-button:hover:not(:disabled) {
  background: #e9f1ff;
}

.lot-card__extra-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.lot-card__extra-status {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: #666;
}

.lot-description {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: #f6f8fb;
  border: 1px solid #e3e8ef;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.lot-description__text,
.lot-description__condition,
.lot-description__details {
  margin: 0 0 0.5rem;
}

.lot-description__details:last-child,
.lot-description__condition:last-child,
.lot-description__text:last-child {
  margin-bottom: 0;
}

.lot-description__section {
  margin-bottom: 0.75rem;
}

.lot-description__label {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #64748b;
}

.lot-description__ai {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px dashed #cbd5e1;
}

.lot-description__ai-summary {
  margin: 0;
  color: #1f2933;
}

.lot-description__ai-status {
  margin: 0;
  color: #64748b;
  font-style: italic;
}

.lot-description__ai-status--error {
  color: #b42318;
  font-style: normal;
}

body.gallery-modal-open {
  overflow: hidden;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.gallery-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.gallery-modal__panel {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100vw - 2rem));
  margin: 4vh auto;
  background: #111;
  border-radius: 12px;
  padding: 1rem;
  color: #fff;
}

.gallery-modal__body {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-modal__image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.gallery-modal__image--loading {
  opacity: 0.35;
}

.gallery-modal__status {
  margin: 0;
  font-size: 1rem;
}

.gallery-modal__counter {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.875rem;
}

.gallery-modal__close {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-modal__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.5rem;
}

.gallery-modal__nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.gallery-modal__nav--prev {
  left: 0.35rem;
}

.gallery-modal__nav--next {
  right: 0.35rem;
}

.lot-card__thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

@media (max-width: 1100px) {
  .content-layout {
    grid-template-columns: 220px minmax(0, 1fr) 240px;
  }
}

@media (max-width: 900px) {
  .content-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .left-sidebar,
  .right-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .source-filter__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.25rem;
  }

  .source-filter__item--all {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .search-form {
    flex-wrap: wrap;
  }

  .search-form input {
    width: 100%;
    flex: 1 1 100%;
  }

  .lot-card {
    grid-template-columns: 1fr;
  }

  .lot-card__image-wrapper {
    height: 180px;
    align-self: stretch;
  }

  .lot-card__body {
    padding: 0 1rem 1rem;
  }
}
