:root {
  --primary-button-disabled-background: #a9cbb8;
  --secondary-button-hover-background: #e6e6e6;
  --warning-message-background-color: #fcf9f0;
  --error-message-background-color: #f4d4cf;
  --error-message-border-color: #f2a1a1;
  --error-message-text-color: #c2412d;
  --scrollable-book-list-title-color: #777777;
  --book-card-border: 1px solid #cccccc;
}

.page-shell {
  padding-top: 32px;
  padding-bottom: 64px;
}

.page-card {
  background: var(--background-secondary-color);
  box-shadow: 0 1px 2px var(--shadow-color);
  padding: 30px 32px 36px;
}

.scanner-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: start;
  padding-bottom: 26px;
  border-bottom: var(--book-card-border);
  margin-bottom: 28px;
}

.scanner-kicker {
  margin-bottom: 10px;
  color: var(--hyperlink-text-color);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bs-hero-title {
  margin: 0;
  color: #4d3f28;
  font-family: "IM Fell English", serif;
  font-size: clamp(2.3rem, 4.8vw, 4rem);
  line-height: 0.98;
  font-weight: 400;
}

.bs-hero-title em {
  color: var(--hyperlink-text-color);
  font-style: normal;
}

.bs-hero-sub {
  max-width: 700px;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.7;
}

.scanner-hero-note {
  padding: 16px 18px;
  border: 1px solid #d8c2a8;
  background: var(--warning-message-background-color);
  font-size: 0.96rem;
  line-height: 1.7;
}

#drop-zone,
#preview-area {
  background: var(--background-secondary-color);
  border: var(--book-card-border);
}

#drop-zone {
  position: relative;
  overflow: hidden;
  border-style: dashed;
  border-width: 1px;
  border-radius: 6px;
  padding: 56px 40px;
  text-align: center;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

#drop-zone:hover,
#drop-zone.drag-over {
  border-color: var(--hyperlink-text-color);
  background: #f7fbfd;
}

#drop-zone svg {
  margin-bottom: 16px;
}

.drop-title {
  color: #4d3f28;
  font-size: 1.15rem;
  font-weight: 700;
}

.drop-hint {
  color: var(--muted-text-color);
  font-size: 0.96rem;
}

.drop-hint-secondary {
  font-size: 0.84rem;
}

.drop-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.drop-action-primary,
.drop-action-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 6px;
  font-size: 0.96rem;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
}

.drop-action-primary {
  border: 1px solid #555555;
  background: var(--primary-button-background);
  color: var(--primary-button-text-color);
}

.drop-action-primary:hover {
  background: var(--primary-button-hover-background);
  color: var(--primary-button-text-color);
}

.drop-action-secondary {
  border: 1px solid #555555;
  background: var(--background-secondary-color);
  color: var(--main-text-color);
}

.drop-action-secondary:hover {
  background: var(--secondary-button-hover-background);
}

.drop-action-primary:focus-visible,
.drop-action-secondary:focus-visible {
  outline: 2px solid var(--hyperlink-text-color);
  outline-offset: 2px;
}

#preview-area {
  margin-top: 24px;
  border-radius: 6px;
  padding: 22px;
}

#preview-img {
  width: 100%;
  max-width: 280px;
  max-height: 360px;
  object-fit: cover;
  border: var(--book-card-border);
}

.preview-side-title,
.results-title,
.book-title,
.title-on-cover {
  color: #4d3f28;
  font-family: "IM Fell English", serif;
}

.preview-side-title {
  font-size: 2rem;
}

.preview-side-hint,
#scanning-state,
.results-count,
.book-author,
.book-description,
.author-on-cover,
.not-found-badge {
  color: var(--muted-text-color);
}

.scan-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scan-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-text-color);
  font-size: 0.92rem;
  line-height: 1.5;
}

.scan-step-dot {
  width: 10px;
  height: 10px;
  border: 1px solid #b8b8b8;
  border-radius: 999px;
  background: #ffffff;
  flex-shrink: 0;
}

.scan-step-status {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.scan-step--active {
  color: #4d3f28;
  font-weight: 600;
}

.scan-step--active .scan-step-dot {
  border-color: var(--hyperlink-text-color);
  background: var(--hyperlink-text-color);
}

.scan-step--done .scan-step-dot {
  border-color: var(--primary-button-background);
  background: var(--primary-button-background);
}

.scan-step--done .scan-step-status {
  color: var(--primary-button-background);
}

.scan-step--skipped {
  opacity: 0.5;
}

.scan-step--skipped .scan-step-status {
  color: var(--muted-text-color);
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid #555555;
  border-radius: 6px;
  background: var(--primary-button-background);
  color: var(--primary-button-text-color);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.btn-scan:hover {
  background: var(--primary-button-hover-background);
  color: var(--primary-button-text-color);
  text-decoration: none;
}

.btn-scan:disabled {
  background: var(--primary-button-disabled-background);
  border-color: #cccccc;
  color: var(--primary-button-text-color);
}

.btn-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid #555555;
  border-radius: 6px;
  background: var(--background-secondary-color);
  color: var(--main-text-color);
  font-size: 1rem;
  transition: background 0.2s ease;
}

.btn-reset:hover {
  background: var(--secondary-button-hover-background);
  color: var(--main-text-color);
}

.preview-actions {
  min-height: 52px;
  align-items: center;
}

#similar-debug {
  border: var(--book-card-border);
  border-radius: 6px;
  background: #faf8f3;
  padding: 14px 16px;
}

