:root{
  --bg: #0b0f19;
  --panel: rgba(255,255,255,.04);
  --border: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --muted2: rgba(255,255,255,.45);

  --shadow: 0 12px 40px rgba(0,0,0,.40);
  --radius: 16px;

  --focus: 0 0 0 3px rgba(120,140,255,.25);
}

*{ box-sizing:border-box; }

/* Default: main list page behaves like an app (no body scroll) */
html, body{
  height: 100%;
  overflow: hidden;
}

/* Detail page: allow normal scrolling */
body[data-page="detail"]{
  overflow: auto;
}
body[data-page="detail"] html{
  overflow: auto;
}

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(120,140,255,.18), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, rgba(0,180,160,.12), transparent 55%),
    var(--bg);
  color: var(--text);
}

/* ---------- layout ---------- */

.wrap{
  max-width: 1120px;
  height: 100vh;
  margin: 0 auto;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Detail page: wrap can grow; allow scrolling */
body[data-page="detail"] .wrap{
  height: auto;
  min-height: 100vh;
}

.cardActions{
  margin-bottom: 12px;
}

.cardActions .btn{
  font-size: 15px;
  padding: 11px 14px;
}

.cardActions .btn.primary{
  background: linear-gradient(
    to bottom,
    rgba(120,140,255,.28),
    rgba(120,140,255,.16)
  );
}

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

.headLeft{
  display:flex;
  flex-direction: column;
  gap: 6px;
}

h1{
  margin:0;
  font-size: 28px;
  letter-spacing: -.02em;
}

.detailTitle{
  font-size: 26px;
  line-height: 1.15;
}

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

input[type="search"], select{
  appearance:none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

input[type="search"]{ width: min(360px, 52vw); }
input::placeholder{ color: var(--muted2); }

input:focus, select:focus{
  box-shadow: var(--focus);
  border-color: rgba(120,140,255,.35);
}

select{
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 55%,
    calc(100% - 11px) 55%;
  background-size: 6px 6px;
  background-repeat:no-repeat;
}

.status{
  font-size: 14px;
  color: var(--muted);
}

.backLink{
  color: var(--muted);
  text-decoration: none;
}
.backLink:hover{
  text-decoration: underline;
}

/* ---------- table container (list page) ---------- */
.tableWrap{
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto; /* this scrolls */
}

.tableWrap{
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.tableWrap::-webkit-scrollbar{ width: 10px; height: 10px; }
.tableWrap::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.20);
  border-radius: 10px;
}
.tableWrap::-webkit-scrollbar-thumb:hover{
  background: rgba(255,255,255,.28);
}

/* ---------- table ---------- */
table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

thead th{
  position: sticky;
  top: 0;
  z-index: 5;

  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .02em;
  color: rgba(255,255,255,.92);

  padding: 14px;
  /* less transparent, more solid */
  background: linear-gradient(to bottom, rgba(20,24,38,.96), rgba(15,19,33,.96));
  border-bottom: 1px solid rgba(255,255,255,.15);

  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(6px);
}

thead th.right{ text-align:right; }
thead th.asc::after{ content:"  ▲"; font-size: 12px; color: var(--muted); }
thead th.desc::after{ content:"  ▼"; font-size: 12px; color: var(--muted); }

tbody td{
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  vertical-align: middle;
}

tbody tr:hover{ background: rgba(255,255,255,.04); }

/* 5-column list table sizing (Title | Author | Published | Size | Type) */
#libTable th:nth-child(2), #libTable td:nth-child(2){ width: 220px; } /* Author */
#libTable th:nth-child(3), #libTable td:nth-child(3){ width: 90px;  } /* Published */
#libTable th:nth-child(4), #libTable td:nth-child(4){ width: 110px; } /* Size */
#libTable th:nth-child(5), #libTable td:nth-child(5){ width: 70px;  } /* Type */

#libTable th:nth-child(n+3), #libTable td:nth-child(n+3){
  padding-left: 10px;
  padding-right: 10px;
  white-space: nowrap;
}

#libTable th:nth-child(4), #libTable td:nth-child(4){
  text-align: right;
}

/* ---------- title cell ---------- */

.titleCell{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: 0;
}

.cover,
.cover.placeholder{
  width: 44px;
  height: 66px;
  flex: 0 0 44px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  box-shadow: 0 6px 16px rgba(0,0,0,.35);
}

.cover.placeholder{
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.03));
}

.titleLink{
  color: inherit;
  text-decoration: none;
  min-width: 0;
  display: block;
}
.titleLink:hover .titleText{
  text-decoration: underline;
}

.titleText{
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.01em;
  white-space: normal;
  min-width: 0;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hint{
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: none;
  margin-left: 6px;
}

/* ---------- misc ---------- */

.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
}

a.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(120,140,255,.35);
  background: linear-gradient(to bottom, rgba(120,140,255,.22), rgba(120,140,255,.12));
  color: var(--text);
  font-weight: 650;
  text-decoration:none;
  white-space: nowrap;
}
a.btn:hover{ filter: brightness(1.08); }
a.btn:active{ transform: translateY(1px); }

/* ---------- detail page card ---------- */

.detailCard{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.detailGrid{
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: start;
}

.bigCover{
  width: 140px;
  height: 210px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  box-shadow: 0 10px 22px rgba(0,0,0,.35);
}

.bigCover.placeholder{
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.03));
}

.detailMetaLine{
  color: var(--muted);
  margin: 2px 0 8px;
}

.kvs{
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.kv{
  display:flex;
  gap: 10px;
}
.kv b{
  width: 110px;
  color: var(--muted);
  font-weight: 650;
}

.desc{
  margin-top: 14px;
  color: var(--text);
  line-height: 1.55;
}

.desc p{ margin: 0 0 10px; }
.desc ul, .desc ol{ margin: 0 0 10px 20px; }
.desc blockquote{
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(120,140,255,.35);
  background: rgba(255,255,255,.04);
  border-radius: 10px;
}
.desc a{
  color: rgba(120,140,255,.95);
  text-decoration: none;
}
.desc a:hover{ text-decoration: underline; }
.desc code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95em;
}

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

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

a.btn.primary{
  font-size: 15px;
  padding: 11px 14px;
}

/* ---------- mobile ---------- */
@media (max-width: 740px){
  .top{
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .controls{
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  input[type="search"]{ width: 100%; }

  /* List page: keep Author, hide Published/Size/Type */
  #libTable th:nth-child(3), #libTable td:nth-child(3),
  #libTable th:nth-child(4), #libTable td:nth-child(4),
  #libTable th:nth-child(5), #libTable td:nth-child(5){
    display: none;
  }

  #libTable th:nth-child(2), #libTable td:nth-child(2){
    width: auto;
    white-space: normal;
  }

  .cover, .cover.placeholder{
    width: 38px;
    height: 56px;
    flex: 0 0 38px;
    border-radius: 7px;
  }

  .titleText{
    -webkit-line-clamp: 4;
  }

  /* Detail page */
  .detailGrid{
    grid-template-columns: 92px 1fr;
  }
  .bigCover{
    width: 92px;
    height: 138px;
    border-radius: 10px;
  }
  .kv b{ width: 92px; }
}
