:root {
  color-scheme: light;
  --paper: #f6f5f1;
  --card: #fffefa;
  --ink: #222c28;
  --muted: #6c746f;
  --line: #dedfd8;
  --green: #31594b;
  --green-dark: #244438;
  --clay: #a35e43;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 42px max(24px, calc((100vw - 1040px) / 2)) 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.72);
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

header h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.language-switch {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  margin-top: 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
}

.language-switch button {
  min-width: 42px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
}

.language-switch button + button { border-left: 1px solid var(--line); }
.language-switch button[aria-pressed="true"] { background: var(--green); color: #fff; }
.language-switch button:hover:not([aria-pressed="true"]) { background: #f0f1eb; color: var(--ink); }

header #stats {
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  width: min(1040px, calc(100% - 48px));
  margin: 36px auto 72px;
}

.tabs {
  display: flex;
  gap: 28px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  margin-bottom: -1px;
  padding: 0 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  transition: color 140ms ease, border-color 140ms ease;
}

.tab:hover, .tab.active {
  border-bottom-color: var(--green);
  color: var(--green-dark);
}

.tab.active { font-weight: 650; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.search-bar { margin-bottom: 12px; }

.search-bar input {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  border: 1px solid #cfd3cb;
  border-radius: 5px;
  outline: none;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-bar input::placeholder { color: #858c86; }
.search-bar input:focus, .location-bar select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(49, 89, 75, 0.12);
}

.location-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.location-bar label { color: var(--muted); font-size: 0.9rem; }

.location-bar select {
  min-height: 40px;
  padding: 7px 34px 7px 12px;
  border: 1px solid #cfd3cb;
  border-radius: 5px;
  outline: none;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.status {
  display: block;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.82rem;
}

.location-bar .status { margin: 0; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 285px), 1fr));
  gap: 12px;
}

.book-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 18px 19px 16px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.book-card:hover {
  border-color: #aebdb3;
  background: #fff;
}

.book-title {
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.book-author { color: #505b55; font-size: 0.9rem; }
.book-publisher { color: var(--muted); font-size: 0.82rem; }

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.tag {
  padding: 3px 7px;
  border: 1px solid #e2e4de;
  border-radius: 3px;
  color: #59635d;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
}

.tag-location { border-color: #d3e0d7; color: var(--green); }
.tag-review { border-color: #ead5c8; color: var(--clay); }
.book-isbn { margin-top: 7px; color: #838a84; font-size: 0.72rem; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 20px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

@media (max-width: 600px) {
  header { padding: 30px 22px 24px; }
  .header-top { gap: 14px; }
  header h1 { font-size: clamp(1.7rem, 8vw, 2.35rem); }
  .language-switch button { min-width: 38px; padding-inline: 7px; }
  main { width: calc(100% - 36px); margin-top: 28px; }
  .tabs { gap: 22px; }
  .book-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
