:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-soft: #f5f5f7;
  --surface-hover: #fafafa;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.13);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --red: #ff3b30;
  --mint: #00a88f;
  --navy: #1d1d1f;
  --hero-start: #f0f5ff;
  --hero-end: #fafafa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.09);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, 0.18);
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elevated: #0d0d0f;
  --surface: rgba(28, 28, 30, 0.78);
  --surface-solid: #1c1c1e;
  --surface-soft: #242426;
  --surface-hover: #2c2c2e;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --subtle: #8e8e93;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.18);
  --blue: #2997ff;
  --blue-hover: #46a6ff;
  --blue-soft: rgba(41, 151, 255, 0.14);
  --red: #ff453a;
  --mint: #63e6d2;
  --navy: #f5f5f7;
  --hero-start: #121820;
  --hero-end: #1c1c1e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 10px 30px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 20px 55px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 35px 100px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.28s ease, color 0.28s ease;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 42%, transparent);
  outline-offset: 3px;
}

/* Brand and theme control */
.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 40px;
  height: 40px;
  padding: 9px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--text);
  box-shadow: var(--shadow-sm);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 7px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
}

.brand-mark i {
  display: block;
  width: 3px;
  border-radius: 3px;
  background: var(--bg-elevated);
}

.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 14px; background: var(--blue); }
.brand-mark i:nth-child(3) { height: 20px; }

.brand b,
.brand small,
.auth-brand > span:last-child b,
.auth-brand > span:last-child small {
  display: block;
}

.brand b,
.auth-brand > span:last-child b {
  color: var(--text);
  font-size: 14px;
  line-height: 1.15;
  letter-spacing: -0.25px;
}

.brand small,
.auth-brand > span:last-child small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.theme-toggle {
  width: 52px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--line-strong);
  transform: scale(1.03);
}

.theme-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 0 7px;
  color: var(--subtle);
  font-size: 13px;
}

.theme-toggle-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="dark"] .theme-toggle-track::before {
  transform: translateX(20px);
}

.theme-toggle-track .sun-icon,
.theme-toggle-track .moon-icon {
  position: relative;
  z-index: 1;
  width: 14px;
  text-align: center;
  line-height: 1;
}

