:root {
  --bg: #1d1712;
  --bar: rgba(29, 23, 18, .82);
  --ink: #f3ead6;
  --muted: #b9a98c;
  --accent: #d9b45a;
  --line: rgba(243, 234, 214, .18);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font: 16px/1.45 "IM Fell English", Georgia, serif; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage.dragging { cursor: grabbing; }

.bar { position: fixed; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--bar); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 2; }
.bar.top { top: 0; padding-top: max(10px, env(safe-area-inset-top)); }
.bar.bottom { bottom: 0; justify-content: center; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.title { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.title b { font-family: "IM Fell English SC", Georgia, serif; font-weight: 400; font-size: 17px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.title span { color: var(--muted); font-size: 13px; }
.search { position: relative; margin-left: auto; flex: 0 1 240px; min-width: 0; }
.search input { width: 100%; font: inherit; color: var(--ink); background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; outline: none; }
.search input:focus { border-color: var(--accent); }
#hits { position: absolute; right: 0; top: calc(100% + 6px); width: min(280px, 80vw); margin: 0; padding: 4px;
  list-style: none; background: #2a221b; border: 1px solid var(--line); border-radius: 12px; max-height: 50vh; overflow: auto; }
#hits li { padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
#hits li[aria-selected="true"], #hits li:hover { background: rgba(217, 180, 90, .18); }
#hits li small { color: var(--muted); }
#hits li.none { color: var(--muted); cursor: default; }
button { font: inherit; color: var(--ink); background: none; border: 0; cursor: pointer; }
.icon { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; flex: none;
  display: grid; place-items: center; background: rgba(255, 255, 255, .06); }
.icon:hover { background: rgba(255, 255, 255, .14); }
.icon:disabled { opacity: .3; cursor: default; }
#info { font-size: 18px; }
.layout { white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.layout[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.where { min-width: 150px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .06); font-size: 15px; }
.toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a221b; border: 1px solid var(--line); padding: 8px 16px; border-radius: 999px; z-index: 3;
  max-width: calc(100vw - 32px); text-align: center; }
dialog { max-width: min(520px, calc(100vw - 32px)); background: #2a221b; color: var(--ink); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px 24px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h2 { font-family: "IM Fell English SC", Georgia, serif; font-weight: 400; margin: 0 0 8px; }
dialog a { color: var(--accent); }
dialog .small { color: var(--muted); font-size: 14px; }
dialog form button { margin-top: 6px; padding: 6px 18px; border-radius: 999px; border: 1px solid var(--line); }
@media (max-width: 560px) {
  .bar.bottom { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .bar.bottom .icon { width: 36px; height: 36px; }
  .layout { padding: 6px 9px; font-size: 13px; }
  .title b { font-size: 15px; max-width: 42vw; }
  .search { flex-basis: 46vw; }
  .layout { white-space: nowrap; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.layout[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.where { min-width: 120px; }
}

/* Missing-page help */
.help { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 2;
  width: min(560px, calc(100vw - 32px)); display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: #2a221b; border: 1px solid var(--line); border-radius: 14px; }
.help p { margin: 0; font-size: 15px; line-height: 1.35; }
.help .primary { flex: none; }
.primary { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--accent); color: #21180f !important;
  text-decoration: none; font-weight: 700; border: 0; cursor: pointer; font: inherit; }
@media (max-width: 560px) { .help { flex-direction: column; align-items: stretch; text-align: center; } }

/* Reading help */
.entry { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow: auto; }
.entry .eh { display: flex; align-items: center; gap: 10px; }
.entry h2 { margin: 0; font-family: "IM Fell English", Georgia, serif; font-size: 30px; }
.entry .x { margin-left: auto; font-size: 18px; color: var(--muted); }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.s3 { color: #e8c37a; border-color: #8a6b32; }
.chip.s4 { color: #f0a35a; border-color: #9a5a22; }
.entry .why { color: var(--muted); margin: 8px 0 12px; font-size: 15px; }
.entry .crop { margin: 0 0 12px; }
.entry .crop .img { position: relative; max-width: 100%; border-radius: 6px; background-color: #fff; background-repeat: no-repeat; }
.entry .crop .mark { position: absolute; left: 0; border: 2px solid #e0932f; border-radius: 4px; box-sizing: border-box; }
.entry .crop .around { color: var(--accent); text-decoration: underline; font-size: 12px; padding: 0; }
.entry .order { margin: 0 0 10px; }
.entry .crop figcaption { color: var(--muted); font-size: 12px; margin-top: 4px; }
.entry .q { margin: 8px 0 6px; font-weight: 700; }
.entry .opts { display: grid; gap: 4px; margin-bottom: 8px; }
.entry .opts label { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.05); cursor: pointer; font-size: 18px; }
.entry .opts small, .entry .bar small { color: var(--muted); font-size: 12px; }
.entry .own { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.entry .own input { flex: 1; min-width: 0; font: inherit; font-size: 17px; color: var(--ink); background: rgba(255,255,255,.08);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.entry .err { color: #f0a35a; min-height: 1.2em; margin: 6px 0; font-size: 14px; }
.entry .ts { margin: 6px 0; }
.entry .acts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.entry .notsure { color: var(--muted); text-decoration: underline; font-size: 14px; }
.entry .bar { position: relative; display: flex; justify-content: space-between; padding: 6px 10px; margin: 4px 0;
  border-radius: 10px; background: rgba(255,255,255,.05); overflow: hidden; font-size: 17px; }
.entry .bar i { position: absolute; inset: 0 auto 0 0; background: rgba(217,180,90,.22); }
.entry .bar span, .entry .bar b { position: relative; }
.entry .bar.me { outline: 1px solid var(--accent); }
.entry .small { color: var(--muted); font-size: 13px; }
.entry .askfriend { color: var(--accent); text-decoration: underline; padding: 0; font-size: 14px; }
