:root {
  --paper: #f7f3ea; --paper-2: #fffdf8; --ink: #1b1a17; --muted: #726f68;
  --line: #d9d3c7; --accent: #755c3b; --accent-soft: #e8ddcd;
  --success: #3e6a50; --danger: #a54a42; --shadow: 0 16px 40px rgba(44,35,25,.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.no-select, .no-select * {
  -webkit-user-select: none !important; user-select: none !important;
  -webkit-touch-callout: none !important;
}
.app-header {
  position: sticky; top: 0; z-index: 20; min-height: 78px;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  background: rgba(247,243,234,.94); backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(117,92,59,.16); touch-action: manipulation;
}
.app-header h1 { margin: 1px 0 0; font-size: 1.15rem; letter-spacing: -.02em; }
.eyebrow,.hero-kicker { margin:0; font-size:.68rem; font-weight:800; letter-spacing:.16em; color:var(--accent); }
.version { border:1px solid var(--line); border-radius:999px; padding:7px 10px; font-size:.75rem; font-weight:800; background:var(--paper-2); }
main { width:min(1040px,100%); margin:0 auto; padding:34px 18px 80px; }
.hero { padding:16px 0 24px; }
.hero h2 { max-width:800px; margin:10px 0 12px; font-family:Georgia,"Times New Roman",serif; font-size:clamp(2.25rem,7vw,4.9rem); line-height:.98; letter-spacing:-.055em; font-weight:600; }
.hero-copy { max-width:720px; color:var(--muted); font-size:1rem; line-height:1.65; }
.search-panel { margin-top:28px; padding:18px; background:var(--paper-2); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
.search-panel>label { display:block; margin-bottom:9px; font-size:.78rem; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.search-row { display:grid; grid-template-columns:1fr auto; gap:10px; }
.search-row input { min-width:0; width:100%; min-height:52px; border:1px solid var(--line); border-radius:12px; padding:0 15px; background:white; color:var(--ink); outline:none; }
.search-row input:focus,input:focus,select:focus { border-color:var(--accent); box-shadow:0 0 0 4px rgba(117,92,59,.12); outline:none; }
.search-row button,.primary-button { min-width:112px; border:0; border-radius:12px; background:var(--ink); color:white; padding:0 20px; font-weight:800; cursor:pointer; }
.search-row button:disabled { opacity:.65; cursor:wait; }
.button-spinner { display:none; width:18px; height:18px; border:2px solid rgba(255,255,255,.35); border-top-color:white; border-radius:50%; animation:spin .8s linear infinite; }
.loading .button-label { display:none; }.loading .button-spinner { display:inline-block; }
@keyframes spin { to { transform:rotate(360deg); } }
.search-options { display:flex; flex-wrap:wrap; gap:8px; margin-top:13px; }
.mode-option input { position:absolute; opacity:0; pointer-events:none; }
.mode-option span { display:block; padding:7px 10px; border:1px solid var(--line); border-radius:999px; color:var(--muted); font-size:.72rem; font-weight:800; cursor:pointer; }
.mode-option input:checked+span { background:var(--accent-soft); color:var(--accent); border-color:transparent; }
.search-tools { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:14px; }
.text-button { border:0; background:transparent; color:var(--accent); padding:4px 0; font-weight:800; cursor:pointer; }
.status-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:12px 0 36px; }
.status-grid.two-column { grid-template-columns:repeat(2,1fr); }
.status-card { display:flex; align-items:center; justify-content:space-between; min-height:82px; padding:16px; border:1px solid var(--line); border-radius:15px; background:rgba(255,253,248,.7); }
.status-label { margin:0 0 6px; color:var(--muted); font-size:.7rem; font-weight:800; text-transform:uppercase; letter-spacing:.09em; }
.status-value { margin:0; font-size:.95rem; font-weight:800; }
.status-dot { width:12px; height:12px; border-radius:50%; border:2px solid var(--line); }
.status-dot.loading { border-color:var(--accent); animation:pulse 1s ease-in-out infinite; }
.status-dot.success { border-color:var(--success); background:var(--success); }
.status-dot.error { border-color:var(--danger); background:var(--danger); }
@keyframes pulse { 50% { transform:scale(.7); opacity:.5; } }
.merge-mark { color:var(--accent); font-weight:900; font-size:.72rem; }
.results-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; padding-bottom:13px; border-bottom:1px solid var(--line); }
.results-heading h2 { margin:4px 0 0; font-family:Georgia,"Times New Roman",serif; font-size:clamp(1.6rem,4vw,2.3rem); }
.heading-actions { display:flex; gap:8px; align-items:center; }
.icon-button { width:42px; height:42px; display:grid; place-items:center; border:1px solid var(--line); border-radius:50%; background:var(--paper-2); cursor:pointer; }
.icon-button svg { width:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.outline-button,.amazon-result-button { min-height:40px; border:1px solid var(--line); border-radius:10px; background:var(--paper-2); color:var(--ink); padding:0 12px; font-weight:800; cursor:pointer; }
.message { margin:22px 0; padding:17px 18px; border:1px dashed var(--line); border-radius:14px; color:var(--muted); line-height:1.5; }
.message.error { border-color:rgba(165,74,66,.45); color:var(--danger); background:rgba(165,74,66,.04); }
.results-list { display:grid; gap:14px; }
.book-card { display:grid; grid-template-columns:92px 1fr; gap:17px; padding:16px; border:1px solid var(--line); border-radius:var(--radius); background:var(--paper-2); box-shadow:0 8px 24px rgba(44,35,25,.045); }
.cover-wrap { position:relative; width:92px; aspect-ratio:2/3; overflow:hidden; border-radius:8px; background:var(--accent-soft); }
.book-cover { width:100%; height:100%; object-fit:cover; display:block; }
.cover-placeholder { position:absolute; inset:0; display:grid; place-items:center; padding:8px; text-align:center; color:var(--accent); font-size:.62rem; font-weight:900; letter-spacing:.08em; }
.book-content { min-width:0; }
.book-topline { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:23px; }
.provider-badges { display:flex; flex-wrap:wrap; gap:5px; }
.provider-badge,.score-badge { border:1px solid var(--line); border-radius:999px; padding:4px 7px; font-size:.62rem; font-weight:900; letter-spacing:.04em; text-transform:uppercase; }
.book-title { margin:10px 0 3px; font-family:Georgia,"Times New Roman",serif; font-size:1.35rem; line-height:1.12; }
.book-subtitle,.book-author { margin:4px 0; color:var(--muted); line-height:1.35; }
.book-author { color:var(--ink); font-weight:700; }.book-subtitle:empty { display:none; }
.book-meta { display:flex; flex-wrap:wrap; gap:7px; margin-top:12px; }
.meta-pill { padding:5px 8px; border-radius:7px; background:#f1ece3; color:var(--muted); font-size:.72rem; font-weight:700; }
.book-footer { display:flex; flex-wrap:wrap; justify-content:space-between; gap:8px; margin-top:15px; padding-top:11px; border-top:1px solid #ebe5da; color:var(--muted); font-size:.72rem; }
.book-actions { margin-top:12px; }
.amazon-result-button { min-height:36px; font-size:.76rem; }
.import-dialog { width:min(680px,calc(100% - 24px)); border:0; padding:0; border-radius:20px; background:var(--paper-2); box-shadow:0 28px 80px rgba(0,0,0,.25); }
.import-dialog::backdrop { background:rgba(27,26,23,.55); backdrop-filter:blur(4px); }
.dialog-shell { padding:22px; }
.dialog-header { display:flex; justify-content:space-between; gap:18px; }
.dialog-header h2 { margin:5px 0 0; font-family:Georgia,"Times New Roman",serif; }
.dialog-close { border:0; background:transparent; font-size:1.8rem; line-height:1; cursor:pointer; }
.dialog-copy { color:var(--muted); line-height:1.5; }
.dialog-shell label { display:grid; gap:6px; color:var(--muted); font-size:.75rem; font-weight:800; }
.dialog-shell input,.dialog-shell select { width:100%; min-height:44px; border:1px solid var(--line); border-radius:10px; padding:0 11px; background:white; color:var(--ink); }
.dialog-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.full-width { grid-column:1/-1; }
.asin-readout { margin-top:13px; padding:10px 12px; background:#f1ece3; border-radius:10px; font-size:.78rem; color:var(--muted); }
.dialog-actions { display:flex; justify-content:flex-end; gap:9px; margin-top:18px; }
.dialog-actions button { min-height:42px; }
@media(max-width:700px){ main{padding-top:22px}.status-grid.two-column{grid-template-columns:1fr}.status-card{min-height:68px}.results-heading{align-items:flex-start}.heading-actions{flex-direction:column-reverse;align-items:flex-end}.outline-button{font-size:.72rem}.dialog-grid{grid-template-columns:1fr}.full-width{grid-column:auto} }
@media(max-width:520px){ .search-row{grid-template-columns:1fr}.search-row button{min-height:50px}.search-tools{align-items:flex-start}.book-card{grid-template-columns:74px 1fr;gap:13px;padding:13px}.cover-wrap{width:74px}.score-badge{display:none}.book-title{font-size:1.15rem} }

.series-result-button {
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 12px;
  font-size: .76rem;
  font-weight: 800;
  cursor: pointer;
}
.book-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.book-series { margin:8px 0 0; color:var(--accent); font-size:.82rem; font-weight:900; }
.series-dialog { width:min(620px,calc(100% - 24px)); max-height:min(82vh,760px); border:0; padding:0; border-radius:20px; background:var(--paper-2); box-shadow:0 28px 80px rgba(0,0,0,.25); }
.series-dialog::backdrop { background:rgba(27,26,23,.55); backdrop-filter:blur(4px); }
.series-shell { padding:22px; }
.series-book-list { display:grid; gap:8px; margin-top:18px; }
.series-book-row { display:grid; grid-template-columns:42px 1fr auto; align-items:center; gap:11px; padding:12px; border:1px solid var(--line); border-radius:12px; background:white; }
.series-book-row.current { border-color:var(--accent); background:var(--accent-soft); }
.series-order { width:34px; height:34px; display:grid; place-items:center; border-radius:50%; background:var(--paper); font-weight:900; color:var(--accent); }
.series-book-title { margin:0; font-family:Georgia,"Times New Roman",serif; font-size:1rem; }
.series-current-label { color:var(--accent); font-size:.66rem; font-weight:900; letter-spacing:.08em; text-transform:uppercase; }
.series-search-book { border:0; background:transparent; color:var(--accent); font-size:.72rem; font-weight:900; cursor:pointer; padding:6px; }
@media(max-width:520px){.series-book-row{grid-template-columns:36px 1fr}.series-search-book{grid-column:2;justify-self:start;padding-left:0}}
