:root {
  color: #2b241c;
  background: #f6f1e7;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
  --ink: #2b241c;
  --muted: #6d6256;
  --paper: #f6f1e7;
  --paper-2: #fffaf3;
  --wood: #6b4428;
  --wood-deep: #3f2a1d;
  --line: #e4d9c8;
  --glass: rgba(246, 241, 231, 0.84);
  --shadow: 0 16px 50px rgba(42, 24, 12, 0.28);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100%; background: var(--paper); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, canvas:focus-visible {
  outline: 3px solid #8a5a32;
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 20;
  padding: 12px 16px;
  background: white;
  border-radius: 8px;
}
.skip-link:focus { top: calc(12px + env(safe-area-inset-top)); }

html.is-shop, html.is-shop body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #24180f;
}
html.is-shop body { position: fixed; inset: 0; width: 100%; }

.shop {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  background: #24180f;
}
.shop canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.shop canvas.is-dragging { cursor: grabbing; }
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(36, 22, 12, 0.35), transparent 22%, transparent 72%, rgba(36, 22, 12, 0.28));
}
.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #3f2a1d;
  color: #f6f1e7;
  z-index: 4;
}
.loading p { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 22px; }

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
  pointer-events: none;
}
.brand, .hud-actions, .icon-button, .hint-chip, .tip, .joystick { pointer-events: auto; }
.brand {
  margin: 0;
  padding: 8px 12px 9px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.brand span, .brand small { display: block; }
.brand span { font-family: Georgia, "Times New Roman", serif; font-size: 18px; line-height: 1.1; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; letter-spacing: 0.02em; }
.hud-actions { display: flex; gap: 8px; }
.icon-button {
  min-width: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
}
.bag-button .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--wood-deep);
  color: #f6f1e7;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.hint-chip {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100% - 180px);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(36, 22, 12, 0.45);
  color: #f8f1e6;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}
.joystick {
  display: none;
  position: absolute;
  z-index: 3;
  left: calc(16px + env(safe-area-inset-left));
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(246, 241, 231, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.38);
  touch-action: none;
}
.joystick-knob {
  position: absolute;
  left: 38px;
  top: 38px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(246, 241, 231, 0.92);
  box-shadow: 0 6px 16px rgba(36, 22, 12, 0.25);
}
.is-panel .joystick, .is-panel .hint-chip { visibility: hidden; }

