/* ═══════════════════════════════════
   家族本棚 — style.css
   ═══════════════════════════════════ */

/* ─── TOKENS ─── */
:root {
  --ink: #1A0F08;
  --paper: #F5EDD8;
  --paper2: #EDE2C8;
  --paper3: #E2D4B0;
  --accent: #8B3A1C;
  --accent2: #C4622D;
  --accent-light: #F2A96A;
  --gold: #C09A3E;
  --shadow: rgba(26,15,8,0.18);
  --shadow2: rgba(26,15,8,0.08);
  --radius: 6px;
  --font-serif: 'Shippori Mincho', serif;
  --font-sans: 'Noto Sans JP', sans-serif;
  --sync-color: #1D9E75;
  --header-h: 58px;
  --sidebar-w: 260px;
  --content-max: 800px;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--ink);
  color: var(--ink);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font-sans); cursor: pointer; }
a { color: inherit; }

/* grain */
body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ─── SETUP SCREEN ─── */
.setup-screen {
  position: fixed; inset: 0; background: var(--ink); z-index: 500;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 20px 60px; overflow-y: auto; overflow-x: hidden; gap: 0;
}
.setup-logo { font-family: var(--font-serif); font-size: clamp(28px,6vw,40px); font-weight: 800; color: var(--paper); letter-spacing: .05em; }
.setup-logo span { color: var(--accent-light); }
.setup-sub { font-size: 12px; letter-spacing: .2em; color: rgba(245,237,216,.65); margin: 4px 0 28px; }
.setup-card { background: rgba(245,237,216,.06); border: 1px solid rgba(245,237,216,.12); border-radius: 14px; padding: 24px; width: 100%; max-width: 440px; }
.setup-card-title { font-family: var(--font-serif); font-size: 19px; font-weight: 700; color: var(--paper); margin-bottom: 6px; }
.setup-card-desc { font-size: 13px; color: rgba(245,237,216,.6); line-height: 1.7; margin-bottom: 18px; }
.setup-steps { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.setup-step { display: flex; gap: 10px; align-items: flex-start; }
.setup-step-num { width: 22px; min-width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--paper); font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.setup-step-text { font-size: 13px; color: rgba(245,237,216,.65); line-height: 1.6; }
.setup-step-text a { color: var(--accent-light); text-decoration: none; }
.setup-sep { border: none; border-top: 1px solid rgba(245,237,216,.1); margin: 18px 0; }
.setup-label { font-size: 12px; letter-spacing: .1em; color: rgba(245,237,216,.6); margin-bottom: 6px; display: block; }
.setup-input {
  width: 100%; padding: 11px 14px; background: rgba(245,237,216,.08);
  border: 1px solid rgba(245,237,216,.15); border-radius: var(--radius);
  color: var(--paper); font-family: var(--font-sans); font-size: 14px;
  outline: none; margin-bottom: 12px; transition: border-color .2s;
}
.setup-input:focus { border-color: var(--accent-light); }
.setup-input::placeholder { color: rgba(245,237,216,.2); }
.setup-btn {
  width: 100%; padding: 14px; background: var(--accent); border: none;
  border-radius: var(--radius); font-family: var(--font-serif); font-size: 16px;
  font-weight: 600; color: var(--paper); cursor: pointer; letter-spacing: .05em;
  transition: background .2s; margin-top: 4px;
}
.setup-btn:hover { background: var(--accent2); }
.setup-divider { text-align: center; color: rgba(245,237,216,.4); font-size: 13px; margin: 18px 0; position: relative; }
.setup-divider::before, .setup-divider::after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: rgba(245,237,216,.1); }
.setup-divider::before { left: 0; } .setup-divider::after { right: 0; }
.setup-local-btn {
  width: 100%; padding: 12px; background: transparent;
  border: 1px solid rgba(245,237,216,.15); border-radius: var(--radius);
  color: rgba(245,237,216,.65); font-family: var(--font-sans); font-size: 14px;
  cursor: pointer; transition: all .2s;
}
.setup-local-btn:hover { border-color: rgba(245,237,216,.3); color: rgba(245,237,216,.9); }
.sql-block { width: 100%; max-width: 440px; margin-top: 20px; }
.sql-block-title { font-size: 12px; letter-spacing: .1em; color: rgba(245,237,216,.45); margin-bottom: 8px; }
.sql-pre {
  background: rgba(245,237,216,.05); border: 1px solid rgba(245,237,216,.1);
  border-radius: 8px; padding: 14px; font-size: 11px; color: rgba(245,237,216,.5);
  overflow-x: auto; line-height: 1.6; font-family: monospace; white-space: pre;
}