.theme-toggle-track .sun-icon { color: #f5a623; }
.theme-toggle-track .moon-icon { color: #6e6e73; }
:root[data-theme="dark"] .theme-toggle-track .moon-icon { color: #d7d7dc; }

/* Authentication */
.auth-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(320px, 0.86fr) minmax(520px, 1.14fr);
  min-height: 100vh;
  background: var(--bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.auth-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-decoration {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 100vh;
  background: #050505;
  color: #fff;
}

.auth-decoration::before {
  content: "";
  position: absolute;
  width: min(54vw, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, rgba(112, 181, 255, 0.88), rgba(0, 113, 227, 0.2) 39%, transparent 70%);
  filter: blur(1px);
  transform: translate(-8%, -3%);
}

.auth-decoration::after {
  content: "Читайте. Исследуйте. Развивайтесь.";
  position: absolute;
  left: clamp(32px, 5vw, 72px);
  right: 32px;
  bottom: 48px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  letter-spacing: 0.1px;
}

.auth-decoration i {
  position: absolute;
  z-index: 1;
  width: clamp(90px, 10vw, 150px);
  height: clamp(125px, 14vw, 210px);
  border-radius: 10px 24px 24px 10px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.auth-decoration i:nth-child(1) { transform: translate(-76%, 8%) rotate(-12deg); }
.auth-decoration i:nth-child(2) { transform: translate(2%, -9%) rotate(3deg); background: rgba(255, 255, 255, 0.19); }
.auth-decoration i:nth-child(3) { transform: translate(80%, 14%) rotate(13deg); }

.auth-decoration span {
  position: relative;
  z-index: 2;
  margin-top: 10px;
  font-size: clamp(17px, 1.8vw, 28px);
  font-weight: 700;
  letter-spacing: 0.23em;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.auth-panel {
  min-height: 100vh;
  padding: 34px clamp(38px, 7vw, 105px) 48px;
  overflow: auto;
  background: var(--bg-elevated);
}

.auth-panel > * {
  width: min(100%, 500px);
  margin-left: auto;
  margin-right: auto;
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(42px, 8vh, 82px);
}

.auth-intro > span,
.eyebrow,
.page-title > span,
.section-heading > div > span {
  color: var(--blue);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.auth-intro h1 {
  margin: 11px 0 14px;
  color: var(--text);
  font-size: clamp(40px, 5vw, 58px);
  line-height: 0.98;
  letter-spacing: -2.7px;
}

.auth-intro p {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 34px 0 25px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.auth-tabs button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.auth-tabs button.is-active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
}

.auth-form {
  display: none;
  animation: fade-up 0.28s ease;
}

.auth-form.is-active { display: block; }

.auth-form > label,
.profile-field label,
.form-row > label {
  display: block;
  margin-bottom: 16px;
}

.auth-form label > span:first-child,
.role-picker legend {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: 0;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-form input::placeholder { color: var(--subtle); }

.auth-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.password-field { position: relative; }
.password-field input { padding-right: 48px; }

.password-field button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}

.role-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.role-picker legend { grid-column: 1 / -1; }
.role-picker label { cursor: pointer; }
.role-picker input { position: absolute; opacity: 0; pointer-events: none; }

.role-picker label > span {
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: 1fr 1fr;
  column-gap: 11px;
  align-items: center;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-solid);
  transition: 0.2s ease;
}

.role-picker label > span i {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--blue-soft);
  color: var(--blue);
  font-style: normal;
  font-weight: 700;
}

.role-picker label > span b { align-self: end; font-size: 12px; }
.role-picker label > span small { align-self: start; margin-top: 2px; color: var(--muted); font-size: 9px; }

.role-picker input:checked + span {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 5%, var(--surface-solid));
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-note {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.form-error {
  min-height: 19px;
  margin: 4px 0 8px;
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
}

.auth-submit,
.primary-button {
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.auth-submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 52px;
  padding: 0 20px;
  font-size: 13px;
}

.auth-submit:hover,
.primary-button:hover { background: var(--blue-hover); }
.auth-submit:active,
.primary-button:active { transform: scale(0.985); }
.auth-submit b { font-size: 20px; font-weight: 400; }
.auth-submit:disabled { opacity: 0.55; cursor: wait; }

.auth-switch {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.auth-switch button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 600;
  cursor: pointer;
}

/* Application shell */
.app-shell {
  position: relative;
  width: min(100%, 1240px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}

.app-shell.is-locked { display: none; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 10px max(28px, env(safe-area-inset-right)) 10px max(28px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--text);
  color: var(--bg-elevated);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.avatar i {
  position: absolute;
  right: -1px;
  bottom: 0;
  width: 10px;
  height: 10px;
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
  background: #30d158;
}

main { padding: 0 0 132px; }

.page {
  display: none;
  padding: 0 34px 54px;
  animation: fade-up 0.3s ease;
}

.page.is-active { display: block; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

/* Home */
.hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 390px;
  margin: 28px 0 22px;
  padding: 58px 7%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(135deg, var(--hero-start), var(--hero-end));
}

.hero::before {
  content: "";
  position: absolute;
  top: -55%;
  right: -8%;
  width: 55%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--blue) 18%, transparent), transparent 68%);
}

.hero-copy {
  position: relative;
  z-index: 2;
  width: 58%;
}

.hero h1 {
  margin: 17px 0 16px;
  color: var(--text);
  font-size: clamp(48px, 6.4vw, 74px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -4.1px;
}

.hero h1 em {
  color: var(--blue);
  font-style: normal;
}

.hero p {
  max-width: 450px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.hero-illustration {
  position: absolute;
  right: 6%;
  bottom: 40px;
  width: 310px;
  height: 300px;
}

.orb { position: absolute; border-radius: 50%; filter: blur(1px); }
.orb-one { right: 0; bottom: 0; width: 245px; height: 245px; background: color-mix(in srgb, var(--blue) 20%, transparent); }
.orb-two { top: 6px; right: 112px; width: 145px; height: 145px; background: rgba(99, 230, 210, 0.15); }

.hero-book {
  position: absolute;
  right: 50px;
  bottom: 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  width: 146px;
  height: 202px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px 22px 22px 8px;
  background: linear-gradient(145deg, #fff, #dcecff);
  box-shadow: -15px 24px 42px rgba(0, 74, 150, 0.2);
  color: #1d1d1f;
  transform: rotate(7deg);
}

.hero-book::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 9px;
  width: 3px;
  background: rgba(0, 113, 227, 0.17);
}

.hero-book span {
  position: relative;
  width: 38px;
  height: 38px;
  border: 8px solid #0071e3;
  border-radius: 50%;
}

.hero-book span::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 16px;
  width: 10px;
  height: 22px;
  border-radius: 4px;
  background: #30c7b3;
}

.hero-book b { font-size: 12px; letter-spacing: 2px; }
.hero-book i { width: 65px; height: 4px; border-radius: 4px; background: #0071e3; }

.float-card {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.32);
  color: #1d1d1f;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.11);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

:root[data-theme="dark"] .float-card { background: rgba(255, 255, 255, 0.12); color: #fff; }
.float-a { top: 28px; right: 5px; transform: rotate(8deg); }
.float-b { top: 94px; left: 24px; font-size: 24px; transform: rotate(-10deg); }
.float-c { right: 182px; bottom: 17px; color: var(--mint); font-size: 10px; transform: rotate(4deg); }

.search-box {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 58px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.search-box svg {
  width: 21px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search-box input::placeholder { color: var(--subtle); }

.search-box kbd {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--subtle);
  font-family: inherit;
  font-size: 13px;
}

.section-block { margin-top: 45px; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 19px;
}

.section-heading h2 {
  margin: 5px 0 0;
  font-size: 28px;
  letter-spacing: -1.1px;
}

.section-heading button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.section-heading button b { margin-left: 4px; font-size: 17px; font-weight: 400; }

.subject-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.subject-card {
  min-height: 128px;
  padding: 17px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.subject-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.subject-card span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 17px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--subject-accent) 12%, var(--surface-solid));
  color: var(--subject-accent);
  font-size: 14px;
  font-weight: 700;
}

.subject-card b { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.subject-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

/* Catalog cards */
.book-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.book-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-5px);
}

.book-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 232px;
  padding: 26px 22px;
  overflow: hidden;
  border-radius: 0;
  background: linear-gradient(145deg, var(--accent), var(--accent2));
  color: #fff;
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 14px;
  width: 2px;
  background: rgba(255, 255, 255, 0.26);
}

.book-cover::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -42px;
  width: 150px;
  height: 150px;
  border: 30px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.book-cover small { font-size: 8px; font-weight: 700; letter-spacing: 1px; opacity: 0.82; }
.book-cover strong { max-width: 82%; margin: auto 0 6px; font-size: 23px; line-height: 1.04; letter-spacing: -0.8px; }
.book-cover b { font-size: 11px; font-weight: 500; opacity: 0.88; }

.book-cover.has-image {
  padding: 0;
  background: color-mix(in srgb, var(--surface-soft) 88%, var(--accent));
}

.book-cover.has-image::before,
.book-cover.has-image::after { display: none; }

.book-cover.has-image img {
  width: 100%;
  height: 100%;
  padding: 14px;
  object-fit: contain;
  filter: drop-shadow(0 9px 13px rgba(0, 0, 0, 0.16));
}

.book-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 19px 20px 20px;
}

.book-info .tag {
  color: var(--blue);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.book-info h3 {
  margin: 8px 30px 5px 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.23;
  letter-spacing: -0.45px;
}

.book-info p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.book-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 15px;
  color: var(--subtle);
  font-size: 10px;
}

.book-meta i { width: 3px; height: 3px; border-radius: 50%; background: var(--subtle); }

.favorite-btn {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: #6e6e73;
  font-size: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.11);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
}

.favorite-btn.is-favorite { background: rgba(255, 255, 255, 0.92); color: #ff375f; }
.coming { opacity: 0.68; }
.coming .book-cover { filter: saturate(0.7); }

.continue-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
}

.continue-card .book-cover {
  flex: 0 0 74px;
  width: 74px;
  height: 102px;
  border-radius: 8px 13px 13px 8px;
}

.continue-card .book-cover.has-image img { padding: 4px; }
.continue-copy { flex: 1; min-width: 0; }
.continue-copy > span { color: var(--blue); font-size: 9px; font-weight: 700; letter-spacing: 0.8px; }
.continue-copy h3 { margin: 5px 0 12px; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 5px; overflow: hidden; border-radius: 5px; background: var(--surface-soft); }
.progress-track i { display: block; height: 100%; border-radius: 5px; background: var(--blue); }
.progress-label { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 9px; }

.continue-card > button {
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* Catalog and empty states */
.page-title { padding: 48px 0 25px; }
.page-title h1 { margin: 6px 0 5px; font-size: clamp(39px, 5vw, 56px); line-height: 1; letter-spacing: -2.7px; }
.page-title p { margin: 0; color: var(--muted); font-size: 13px; }
.catalog-search { max-width: 650px; }

.filter-row {
  display: flex;
  gap: 8px;
  padding: 20px 0 22px;
  overflow: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.2s ease;
}

.filter-chip:hover { border-color: var(--line-strong); color: var(--text); }
.filter-chip.is-active { border-color: var(--text); background: var(--text); color: var(--bg-elevated); }

.empty-state {
  display: none;
  padding: 72px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible { display: block; }

.empty-state > span {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: auto;
  border-radius: 22px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 31px;
}

.empty-state h3 { margin: 16px 0 5px; color: var(--text); font-size: 19px; }
.empty-state p { max-width: 350px; margin: 0 auto 20px; font-size: 12px; line-height: 1.6; }
.primary-button { padding: 12px 18px; font-size: 12px; }

/* Profile */
.profile-hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 0 26px;
  text-align: center;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin: auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #2f80ed, #0059b7);
  color: #fff;
  font-size: 25px;
  font-weight: 700;
  box-shadow: 0 16px 35px rgba(0, 113, 227, 0.25);
}

.profile-hero h1 { margin: 18px 0 4px; font-size: 28px; letter-spacing: -1px; }
.profile-hero p { margin: 0; color: var(--muted); font-size: 12px; }

.stats-row,
.settings-card {
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
  padding: 20px 0;
}

.stats-row div { border-right: 1px solid var(--line); text-align: center; }
.stats-row div:last-child { border: 0; }
.stats-row b,
.stats-row span { display: block; }
.stats-row b { color: var(--text); font-size: 23px; }
.stats-row span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.settings-card button {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 72px;
  padding: 0 17px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.settings-card button:hover { background: var(--surface-hover); }
.settings-card button:last-child { border-bottom: 0; }

.setting-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-weight: 700;
}

.setting-icon.blue { background: var(--blue-soft); color: var(--blue); }
.setting-icon.mint { background: rgba(48, 209, 88, 0.12); color: #26a844; }
.setting-icon.orange { background: rgba(255, 159, 10, 0.13); color: #d88300; }
.setting-icon.red { background: rgba(255, 59, 48, 0.12); color: var(--red); }
.theme-setting-icon .moon-icon { display: none; }
:root[data-theme="dark"] .theme-setting-icon .sun-icon { display: none; }
:root[data-theme="dark"] .theme-setting-icon .moon-icon { display: inline; }

.settings-card button > span:nth-child(2) { flex: 1; }
.settings-card button b,
.settings-card button small { display: block; }
.settings-card button b { font-size: 13px; }
.settings-card button small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.settings-card button > i { color: var(--subtle); font-size: 22px; font-style: normal; font-weight: 300; }
.version { margin: 28px 0; color: var(--subtle); font-size: 9px; text-align: center; }

/* Navigation */
.bottom-nav {
  position: fixed;
  z-index: 40;
  bottom: 16px;
  left: 50%;
  display: flex;
  justify-content: space-around;
  width: min(680px, calc(100% - 32px));
  height: 76px;
  padding: 8px max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.14);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  transform: translateX(-50%);
}

.bottom-nav button {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 140px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--subtle);
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.bottom-nav button:hover { background: var(--surface-soft); color: var(--text); }
.bottom-nav button.is-active { color: var(--blue); }
.bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* Book details */
.scrim {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: 0.28s ease;
}

.scrim.is-open { opacity: 1; visibility: visible; }

.book-sheet {
  position: fixed;
  z-index: 51;
  bottom: 0;
  left: 50%;
  width: min(100%, 650px);
  max-height: 92vh;
  padding: 36px 26px max(32px, env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 105%);
  transition: transform 0.34s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.book-sheet.is-open { transform: translate(-50%, 0); }

.sheet-close {
  position: absolute;
  z-index: 2;
  top: 15px;
  right: 17px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
}

.sheet-hero { display: flex; gap: 23px; padding: 11px 34px 24px 0; }
.sheet-hero .book-cover { flex: 0 0 130px; width: 130px; height: 184px; border-radius: 8px 15px 15px 8px; }
.sheet-hero .book-cover.has-image img { padding: 7px; }
.sheet-copy { padding-top: 13px; }
.sheet-copy > span { color: var(--blue); font-size: 9px; font-weight: 700; letter-spacing: 1px; }
.sheet-copy h2 { margin: 7px 0; font-size: 25px; line-height: 1.08; letter-spacing: -0.8px; }
.sheet-copy p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.sheet-description {
  margin: 12px 0;
  padding: 15px;
  border-radius: 15px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.sheet-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.sheet-meta div { min-width: 0; padding: 12px; border-radius: 14px; background: var(--surface-soft); }
.sheet-meta span,
.sheet-meta b { display: block; }
.sheet-meta span { margin-bottom: 4px; color: var(--muted); font-size: 8px; }
.sheet-meta b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; }
.sheet-actions { display: flex; gap: 10px; margin-top: 19px; }

.sheet-actions button {
  flex: 1;
  padding: 15px;
  border: 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.sheet-actions .read-button { background: var(--blue); color: #fff; }
.sheet-actions .save-button { background: var(--surface-soft); color: var(--text); }
.sheet-actions button:disabled { background: var(--surface-soft); color: var(--subtle); cursor: not-allowed; }

.toast {
  position: fixed;
  z-index: 110;
  bottom: 106px;
  left: 50%;
  padding: 11px 17px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.9);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.23);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transform: translate(-50%, 18px);
  transition: 0.22s ease;
}

.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* PDF reader */
.reader {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: 0.25s ease;
}

.reader.is-open { opacity: 1; visibility: visible; transform: none; }

.reader-bar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  height: 68px;
  padding: 8px max(15px, env(safe-area-inset-right)) 8px max(15px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.reader-bar button {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}

.reader-bar div { flex: 1; min-width: 0; }
.reader-bar b,
.reader-bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-bar b { font-size: 13px; }
.reader-bar span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.reader iframe { flex: 1; width: 100%; border: 0; background: #fff; }

.reader-fallback {
  position: absolute;
  bottom: 20px;
  left: 50%;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 15px;
  background: rgba(29, 29, 31, 0.92);
  box-shadow: var(--shadow-md);
  color: #fff;
  transform: translateX(-50%);
}

.reader-fallback p { margin: 0; font-size: 9px; white-space: nowrap; }
.reader-fallback button { padding: 8px 11px; border: 0; border-radius: 999px; background: #2997ff; color: #fff; font-size: 9px; font-weight: 600; }

/* Responsive */
@media (max-width: 980px) {
  .auth-screen { grid-template-columns: 0.75fr 1.25fr; }
  .auth-decoration span { letter-spacing: 0.14em; }
  .hero-copy { width: 60%; }
  .hero-illustration { right: 2%; transform: scale(0.9); transform-origin: right bottom; }
  .subject-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .auth-screen { display: block; overflow: auto; background: var(--bg-elevated); }
  .auth-decoration { display: none; }
  .auth-panel { min-height: 100vh; padding: 22px 24px 42px; }
  .auth-topbar { margin-bottom: 50px; }
  .auth-intro h1 { font-size: 44px; letter-spacing: -2.3px; }
  .topbar { height: 68px; padding-right: 20px; padding-left: 20px; }
  .page { padding-right: 22px; padding-left: 22px; }
  .hero { min-height: 330px; margin: 18px 0 20px; padding: 42px 30px; }
  .hero-copy { width: 66%; }
  .hero h1 { font-size: 47px; letter-spacing: -3px; }
  .hero p { max-width: 300px; font-size: 13px; }
  .hero-illustration { right: -48px; bottom: 16px; transform: scale(0.75); }
  .subject-row { display: flex; margin: 0 -22px; padding: 0 22px 9px; overflow: auto; scrollbar-width: none; }
  .subject-row::-webkit-scrollbar { display: none; }
  .subject-card { flex: 0 0 126px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .book-cover { height: 205px; }
  .book-info { padding: 16px; }
  .book-info h3 { font-size: 15px; }
  .section-heading h2 { font-size: 24px; }
  .page-title { padding-top: 38px; }
  .page-title h1 { font-size: 42px; }
  .bottom-nav { bottom: 0; width: 100%; height: 78px; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 0; box-shadow: 0 -7px 28px rgba(0, 0, 0, 0.08); }
  .reader-fallback { display: flex; }
}

@media (max-width: 520px) {
  .brand > span:last-child { display: none; }
  .auth-brand > span:last-child { display: block; }
  .topbar .theme-toggle { width: 48px; }
  :root[data-theme="dark"] .topbar .theme-toggle-track::before { transform: translateX(16px); }
  .hero { min-height: 390px; padding: 38px 24px 190px; border-radius: 26px; }
  .hero-copy { width: 100%; }
  .hero h1 { font-size: 43px; }
  .hero p { max-width: 100%; }
  .hero-illustration { right: 0; bottom: -36px; left: 50%; transform: translateX(-50%) scale(0.68); transform-origin: center; }
  .search-box kbd { display: none; }
  .section-block { margin-top: 38px; }
  .section-heading button { font-size: 0; }
  .section-heading button b { font-size: 21px; }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { display: grid; grid-template-columns: 112px minmax(0, 1fr); min-height: 164px; border-radius: 20px; }
  .book-card .book-cover { grid-row: 1; width: 112px; height: 100%; min-height: 164px; }
  .book-card .book-cover.has-image img { padding: 8px; }
  .book-card .book-info { grid-column: 2; grid-row: 1; padding: 19px 16px; }
  .book-info h3 { margin-right: 27px; font-size: 14px; }
  .book-meta { margin-top: auto; }
  .favorite-btn { top: 12px; right: 12px; width: 33px; height: 33px; }
  .continue-card { gap: 13px; padding: 13px; }
  .continue-card .book-cover { flex-basis: 60px; width: 60px; height: 84px; }
  .continue-card > button { padding: 11px; font-size: 0; }
  .continue-card > button::after { content: "→"; font-size: 17px; }
  .page-title h1 { font-size: 38px; letter-spacing: -2px; }
  .sheet-hero .book-cover { flex-basis: 105px; width: 105px; height: 150px; }
  .sheet-copy h2 { font-size: 21px; }
  .sheet-meta { grid-template-columns: 1fr 1fr; }
  .sheet-actions { position: sticky; bottom: 0; padding-top: 12px; background: var(--bg-elevated); }
}

@media (max-width: 430px) {
  .auth-panel { padding-right: 19px; padding-left: 19px; }
  .auth-topbar { margin-bottom: 42px; }
  .auth-intro h1 { font-size: 39px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .role-picker label > span { grid-template-columns: 36px 1fr; min-height: 72px; padding: 10px; }
  .role-picker label > span i { width: 36px; height: 36px; }
  .page { padding-right: 17px; padding-left: 17px; }
  .hero { margin-right: 0; margin-left: 0; }
  .subject-row { margin-right: -17px; margin-left: -17px; padding-right: 17px; padding-left: 17px; }
  .sheet-actions { flex-direction: column-reverse; }
  .reader-fallback p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