.tip {
  position: absolute;
  z-index: 4;
  left: calc(16px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
  top: calc(78px + env(safe-area-inset-top));
  max-width: 440px;
  margin: 0 auto;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.tip h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 28px; line-height: 1.15; margin: 6px 0 8px; }
.tip p { margin: 0 0 14px; line-height: 1.45; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

.primary-button, .secondary-button {
  min-height: 48px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 16px;
}
.primary-button { background: var(--wood-deep); color: #f6f1e7; }
.secondary-button { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.action-stack { display: grid; gap: 8px; }
.local-note, .total-line, .result-count, .storage-notice { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; }
.storage-notice { color: #8a3d22; text-align: left; }

.sheet-layer { position: absolute; inset: 0; z-index: 6; }
.scrim { position: absolute; inset: 0; background: rgba(28, 18, 10, 0.35); }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(78dvh, 680px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  animation: sheet-in 0.22s ease;
}
.sheet-grip { width: 42px; height: 4px; border-radius: 99px; background: #ddcbb8; margin: 8px auto 0; }
.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 8px 18px;
}
.sheet-bar h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 22px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-body { overflow: auto; padding: 0 18px 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.sheet-footer {
  padding: 8px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
@keyframes sheet-in { from { transform: translateY(16px); } to { transform: none; } }

.inspect { display: grid; grid-template-columns: 108px 1fr; gap: 14px; align-items: start; }
.inspect-cover {
  min-height: 168px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e7dcc8;
}
.inspect-cover .book-cover { width: 100%; height: 154px; }
.inspect-cover.forest { background: #d7e0d4; }
.inspect-cover.architecture { background: #d9d6cf; }
.inspect-cover.color { background: #f0d5cb; }
.inspect-cover.sea { background: #d5e4e2; }
.inspect-cover.night { background: #d5d8e0; }
.inspect-cover.wine { background: #f0d5d4; }
.inspect-cover.gold { background: #f0e2c4; }
.byline { margin: 4px 0; color: var(--muted); }
.price { margin: 8px 0; font-size: 22px; font-family: Georgia, "Times New Roman", serif; }
.description { margin: 0 0 10px; line-height: 1.5; font-size: 16px; }
.specs { margin: 0; color: var(--muted); font-size: 14px; }

.book-cover { position: relative; width: 92px; height: 132px; border-radius: 2px 4px 4px 2px; box-shadow: 4px 4px 0 #e4d8c6, 6px 6px 0 #6b5344; background-repeat: no-repeat; }
.cover-spine { position: absolute; inset: 0 auto 0 0; width: 7px; background: linear-gradient(90deg, rgba(0,0,0,.28), transparent); }
.generated { padding: 10px 8px 8px; display: flex; flex-direction: column; overflow: hidden; }
.generated strong { font-family: Georgia, "Times New Roman", serif; font-size: 13px; line-height: 1.15; position: relative; }
.generated em { margin-top: auto; font-style: normal; font-size: 11px; position: relative; }
.gen-band { position: absolute; left: 0; right: 0; bottom: 0; height: 32%; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button, .filters button {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  font-size: 14px;
}
.tabs button.active, .filters button.active { background: var(--wood-deep); color: #f6f1e7; border-color: var(--wood-deep); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  margin-bottom: 8px;
}
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; padding: 12px 0; }
.result-count { text-align: left; margin-bottom: 8px; }
.book-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.book-row {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  text-align: left;
  background: var(--paper-2);
}
.book-row .book-cover { width: 48px; height: 68px; box-shadow: 2px 2px 0 #e4d8c6, 3px 3px 0 #6b5344; }
.book-row .generated strong { font-size: 8px; }
.book-row .generated em, .book-row .gen-band { display: none; }
.book-row-copy { display: grid; gap: 2px; min-width: 0; }
.row-title { font-family: Georgia, "Times New Roman", serif; font-size: 18px; line-height: 1.15; }
.row-author, .row-price { color: var(--muted); font-size: 14px; }
.row-price { font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 28px 10px 12px; color: var(--muted); }
.empty-state h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; color: var(--ink); margin: 8px 0; }
.info-copy p, .event-row p { line-height: 1.5; }
.info-copy .secondary-button { margin: 8px 0 18px; }
.event-row { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.event-day { font-family: Georgia, "Times New Roman", serif; font-size: 28px; color: var(--wood); }
.event-row h3, .event-row h4 { margin: 4px 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 20px; }
.event-time { color: var(--muted); font-size: 14px; }

.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.fallback { min-height: 100dvh; padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.fallback-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.fallback-bar h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 34px; margin: 4px 0 0; }
.fallback-actions { display: flex; gap: 8px; }
.fallback-note { color: var(--muted); line-height: 1.45; }
.fallback-error { color: #8a3d22; }
.fallback-events { margin-top: 28px; }
.fallback-events h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.fallback .book-list { grid-template-columns: 1fr; }
.fallback .book-row .book-cover { width: 64px; height: 92px; }
.fallback .book-list { gap: 12px; }

@media (pointer: coarse), (max-width: 820px) {
  .joystick { display: block; }
  .hint-chip { left: auto; right: calc(12px + env(safe-area-inset-right)); transform: none; bottom: calc(28px + env(safe-area-inset-bottom)); max-width: 46vw; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .joystick { width: 104px; height: 104px; }
  .joystick-knob { width: 48px; height: 48px; left: 28px; top: 28px; }
  .tip h2 { font-size: 22px; }
  .sheet { max-height: 86dvh; }
}
@media (min-width: 960px) and (pointer: fine) {
  .sheet {
    left: auto;
    top: 0;
    width: min(420px, 100%);
    max-height: none;
    height: 100%;
    border-radius: 0;
    animation-name: drawer-in;
  }
  .sheet-grip { display: none; }
  .sheet-bar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .hint-chip { bottom: 22px; }
}
@keyframes drawer-in { from { transform: translateX(16px); } to { transform: none; } }
@media (min-width: 720px) {
  .fallback .book-list { grid-template-columns: 1fr 1fr; }
  .inspect { grid-template-columns: 140px 1fr; }
  .book-cover { width: 112px; height: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .loading p { font-size: 18px; }
}
