/* ===== Base ===== */
:root{
  --bg:#0b0c10;
  --panel:#111318;
  --panel2:#0f1116;
  --text:#eaeef7;
  --muted:#9aa3b2;
  --stroke:rgba(255,255,255,.10);
  --shadow: 0 20px 60px rgba(0,0,0,.55);
  --shadow2: 0 10px 30px rgba(0,0,0,.45);
  --radius: 18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: radial-gradient(1000px 600px at 50% 10%, rgba(255,255,255,.06), transparent 60%),
              var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  overflow:hidden;
}

/* ===== Topbar ===== */
.topbar{
  position:sticky;
  top:0;
  z-index:10;
  height:64px;
  padding: 10px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  background: linear-gradient(to bottom, rgba(15,17,22,.88), rgba(15,17,22,.72));
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--stroke);
}

.brand{ display:flex; align-items:center; gap:12px; min-width:0; }
.dot{
  width:12px; height:12px; border-radius:999px;
  background: linear-gradient(135deg, #d7dbe6, #7b859b);
  box-shadow: 0 0 0 6px rgba(255,255,255,.06);
}
.title{ min-width:0; }
.name{
  font-weight:700;
  letter-spacing:.12em;
  font-size:12px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.sub{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.controls{ display:flex; align-items:center; gap:10px; }
.btn{
  width:40px; height:40px;
  border-radius:12px;
  border:1px solid var(--stroke);
  background: linear-gradient(to bottom, rgba(255,255,255,.06), rgba(255,255,255,.03));
  color:var(--text);
  cursor:pointer;
  box-shadow: var(--shadow2);
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{ transform: translateY(-1px); border-color:rgba(255,255,255,.18); }
.btn:active{ transform: translateY(0px) scale(.98); }
.btn:focus-visible{ outline: 3px solid rgba(255,255,255,.20); outline-offset:2px; }

.counter{
  min-width:86px;
  height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  color:var(--text);
  font-weight:600;
}
.counter .sep{ opacity:.6; padding:0 6px; }

/* ===== Layout ===== */
.stage{
  height: calc(100% - 64px);
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:0;
}

.viewer{
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
  overflow:hidden;
}

.spread{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items:center;
  justify-items:center;
  width: min(1280px, 100%);
}

.page{
  width: 100%;
  max-width: 620px;
  height: auto;
  max-height: calc(100vh - 140px);
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: #111;
  border:1px solid rgba(255,255,255,.08);
  user-select:none;
  -webkit-user-drag:none;
  transform: translateZ(0);
  opacity: 1;
  transition: opacity .18s ease;
}

.hint{
  position:absolute;
  bottom: 18px;
  left: 18px;
  font-size:12px;
  color: rgba(255,255,255,.70);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.10);
  padding: 10px 12px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}

/* ===== Thumbnails ===== */
.thumbs{
  border-left:1px solid var(--stroke);
  background: linear-gradient(to bottom, rgba(17,19,24,.92), rgba(17,19,24,.86));
  backdrop-filter: blur(10px);
  overflow:auto;
}
.thumbsInner{
  padding: 14px;
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.thumb{
  position:relative;
  border-radius: 14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.25);
  cursor:pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.thumb:hover{ transform: translateY(-1px); border-color:rgba(255,255,255,.20); }
.thumb:focus-visible{ outline: 3px solid rgba(255,255,255,.20); outline-offset:2px; }
.thumb img{
  width:100%;
  height:auto;
  display:block;
}
.badge{
  position:absolute;
  top:10px; left:10px;
  font-size:12px;
  font-weight:700;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  border:1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
}
.thumb.active{ border-color: rgba(255,255,255,.28); }

/* ===== Responsive ===== */
@media (max-width: 980px){
  body{ overflow:auto; }
  .stage{
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height:auto;
  }
  .thumbs{
    border-left:0;
    border-top:1px solid var(--stroke);
    max-height: 260px;
  }
  .page{
    max-width: 92vw;
    max-height: calc(100vh - 170px);
  }
  .spread{
    grid-template-columns: 1fr; /* single page on mobile */
    gap: 10px;
  }
  #rightPage{ display:none; }
}
