:root {
  --bg: #f6f3ec;
  --paper: #fff;
  --ink: #1f1d1a;
  --muted: #6f6a60;
  --line: #e2dccf;
  --gold: #a8843f;
  --gold-ink: #fff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Noto Sans SC", "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, .button {
  font: inherit; font-size: 13px; line-height: 1; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; min-height: 34px;
}
button:disabled, .button[aria-disabled="true"] { opacity: .45; pointer-events: none; }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.bar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.bar-inner {
  max-width: 900px; margin: 0 auto; padding: 10px 14px;
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
}
.heading { min-width: 0; }
h1 { font-size: 17px; margin: 0; line-height: 1.3; }
.meta { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.langs { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--paper); }
.langs button { border: 0; border-radius: 0; min-height: 32px; padding: 7px 11px; }
.langs button + button { border-left: 1px solid var(--line); }
.langs button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.actions { display: inline-flex; gap: 8px; }

.doc { max-width: 900px; margin: 0 auto; padding: 14px 10px calc(28px + env(safe-area-inset-bottom)); }
.state { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }
.state.error { color: #a33a2b; }
.state:empty { display: none; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.page {
  position: relative; background: var(--paper); overflow: hidden;
  box-shadow: 0 1px 3px rgb(0 0 0 / .08), 0 6px 20px rgb(0 0 0 / .05); border-radius: 4px;
}
.page canvas { display: block; width: 100%; height: 100%; }

/* Text layer, from pdf.js web/pdf_viewer.css (4.10): transparent text over the canvas, selectable and copyable. */
.textLayer {
  position: absolute; inset: 0; overflow: clip; opacity: 1; line-height: 1;
  text-align: initial; -webkit-text-size-adjust: none; text-size-adjust: none;
  forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
}
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; }
.textLayer span.markedContent { top: 0; height: 0; }
.textLayer ::selection { background: rgb(0 0 255 / .25); }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: rgb(31 29 26 / .92); color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 999px;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .bar-inner { padding: 8px 10px; }
  h1 { font-size: 16px; }
  .tools { width: 100%; justify-content: space-between; }
  .doc { padding: 10px 6px 24px; }
  .pages { gap: 8px; }
}