.similar-debug-title {
  color: #4d3f28;
  font-weight: 700;
  margin-bottom: 4px;
}

.similar-debug-meta {
  color: var(--muted-text-color);
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.similar-debug-block + .similar-debug-block {
  margin-top: 12px;
}

.similar-debug-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--scrollable-book-list-title-color);
  margin-bottom: 6px;
}

.similar-debug pre {
  margin: 0;
  padding: 12px;
  border: 1px solid #ddd7ca;
  border-radius: 4px;
  background: #fffdf9;
  color: var(--main-text-color);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

#scanning-state {
  min-height: 52px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.bs-spinner {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.page-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #cccccc;
  border-top-color: var(--hyperlink-text-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

#error-box {
  background: var(--error-message-background-color);
  border: 1px solid var(--error-message-border-color);
  color: var(--error-message-text-color);
  border-radius: 3px;
  padding: 14px 16px;
}

.results-note {
  padding: 12px 14px;
  border: 1px solid #d8c2a8;
  border-radius: 6px;
  background: var(--warning-message-background-color);
  color: var(--main-text-color);
  line-height: 1.6;
}

#results-section {
  border-top: var(--book-card-border);
}

.results-title {
  font-size: 2rem;
}

.book-card {
  position: relative;
  height: 100%;
  background: var(--background-secondary-color);
  border: var(--book-card-border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
  animation: fadeUp 0.4s ease both;
}

.book-card:hover {
  transform: translateY(-2px);
  border-color: #b8b8b8;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.book-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 2 / 3;
  overflow: hidden;
}

.book-cover-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  background:
    linear-gradient(to right, rgba(0, 0, 0, 0) 2.25%, rgba(0, 0, 0, 0.15) 2.7%, rgba(0, 0, 0, 0.25) 3%, rgba(0, 0, 0, 0.15) 3.3%, rgba(0, 0, 0, 0) 3.75%),
    linear-gradient(to right, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0) 0.25%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0) 0.25%),
    linear-gradient(to left, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0.25) 0.5%),
    linear-gradient(to top, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0.25) 0.5%);
}

#btn-camera {
  display: none;
}

@media (max-width: 767px) {
  #btn-camera {
    display: inline-flex;
  }
}

.book-cover--image::after {
  display: none;
}

.book-cover--image {
  background: #f6f1e6 !important;
}

.book-cover--image .book-cover-image {
  padding: 8px;
  background: #f6f1e6;
}

.book-cover-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
}

.title-on-cover {
  font-size: 1rem;
  line-height: 1.25;
}

.author-on-cover {
  font-size: 0.82rem;
}

.identified-label {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.book-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 52px;
}

.identified-label {
  width: fit-content;
  padding: 3px 8px;
  background: #f5f5f5;
  border: 1px solid #dddddd;
  color: var(--scrollable-book-list-title-color);
}

.book-title {
  font-size: 1.2rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-description {
  font-size: 0.82rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-price {
  color: var(--primary-button-background);
  font-size: 1.05rem;
  font-weight: 700;
}

.book-old-price {
  color: var(--muted-text-color);
  font-size: 0.82rem;
  text-decoration: line-through;
}

.book-card--linked {
  cursor: pointer;
}

.book-card--linked:focus-visible {
  outline: 2px solid var(--hyperlink-text-color);
  outline-offset: 2px;
}

.book-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.book-shop-link {
  position: absolute;
  right: -1px;
  bottom: -1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-top-left-radius: 6px;
  background: var(--primary-button-background);
  color: var(--primary-button-text-color);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
  text-decoration: none;
  flex-shrink: 0;
}

.book-shop-link:hover {
  background: var(--primary-button-hover-background);
  color: var(--primary-button-text-color);
  text-decoration: none;
}

.not-found-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #dddddd;
  border-radius: 4px;
  background: #f5f5f5;
  font-size: 0.8rem;
}

@media (max-width: 991px) {
  .scanner-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .page-shell {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .page-card {
    padding: 22px 16px 28px;
    box-shadow: none;
  }

  #preview-area {
    padding: 18px;
  }
}
