:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-2: #f0f3f7;
  --text: #182033;
  --muted: #667084;
  --dim: #98a2b3;
  --border: #dce2ea;
  --border-2: #c5ceda;
  --accent: #0b57d0;
  --accent-2: #0845a6;
  --danger: #c62828;
  --danger-bg: #fff0f0;
  --shadow: 0 18px 60px rgba(20, 34, 61, .12);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }
svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
a { color: inherit; text-decoration: none; }

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(330px, 410px) minmax(0, 1fr);
}

.sidebar {
  min-height: 100dvh;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand { font-size: 17px; font-weight: 750; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.upload {
  margin: 14px;
  padding: 12px;
  border: 1px dashed var(--border-2);
  border-radius: 8px;
  background: var(--panel-2);
  display: grid;
  gap: 10px;
}
.upload.drag { border-color: var(--accent); background: #eef5ff; }
.uploadButton {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}
.uploadButton:hover { background: var(--accent-2); }
.titleInput {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}
.titleInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 87, 208, .12); }
.hint { color: var(--muted); font-size: 12px; }

.listHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.list {
  flex: 1;
  overflow: auto;
  padding: 0 10px 14px;
}

.pdfItem {
  border: 1px solid transparent;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 7px;
  margin-bottom: 6px;
}
.pdfItem:hover { background: var(--panel-2); }
.pdfItem.active { border-color: #b7cdf4; background: #eef5ff; }

.itemMain {
  min-width: 0;
  border: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  background: transparent;
  color: inherit;
  text-align: left;
}
.fileIcon {
  width: 34px;
  height: 42px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #ffffff;
  border: 1px solid var(--border);
}
.itemText { min-width: 0; display: grid; gap: 2px; }
.itemText strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.itemText small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }

.itemActions { display: inline-flex; gap: 2px; }
.iconbtn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
}
.iconbtn:hover { color: var(--text); border-color: var(--border); background: #fff; }
.iconbtn.danger:hover { color: var(--danger); border-color: #f1b7b7; background: var(--danger-bg); }

.reader {
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #e9edf3;
}
.readerBar {
  height: 68px;
  flex: 0 0 auto;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--border);
}
.readerTitle { min-width: 0; display: grid; gap: 2px; }
.readerTitle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.readerTitle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.readerActions { display: inline-flex; gap: 8px; flex: 0 0 auto; }
.btn {
  height: 36px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.btn:hover { border-color: #9dadc0; background: #f9fafc; }
.pdfFrame { flex: 1; width: 100%; border: 0; background: #dfe4ec; }

.empty, .emptyReader {
  color: var(--muted);
  text-align: center;
}
.empty {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  margin: 4px;
}
.emptyReader {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 10px;
}
.emptyReader strong { color: var(--text); }
.emptyIcon {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--border);
}
.emptyIcon svg { width: 28px; height: 28px; }

.loginPage {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.loginBox {
  width: min(100%, 380px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.loginMark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef5ff;
  color: var(--accent);
  font-weight: 800;
}
.loginBox h1 { margin: 2px 0 0; font-size: 22px; }
.loginBox p { margin: 0 0 4px; color: var(--muted); }
.loginBox input {
  height: 42px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 0 11px;
  outline: none;
}
.loginBox input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(11, 87, 208, .12); }
.primary {
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 750;
}
.primary:hover { background: var(--accent-2); }
.error {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s, transform .16s;
  padding: 9px 12px;
  border-radius: 8px;
  color: #fff;
  background: rgba(24, 32, 51, .92);
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  z-index: 30;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { min-height: 48dvh; border-right: 0; border-bottom: 1px solid var(--border); }
  .list { max-height: 42dvh; }
  .reader { min-height: 52dvh; }
  .readerBar { height: auto; align-items: stretch; flex-direction: column; }
  .readerActions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn { min-width: 0; padding: 0 8px; }
  .btn span { overflow: hidden; text-overflow: ellipsis; }
  .pdfFrame { min-height: 56dvh; }
}

@media (max-width: 480px) {
  .topbar { height: 58px; }
  .upload { margin: 10px; }
  .pdfItem { grid-template-columns: 1fr; }
  .itemActions { justify-content: flex-end; }
  .readerActions { grid-template-columns: 1fr; }
}