/* ─── SETUP PREVIEW MOCKUP ─── */
.setup-preview { width: 100%; max-width: 440px; margin: 0 0 28px; }
.preview-label { font-size: 15px; letter-spacing: .2em; color: rgba(245,237,216,.7); text-align: center; margin-bottom: 16px; }

.preview-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .setup-preview { max-width: 960px; }
  .preview-grid { grid-template-columns: repeat(3, 1fr); align-items: stretch; }
}

.preview-block { display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow: hidden; }
.preview-block .preview-phone { flex: 1; }
.preview-block-title {
  font-size: 13px; font-weight: 600; letter-spacing: .08em;
  color: rgba(245,237,216,.95); text-align: center;
}

.preview-phone {
  background: var(--paper); border-radius: 18px;
  padding: 14px; display: flex; flex-direction: column; gap: 7px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 1px rgba(245,237,216,.1);
  pointer-events: none; user-select: none;
  width: 100%; overflow: hidden; box-sizing: border-box;
}
.preview-scan-btn {
  background: var(--accent); color: var(--paper);
  border-radius: 9px; padding: 10px; text-align: center;
  font-size: 12px; font-weight: 500;
}
.preview-isbn-row { display: flex; gap: 6px; }
.preview-isbn-input {
  flex: 1; background: rgba(26,15,8,.06); border: 1px solid rgba(26,15,8,.15);
  border-radius: 7px; padding: 7px 10px; font-size: 11px; color: rgba(26,15,8,.35);
}
.preview-isbn-btn {
  background: var(--ink); color: var(--paper);
  border-radius: 7px; padding: 7px 12px; font-size: 11px;
}
.preview-section-label { font-size: 10px; letter-spacing: .12em; color: rgba(26,15,8,.45); margin-top: 2px; }
.preview-select {
  background: rgba(26,15,8,.05); border: 1px solid rgba(26,15,8,.15);
  border-radius: 7px; padding: 6px 10px; font-size: 11px; color: rgba(26,15,8,.7);
}
.preview-loc-grid { display: flex; gap: 5px; flex-wrap: wrap; }
.preview-loc-btn {
  padding: 4px 10px; border-radius: 8px; font-size: 11px;
  border: 1px solid rgba(26,15,8,.2); color: rgba(26,15,8,.55); background: transparent;
}
.preview-loc-btn.on { background: var(--accent); color: var(--paper); border-color: var(--accent); }
.preview-register-btn {
  background: var(--accent); color: var(--paper); border-radius: 9px;
  padding: 10px; text-align: center; font-size: 12px; font-weight: 500; margin-top: 4px;
}
.preview-search-bar {
  background: rgba(26,15,8,.05); border: 1px solid rgba(26,15,8,.12);
  border-radius: 20px; padding: 7px 12px; font-size: 11px; color: rgba(26,15,8,.35);
}
.preview-filter-row { display: flex; gap: 5px; flex-wrap: wrap; }
.preview-chip {
  padding: 3px 10px; border-radius: 14px; font-size: 11px;
  border: 1px solid rgba(26,15,8,.2); color: rgba(26,15,8,.55); background: transparent;
}
.preview-chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.preview-list-hd {
  display: flex; justify-content: space-between;
  font-size: 10px; color: rgba(26,15,8,.4); margin-top: 2px;
}
.preview-card {
  background: #fff; border-radius: 9px; padding: 9px;
  display: flex; gap: 9px; box-shadow: 0 1px 4px rgba(26,15,8,.1);
}
.preview-cover {
  width: 38px; min-width: 38px; height: 52px;
  background: rgba(26,15,8,.08); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.preview-info { flex: 1; min-width: 0; }
.preview-title { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 1px; }
.preview-author { font-size: 10px; color: rgba(26,15,8,.45); margin-bottom: 5px; }
.preview-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 3px; }
.preview-tag-loc   { font-size: 10px; padding: 2px 6px; border-radius: 8px; background: rgba(139,58,28,.1); color: #8B3A1C; border: 1px solid rgba(139,58,28,.2); }
.preview-tag-buyer { font-size: 10px; padding: 2px 6px; border-radius: 8px; background: rgba(74,103,65,.1);  color: #4A6741; border: 1px solid rgba(74,103,65,.2); }
.preview-tag-genre { font-size: 10px; padding: 2px 6px; border-radius: 8px; background: rgba(30,58,95,.08);  color: #1E3A5F; border: 1px solid rgba(30,58,95,.15); }
.preview-date { font-size: 10px; color: rgba(26,15,8,.32); }

.preview-sync-bar {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: rgba(26,15,8,.7);
  background: rgba(29,158,117,.1); border: 1px solid rgba(29,158,117,.25);
  border-radius: 8px; padding: 7px 10px;
}
.preview-sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #1D9E75; flex-shrink: 0; }
.preview-rt-banner {
  background: rgba(139,58,28,.08); border: 1px solid rgba(139,58,28,.2);
  border-radius: 8px; padding: 7px 10px; font-size: 11px; color: rgba(26,15,8,.7);
}
.preview-member-list { display: flex; flex-direction: column; gap: 5px; }
.preview-member { display: flex; align-items: center; gap: 7px; font-size: 12px; color: rgba(26,15,8,.7); }
.preview-member-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.preview-total-box {
  margin-top: 6px; background: rgba(26,15,8,.04); border: 1px solid rgba(26,15,8,.1);
  border-radius: 10px; padding: 12px; text-align: center;
}
.preview-total-num { font-family: var(--font-serif); font-size: 32px; font-weight: 700; color: var(--accent); line-height: 1; }
.preview-total-label { font-size: 11px; color: rgba(26,15,8,.45); margin-top: 4px; }

/* ─── APP LAYOUT ─── */
#appRoot { display: none; min-height: 100vh; }

/* Header */
.header {
  background: var(--ink); height: var(--header-h);
  padding: 0 20px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid rgba(245,237,216,.1);
}
.header-logo { font-family: var(--font-serif); font-size: 20px; font-weight: 700; color: var(--paper); letter-spacing: .05em; line-height: 1; }
.header-logo span { color: var(--accent-light); }
.header-sub { font-size: 9px; color: rgba(245,237,216,.65); letter-spacing: .15em; margin-top: 2px; }
.sync-status { display: flex; align-items: center; gap: 6px; font-size: 11px; cursor: pointer; padding: 6px 10px; border-radius: 20px; border: 1px solid transparent; transition: all .2s; }
.sync-status:hover { background: rgba(245,237,216,.06); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(245,237,216,.2); transition: background .3s; flex-shrink: 0; }
.sync-dot.connected { background: var(--sync-color); animation: pulse 2s infinite; }
.sync-dot.local { background: var(--gold); }
.sync-dot.error { background: #e24b4a; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(29,158,117,.4); } 50% { box-shadow: 0 0 0 4px rgba(29,158,117,0); } }
.sync-label { color: rgba(245,237,216,.5); font-family: var(--font-sans); white-space: nowrap; }

/* ─── DESKTOP LAYOUT (≥768px) ─── */
.app-body {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--ink);
  border-right: 1px solid rgba(245,237,216,.08);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 0 24px;
}
.sidebar-section-title {
  font-size: 10px;
  letter-spacing: .15em;
  color: rgba(245,237,216,.65);
  padding: 0 16px;
  margin: 16px 0 8px;
  font-family: var(--font-sans);
  font-weight: 500;
}
.sidebar-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  color: rgba(245,237,216,.65);
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  background: none;
  border-top: none; border-right: none; border-bottom: none;
  width: 100%;
  text-align: left;
}
.sidebar-tab:hover { color: var(--accent-light); background: rgba(245,237,216,.04); }
.sidebar-tab.active { color: var(--accent-light); border-left-color: var(--accent); background: rgba(245,237,216,.06); }
.sidebar-tab-inner { display: flex; align-items: center; gap: 10px; }
.sidebar-tab-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sidebar-tab-edit { opacity: 0; font-size: 13px; color: rgba(245,237,216,.35); padding: 2px 6px; border-radius: 4px; transition: all .15s; background: none; border: none; cursor: pointer; }
.sidebar-tab:hover .sidebar-tab-edit { opacity: 1; }
.sidebar-tab-edit:hover { color: var(--accent-light); background: rgba(245,237,216,.1); }
.sidebar-add-btn {
  margin: 12px 16px 0;
  padding: 9px 14px;
  background: rgba(245,237,216,.06);
  border: 1px dashed rgba(245,237,216,.15);
  border-radius: var(--radius);
  color: rgba(245,237,216,.4);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: all .2s;
  text-align: left;
  width: calc(100% - 32px);
}
.sidebar-add-btn:hover { background: rgba(245,237,216,.1); color: rgba(245,237,216,.7); border-color: rgba(245,237,216,.3); }

/* Main content area */
.content-area {
  flex: 1;
  background: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(26,15,8,.04) 28px);
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
}

/* Realtime banner */
.rt-banner { display: none; background: #E1F5EE; border-bottom: 1px solid #9FE1CB; padding: 8px 20px; font-size: 12px; color: #0F6E56; align-items: center; gap: 8px; }
.rt-banner.show { display: flex; animation: fadeIn .4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile tabs (hidden on desktop) */
.mobile-tabs {
  display: none;
  background: var(--paper2);
  overflow-x: auto;
  border-bottom: 2px solid var(--paper3);
  scrollbar-width: none;
}
.mobile-tabs::-webkit-scrollbar { display: none; }
.mobile-tab-inner { display: flex; padding: 0 16px; }
.mobile-tab {
  padding: 11px 14px 9px; font-family: var(--font-serif); font-size: 13px;
  font-weight: 600; color: rgba(26,15,8,.45); cursor: pointer; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .2s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.mobile-tab:hover { color: var(--accent); }
.mobile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.mobile-tab-add { padding: 11px 12px 9px; font-size: 18px; color: rgba(26,15,8,.3); cursor: pointer; background: none; border: none; }
.mobile-tab-add:hover { color: var(--accent); }

/* ─── SCAN SECTION ─── */
.scan-section { padding: 16px 20px; background: var(--paper2); border-bottom: 1px solid var(--paper3); }
.scan-btn {
  width: 100%; padding: 13px; background: var(--accent); color: var(--paper); border: none;
  border-radius: var(--radius); font-family: var(--font-serif); font-size: 16px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  letter-spacing: .05em; transition: background .2s; box-shadow: 0 2px 8px var(--shadow);
}
.scan-btn:hover { background: var(--accent2); }
.scan-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.manual-row { display: flex; gap: 8px; margin-top: 10px; }
.isbn-input {
  flex: 1; padding: 10px 12px; background: var(--paper); border: 1.5px solid var(--paper3);
  border-radius: var(--radius); font-family: var(--font-sans); font-size: 14px; color: var(--ink); outline: none;
}
.isbn-input:focus { border-color: var(--accent); }
.isbn-input::placeholder { color: rgba(26,15,8,.3); }
.search-isbn-btn {
  padding: 10px 18px; background: var(--ink); color: var(--paper); border: none;
  border-radius: var(--radius); font-family: var(--font-serif); font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .2s;
}
.search-isbn-btn:hover { background: var(--accent); }

/* ─── SEARCH / FILTER ─── */
.search-filter-wrap { background: var(--paper2); border-bottom: 1px solid var(--paper3); padding: 10px 20px 0; }
.search-wrap-inner { position: relative; margin-bottom: 10px; }
.search-bar {
  width: 100%; padding: 9px 12px 9px 36px; background: var(--paper);
  border: 1.5px solid var(--paper3); border-radius: 20px; font-size: 14px;
  color: var(--ink); outline: none; font-family: var(--font-sans);
}
.search-bar:focus { border-color: var(--accent); }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: rgba(26,15,8,.3); font-size: 15px; pointer-events: none; }
.filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--paper3);
  background: var(--paper); font-size: 12px; cursor: pointer; white-space: nowrap;
  color: rgba(26,15,8,.6); transition: all .15s; flex-shrink: 0;
}
.filter-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ─── BOOK LIST ─── */
.list-header { padding: 14px 20px 8px; display: flex; align-items: center; justify-content: space-between; }
.sort-select {
  padding: 4px 8px; border-radius: var(--radius); border: 1px solid var(--paper3);
  background: var(--paper); color: rgba(26,15,8,.6); font-family: var(--font-sans);
  font-size: 12px; cursor: pointer; outline: none;
}
.sort-select:focus { border-color: var(--accent); }
.list-title { font-family: var(--font-serif); font-size: 13px; color: rgba(26,15,8,.5); letter-spacing: .08em; }
.list-count { font-size: 12px; color: rgba(26,15,8,.4); }

.book-list { padding: 0 20px 80px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }

.book-card {
  background: var(--paper); border: 1px solid var(--paper3); border-radius: 8px;
  display: flex; gap: 12px; padding: 14px; box-shadow: 0 1px 4px var(--shadow2);
  position: relative; transition: box-shadow .2s, transform .1s; cursor: pointer;
}
.book-card:hover { box-shadow: 0 4px 16px var(--shadow); transform: translateY(-1px); }
.book-card.new-flash { animation: flashNew 1.2s ease; }
@keyframes flashNew { 0% { background: #d8f5ec; } 100% { background: var(--paper); } }

.book-cover {
  width: 58px; min-width: 58px; height: 84px; border-radius: 4px;
  background: var(--paper2); display: flex; align-items: center; justify-content: center;
  font-size: 28px; overflow: hidden; box-shadow: 2px 2px 6px var(--shadow);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-placeholder {
  width: 58px; min-width: 58px; height: 84px; border-radius: 4px;
  background: var(--paper3); display: flex; align-items: center; justify-content: center; font-size: 24px;
  box-shadow: 2px 2px 6px var(--shadow);
}
.book-info { flex: 1; min-width: 0; padding-right: 24px; }
.book-title {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600;
  color: var(--ink); line-height: 1.4; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.book-author { font-size: 12px; color: rgba(26,15,8,.55); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.location-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; line-height: 1.4; }
.book-delete {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
  background: none; border: none; cursor: pointer; color: rgba(26,15,8,.4);
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: all .2s;
}
.book-delete:hover { color: var(--accent); background: rgba(139,58,28,.1); }

/* ─── CAMERA MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,15,8,.92); z-index: 200;
  display: none; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.camera-container { width: 100%; max-width: 460px; }
.camera-title { font-family: var(--font-serif); font-size: 18px; color: var(--paper); text-align: center; margin-bottom: 16px; }
#qr-reader { border-radius: 10px; overflow: hidden; background: #000; min-height: 200px; }
#qr-reader img { display: none !important; }
#qr-reader video { width: 100% !important; border-radius: 10px; }
#qr-reader__dashboard { display: none !important; }
.camera-hint { text-align: center; color: rgba(245,237,216,.6); font-size: 12px; margin-top: 12px; }
#scanStatus { text-align: center; color: rgba(245,237,216,.5); font-size: 12px; margin-top: 6px; min-height: 18px; }
.camera-close {
  display: block; width: 100%; margin-top: 16px; padding: 13px;
  background: rgba(245,237,216,.1); border: 1px solid rgba(245,237,216,.2);
  border-radius: var(--radius); color: var(--paper); font-family: var(--font-serif);
  font-size: 15px; cursor: pointer; text-align: center; transition: background .2s;
}
.camera-close:hover { background: rgba(245,237,216,.18); }

/* ─── DETAIL SHEET ─── */
.detail-modal { position: fixed; inset: 0; z-index: 300; display: none; align-items: flex-end; }
.detail-modal.open { display: flex; }
.detail-backdrop { position: absolute; inset: 0; background: rgba(26,15,8,.5); }
.detail-sheet {
  position: relative; width: 100%; background: var(--paper);
  border-radius: 16px 16px 0 0; padding: 20px 24px 40px;
  max-height: 85vh; overflow-y: auto; animation: slideUp .3s ease;
}
/* on desktop: show as centered dialog */
@media (min-width: 768px) {
  .detail-modal { align-items: center; justify-content: center; }
  .detail-sheet {
    width: 500px; max-width: 95vw; border-radius: 14px;
    max-height: 90vh; animation: fadeInScale .25s ease;
  }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeInScale { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.detail-handle { width: 40px; height: 4px; background: var(--paper3); border-radius: 2px; margin: 0 auto 20px; }
.detail-cover-row { display: flex; gap: 16px; margin-bottom: 16px; }
.detail-cover {
  width: 80px; min-width: 80px; height: 112px; border-radius: 4px;
  background: var(--paper2); overflow: hidden; box-shadow: 3px 3px 10px var(--shadow);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-book-title { font-family: var(--font-serif); font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.4; margin-bottom: 6px; }
.detail-book-author { font-size: 13px; color: rgba(26,15,8,.55); margin-bottom: 4px; }
.detail-book-publisher { font-size: 12px; color: rgba(26,15,8,.4); }
.detail-isbn { font-size: 12px; color: rgba(26,15,8,.35); margin-top: 4px; }
.detail-section { margin-top: 16px; }
.detail-label { font-size: 11px; font-weight: 500; letter-spacing: .1em; color: rgba(26,15,8,.4); margin-bottom: 8px; font-family: var(--font-sans); }
.detail-description { font-size: 13px; color: rgba(26,15,8,.6); line-height: 1.7; max-height: 80px; overflow: hidden; }
.select-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.loc-btn {
  padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--paper3);
  background: var(--paper); font-family: var(--font-sans); font-size: 13px;
  color: rgba(26,15,8,.6); cursor: pointer; transition: all .15s;
}
.loc-btn.selected { border-color: var(--accent); background: var(--accent); color: var(--paper); }
.loc-btn:hover:not(.selected) { border-color: var(--accent2); color: var(--accent); }
.detail-save {
  width: 100%; margin-top: 20px; padding: 14px; background: var(--accent); color: var(--paper);
  border: none; border-radius: var(--radius); font-family: var(--font-serif); font-size: 16px;
  font-weight: 600; cursor: pointer; letter-spacing: .05em; transition: background .2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.detail-save:hover { background: var(--accent2); }

/* ─── LOCATION MODAL ─── */
.loc-add-modal { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; padding: 20px; }
.loc-add-modal.open { display: flex; }
.loc-add-backdrop { position: absolute; inset: 0; background: rgba(26,15,8,.7); }
.loc-add-sheet {
  position: relative; background: var(--paper); border-radius: 12px; padding: 24px;
  width: 100%; max-width: 340px; animation: fadeInScale .2s ease;
}
.loc-add-title { font-family: var(--font-serif); font-size: 17px; font-weight: 700; margin-bottom: 16px; color: var(--ink); }
.loc-add-input {
  width: 100%; padding: 11px 14px; background: var(--paper2); border: 1.5px solid var(--paper3);
  border-radius: var(--radius); font-family: var(--font-sans); font-size: 15px; color: var(--ink);
  outline: none; margin-bottom: 12px;
}
.loc-add-input:focus { border-color: var(--accent); }
.color-picker { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: border-color .15s; }
.color-dot.selected { border-color: var(--ink); }
.loc-add-actions { display: flex; gap: 8px; }
.loc-add-cancel { flex: 1; padding: 11px; background: var(--paper2); border: none; border-radius: var(--radius); font-family: var(--font-sans); font-size: 14px; cursor: pointer; color: rgba(26,15,8,.6); }
.loc-add-ok { flex: 1; padding: 11px; background: var(--accent); border: none; border-radius: var(--radius); font-family: var(--font-serif); font-size: 14px; font-weight: 600; cursor: pointer; color: var(--paper); }
.loc-delete-btn {
  width: 100%; margin-top: 10px; padding: 10px; background: none;
  border: 1px solid rgba(200,60,40,.25); border-radius: var(--radius);
  color: rgba(200,60,40,.7); font-family: var(--font-sans); font-size: 13px;
  cursor: pointer; transition: all .2s;
}
.loc-delete-btn:hover { background: rgba(200,60,40,.08); border-color: rgba(200,60,40,.5); color: rgba(200,60,40,1); }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 10px 22px; border-radius: 20px;
  font-size: 13px; font-family: var(--font-sans); opacity: 0; transition: all .3s;
  white-space: nowrap; z-index: 9000; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── MISC ─── */
.empty-state { text-align: center; padding: 60px 32px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-family: var(--font-serif); font-size: 16px; color: rgba(26,15,8,.4); margin-bottom: 6px; }
.empty-sub { font-size: 12px; color: rgba(26,15,8,.3); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(245,237,216,.3); border-top-color: var(--paper); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { border-color: rgba(26,15,8,.15); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── GENRE ─── */
.genre-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
  background: rgba(26,15,8,.08); color: rgba(26,15,8,.55); border: 1px solid rgba(26,15,8,.12);
}
.genre-select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--paper3); background: var(--paper);
  color: var(--ink); font-family: var(--font-sans); font-size: 14px;
  outline: none; cursor: pointer;
}
.genre-select:focus { border-color: var(--accent); }

/* ─── HELP BUTTON ─── */
.help-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(245,237,216,.1); border: 1px solid rgba(245,237,216,.2);
  color: rgba(245,237,216,.6); font-size: 13px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s; flex-shrink: 0;
}
.help-btn:hover { background: rgba(245,237,216,.18); color: var(--paper); }

/* ─── HELP MODAL ─── */
.help-modal { position: fixed; inset: 0; z-index: 400; display: none; align-items: flex-end; }
.help-modal.open { display: flex; }
.help-backdrop { position: absolute; inset: 0; background: rgba(26,15,8,.6); }
.help-sheet {
  position: relative; width: 100%; background: var(--paper);
  border-radius: 16px 16px 0 0; max-height: 85vh; overflow-y: auto;
  animation: slideUp .3s ease;
}
@media (min-width: 768px) {
  .help-modal { align-items: center; justify-content: center; }
  .help-sheet { width: 480px; max-width: 95vw; border-radius: 14px; max-height: 85vh; animation: fadeInScale .25s ease; }
}
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 12px; border-bottom: 1px solid var(--paper3);
  position: sticky; top: 0; background: var(--paper); z-index: 1;
}
.help-title { font-family: var(--font-serif); font-size: 18px; font-weight: 700; color: var(--ink); }
.help-close {
  width: 30px; height: 30px; border-radius: 50%; background: var(--paper2);
  border: none; color: rgba(26,15,8,.5); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.help-close:hover { background: var(--paper3); color: var(--ink); }
.help-body { padding: 16px 20px 36px; display: flex; flex-direction: column; gap: 20px; }
.help-section { display: flex; flex-direction: column; gap: 8px; }
.help-section-title { font-family: var(--font-serif); font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.help-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: rgba(26,15,8,.7); line-height: 1.6; }
.help-step {
  min-width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  color: var(--paper); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;
}

/* ─── MOBILE MENU BUTTON ─── */
.mobile-menu-btn {
  display: none;
  width: 34px; height: 34px; border-radius: 8px;
  background: rgba(245,237,216,.1); border: 1px solid rgba(245,237,216,.2);
  color: rgba(245,237,216,.8); font-size: 20px; line-height: 1;
  cursor: pointer; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .2s;
}
.mobile-menu-btn:hover { background: rgba(245,237,216,.18); }

/* ─── SIDEBAR OVERLAY (mobile drawer backdrop) ─── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  top: var(--header-h); background: rgba(26,15,8,.55); z-index: 140;
}
.sidebar-overlay.open { display: block; }

/* ─── RESPONSIVE BREAKPOINTS ─── */

/* Tablet (≥768px): desktop sidebar layout */
@media (min-width: 768px) {
  .mobile-tabs { display: none !important; }
  .sidebar { display: flex; }
  .detail-handle { display: none; }
  .mobile-menu-btn { display: none !important; }
}

/* Mobile (<768px): sidebar as drawer, show tab bar */
@media (max-width: 767px) {
  .mobile-menu-btn { display: flex; }
  .sidebar {
    display: flex !important;
    position: fixed;
    left: 0; top: var(--header-h); bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform .3s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(26,15,8,.4); }
  .mobile-tabs { display: block; }
  .book-list { padding: 0 8px 80px; gap: 8px; }
  .book-card { padding: 10px; gap: 10px; }
  .book-cover, .book-cover-placeholder { width: 48px; min-width: 48px; height: 68px; font-size: 20px; }
  .book-title { font-size: 14px; }
  .book-author { font-size: 11px; }
  .scan-section { padding: 10px 12px; }
  .manual-row { margin-top: 8px; }
  .scan-btn { font-size: 15px; padding: 11px; }
  .search-filter-wrap { padding: 8px 8px 0; }
  .list-header { padding: 10px 8px 4px; }
  .detail-sheet { padding: 16px 14px 32px; }
  .header { padding: 0 14px; }
}

/* Wide desktop (≥1100px): 2-column book grid */
@media (min-width: 1100px) {
  .book-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Extra wide (≥1400px): 3-column book grid */
@media (min-width: 1400px) {
  .book-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Touch: bigger tap targets */
@media (hover: none) {
  .scan-btn { padding: 15px; }
  .filter-chip { padding: 6px 14px; }
  .sidebar-tab-edit { opacity: 1; }
}
