/* DrTory Comic Reader — v1.0 (single-folder widget)
   Works as standalone page OR inside iframe.
*/
:root{
  --bg:#0b1220;
  --card:#0f1b33;
  --card2:#111a2b;
  --text:#eef2ff;
  --muted:rgba(238,242,255,.72);
  --line:rgba(255,255,255,.12);
  --btn:rgba(255,255,255,.08);
  --btn2:rgba(255,255,255,.14);
  --accent:#7dd3fc;
  --accent2:#a78bfa;
  --shadow: 0 16px 50px rgba(0,0,0,.45);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(167,139,250,.25), transparent 55%),
    radial-gradient(900px 600px at 80% 20%, rgba(125,211,252,.20), transparent 55%),
    linear-gradient(180deg, #071022, #0b1220 55%, #050a14);
  color:var(--text);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

a{ color:var(--accent); text-decoration:none; }
a:hover{ text-decoration:underline; }

.drtComic{
  max-width: 1280px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.drtTop{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border:1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.03));
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.drtBrand{ display:flex; gap:10px; align-items:center; }
.drtLogo{
  width:40px;height:40px;border-radius:14px;
  display:grid;place-items:center;
  background: linear-gradient(135deg, rgba(125,211,252,.28), rgba(167,139,250,.24));
  border:1px solid var(--line);
}
.drtTitle{ font-weight:800; letter-spacing:.2px; font-size: 16px; }
.drtSub{ color:var(--muted); font-size: 12px; }

.drtControls{ display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.btn{
  appearance:none; border:1px solid var(--line);
  background: var(--btn);
  color:var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  font-weight:700;
  font-size: 13px;
  cursor:pointer;
}
.btn:hover{ background: var(--btn2); }
.btn:active{ transform: translateY(1px); }
.btnPrimary{
  background: linear-gradient(135deg, rgba(125,211,252,.35), rgba(167,139,250,.32));
}

.select{
  width:100%;
  border:1px solid var(--line);
  background: rgba(0,0,0,.25);
  color:var(--text);
  padding: 10px 10px;
  border-radius: 12px;
  font-weight:700;
}

.drtMain{
  display:grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
  margin-top: 12px;
}

.drtPanel{
  border:1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.04);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.drtPanelHead{
  padding: 12px 12px 10px;
  border-bottom:1px solid var(--line);
  background: rgba(0,0,0,.18);
}
.drtPanelTitle{ font-weight:800; font-size: 13px; margin-bottom: 8px; color: var(--muted); }

.thumbs{
  padding: 10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: calc(100dvh - 190px);
  overflow:auto;
}
.thumb{
  border:1px solid var(--line);
  border-radius: 14px;
  overflow:hidden;
  background: rgba(0,0,0,.22);
  cursor:pointer;
  position:relative;
}
.thumb img{ display:block; width:100%; height: 120px; object-fit: cover; }
.thumb .cap{
  position:absolute; left:8px; bottom:8px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight:800;
  background: rgba(0,0,0,.55);
  border:1px solid rgba(255,255,255,.14);
}
.thumb.isActive{ outline: 2px solid rgba(125,211,252,.75); }

.drtViewer{
  border:1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.03);
  box-shadow: var(--shadow);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height: 60dvh;
}

.stageWrap{
  flex:1;
  background:
    radial-gradient(900px 600px at 70% 10%, rgba(255,255,255,.07), transparent 55%),
    linear-gradient(180deg, rgba(0,0,0,.24), rgba(0,0,0,.12));
  position:relative;
}
.stage{
  width:100%;
  height:100%;
  display:grid;
  place-items:center;
  padding: 10px;
}
.stage img{
  max-width: 100%;
  max-height: calc(100dvh - 240px);
  border-radius: 14px;
  box-shadow: 0 14px 50px rgba(0,0,0,.50);
  transform-origin: center center;
  cursor: zoom-in;
  user-select:none;
}

.drtMeta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 12px 14px;
  border-top:1px solid var(--line);
  background: rgba(0,0,0,.18);
}
.pageTitle{ font-weight:900; font-size: 14px; }
.pageCount{ color:var(--muted); font-size: 12px; margin-top: 2px; }
.rawLink{ font-weight:800; font-size: 13px; }

.drtFoot{
  margin-top: 12px;
  padding: 10px 14px;
  border:1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.hideUI .drtTop,
.hideUI .drtLeft,
.hideUI .drtFoot{ display:none; }
.hideUI .drtMain{ grid-template-columns: 1fr; margin-top: 0; }
.hideUI .drtViewer{ min-height: calc(100dvh - 24px); }
.hideUI .stage img{ cursor: zoom-out; max-height: calc(100dvh - 54px); }

@media (max-width: 980px){
  .drtMain{ grid-template-columns: 1fr; }
  .thumbs{ grid-template-columns: 1fr 1fr 1fr; max-height: none; }
  .stage img{ max-height: calc(100dvh - 300px); }
}
@media (max-width: 640px){
  .thumbs{ grid-template-columns: 1fr 1fr; }
  .btn{ padding: 9px 10px; }
}
