:root{
  --bg: #0b0c10;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);
  --border: rgba(255,255,255,0.12);
  --shadow: 0 18px 60px rgba(0,0,0,0.55);
  --radius: 18px;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }

body{
  margin: 0;
  background:
    radial-gradient(1200px 800px at 25% 10%, rgba(255,255,255,0.07), transparent 60%),
    radial-gradient(900px 600px at 80% 30%, rgba(255,255,255,0.05), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

.shell{
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.topbar{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 14px;
}

.brand .title{
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand .subtitle{
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.top-actions{ display:flex; gap: 10px; align-items:center; }

.stage{
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.home, .reader{
  display: block;
}

.home-card{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.home-cover, .home-copy{
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-cover{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 10px;
}

.home-cover img{
  width: 100%;
  height: 100%;
  max-height: 72vh;
  object-fit: contain;
  display:block;
  background: rgba(0,0,0,0.22);
  border-radius: 14px;
}

.home-copy{
  padding: 18px;
  display:flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.home-copy h1{
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.2px;
}

.lead{
  margin: 0;
  color: rgba(255,255,255,0.86);
  font-size: 15px;
  line-height: 1.5;
}

.muted{
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.home-actions{
  margin-top: 10px;
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
}

.reader{
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.page-frame{
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;

  aspect-ratio: 4 / 3;
  cursor: pointer;
  outline: none;
}

.page-frame:focus-visible{
  outline: 2px solid rgba(255,255,255,0.6);
  outline-offset: 3px;
}

.page-frame img{
  width: 100%;
  height: 100%;
  object-fit: contain;
  display:block;
  user-select:none;
  -webkit-user-select:none;
  background: rgba(0,0,0,0.22);

  opacity: 1;
  transition: opacity 140ms ease;
}

.page-frame img.loading{
  opacity: 0.18;
}

.status-overlay{
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  line-height: 1.35;
  display: none;
  white-space: pre-line;
}

.controls{
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.controls .row{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  flex-wrap: wrap;
}

.slider-row{
  margin-top: 10px;
  justify-content: space-between;
  gap: 12px;
}

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

button{
  appearance:none;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel2);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover{ transform: translateY(-1px); }
button:active{ transform: translateY(0px); }
button:disabled{ opacity: 0.45; cursor: not-allowed; }

button.primary{ padding: 10px 14px; }
button.pill{
  width: 54px;
  display:flex;
  align-items:center;
  justify-content:center;
}
button.ghost{ background: transparent; }

button:focus-visible,
input[type="range"]:focus-visible{
  outline: 2px solid rgba(255,255,255,0.6);
  outline-offset: 2px;
}

input[type="range"]{ width: min(520px, 100%); }

.footer{
  display:flex;
  justify-content:center;
  padding-bottom: 6px;
  text-align: center;
}

.footer a{
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.25);
}
.footer a:hover{
  border-bottom-color: rgba(255,255,255,0.6);
}

.dot{ margin: 0 8px; color: rgba(255,255,255,0.35); }

@media (max-width: 900px){
  .home-card{ grid-template-columns: 1fr; }
}

@media (max-width: 640px){
  .page-frame{ aspect-ratio: 3 / 4; }
}
