:root {
  --bg: #0a1f36;
  --bg2: #0f2e50;
  --accent: #2b8fd6;
  --text: #eef4fa;
  --muted: color-mix(in srgb, var(--text) 62%, transparent);
  --line: color-mix(in srgb, var(--text) 14%, transparent);
  --glass: color-mix(in srgb, var(--text) 8%, transparent);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(120% 80% at 50% 40%, var(--bg2) 0%, var(--bg) 70%);
  background-color: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, a { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  gap: 10px;
}

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chip {
  flex: none; height: 40px; padding: 6px 12px; background: #fff; border-radius: 10px;
  display: grid; place-items: center;
}
.chip img { height: 26px; width: auto; display: block; }
.heading { min-width: 0; flex: 1; }
.heading h1 {
  font-size: 15px; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.heading p { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line); transition: background .2s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 14%, transparent); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }

/* ---------- Stage ---------- */
.stage { position: relative; min-height: 0; display: grid; place-items: center; perspective: 1800px; }
#book { position: relative; transition: translate .7s cubic-bezier(.3,.7,.2,1); }
#book .page { background: #fff; }
#book .page img { width: 100%; height: 100%; display: block; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.book-shadow {
  position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%);
  width: 70%; height: 30px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.55), transparent);
  filter: blur(6px); pointer-events: none;
}
.book-wrap { position: relative; opacity: 0; }
.book-wrap.in { animation: rise 1.1s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes rise {
  0%   { opacity: 0; transform: translateY(60px) rotateX(38deg) scale(.86); filter: blur(4px); }
  60%  { opacity: 1; filter: blur(0); }
  100% { opacity: 1; transform: none; }
}
.hint {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 12.5px; color: var(--text); background: color-mix(in srgb, var(--bg) 80%, transparent);
  border: 1px solid var(--line); padding: 7px 14px; border-radius: 99px;
  display: flex; align-items: center; gap: 8px; pointer-events: none; white-space: nowrap;
  opacity: 0; transition: opacity .5s;
}
.hint.show { opacity: 1; }
.hint svg { width: 16px; height: 16px; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(5px); } }

/* side arrows on wide screens */
.side { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; }
.side.prev { left: 4px; } .side.next { right: 4px; }
@media (max-width: 760px) { .side { display: none; } }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; text-align: center;
  background: var(--bg); transition: opacity .6s, visibility .6s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader .chip { height: 56px; padding: 10px 18px; margin: 0 auto 22px; border-radius: 14px; }
.loader .chip img { height: 36px; }
.loader h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.015em; padding: 0 24px; }
.loader p { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.bar { width: 180px; height: 3px; border-radius: 3px; background: var(--line); margin: 26px auto 0; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s; }

/* ---------- Bottom ---------- */
.bottom { display: grid; gap: 10px; justify-items: center; }
.dock {
  display: flex; align-items: center; gap: 6px; padding: 5px;
  border-radius: 16px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.dock .icon-btn { background: none; border-color: transparent; }
.dock .icon-btn:hover { background: var(--glass); }
.counter { min-width: 64px; text-align: center; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.counter b { color: var(--text); font-weight: 600; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }

.contact { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.contact a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  font-size: 13.5px; font-weight: 550; padding: 9px 15px; border-radius: 12px;
  border: 1px solid var(--line); transition: background .2s, border-color .2s;
}
.contact a:hover { background: var(--glass); }
.contact a.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.contact a.primary:hover { filter: brightness(1.08); }
.contact svg { width: 16px; height: 16px; }

/* ---------- Sheets (thumbnails / zoom) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40; display: none;
  background: color-mix(in srgb, var(--bg) 92%, black); 
}
.sheet.open { display: block; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px; background: inherit;
}
.sheet-head h3 { font-size: 15px; font-weight: 600; }
.thumbs {
  display: grid; gap: 14px; padding: 6px 14px 30px; max-width: 980px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.thumbs button { text-align: center; font-size: 12.5px; color: var(--muted); }
.thumbs img { width: 100%; display: block; border-radius: 6px; margin-bottom: 7px; background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); outline: 2px solid transparent; outline-offset: 3px; transition: outline-color .2s; }
.thumbs button[aria-current="true"] img { outline-color: var(--accent); }
.thumbs button[aria-current="true"] { color: var(--text); }

#zoom { overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.zoom-body { padding: 0 14px 30px; display: grid; justify-items: center; }
.zoom-body img { width: 100%; max-width: 1100px; height: auto; background: #fff; border-radius: 4px; transition: max-width .3s; }
#zoom.big .zoom-body img { max-width: none; width: 220%; }
.zoom-tools { display: flex; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--text); color: var(--bg); font-size: 13.5px; font-weight: 550;
  padding: 9px 16px; border-radius: 10px; opacity: 0; transition: .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Coming soon ---------- */
.soon { display: grid; place-items: center; text-align: center; padding: 20px; }
.soon h2 { font-size: clamp(22px, 5vw, 30px); font-weight: 650; letter-spacing: -0.02em; }
.soon p { color: var(--muted); margin: 10px auto 26px; max-width: 34ch; line-height: 1.5; }
.soon .list { display: grid; gap: 10px; width: min(360px, 100%); }
.soon .list a {
  display: flex; align-items: center; gap: 12px; text-decoration: none; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; padding: 10px; transition: background .2s;
}
.soon .list a:hover { background: var(--glass); }
.soon .list img { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; background: #fff; }
.soon .list span { font-size: 14px; font-weight: 550; }

@media (min-width: 761px) {
  .app { padding-left: 24px; padding-right: 24px; }
  .heading h1 { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-wrap.in { animation: fade .3s forwards; }
  .hint svg { animation: none; }
}

/* Phones held sideways: give the page all the height */
@media (max-height: 520px) {
  .app { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); gap: 4px; grid-template-columns: 1fr; }
  .chip { height: 30px; padding: 4px 9px; } .chip img { height: 20px; }
  .heading p, .contact, .hint { display: none; }
  .top .icon-btn { width: 32px; height: 32px; }
  .dock { padding: 2px; } .dock .icon-btn { width: 34px; height: 34px; }
  .bottom { gap: 0; }
}
