
:root {
  color-scheme: dark;
  --bg: #050812;
  --panel: #151823;
  --panel-2: #10131d;
  --text: #f4f7ff;
  --muted: #aeb6d3;
  --line: rgba(154, 169, 230, .28);
  --accent: #8ea2ff;
  --accent-2: #b6c3ff;
  --warning: #ffd56a;
  --shadow: 0 24px 80px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overflow-x: hidden; }
a { color: inherit; }
.portal-shell { min-height: 100vh; background: radial-gradient(circle at top left, rgba(86, 101, 190, .28), transparent 38rem), linear-gradient(90deg, rgba(24, 30, 70, .85), transparent 18rem), var(--bg); }
.wrap { width: min(1180px, calc(100vw - 40px)); margin: 0 auto; }
.topbar { padding: 28px 0 16px; display:flex; gap:16px; align-items:center; justify-content:space-between; }
.back { text-decoration:none; color: var(--muted); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.back:hover { color: var(--text); }
.badge { display:inline-flex; align-items:center; gap:8px; width:max-content; padding: 7px 12px; border-radius:999px; background: rgba(142,162,255,.15); border:1px solid var(--line); color:var(--accent-2); font-size:12px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.hero { display:grid; grid-template-columns: 210px minmax(0,1fr); gap:28px; align-items:end; padding: 24px 0 28px; }
.cover { width:210px; aspect-ratio: 408 / 504; border-radius:22px; object-fit:cover; box-shadow: var(--shadow); border:1px solid var(--line); background:#111; }
h1 { font-size: clamp(36px, 5vw, 72px); line-height:.92; letter-spacing:-.06em; margin:14px 0 14px; }
.sub { max-width: 780px; color:var(--muted); font-size:18px; line-height:1.55; margin:0; }
.actions { display:flex; flex-wrap:wrap; gap:12px; margin-top:22px; }
.btn { appearance:none; border:1px solid var(--line); background: rgba(255,255,255,.06); color:var(--text); border-radius:14px; padding:12px 16px; font-weight:800; text-decoration:none; cursor:pointer; }
.btn.primary { background: var(--text); color:#070a14; border-color: var(--text); }
.btn:hover { transform: translateY(-1px); }
.meta-grid { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:14px; margin: 0 0 20px; }
.meta-card { background: rgba(18, 22, 34, .82); border:1px solid var(--line); border-radius:20px; padding:14px 16px; }
.meta-card strong { display:block; font-size:13px; color:var(--accent-2); text-transform:uppercase; letter-spacing:.08em; margin-bottom:5px; }
.meta-card span { color:var(--text); font-size:15px; }
.viewer-frame { border:1px solid var(--line); border-radius:24px; overflow:hidden; background:#0e111b; box-shadow: var(--shadow); margin-bottom:36px; }
.viewer-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 14px; background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); border-bottom:1px solid var(--line); }
.viewer-head .title { font-weight:900; letter-spacing:-.02em; }
.viewer-head .hint { color:var(--muted); font-size:13px; }
.pdf-embed { display:block; width:100%; height: calc(100vh - 265px); min-height: 620px; max-height: 1100px; border:0; background:#242733; }
.fallback { padding:18px; color:var(--muted); }
.note { margin:0 0 42px; color:var(--muted); font-size:13px; line-height:1.55; }
.install { background: rgba(18, 22, 34, .78); border:1px solid var(--line); border-radius:22px; padding:20px; margin: 24px 0 44px; }
.install h2 { margin:0 0 10px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
pre { overflow:auto; padding:14px; border-radius:14px; background:#090c15; color:#e9edff; border:1px solid var(--line); }
@media (max-width: 760px) {
  .wrap { width: min(100vw - 24px, 1180px); }
  .hero { grid-template-columns: 1fr; align-items:start; gap:18px; }
  .cover { width: 155px; }
  .meta-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pdf-embed { height: calc(100vh - 220px); min-height: 520px; }
}
@media (max-width: 430px) {
  .meta-grid { grid-template-columns: 1fr; }
  .viewer-head { align-items:flex-start; flex-direction:column; }
}

/* Execute pass: static-safe browser PDF uploader and canvas viewer */
.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: stretch;
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(18, 22, 34, .82);
  box-shadow: 0 18px 55px rgba(0,0,0,.25);
}
.upload-panel h2 {
  margin: 12px 0 8px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
  letter-spacing: -.04em;
}
.upload-panel p {
  margin: 0;
  max-width: 700px;
  color: var(--muted);
  line-height: 1.55;
}
.drop-zone {
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
  padding: 18px;
  border: 1px dashed rgba(182, 195, 255, .5);
  border-radius: 22px;
  background: rgba(142,162,255,.08);
  cursor: pointer;
}
.drop-zone.drag-over {
  border-color: var(--accent-2);
  background: rgba(142,162,255,.18);
}
.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
.drop-zone strong {
  color: var(--text);
}
.drop-zone small,
.page-control,
.zoom-readout {
  color: var(--muted);
  font-size: 13px;
}
.enhanced-viewer {
  overflow: hidden;
}
.pdf-control-head {
  align-items: flex-start;
}
.pdf-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 720px;
}
.btn.small {
  min-height: 36px;
  padding: 8px 11px;
  border-radius: 12px;
  font-size: 13px;
}
.btn.danger {
  border-color: rgba(255, 118, 118, .45);
  color: #ffd0d0;
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}
.page-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.page-control input {
  width: 64px;
  border: 0;
  border-radius: 8px;
  padding: 6px 7px;
  background: rgba(0,0,0,.28);
  color: var(--text);
  font: inherit;
}
.zoom-readout {
  min-width: 54px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
}
.canvas-stage {
  position: relative;
  min-height: 660px;
  overflow: auto;
  display: grid;
  place-items: start center;
  padding: 18px;
  background: #171a24;
}
#pdf-canvas {
  max-width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}
.viewer-message {
  position: absolute;
  inset: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(10,12,20,.78);
  padding: 20px;
}
.viewer-message.hidden {
  display: none;
}
.native-fallback {
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.025);
}
.native-fallback summary {
  cursor: pointer;
  padding: 13px 16px;
  color: var(--accent-2);
  font-weight: 900;
}
@media (max-width: 900px) {
  .upload-panel {
    grid-template-columns: 1fr;
  }
  .pdf-control-head {
    display: grid;
  }
  .pdf-controls {
    justify-content: flex-start;
  }
  .canvas-stage {
    min-height: 560px;
    padding: 10px;
  }
}
@media (max-width: 520px) {
  .pdf-controls > * {
    flex: 1 1 auto;
  }
  .page-control {
    flex-basis: 100%;
    justify-content: center;
  }
  .canvas-stage {
    min-height: 480px;
  }
}
