@font-face {
  font-family: 'sandro-universal-bold';
  src: url('../fonts/SandroUniversal-Bold.woff2') format('woff2'),
       url('../fonts/SandroUniversal-Bold.woff') format('woff');
  font-display: swap;
}

@font-face {
  font-family: 'sandro-universal-regular';
  src: url('../fonts/SandroUniversal-Regular.woff2') format('woff2'),
       url('../fonts/SandroUniversal-Regular.woff') format('woff');
  font-display: swap;
}

:root {
  --bg: #e7e7e7;
  --ink: #1a1a1a;
  --muted: #666;
  --accent: #77512d;
  --accent-soft: rgba(119, 81, 45, 0.12);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'sandro-universal-regular', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Top and bottom bars */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  flex: none;
}

.bar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: 'sandro-universal-bold', sans-serif;
  font-size: clamp(16px, 2.4vw, 22px);
  font-weight: normal;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover { background: var(--accent-soft); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.3; cursor: default; background: none; }

.back { padding: 6px 12px 6px 6px; }

.round {
  width: 44px;
  height: 44px;
}

.langs {
  display: flex;
  gap: 4px;
}

.langs a {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-family: 'sandro-universal-bold', sans-serif;
  font-size: 14px;
  text-decoration: none;
}

.langs a[aria-current="true"] {
  background: var(--accent);
  color: #fff;
}

.controls {
  justify-content: center;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.counter {
  min-width: 90px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.fs { margin-left: 8px; }

/* Book stage */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
}

.book {
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
}

.book.hidden { visibility: hidden; }

.page {
  background: #fff;
  overflow: hidden;
}

.page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Soft shadow under the open book */
.stf__parent {
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.18));
}

/* Loading / error overlay */
.status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.status[hidden] { display: none; }
.status p { margin: 0; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.status.error .spinner { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .back span { display: none; }
  .back { padding: 6px; }
  .langs a { padding: 4px 8px; font-size: 13px; }
}
