:root {
  --ink: #1a211b;
  --muted: #657066;
  --paper: #f7f4ed;
  --card: #fffdf8;
  --line: #deded3;
  --forest: #193a29;
  --forest-light: #28543b;
  --gold: #e2b85c;
  --cream: #f0e8d6;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 87% 5%, #efe6d2 0, transparent 24rem), var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
.page-shell { width: min(100% - 42px, 1000px); margin: 0 auto; }
.site-header { min-height: 92px; padding: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--forest); font-size: 16px; font-weight: 700; letter-spacing: -0.3px; text-decoration: none; line-height: 1.15; max-width: 280px; }
.brand-mark { height: 25px; width: 23px; display: inline-flex; align-items: end; gap: 2px; padding: 4px 3px; background: var(--forest); border-radius: 2px 2px 7px 7px; transform: rotate(-3deg); }
.brand-mark span { display: block; width: 3px; background: var(--cream); }
.brand-mark span:nth-child(1) { height: 11px; }.brand-mark span:nth-child(2) { height: 15px; }.brand-mark span:nth-child(3) { height: 9px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.connection-pill { display: flex; gap: 7px; align-items: center; color: #607064; font-size: 12px; font-weight: 600; }
.connection-pill i { height: 7px; width: 7px; display: block; border-radius: 50%; background: #9aa298; }
.connection-pill.connected i { background: #4eaf72; box-shadow: 0 0 0 3px #dbeedd; }
.icon-button, .close-button { border: 0; background: transparent; color: var(--forest); }
.icon-button { width: 34px; height: 34px; padding: 7px; border: 1px solid #d8dbd4; border-radius: 50%; }
.icon-button:hover { background: #eeeade; }
.icon-button.connected { border-color: #4eaf72; color: #2f6b45; background: #ecf7ee; }
.icon-button svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; }
#open-account svg { stroke-width: 1.6; }
.account-error { margin: 2px 0 0; padding: 9px 11px; color: #963c2f; border-radius: 6px; background: #fbeae6; font-size: 12px; line-height: 1.5; }
.hero { padding: 70px 0 64px; max-width: 640px; }
.eyebrow, .section-kicker { margin: 0 0 12px; color: #617064; text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 700; }
h1, h2 { margin: 0; color: var(--forest); letter-spacing: -1.8px; }
h1 { font-family: "Playfair Display", Georgia, serif; font-weight: 600; font-size: clamp(48px, 8vw, 76px); line-height: .98; }
h1 em { color: #ab7427; font-weight: 600; }
.hero-copy { max-width: 480px; margin: 25px 0 0; color: #536055; line-height: 1.7; font-size: 16px; }
.scan-card { position: relative; padding: 37px 40px 30px; background: var(--forest); border-radius: 16px; color: #f9f6ed; box-shadow: 0 15px 28px #193a2914; overflow: hidden; }
.scan-card::after { content: ""; position: absolute; width: 300px; height: 300px; right: -152px; top: -205px; border: 1px solid #ffffff1f; border-radius: 50%; }
.scan-card-heading { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; }
.scan-card .section-kicker { color: #b7c7b9; }.scan-card h2 { color: #fffaf0; font-size: 27px; }
.barcode-decoration { display: flex; align-items: stretch; gap: 3px; height: 35px; opacity: .65; padding-top: 1px; }
.barcode-decoration b { display: block; width: 2px; background: #e4d5b7; }.barcode-decoration b:nth-child(2) { width: 4px; }.barcode-decoration b:nth-child(3) { width: 1px; }.barcode-decoration b:nth-child(4) { width: 3px; }.barcode-decoration b:nth-child(6) { width: 5px; }.barcode-decoration b:nth-child(7) { width: 2px; }
.input-row { position: relative; z-index: 1; display: flex; gap: 11px; margin-top: 30px; }
.isbn-field { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; padding: 0 15px; border-radius: 7px; background: #fffdf8; color: var(--forest); }
.isbn-field svg { flex: 0 0 auto; width: 21px; stroke: #79857a; stroke-width: 1.5; fill: none; }
.isbn-field input { width: 100%; height: 58px; padding: 0; outline: none; color: var(--ink); border: 0; background: transparent; font-family: "DM Mono", monospace; font-size: 16px; }
.isbn-field input::placeholder { color: #899188; font-family: "DM Sans", sans-serif; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; border: 0; border-radius: 7px; padding: 0 19px; min-height: 52px; font-weight: 700; font-size: 14px; transition: transform .15s, background .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); }.button:active { transform: translateY(0); }.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button-primary { color: #213021; background: var(--gold); box-shadow: 0 4px 0 #b28330; }.button-primary:hover { background: #ebc36c; }
.button-secondary { color: #fffaf0; min-height: 43px; border: 1px solid #ffffff51; background: #ffffff12; }.button-secondary:hover { background: #ffffff20; }
.button-cobiss { min-height: 44px; color: #244e78; border: 1px solid #9bb2c7; background: #f7fbff; text-decoration: none; }.button-cobiss:hover { background: #e9f2fa; }
.button-goodreads { min-height: 44px; color: #5a3b1e; border: 1px solid #d9c39b; background: #fdf6e9; text-decoration: none; }.button-goodreads:hover { background: #f7ebd2; }
.button-secondary svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.button-quiet { min-height: auto; padding: 8px 5px; background: transparent; color: #6c766c; }.button-quiet:hover { color: var(--forest); }
.field-help { position: relative; z-index: 1; margin: 11px 0 0; font-size: 12px; color: #bbcabd; }.text-button { padding: 0; border: 0; background: none; color: #ead38f; font-family: "DM Mono", monospace; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.scan-options { position: relative; z-index: 1; display: grid; grid-template-columns: auto auto 1fr; gap: 13px; align-items: center; margin-top: 23px; }.scan-options > span { color: #a3b5a5; font-size: 12px; }.scan-options p { margin: 0; color: #bccabd; font-size: 12px; }
.result-section { margin-top: 26px; }.hidden { display: none; }
.book-result { display: grid; grid-template-columns: 136px 1fr; gap: 28px; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 10px 22px #242c1e08; }
.manual-entry { display: grid; grid-template-columns: 52px 1fr; gap: 18px; padding: 26px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 10px 22px #242c1e08; }.manual-entry-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: #93621f; background: #f4ead0; font-family: "Playfair Display", Georgia, serif; font-size: 29px; }.manual-entry h2 { font-family: "Playfair Display", Georgia, serif; font-size: 30px; }.manual-copy { max-width: 580px; margin: 9px 0 19px; color: #657066; font-size: 14px; line-height: 1.6; }.manual-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }.manual-fields label { display: grid; gap: 6px; color: #3d493f; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }.manual-fields input { width: 100%; padding: 11px; border: 1px solid #cbd0c8; border-radius: 6px; outline-color: #8aaa7c; color: var(--ink); background: #fffefb; font-size: 14px; letter-spacing: 0; text-transform: none; }
.result-cover { width: 136px; height: 204px; object-fit: cover; background: #e8e4da; border-radius: 4px; box-shadow: 4px 7px 11px #1f312322; }.result-cover.no-cover { object-fit: contain; padding: 20px; }
.result-details { align-self: center; }.match-label { margin: 0 0 8px; color: #a46d22; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }.result-title { font-family: "Playfair Display", Georgia, serif; font-size: clamp(25px, 3vw, 35px); line-height: 1.1; }.result-author { margin: 8px 0; color: #2b4634; font-size: 16px; font-weight: 600; }.result-meta { margin: 0; color: #7b857b; font-size: 13px; }.result-description { display: -webkit-box; margin: 16px 0 18px; overflow: hidden; color: #586359; font-size: 14px; line-height: 1.55; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }.result-actions { display: flex; align-items: center; gap: 12px; }.result-actions .button-primary { min-height: 44px; }
.collection-section { padding: 85px 0 80px; }.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }.section-heading h2 { font-family: "Playfair Display", Georgia, serif; font-size: 33px; }.collection-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }.clear-button { padding: 4px 0; color: #859084; border: 0; border-bottom: 1px solid #c6ccc4; background: none; font-size: 12px; }.clear-button:hover { color: #903d31; border-color: #903d31; }
.view-toggle { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #efece2; }.view-toggle-button { padding: 6px 13px; border: 0; border-radius: 6px; background: none; color: #6c766c; font-size: 12px; font-weight: 700; }.view-toggle-button.active { color: var(--forest); background: #fffdf8; box-shadow: 0 1px 3px #24322010; }
.collection-controls .button-quiet { padding: 6px 10px; border: 1px solid #cbd0c8; border-radius: 7px; font-size: 12px; font-weight: 700; }.collection-controls .button-quiet:hover { border-color: #8aaa7c; color: var(--forest); background: #f4f6f0; }
.sheet-wrapper { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
.sheet-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet-table th { position: sticky; top: 0; padding: 10px 14px; color: #f0ead6; text-align: left; white-space: nowrap; background: var(--forest); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sheet-table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.sheet-table tr:nth-child(even) td { background: #faf8f1; }
.sheet-table td.sheet-title { min-width: 180px; color: var(--forest); font-weight: 600; }
.sheet-table td.sheet-isbn { font-family: "DM Mono", monospace; color: #6c766c; white-space: nowrap; }
.sheet-table td.sheet-desc { max-width: 320px; overflow: hidden; color: #657066; text-overflow: ellipsis; white-space: nowrap; }
.library-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--line); }.library-list:empty { display: none; }.library-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 15px; align-items: center; padding: 12px 16px; background: var(--card); }.library-cover { width: 48px; height: 64px; border-radius: 2px; object-fit: cover; background: #e7e3d9; }.library-title { margin: 0; color: var(--forest); font-family: "Playfair Display", Georgia, serif; font-size: 18px; }.library-author { margin: 3px 0 0; color: var(--muted); font-size: 13px; }.library-date { color: #849085; font-family: "DM Mono", monospace; font-size: 10px; }.empty-library { min-height: 160px; display: grid; place-content: center; text-align: center; color: #899188; border: 1px dashed #cfd2c9; border-radius: 11px; }.empty-library p { margin: 9px 0 0; font-size: 14px; }.empty-book { color: #bd9853; font-size: 37px; font-family: Georgia, serif; transform: rotate(-28deg); }
.title-search-results { display: grid; gap: 8px; margin-top: 16px; }
.title-search-results:empty { margin: 0; }
.title-match { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 10px 12px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fffefb; }
.title-match:hover { border-color: #8aaa7c; background: #f6f8f2; }
.title-match img { width: 40px; height: 56px; object-fit: cover; border-radius: 2px; background: #e7e3d9; }
.title-match span { display: grid; gap: 2px; min-width: 0; }
.title-match strong { color: var(--forest); font-family: "Playfair Display", Georgia, serif; font-size: 15px; line-height: 1.25; }
.title-match em { color: #4c574d; font-style: normal; font-size: 12px; }
.title-match small { color: #8b958b; font-size: 11px; }
.text-button-inline { padding: 0; border: 0; background: none; color: #a46d22; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
dialog { width: min(100% - 36px, 600px); border: 0; border-radius: 14px; color: var(--ink); background: #fffdf8; box-shadow: 0 20px 60px #1c2b20aa; }dialog::backdrop { background: #102017a6; backdrop-filter: blur(3px); }.camera-dialog { padding: 25px; }.settings-dialog { padding: 0; }.dialog-header { display: flex; align-items: start; justify-content: space-between; }.dialog-header .section-kicker { margin-bottom: 5px; }.dialog-header h2 { font-family: "Playfair Display", Georgia, serif; font-size: 26px; }.close-button { margin: -7px -7px 0 0; font-size: 31px; line-height: 1; }.camera-viewfinder { position: relative; display: grid; min-height: 320px; overflow: hidden; place-items: center; margin-top: 22px; border-radius: 8px; background: #122217; }.camera-viewfinder video { position: absolute; width: 100%; height: 100%; object-fit: cover; }.camera-viewfinder p { position: relative; z-index: 2; color: #ecf2eb; font-size: 13px; }.scan-guide { position: absolute; z-index: 1; left: 12%; right: 12%; top: 36%; height: 30%; border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold); box-shadow: 0 0 0 999px #00000017; }.scan-guide::after { position: absolute; top: 50%; left: 0; width: 100%; height: 1px; content: ""; background: #e9c665; box-shadow: 0 0 12px #e9c665; animation: scan 2s ease-in-out infinite; }.dialog-help { margin: 16px 2px 0; color: #6f796f; font-size: 12px; line-height: 1.5; }
.settings-dialog .dialog-header { padding: 25px 27px 20px; border-bottom: 1px solid var(--line); }.settings-body { padding: 24px 27px 27px; }.settings-body > p { margin: 0 0 18px; color: #5a655a; line-height: 1.5; font-size: 14px; }.settings-field { display: grid; gap: 7px; color: #39463a; font-size: 12px; font-weight: 700; }.settings-field input { width: 100%; border: 1px solid #cbd0c8; border-radius: 6px; padding: 12px; outline-color: #8aaa7c; font-family: "DM Mono", monospace; font-size: 12px; }.settings-actions { display: flex; align-items: center; gap: 11px; margin-top: 17px; }.settings-actions .button-primary { min-height: 44px; }details { margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--line); color: #5e695e; font-size: 13px; line-height: 1.55; }summary { color: var(--forest); cursor: pointer; font-weight: 700; }details ol { margin: 11px 0 0; padding-left: 20px; }details a { color: #a46d22; }code { padding: 1px 4px; border-radius: 3px; background: #eeece5; font-family: "DM Mono", monospace; font-size: .9em; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 26px; padding: 12px 18px; transform: translate(-50%, 20px); color: #fffef9; border-radius: 7px; background: var(--forest); box-shadow: 0 8px 20px #18291944; font-size: 13px; opacity: 0; transition: .25s; }.toast.show { transform: translate(-50%, 0); opacity: 1; }
@keyframes scan { 0%, 100% { transform: translateY(-35px); } 50% { transform: translateY(35px); } }
@media (max-width: 620px) { .page-shell { width: min(100% - 28px, 1000px); }.site-header { height: 74px; }.connection-pill { display: none; }.hero { padding: 55px 0 48px; }.scan-card { padding: 28px 20px 25px; }.barcode-decoration { display: none; }.input-row { flex-direction: column; }.input-row .button { min-height: 48px; }.scan-options { grid-template-columns: auto 1fr; }.scan-options p { grid-column: 1 / -1; }.book-result { grid-template-columns: 94px 1fr; gap: 17px; padding: 17px; }.manual-entry { grid-template-columns: 1fr; padding: 20px; }.manual-fields { grid-template-columns: 1fr; }.result-cover { width: 94px; height: 141px; }.result-description { display: none; }.result-actions { flex-wrap: wrap; margin-top: 16px; }.collection-section { padding-top: 60px; }.library-item { grid-template-columns: 42px 1fr; gap: 12px; }.library-cover { width: 42px; height: 57px; }.library-date { grid-column: 2; }.camera-viewfinder { min-height: 290px; } }
@media (max-width: 380px) { .book-result { grid-template-columns: 1fr; }.result-cover { width: 90px; height: 135px; }.result-details { align-self: start; } }

/* --- Physical places ---------------------------------------------------- */

.location-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.9rem 0 0.2rem;
}

.location-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.location-select,
.location-new-input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  max-width: 100%;
}

.location-select:focus-visible,
.location-new-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.location-new-input {
  flex: 1 1 14rem;
  min-width: 0;
}

.location-new-input.hidden {
  display: none;
}

/* On a saved card the picker is secondary to the title, so it sits quieter. */
.library-location {
  margin: 0.45rem 0 0;
}

.library-location .location-label {
  font-size: 0.62rem;
}

.library-location .location-select {
  padding: 0.28rem 0.5rem;
  font-size: 0.82rem;
  background: transparent;
  border-color: var(--line);
}

.library-body {
  min-width: 0;
}

.place-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
}

.place-filter svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
}

.place-filter select {
  font: inherit;
  font-size: 0.85rem;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.1rem;
  color: inherit;
  max-width: 11rem;
}

.place-filter select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 0.3rem;
}

.place-filter select[hidden] {
  display: none;
}

.sheet-place {
  white-space: nowrap;
  color: var(--muted);
}

.library-filter-empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--card);
}

/* The scan card is dark, so the picker there needs its own light treatment
   rather than the default one used against cream backgrounds. */
.default-place {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #ffffff1f;
}

.default-place .location-picker {
  margin: 0;
  gap: 10px;
}

.default-place .location-label {
  color: #a3b5a5;
  font-size: 11px;
}

.default-place .location-select,
.default-place .location-new-input {
  background: #ffffff14;
  border-color: #ffffff2e;
  color: #f4f1e6;
  font-size: 13px;
  padding: 7px 10px;
}

.default-place .location-new-input::placeholder {
  color: #ffffff5c;
}

.default-place .location-select:focus-visible,
.default-place .location-new-input:focus-visible {
  outline-color: var(--gold);
}

/* Native dropdown lists render in the OS palette, so options must be dark-on-
   light regardless of the field they drop out of. */
.default-place .location-select option {
  color: var(--ink);
  background: var(--card);
}

/* --- Copies ------------------------------------------------------------- */

.copy-count {
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--forest);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  vertical-align: middle;
}

.copies {
  margin-top: 6px;
  min-width: 0;
}

/* Each panel fills the track, so a swipe moves exactly one copy at a time
   instead of drifting between two. */
.copies-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.copies-track::-webkit-scrollbar {
  display: none;
}

.copy-panel {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  padding-right: 12px;
}

.copy-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 18px;
}

.copy-badge {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #849085;
}

.copy-remove {
  padding: 0;
  border: 0;
  background: none;
  color: #a2564b;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.copy-remove:hover {
  color: #7d3f36;
}

.copies .library-location {
  margin-top: 2px;
}

.copy-dots {
  display: flex;
  gap: 5px;
  margin-top: 7px;
}

.copy-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #cfd2c9;
  cursor: pointer;
  transition: background 0.15s ease;
}

.copy-dot.active {
  background: var(--forest);
}

.copy-dot:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.sheet-copy {
  white-space: nowrap;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.already-owned {
  margin: 12px 0 0;
  padding: 7px 11px;
  border-radius: 7px;
  background: var(--cream);
  color: var(--forest);
  font-size: 12.5px;
}

.library-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  align-self: start;
}

/* Kept visually quiet until reached for, so a destructive control doesn't
   compete with the book itself. */
.library-delete {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #b0b7ae;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.library-delete:hover,
.library-delete:focus-visible {
  background: #f2e3e0;
  color: #a2564b;
}

.library-delete:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* Touch targets don't get hover, so the control stays permanently visible
   there rather than relying on a state that never arrives. */
@media (hover: none) {
  .library-delete { color: #9aa398; }
}

/* The card collapses to two columns on narrow screens, where the aside drops
   under the text instead of sitting beside it. */
@media (max-width: 620px) {
  .library-aside {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
}

/* --- Google sign-in ----------------------------------------------------- */

/* Google's brand guidelines expect a white button with their mark at full
   colour, so this deliberately steps outside the app's palette. */
.button-google {
  width: 100%;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  font-weight: 500;
}

.button-google:hover {
  background: #f8f9fa;
  border-color: #d2d5d9;
}

.google-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* --- Themes -------------------------------------------------------------
   The chips use their own pair of variables rather than --cream/--forest,
   because --cream also paints the little book bars that sit on the dark
   green brand mark and must stay light in either theme. */
:root {
  --chip-bg: var(--cream);
  --chip-ink: var(--forest);
  --danger: #a2564b;
  --danger-soft: #f2e3e0;
  --dot: #cfd2c9;
  --page-glow: #efe6d2;
}

[data-theme="dark"] {
  --ink: #e8e5db;
  --muted: #98a199;
  --paper: #141814;
  --card: #1c211d;
  --line: #2c332e;
  --forest: #1f4530;
  --forest-light: #2d6142;
  --gold: #e2b85c;
  --cream: #f0e8d6;
  --chip-bg: #2a322c;
  --chip-ink: #dfe6d9;
  --danger: #d98b7e;
  --danger-soft: #3a2622;
  --dot: #3d453e;
  --page-glow: #1c2a20;
  color-scheme: dark;
}

[data-theme="dark"] body {
  background: radial-gradient(circle at 87% 5%, var(--page-glow) 0, transparent 24rem), var(--paper);
}

[data-theme="dark"] dialog {
  background: var(--card);
  box-shadow: 0 20px 60px #0009;
}

[data-theme="dark"] .settings-body > p,
[data-theme="dark"] .dialog-help,
[data-theme="dark"] details,
[data-theme="dark"] .connection-pill { color: var(--muted); }

[data-theme="dark"] .settings-field { color: var(--ink); }

[data-theme="dark"] .settings-field input {
  background: #11150f;
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] code { background: #262c26; }
[data-theme="dark"] details a { color: var(--gold); }
[data-theme="dark"] .sheet-table th { background: var(--chip-bg); }

/* Google asks for their button to stay light, so it keeps a pale surface
   in both themes rather than inverting with everything else. */
[data-theme="dark"] .button-google { background: #f1f1ef; border-color: #40463f; }
[data-theme="dark"] .button-google:hover { background: #e6e6e3; }

.copy-count { background: var(--chip-bg); color: var(--chip-ink); }
.already-owned { background: var(--chip-bg); color: var(--chip-ink); }
.copy-remove { color: var(--danger); }
.copy-remove:hover { color: var(--danger); filter: brightness(0.85); }
.copy-dot { background: var(--dot); }
.copy-badge { color: var(--muted); }
.library-delete { color: var(--muted); }
.library-delete:hover,
.library-delete:focus-visible { background: var(--danger-soft); color: var(--danger); }

/* --- Settings panel ------------------------------------------------------ */

.settings-section + .settings-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-section h3 {
  margin: 0 0 6px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.settings-section p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.theme-choice {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.theme-option {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.theme-option[aria-pressed="true"] {
  background: var(--forest);
  color: #f4f1e6;
}

.theme-option:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* --- Search ------------------------------------------------------------- */

.collection-search,
.title-search {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
}

.collection-search svg,
.title-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0.55;
}

.collection-search input,
.title-search input {
  font: inherit;
  font-size: 13px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 8px 0;
  width: 13rem;
  max-width: 100%;
}

.collection-search input:focus,
.title-search input:focus { outline: none; }

.collection-search:focus-within,
.title-search:focus-within { border-color: var(--gold); }

/* The scan card is dark, so its search field gets the same light treatment
   as the place picker above it. */
.scan-alt {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.scan-alt .title-search {
  flex: 1 1 16rem;
  background: #ffffff14;
  border-color: #ffffff2e;
  color: #f4f1e6;
}

.scan-alt .title-search input { width: 100%; color: #f4f1e6; }
.scan-alt .title-search input::placeholder { color: #ffffff5c; }

.title-search-results {
  position: relative;
  z-index: 2;
  margin-top: 10px;
  max-height: 17rem;
  overflow-y: auto;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
}

.title-search-hit {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  cursor: pointer;
}

.title-search-hit:last-child { border-bottom: 0; }
.title-search-hit:hover { background: var(--paper); }

.title-search-title { display: block; font-weight: 600; font-size: 14px; }
.title-search-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.title-search-empty { margin: 0; padding: 14px; color: var(--muted); font-size: 13px; }

.field-optional {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-left: 5px;
}

/* --- Toggles ------------------------------------------------------------- */

.toggle-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 9px 0;
  cursor: pointer;
}

.toggle-row input { margin-top: 3px; flex: 0 0 auto; accent-color: var(--forest); }
.toggle-row span { font-size: 13px; color: var(--muted); line-height: 1.5; }
.toggle-row strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 1px; }

.button-social { width: 100%; justify-content: center; gap: 10px; }
.social-mark { width: 18px; height: 18px; flex: 0 0 auto; }
.button-microsoft { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; font-weight: 500; }
.button-apple { background: #000; color: #fff; border: 1px solid #000; font-weight: 500; }
.button-microsoft + .button-apple, .button-google + .button-social { margin-top: 8px; }
[data-theme="dark"] .button-microsoft { background: #f1f1ef; border-color: #40463f; }
[data-theme="dark"] .button-apple { background: #fff; color: #000; border-color: #fff; }

/* --- Scanning options, beside the Find book button ----------------------- */

.scan-filters {
  position: relative;
  flex: 0 0 auto;
}

.scan-filters-toggle {
  position: relative;
  border-color: #ffffff2e;
  background: #ffffff14;
  color: #f4f1e6;
}

.scan-filters-toggle:hover { background: #ffffff24; }

.scan-filters-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

/* Marks that scanning is not behaving in the default way. */
.scan-filters-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

.scan-filters-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 20;
  width: min(19rem, calc(100vw - 40px));
  padding: 14px 16px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 14px 38px #0000002e;
  text-align: left;
}

.scan-filters-panel[hidden] { display: none; }

.scan-filters-title {
  margin: 0 0 4px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.scan-filters-hint {
  margin: 8px 0 0;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

/* The panel hangs off a dark card but is itself a light surface, so its rows
   need the ordinary text colour rather than the card's. */
.scan-filters-panel .toggle-row span { color: var(--muted); }
.scan-filters-panel .toggle-row strong { color: var(--ink); }

@media (max-width: 620px) {
  .scan-filters-panel { right: auto; left: 0; }
}

/* --- Sorting ------------------------------------------------------------- */

.sort-select {
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: inherit;
}

/* --- Stats --------------------------------------------------------------- */

.stats-bar {
  margin: 4px 0 0;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* --- Wishlist ------------------------------------------------------------ */

.wishlist-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.wishlist-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.wishlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
}

.wishlist-cover {
  width: 36px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
}

.wishlist-body {
  flex: 1;
  min-width: 0;
}

.wishlist-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wishlist-author {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.wishlist-remove {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
}

.wishlist-remove:hover { background: var(--danger-soft); color: var(--danger); }

.wishlist-button { margin-left: 4px; }

/* --- Notes --------------------------------------------------------------- */

.book-note {
  margin-top: 6px;
}

.book-note summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.book-note summary:hover { color: var(--ink); }

.book-note-text {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 3.5em;
}

.book-note-text:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* --- Scan queue badge ---------------------------------------------------- */

.queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--forest);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  animation: queue-pulse 1.2s ease infinite;
}

.queue-badge[hidden] { display: none; }

@keyframes queue-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* --- Session bar --------------------------------------------------------- */

.session-bar {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #ffffff14;
  border: 1px solid #ffffff1f;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: #a3b5a5;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-bar[hidden] { display: none; }

.session-missed-list {
  color: #e8a87c;
  font-size: 10px;
}

.session-reset {
  margin-left: auto;
  padding: 0 6px;
  border: 0;
  background: none;
  color: #ffffff5c;
  font-size: 14px;
  cursor: pointer;
}

.session-reset:hover { color: #ffffffaa; }

/* --- Scan navigation ----------------------------------------------------- */

.scan-nav {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.scan-nav[hidden] { display: none; }

.scan-nav-prev,
.scan-nav-next {
  font-size: 12px;
  padding: 5px 10px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-nav-label {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: #a3b5a5;
}

/* --- Barcode copy row ---------------------------------------------------- */

.barcode-copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.barcode-display {
  font-family: "DM Mono", monospace;
  font-size: 15px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--cream);
  color: var(--forest);
  user-select: all;
}

.copy-barcode-btn {
  font-size: 12px;
  padding: 5px 12px;
}

/* --- Fix: input row wrapping so filters don't get cut off ---------------- */

.input-row {
  flex-wrap: wrap;
}

.input-row .isbn-field {
  flex: 1 1 280px;
}

.input-row .button-primary {
  flex: 0 0 auto;
  white-space: nowrap;
}

.scan-filters {
  flex: 0 0 auto;
}

/* Enough breathing room on mobile */
@media (max-width: 620px) {
  .input-row {
    gap: 10px;
  }
  .input-row .button-primary {
    flex: 1 1 100%;
  }
  .scan-filters {
    position: absolute;
    top: -50px;
    right: 0;
  }
}
/* ============================================================
   ДОБАВИ ТОВА В КРАЯ НА styles.css
   ============================================================ */

/* --- Onboarding overlay ---------------------------------------- */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #14281d;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.onboarding-overlay.hidden {
  display: none;
}

.onboarding-card {
  background: #1e3a28;
  border: 1px solid #2e5038;
  border-radius: 1.25rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.onboarding-logo {
  font-size: 3rem;
  line-height: 1;
}

.onboarding-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ead8aa;
  margin: 0;
}

.onboarding-sub {
  font-size: 0.9rem;
  color: #8fad9a;
  margin: 0;
  max-width: 28ch;
}

.onboarding-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.625rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: #fff;
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.onboarding-google-btn:hover {
  opacity: 0.9;
}

.onboarding-divider {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #4d7a5e;
  font-size: 0.8rem;
}

.onboarding-divider::before,
.onboarding-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #2e5038;
}

.onboarding-email-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.onboarding-email-form input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid #2e5038;
  background: #14281d;
  color: #e8dfc8;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.onboarding-email-form input:focus {
  outline: 2px solid #5a9e72;
  border-color: #5a9e72;
}

.onboarding-error {
  background: #4a1515;
  border: 1px solid #8b2020;
  border-radius: 0.4rem;
  padding: 0.5rem 0.75rem;
  color: #f5a0a0;
  font-size: 0.85rem;
  text-align: left;
}

.onboarding-error.hidden {
  display: none;
}

.onboarding-email-actions {
  display: flex;
  gap: 0.5rem;
}

.onboarding-email-actions .button {
  flex: 1;
}

/* --- Profile type picker --------------------------------------- */

.profile-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

.profile-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.5rem;
  border-radius: 0.75rem;
  border: 2px solid #2e5038;
  background: #14281d;
  color: #e8dfc8;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.875rem;
}

.profile-type-card:hover {
  border-color: #5a9e72;
  background: #1e3a28;
}

.profile-type-card.selected {
  border-color: #7ec89a;
  background: #1e3a28;
}

.profile-type-emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.profile-type-label {
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
}

#profile-other-input {
  width: 100%;
}

#profile-other-input.hidden {
  display: none;
}

#profile-other-text {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid #2e5038;
  background: #14281d;
  color: #e8dfc8;
  font-size: 0.95rem;
  box-sizing: border-box;
}

/* --- Limits bar ----------------------------------------------- */

#limits-bar {
  margin: 0.5rem 0;
}

.limits-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  background: #1a2e1f;
  border: 1px solid #2e5038;
  font-size: 0.8rem;
  color: #8fad9a;
}

.limits-bar-inner.near-limit {
  border-color: #8b5a00;
  background: #2a1e0a;
  color: #d4a060;
}

.limits-track {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: #2e5038;
  overflow: hidden;
}

.limits-fill {
  height: 100%;
  border-radius: 3px;
  background: #5a9e72;
  transition: width 0.4s ease;
}

.limits-bar-inner.near-limit .limits-fill {
  background: #d4a060;
}

.limits-label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.limits-upgrade-btn {
  background: none;
  border: 1px solid #d4a060;
  border-radius: 0.35rem;
  color: #d4a060;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.limits-upgrade-btn:hover {
  background: #2a1e0a;
}

/* --- Limits modal --------------------------------------------- */

#limits-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#limits-modal.hidden {
  display: none;
}

.limits-modal-card {
  position: relative;
  background: #1e3a28;
  border: 1px solid #2e5038;
  border-radius: 1.25rem;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.limits-modal-card h2 {
  margin: 0 0 0.5rem;
  color: #ead8aa;
  font-size: 1.3rem;
}

.limits-modal-card p {
  color: #8fad9a;
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.limits-modal-card strong {
  color: #e8dfc8;
}

.limits-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.875rem;
  background: none;
  border: none;
  color: #4d7a5e;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.limits-modal-close:hover {
  color: #e8dfc8;
}

.bundles-grid {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.bundle-card {
  background: #14281d;
  border: 1px solid #2e5038;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 100px;
  flex: 1;
  max-width: 130px;
}

.bundle-slots {
  font-size: 1.1rem;
  font-weight: 700;
  color: #7ec89a;
}

.bundle-price {
  font-size: 0.85rem;
  color: #8fad9a;
  margin-bottom: 0.25rem;
}

.bundle-card .button {
  width: 100%;
  font-size: 0.85rem;
  padding: 0.45rem 0.75rem;
}

.limits-modal-note {
  font-size: 0.8rem;
  color: #4d7a5e;
  margin: 0;
}

/* --- Admin panel ---------------------------------------------- */

#admin-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: #0d1f14;
  border-top: 2px solid #5a9e72;
  padding: 1.25rem 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

#admin-panel.hidden {
  display: none;
}

.admin-panel-inner h3 {
  margin: 0 0 0.75rem;
  color: #7ec89a;
  font-size: 1rem;
}

.admin-panel-inner p {
  font-size: 0.85rem;
  color: #8fad9a;
  margin: 0 0 0.75rem;
}

.admin-panel-inner code {
  font-size: 0.8rem;
  background: #1a2e1f;
  padding: 0.15rem 0.4rem;
  border-radius: 0.3rem;
  color: #ead8aa;
  word-break: break-all;
}

.admin-field {
  margin-bottom: 0.625rem;
}

.admin-field label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: #8fad9a;
}

.admin-field input {
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid #2e5038;
  background: #14281d;
  color: #e8dfc8;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  max-width: 400px;
}

.admin-result {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: #8fad9a;
  min-height: 1.2em;
}

#app-version {
  cursor: pointer;
  user-select: none;
}
