:root {
  --teal: #0a6a87;
  --teal-dark: #085a73;
  --teal-light: #3f8ea6;
  --ink: #1d1d1f;
  --muted: #5d6670;
  --bg: #eef0f1;
  --line: #d9dde0;
  --accent: #36b6ea;
  --pink: #c8104e;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: inherit; }
button { font: inherit; cursor: pointer; }

/* No selecting, dragging or printing of the course material. */
.protected, .protected * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
canvas { -webkit-user-drag: none; }
@media print { body { display: none !important; } }
body.hidden .page canvas { filter: blur(18px); }

/* ---------- top bar ---------- */
.topbar {
  height: 56px; background: var(--teal); color: #fff;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-size: 18px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title b { font-weight: 700; }
.topbar a, .topbar button { color: #fff; background: none; border: 0; text-decoration: none; font-size: 14px; padding: 8px; }
.topbar .who { font-size: 14px; opacity: .85; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; }
.icon-btn:hover, .topbar a:hover, .topbar button:hover { background: rgba(255,255,255,.12); }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 32px 28px; box-shadow: 0 8px 30px rgba(0,0,0,.06);
}
.login h1 { font-size: 15px; letter-spacing: .12em; color: var(--teal); margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.login input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px;
}
.login input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login button {
  width: 100%; margin-top: 22px; padding: 12px; border: 0; border-radius: 6px;
  background: var(--teal); color: #fff; font-weight: 600; font-size: 15px;
}
.login button:hover { background: var(--teal-dark); }
.login button:disabled { opacity: .6; cursor: wait; }
.login .error { color: var(--pink); font-size: 14px; min-height: 20px; margin-top: 12px; }

/* ---------- dashboard ---------- */
.dash {
  max-width: 1040px; margin: 32px auto; padding: 32px; background: #f4f4f4; border: 1px solid var(--line);
  border-radius: 6px; display: grid; grid-template-columns: 1fr 260px 300px; gap: 40px; align-items: start;
}
.intro h2 { font-size: 15px; letter-spacing: .02em; margin: 6px 0 16px; }
.intro p { font-size: 14px; line-height: 1.6; color: #3a3f44; margin: 0 0 12px; }
.intro ul { font-size: 14px; line-height: 1.6; color: #3a3f44; padding-left: 18px; margin: 0 0 12px; }

.cover {
  display: block; aspect-ratio: 240 / 370; border: 6px solid var(--accent); text-decoration: none;
  position: relative; overflow: hidden; background: #4e7ea8; transition: transform .15s ease, box-shadow .15s ease;
}
.cover:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.15); }
.cover svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover .t { position: absolute; left: 20px; right: 16px; top: 44px; color: #fff; font-weight: 700; font-size: 17px; line-height: 1.25; }
.cover .tag { display: inline-block; margin-top: 10px; background: #fff; color: #2f5f86; font-size: 12px; font-weight: 700; padding: 4px 10px; letter-spacing: .04em; }
.cover .cta { position: absolute; left: 0; right: 0; top: 58%; text-align: center; color: #fff; font-size: 15px; }

.tools { display: grid; gap: 22px; }
.card {
  display: block; background: #fff; border: 1px solid var(--line); padding: 16px; text-align: center;
  text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.card h3 { font-size: 13px; letter-spacing: .02em; margin: 0 0 4px; text-transform: uppercase; }
.card em { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.old { display: grid; grid-template-columns: 1fr 120px; gap: 16px; align-items: center; text-decoration: none; }
.old span { font-size: 13px; line-height: 1.5; }
.old .thumb { background: #fff; border: 1px solid var(--line); padding: 8px; }
.old .thumb b { display: block; color: #2f5f86; font-size: 10px; margin-top: 6px; line-height: 1.3; }
.old:hover .thumb { border-color: var(--accent); }

@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; margin: 0; border: 0; border-radius: 0; padding: 24px 18px; gap: 28px; }
  .cover { max-width: 260px; margin: 0 auto; width: 100%; }
}

/* ---------- reader ---------- */
.reader { display: flex; height: calc(100% - 56px); }
.toc {
  width: 240px; flex: none; background: var(--teal); color: #fff; overflow-y: auto; overflow-x: hidden; padding: 8px 0;
}
.toc a {
  display: block; padding: 9px 16px; font-size: 13px; font-weight: 600; text-decoration: none; position: relative;
}
.toc a:hover { background: rgba(255,255,255,.08); }
.toc a.active { background: var(--teal-light); }
.toc a.active::after {
  content: ""; position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  border: 9px solid transparent; border-right-color: #fff;
}
.pages { flex: 1; overflow-y: auto; background: #fff; padding: 24px 16px 80px; position: relative; }
.page { max-width: 860px; margin: 0 auto 18px; aspect-ratio: 210 / 297; background: #f6f7f8; position: relative; box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.page canvas { width: 100%; height: 100%; display: block; }
.page .num { position: absolute; bottom: -16px; right: 0; font-size: 11px; color: var(--muted); }
.page.error::before { content: attr(data-error); position: absolute; inset: 0; display: grid; place-items: center; color: var(--pink); font-size: 14px; padding: 20px; text-align: center; }
.to-top {
  position: fixed; right: 26px; bottom: 26px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: var(--pink); color: #fff; display: none; place-items: center; box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.to-top.show { display: grid; }

@media (max-width: 760px) {
  .toc { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 9; transform: translateX(-100%); transition: transform .2s ease; }
  .reader.toc-open .toc { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.25); }
  .pages { padding: 12px 8px 80px; }
}
@media (min-width: 761px) {
  .reader.toc-closed .toc { display: none; }
}
