:root {
  --blue: #4078BD; --blue-dark: #2B5384; --blue-light: #8FB4DB; --navy: #16273F; --navy-mid: #213F66;
  --ice: #CFE0F2; --cloud: #F1F6FC; --hairline: #D6E2F0; --ink: #1B2735; --slate: #475569; --grey: #6B7280;
  --bg: #FFFFFF; --text: var(--ink); --muted: var(--slate); --card: var(--cloud); --line: var(--hairline);
  --warn: #9A4B00;
  --head: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --body: Calibri, 'Segoe UI', system-ui, Arial, sans-serif;
  color-scheme: light;
}
body[data-theme="sepia"] { --bg: #F6EFE2; --card: #EFE5D2; --line: #DDCFB6; --text: #3B2F22; --muted: #6A5A45; }
body[data-theme="dark"] { --bg: #0F1C2E; --card: #16273F; --line: #213F66; --text: #E6EEF8; --muted: #A9BCD3; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); line-height: 1.25; }
a { color: var(--blue); }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 2px; }
.hx-muted { color: var(--muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Printing is blocked on every page of the app. */
@media print { html, body { display: none !important; } }

/* Top bar */
.hx-bar { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--navy); color: #fff; }
.hx-bar a, .hx-bar button { color: #fff; }
.hx-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.hx-brand img { height: 26px; width: auto; display: block; }
.hx-sep { width: 1px; height: 22px; background: var(--navy-mid); }
.hx-bar .hx-title { font-family: var(--head); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.hx-bar .hx-tools { display: flex; align-items: center; gap: 4px; }
.hx-icon-btn { min-width: 40px; height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-weight: 600; }
.hx-icon-btn:hover { background: var(--navy-mid); }
.hx-icon-btn[aria-pressed="true"] { border-color: var(--blue-light); }
.hx-swatch { width: 18px; height: 18px; border-radius: 50%; display: inline-block; border: 1px solid var(--blue-light); vertical-align: middle; }
.hx-link-btn { background: none; border: 0; color: var(--ice); cursor: pointer; text-decoration: underline; padding: 8px; }

/* Login */
.hx-login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--navy); }
.hx-login-card { width: 100%; max-width: 420px; background: #fff; color: var(--ink); border-radius: 14px; padding: 32px 28px; }
.hx-login-card img { height: 34px; margin-bottom: 20px; }
.hx-login-card h1 { font-size: 24px; margin: 0 0 8px; color: var(--navy); }
.hx-login-card p { margin: 0 0 20px; color: var(--slate); }
.hx-login-card label { display: block; font-weight: 600; margin-bottom: 6px; }
.hx-login-card input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: 8px; font: inherit; }
.hx-primary { margin-top: 14px; width: 100%; height: 46px; border: 0; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 700; cursor: pointer; }
.hx-primary:hover { background: var(--blue-dark); }
.hx-primary:disabled { opacity: .6; cursor: wait; }
#status { margin-top: 16px; min-height: 1.5em; color: var(--slate); }

/* Library */
.hx-page { max-width: 1080px; margin: 0 auto; padding: 28px 16px 64px; }
.hx-page h1 { font-size: 26px; margin: 0 0 4px; color: var(--navy); }
.hx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; margin-top: 24px; }
.hx-book { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); background: var(--cloud); border: 1px solid var(--hairline); border-radius: 12px; overflow: hidden; transition: border-color .15s; }
.hx-book:hover { border-color: var(--blue); }
.hx-cover { aspect-ratio: 2 / 3; background: var(--navy); overflow: hidden; }
.hx-cover img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.hx-book-meta { padding: 12px 14px 16px; }
.hx-book-meta h2 { font-size: 16px; margin: 8px 0 4px; }
.hx-book-meta p { margin: 0; font-size: 14px; }
.hx-chip { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: #fff; background: var(--blue); border-radius: 999px; padding: 2px 10px; }
.hx-expiry { margin-top: 8px !important; color: var(--slate); }
.hx-expiry.soon { color: var(--warn); font-weight: 600; }
.hx-notice { background: #FFF6E5; border: 1px solid #F0D29A; color: #6B3D00; padding: 10px 14px; border-radius: 8px; }
.hx-empty { text-align: center; padding: 48px 16px; color: var(--muted); max-width: 520px; margin: 0 auto; }
.hx-empty h2 { color: var(--text); }

/* Reader */
.hx-reader-page { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; overflow: hidden; }
#stage { position: relative; overflow: hidden; background: var(--bg); }
#reader { position: absolute; inset: 0; }
#reader iframe { border: 0; }
.readium-navigator-iframe { width: 100%; height: 100%; inset: 0; border: 0; margin: 0; }
.hx-watermark { position: absolute; inset: 0; pointer-events: none; z-index: 5; background-repeat: repeat; }
body[data-theme="dark"] .hx-watermark { filter: invert(1); }
.hx-pdf { position: absolute; inset: 0; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 16px; }
.hx-pdf canvas { background: #fff; box-shadow: 0 1px 4px rgba(22, 39, 63, .18); }
.hx-foot { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--bg); font-size: 14px; }
.hx-foot .hx-nav-btn { min-width: 44px; height: 40px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; cursor: pointer; font-weight: 700; }
.hx-foot .hx-nav-btn:hover { border-color: var(--blue); }
.hx-progress { flex: 1; min-width: 0; }
.hx-progress-track { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 4px; }
#progress-bar { height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.hx-progress-text { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
#chapter-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#expiry { color: var(--muted); white-space: nowrap; }

#toc { position: absolute; top: 0; left: 0; bottom: 0; width: min(360px, 90vw); z-index: 20; background: var(--bg); border-right: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: 4px 0 18px rgba(22, 39, 63, .15); }
#toc[hidden] { display: none; }
.hx-toc-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.hx-toc-head h2 { font-size: 16px; margin: 0; }
.hx-toc-head button { background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; width: 40px; height: 40px; }
#toc-list { overflow: auto; padding: 8px 0 24px; }
#toc-list ol { list-style: none; margin: 0; padding: 0; }
#toc-list a, #toc-list span { display: block; padding: 8px 16px 8px 12px; color: var(--text); text-decoration: none; }
#toc-list a:hover { background: var(--card); color: var(--blue); }
.hx-jump { display: flex; align-items: center; gap: 8px; padding: 8px 16px 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.hx-jump input { width: 90px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.hx-jump button { height: 36px; padding: 0 14px; border: 0; background: var(--blue); color: #fff; border-radius: 6px; cursor: pointer; }

/* Blur when the window loses focus or a screenshot key is pressed. */
body.hx-shield #stage { filter: blur(18px); }
body.hx-shield::after { content: 'Reading paused. Click the page to continue.'; position: fixed; left: 0; right: 0; top: 56px; bottom: 58px; display: grid; place-items: center; z-index: 30; font: 600 18px var(--head); color: var(--text); pointer-events: none; }

.hx-toast { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
.hx-toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  .hx-bar { gap: 6px; padding: 0 8px; }
  .hx-sep, .hx-brand img.wide { display: none; }
  .hx-hide-sm { display: none !important; }
  #expiry { display: none; }
}

/* Access codes */
.hx-alt { margin: 18px 0 0 !important; font-size: 14px; }
.hx-hint { font-size: 13px; margin: 6px 0 0 !important; }
.hx-code-input { font-family: Consolas, 'Courier New', monospace; letter-spacing: .08em; text-transform: uppercase; }
.hx-success { background: #EAF4EC; border: 1px solid #BFDCC5; color: #1D4D2A; padding: 10px 14px; border-radius: 8px; }
.hx-error { background: #FDECEC; border: 1px solid #F2C2C2; color: #7A1D1D; padding: 10px 14px; border-radius: 8px; }
.hx-batch { background: var(--cloud); border: 1px solid var(--hairline); border-radius: 12px; padding: 18px 18px 14px; margin-top: 18px; }
.hx-batch-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.hx-batch h2 { font-size: 18px; margin: 0 0 4px; color: var(--navy); }
.hx-batch p { margin: 0 0 2px; font-size: 14px; }
.hx-batch-count { font-family: var(--head); color: var(--slate); white-space: nowrap; }
.hx-batch-count span { font-size: 26px; font-weight: 700; color: var(--navy); }
.hx-meter { height: 6px; background: var(--hairline); border-radius: 3px; overflow: hidden; margin: 12px 0; }
.hx-meter div { height: 100%; background: var(--blue); }
.hx-batch-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hx-secondary { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid var(--blue); border-radius: 8px; background: #fff; color: var(--blue-dark); font-weight: 600; text-decoration: none; cursor: pointer; font-size: 14px; }
.hx-secondary:hover { background: var(--ice); }
.hx-codes { margin-top: 14px; }
.hx-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--hairline); border-radius: 8px; }
.hx-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hx-table th { background: var(--navy); color: #fff; font-family: var(--head); font-weight: 600; font-size: 13px; text-align: left; padding: 8px 10px; white-space: nowrap; }
.hx-table td { padding: 8px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.hx-table tbody tr:nth-child(even) td { background: var(--cloud); }
.hx-code { font-family: Consolas, 'Courier New', monospace; letter-spacing: .04em; }
.hx-status { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; background: var(--hairline); color: var(--slate); }
.hx-status.s-in-use { background: #DCEBFA; color: var(--blue-dark); }
.hx-status.s-unused { background: #EAF4EC; color: #1D4D2A; }
.hx-status.s-cancelled, .hx-status.s-expired-unused, .hx-status.s-access-ended-early { background: #FDECEC; color: #7A1D1D; }

/* Sign-in options and the Account page */
.hx-textbtn { background: none; border: 0; color: var(--blue-dark); text-decoration: underline; cursor: pointer; padding: 10px 0 0; font: inherit; font-size: 14px; }
.hx-row-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hx-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--slate); font-size: 13px; }
.hx-or::before, .hx-or::after { content: ''; flex: 1; height: 1px; background: var(--hairline); }
.hx-secondary-full { width: 100%; height: 46px; border: 1px solid var(--blue); border-radius: 8px; background: #fff; color: var(--blue-dark); font-weight: 700; cursor: pointer; }
.hx-secondary-full:hover { background: var(--cloud); }
.hx-sent { background: var(--cloud); border: 1px solid var(--hairline); border-radius: 8px; padding: 10px 12px; color: var(--ink) !important; }
.hx-otp { font-size: 24px !important; letter-spacing: .35em; text-align: center; height: 52px !important; }
.hx-narrow { max-width: 760px; }
.hx-panel { background: #fff; border: 1px solid var(--hairline); border-radius: 12px; padding: 18px 20px; margin-top: 18px; }
.hx-panel h2 { font-size: 18px; margin: 0 0 8px; color: var(--navy); }
.hx-panel h3 { font-size: 15px; margin: 0 0 2px; color: var(--navy); }
.hx-panel p { margin: 0; font-size: 14px; }
.hx-panel form { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-width: 360px; }
.hx-panel label { font-weight: 600; font-size: 14px; }
.hx-panel input { height: 42px; padding: 0 12px; border: 1px solid var(--hairline); border-radius: 8px; font: inherit; }
.hx-method { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.hx-method:first-of-type { border-top: 0; }
.hx-method-actions { display: flex; gap: 14px; align-items: center; }
.hx-btn { min-height: 40px; padding: 0 14px; border: 1px solid var(--blue); border-radius: 8px; background: #fff; color: var(--blue-dark); font-weight: 700; cursor: pointer; font: inherit; font-weight: 700; font-size: 14px; }
.hx-btn:hover { background: var(--cloud); }
.hx-btn.primary { background: var(--blue); color: #fff; }
.hx-btn:disabled { opacity: .6; cursor: wait; }
.hx-subform { padding: 4px 0 14px; }
.hx-list { list-style: none; margin: 0; padding: 0; }
.hx-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: var(--cloud); border: 1px solid var(--hairline); border-radius: 8px; margin-top: 8px; font-size: 14px; flex-wrap: wrap; }
.hx-list li .hx-chip { margin-left: 8px; }
.hx-list li > div > .hx-muted { display: block; margin-top: 2px; }
.hx-page [hidden], .hx-login [hidden] { display: none !important; }
