:root{
  --bg:#0b0f15;
  --panel:#0f1722;
  --panel2:#0c131d;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --muted2:#6b7280;
  --border:rgba(255,255,255,0.08);
  --accent:#60a5fa;
  --accent2:#a78bfa;
  --shadow:0 10px 30px rgba(0,0,0,.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:linear-gradient(180deg, var(--bg), #070a0f 60%);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

#app{
  height:100%;
  display:flex;
}

#sidebar{
  width:360px;
  min-width:300px;
  max-width:440px;
  background:linear-gradient(180deg, var(--panel), var(--panel2));
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
}

#brand{
  padding:18px 18px 10px 18px;
  border-bottom:1px solid var(--border);
}
.brand-title{
  font-size:18px;
  font-weight:700;
  letter-spacing:.2px;
}
.brand-subtitle{
  margin-top:6px;
  font-size:12px;
  color:var(--muted);
}

#sidebar-controls{
  padding:12px 18px 12px 18px;
  border-bottom:1px solid var(--border);
}
#search{
  width:100%;
  padding:10px 10px;
  border-radius:10px;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.10);
  color:var(--text);
  outline:none;
}
#search:focus{
  border-color:rgba(96,165,250,0.55);
  box-shadow:0 0 0 3px rgba(96,165,250,0.18);
}

.row{display:flex; gap:10px; margin-top:10px}

.btn{
  cursor:pointer;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.06);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  font-weight:600;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  transition:transform .05s ease, background .12s ease, border-color .12s ease;
}
.btn:hover{ background:rgba(255,255,255,0.09); border-color:rgba(255,255,255,0.18); }
.btn:active{ transform:translateY(1px); }
.btn.small{ padding:8px 10px; font-size:12px; border-radius:10px; }
.btn.ghost{ background:transparent; }

#nav{
  padding:8px 10px 10px 10px;
  overflow:auto;
  flex:1;
}

.module{
  border:1px solid rgba(255,255,255,0.08);
  border-radius:14px;
  margin:10px;
  overflow:hidden;
  box-shadow:0 1px 0 rgba(255,255,255,0.03);
}
.module-header{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px;
  background:rgba(255,255,255,0.05);
  border:0;
  color:var(--text);
  cursor:pointer;
  font-weight:800;
  letter-spacing:.1px;
}
.module-header .count{
  font-weight:700;
  font-size:12px;
  color:var(--muted);
}
.module-pages{
  padding:8px 8px 10px 8px;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.page-link{
  text-align:left;
  width:100%;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(0,0,0,0.15);
  padding:10px 10px;
  border-radius:12px;
  color:var(--text);
  cursor:pointer;
  font-weight:650;
}
.page-link:hover{
  border-color:rgba(96,165,250,0.40);
  box-shadow:0 0 0 2px rgba(96,165,250,0.12);
}
.page-link .meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:4px;
}
.page-link .label{
  font-size:12px;
  color:var(--muted);
  font-weight:700;
}
.page-link .title{
  font-size:13px;
  line-height:1.25;
}
.page-link.active{
  border-color:rgba(167,139,250,0.55);
  box-shadow:0 0 0 3px rgba(167,139,250,0.16);
}

#sidebar-footer{
  padding:12px 18px 16px 18px;
  border-top:1px solid var(--border);
  color:var(--muted);
  font-size:12px;
}
.hint{margin-top:6px}
kbd{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:11px;
  border:1px solid rgba(255,255,255,0.14);
  padding:2px 6px;
  border-radius:8px;
  background:rgba(255,255,255,0.06);
  color:var(--text);
}

#main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}

#topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  background:rgba(0,0,0,0.10);
}

.crumbs{display:flex; flex-direction:column; min-width:0}
.crumb-module{
  font-size:12px;
  color:var(--muted);
  font-weight:800;
}
.crumb-title{
  font-size:16px;
  font-weight:900;
  letter-spacing:.2px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width:72vw;
}

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

#viewerWrap{
  position:relative;
  flex:1;
  min-height:0;
  padding:10px;
}
#viewer{
  width:100%;
  height:100%;
  border:1px solid rgba(255,255,255,0.10);
  border-radius:18px;
  background:white;
  box-shadow:var(--shadow);
}

#statusbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 16px;
  border-top:1px solid var(--border);
  color:var(--muted);
  font-size:12px;
}

@media (max-width: 980px){
  #sidebar{ width:320px; }
}
@media (max-width: 820px){
  #sidebar{ display:none; }
  #viewerWrap{ padding:0; }
  #viewer{ border-radius:0; border-left:0; border-right:0; }
  .crumb-title{ max-width:92vw; }
}


/* Role bar */
#roleBar{
  border:1px solid var(--border);
  background:rgba(255,255,255,0.03);
  border-radius:14px;
  padding:10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  margin-bottom:10px;
}
#roleBar .row{ gap:8px; }
#roleBar .field{ flex:1; min-width:0; }
#roleBar label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}
#roleBar select{
  width:100%;
  background:rgba(255,255,255,0.03);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 12px;
  outline:none;
}
#roleBar select:focus{
  border-color:rgba(96,165,250,0.7);
  box-shadow:0 0 0 3px rgba(96,165,250,0.15);
}

.module-header.static{
  cursor:default;
  pointer-events:none;
  opacity:0.95;
}

.btn.small{
  padding:8px 10px;
  border-radius:12px;
}


/* ------------------------------------------------------------
   2-screen demo helpers
   ------------------------------------------------------------ */
body.mode-viewer #sidebar,
body.mode-viewer #topbar,
body.mode-viewer #statusbar{
  display:none !important;
}
body.mode-viewer #viewerWrap{
  padding:0 !important;
}
body.mode-viewer #viewer{
  border:0 !important;
  border-radius:0 !important;
  box-shadow:none !important;
}
body.mode-viewer #main{
  flex:1;
}
