/* ==========================================================================
   SecureDocs — Design System
   Palette: indigo + green accents   Type: Manrope / Inter (Latin + Cyrillic)
   ========================================================================== */

:root {
  /* Brand */
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-400: #818cf8;
  --primary-100: #e0e7ff;
  --primary-50: #eef2ff;
  --on-primary: #ffffff;

  --accent: #16a34a;
  --accent-50: #ecfdf5;
  --accent-100: #d1fae5;

  --warn: #d97706;
  --warn-50: #fffbeb;
  --danger: #dc2626;
  --danger-50: #fef2f2;

  /* Surfaces */
  --bg: #f5f6fd;
  --card: #ffffff;
  --muted: #f3f5fb;
  --border: #e6e8f5;
  --border-strong: #d5d9ee;

  /* Text */
  --fg: #1e1b4b;
  --fg-2: #3f3d69;
  --muted-fg: #6b7191;
  --faint-fg: #9aa0bd;

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;
  --r-full: 999px;

  /* Shadows */
  --sh-xs: 0 1px 2px rgba(30, 27, 75, .06);
  --sh-sm: 0 2px 6px rgba(30, 27, 75, .06), 0 1px 2px rgba(30, 27, 75, .04);
  --sh-md: 0 8px 24px rgba(49, 46, 129, .08), 0 2px 6px rgba(49, 46, 129, .05);
  --sh-lg: 0 18px 45px rgba(49, 46, 129, .13), 0 4px 12px rgba(49, 46, 129, .06);
  --sh-primary: 0 8px 20px rgba(79, 70, 229, .28);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .3, 1);
  --dur: 220ms;

  /* Layout */
  --nav-h: 68px;
  --container: 1240px;

  /* Elevation scale */
  --z-nav: 40;
  --z-dropdown: 60;
  --z-modal: 100;
  --z-toast: 200;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-2);
  background:
    radial-gradient(1100px 620px at 12% -8%, #e7ebff 0%, rgba(231, 235, 255, 0) 60%),
    radial-gradient(900px 520px at 92% 2%, #e6fbf1 0%, rgba(230, 251, 241, 0) 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--fg);
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -.01em;
}

h1 { font-size: 2.5rem; font-weight: 700; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

img { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid rgba(79, 70, 229, .45);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--primary); color: #fff; padding: .7rem 1.1rem; border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 26px; height: 26px; }

/* ========================= Layout helpers ========================= */

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } 
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.text-muted { color: var(--muted-fg); }
.text-sm { font-size: .875rem; }
.text-xs { font-size: .8125rem; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } 
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.tabular { font-variant-numeric: tabular-nums; }

.page { padding: 40px 0 80px; animation: pageIn .32s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 28px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary-600); background: #fff; border: 1px solid var(--primary-100);
  padding: 6px 13px; border-radius: var(--r-full); margin-bottom: 14px; box-shadow: var(--sh-xs);
}
.page-head p { color: var(--muted-fg); max-width: 70ch; margin-top: 10px; }

/* ========================= Navbar ========================= */

.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  height: var(--nav-h);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { height: var(--nav-h); display: flex; align-items: center; gap: 20px; }

.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 1.2rem; }
.logo:hover { color: var(--fg); }
.logo-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--primary-400), var(--primary));
  color: #fff; box-shadow: var(--sh-primary);
}
.logo-mark .icon { width: 22px; height: 22px; }

.nav-links { display: flex; align-items: center; gap: 6px; margin-left: 14px; }
.nav-link {
  white-space: nowrap; padding: 9px 14px; border-radius: var(--r-full); font-weight: 500; font-size: .95rem;
  color: var(--muted-fg); transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--muted); color: var(--fg); }
.nav-link.active { background: var(--primary-50); color: var(--primary-600); font-weight: 600; }

.nav-spacer { flex: 1; }

/* Sections announced ahead of time: visible where they will live, marked
   "Soon", and quieter than the sections that work */
.soon-tag {
  display: inline-block; margin-left: 7px; padding: 2px 7px; border-radius: var(--r-full);
  background: var(--primary-50); color: var(--primary-600); font-family: 'Manrope', sans-serif;
  font-size: .64rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; line-height: 1.5;
  white-space: nowrap;
}
.nav-soon {
  display: inline-flex; align-items: center; justify-content: flex-start;
  border: 0; background: none; font: inherit; font-weight: 500; font-size: .95rem; cursor: default;
}
.nav-soon:hover { background: none; color: var(--muted-fg); }

.icon-btn.nav-toggle { display: none; }

/* Avatar + menu */
.avatar {
  width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center;
  font-family: 'Manrope', sans-serif; font-weight: 600; color: #fff; font-size: .95rem;
  background: linear-gradient(140deg, var(--primary-400), var(--primary)); flex: none;
  letter-spacing: .02em;
}
.avatar.teacher { background: linear-gradient(140deg, #fb7185, #be123c); }
.avatar.xs { width: 30px; height: 30px; font-size: .75rem; }
.avatar.sm { width: 36px; height: 36px; font-size: .82rem; }

.usermenu { position: relative; }
.usermenu-btn {
  display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 5px 12px 5px 5px; cursor: pointer; min-height: 44px;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.usermenu-btn:hover { box-shadow: var(--sh-sm); border-color: var(--border-strong); }
.usermenu-btn .name {
  font-weight: 600; font-size: .9rem; color: var(--fg);
  /* the admin may rename themselves at any length; the full name is in the menu */
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 244px; z-index: var(--z-dropdown);
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--sh-lg);
  padding: 8px; animation: pop .18s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.usermenu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-sm); border: 0; background: none; cursor: pointer;
  color: var(--fg-2); font-size: .93rem; font-weight: 500; min-height: 44px;
  transition: background var(--dur) var(--ease);
}
.menu-item:hover { background: var(--muted); color: var(--fg); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-50); }

/* ========================= Buttons ========================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 44px; padding: 11px 20px; border-radius: var(--r-full);
  border: 1px solid transparent; background: var(--primary); color: var(--on-primary);
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: .95rem; cursor: pointer;
  box-shadow: var(--sh-primary);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease), opacity var(--dur) var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-600); color: #fff; box-shadow: 0 10px 26px rgba(79, 70, 229, .34); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }

.btn-ghost { background: #fff; color: var(--fg); border-color: var(--border); box-shadow: var(--sh-xs); }
.btn-ghost:hover { background: var(--muted); color: var(--fg); border-color: var(--border-strong); box-shadow: var(--sh-sm); }

.btn-danger { background: var(--danger); box-shadow: 0 8px 20px rgba(220, 38, 38, .22); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { min-height: 38px; padding: 8px 15px; font-size: .875rem; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1.03rem; }
.btn-block { width: 100%; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: #fff; color: var(--muted-fg); cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary-100); background: var(--primary-50); }
.icon-btn.danger:hover { color: var(--danger); border-color: #fecaca; background: var(--danger-50); }

/* ========================= Cards ========================= */

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); padding: 24px;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-full);
  font-size: .78rem; font-weight: 600; background: var(--muted); color: var(--muted-fg);
  font-family: 'Manrope', sans-serif; letter-spacing: .01em;
}
.badge-success { background: var(--accent-50); color: #12833c; }
.badge-lock { background: #f1f2f8; color: #6b7191; }
.badge-primary { background: var(--primary-50); color: var(--primary-600); }
.badge-danger { background: var(--danger-50); color: #b91c1c; }
.badge, td[data-term] { white-space: nowrap; }
.badge-warn { background: var(--warn-50); color: #b45309; }

.divider { height: 1px; background: var(--border); border: 0; margin: 20px 0; }

/* ========================= Forms ========================= */

.field { margin-bottom: 18px; }
.field label { display: block; font-size: .875rem; font-weight: 600; color: var(--fg); margin-bottom: 7px; font-family: 'Manrope', sans-serif; }
.field .req { color: var(--danger); }
.field .hint { font-size: .8125rem; color: var(--muted-fg); margin-top: 6px; }
.field .err { font-size: .8125rem; color: var(--danger); margin-top: 6px; display: flex; align-items: center; gap: 6px; }

.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: #fff; color: var(--fg);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  font-size: 1rem;
}
.input::placeholder, .textarea::placeholder { color: var(--faint-fg); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary-400); box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}
.input.invalid, .select.invalid { border-color: var(--danger); }
.textarea { min-height: 108px; resize: vertical; line-height: 1.6; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7191' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint-fg); pointer-events: none; }
.input-icon .input { padding-left: 44px; }

.checkline {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); cursor: pointer; min-height: 44px; background: #fff;
  transition: all var(--dur) var(--ease); font-size: .92rem; font-weight: 500;
}
.checkline:hover { border-color: var(--primary-100); background: var(--primary-50); }
.checkline input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.checkline.on { border-color: var(--primary-400); background: var(--primary-50); color: var(--primary-600); }

/* ========================= Tables ========================= */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: #fff; box-shadow: var(--sh-sm); }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
thead th {
  text-align: left; font-family: 'Manrope', sans-serif; font-size: .78rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted-fg); font-weight: 600;
  padding: 14px 18px; background: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: .93rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover { background: #fafbff; }

/* ========================= Toast ========================= */

.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 13px 18px; border-radius: var(--r-md);
  background: #fff; border: 1px solid var(--border); box-shadow: var(--sh-lg); color: var(--fg);
  font-weight: 500; font-size: .92rem; max-width: 360px;
  animation: toastIn .28s var(--ease) both;
}
.toast .icon { color: var(--accent); }
.toast.err .icon { color: var(--danger); }
.toast.info .icon { color: var(--primary); }
.toast.out { animation: toastOut .22s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ========================= Modal ========================= */

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center;
  background: rgba(23, 20, 60, .48); backdrop-filter: blur(4px); padding: 20px;
  animation: fadeIn .2s var(--ease) both; overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px; background: #fff; border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  animation: modalIn .28s var(--ease) both; margin: auto;
}
.modal.wide { max-width: 680px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 24px 8px; }
.modal-head h3 { flex: 1; }
.modal-body { padding: 12px 24px 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 24px 24px; flex-wrap: wrap; }
.modal-icon { width: 46px; height: 46px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.modal-icon.warn { background: var(--warn-50); color: var(--warn); }
.modal-icon.danger { background: var(--danger-50); color: var(--danger); }

/* ========================= Login ========================= */

.login-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: center; min-height: calc(100vh - var(--nav-h) - 120px); }
.login-card { max-width: 470px; width: 100%; padding: 34px; border-radius: var(--r-xl); }
.login-aside { padding: 20px; }
.login-aside h1 { font-size: 2.7rem; margin-bottom: 14px; }
.login-aside p { color: var(--muted-fg); font-size: 1.05rem; max-width: 48ch; }
.demo-accounts { display: grid; gap: 12px; margin-top: 26px; }
.demo-acc {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r-md);
  background: #fff; border: 1px solid var(--border); box-shadow: var(--sh-sm); cursor: pointer; text-align: left;
  transition: all var(--dur) var(--ease); width: 100%;
}
.demo-acc:hover { border-color: var(--primary-400); box-shadow: var(--sh-md); transform: translateY(-2px); }
.demo-acc .k { font-family: 'Manrope', sans-serif; font-weight: 600; color: var(--fg); }
.demo-acc .c { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; color: var(--muted-fg); }

.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border-radius: var(--r-md);
  background: var(--danger-50); border: 1px solid #fecaca; color: #991b1b; font-size: .9rem; font-weight: 500;
  margin-bottom: 18px; animation: shake .4s var(--ease) both;
}
.alert .icon { color: var(--danger); flex: none; margin-top: 1px; }
/* news, not a mistake: no shake, no red */
.alert.info { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary-600); animation: none; }
.alert.info .icon { color: var(--primary); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ========================= Document cards ========================= */

.cover-indigo { background: linear-gradient(135deg, #6366f1, #4338ca); }
.cover-green { background: linear-gradient(135deg, #34d399, #0f9d58); }
.cover-amber { background: linear-gradient(135deg, #fbbf24, #d97706); }

.course-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.course-body h3 { margin-bottom: 6px; }
.course-body p { color: var(--muted-fg); font-size: .92rem; flex: 1; }
.course-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; }
.course-meta { display: flex; align-items: center; gap: 14px; color: var(--muted-fg); font-size: .84rem; font-weight: 500; }
.course-meta span { display: inline-flex; align-items: center; gap: 5px; }

.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; }

.book-card {
  position: relative; display: flex; flex-direction: column; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden;
  box-shadow: var(--sh-sm); padding: 0; width: 100%;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.book-card:hover { transform: translateY(-4px); box-shadow: var(--sh-lg); border-color: var(--primary-100); }
.book-card:active { transform: translateY(-1px) scale(.995); }
/* the card is a link: its text keeps the page colours, not the link blue */
a.book-card, a.book-card:hover { color: inherit; }

.book-cover {
  position: relative; min-height: 210px; padding: 30px 30px 26px 46px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; color: #fff;
}
.book-cover::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px); background-size: 20px 20px;
}
.book-cover > .icon { width: 40px; height: 40px; opacity: .95; margin-bottom: 12px; position: relative; z-index: 1; }
.book-cover-title {
  font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 1.5rem; line-height: 1.2;
  position: relative; z-index: 1;
}
.book-cover-author { font-size: .875rem; opacity: .85; position: relative; z-index: 1; }
.book-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 18px; z-index: 1;
  background: linear-gradient(90deg, rgba(0, 0, 0, .28), rgba(0, 0, 0, .04));
  border-right: 1px solid rgba(255, 255, 255, .22);
}

/* announced sections under the documents: no lift, no link, light cover */
.soon-section { margin-top: 56px; }
.soon-card { cursor: default; box-shadow: none; }
.soon-card:hover, .soon-card:active { transform: none; box-shadow: none; border-color: var(--border); }
.soon-cover { min-height: 170px; padding-left: 30px; background: linear-gradient(135deg, #f3f4fd, #e6e9f9); color: var(--primary-600); }
.soon-cover::after { background-image: radial-gradient(rgba(79, 70, 229, .09) 1px, transparent 1px); }
.soon-cover .book-cover-title { color: var(--fg); }
.soon-badge { position: absolute; top: 18px; right: 18px; z-index: 1; background: #fff; }

/* ========================= Document reader ========================= */

/* one column of pages, nothing around them — a page is read, not scanned */
.reader-narrow { max-width: 920px; margin: 0 auto; }
.book-pages { display: grid; gap: 26px; }

.book-full-head {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm); padding: 26px; margin-bottom: 26px;
}
.book-full-head h1 { font-size: 2rem; }

.book-page { margin: 0; }
/* nothing to select, copy, or long-press "Save to Photos" on (iOS ignores
   a prevented contextmenu; the callout needs its own switch) */
.book-pages, .book-pages img { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* the window lost focus: hide the book. No transition — a capture taken
   at that moment must already get the blur. */
.reader-shield {
  display: none; position: fixed; inset: 0; z-index: 40; place-items: center; padding: 16px;
  background: rgba(245, 246, 253, .55); cursor: pointer;
}
.reader-shielded .reader-shield { display: grid; }
.reader-shielded .book-pages img { filter: blur(24px); }
.reader-shield-card { max-width: 380px; text-align: center; padding: 28px; }
.reader-shield-card .icon { color: var(--primary); margin-bottom: 10px; }

/* printing gives a blank sheet with one line, never the book */
.print-only { display: none; }
@media print {
  body > *:not(.print-only) { display: none !important; }
  .print-only { display: block; margin-top: 40vh; text-align: center; font: 600 18pt Manrope, Inter, sans-serif; color: #000; }
}
.book-page-shell {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border-strong); background: #fff; box-shadow: var(--sh-md);
  /* the real page's proportions arrive with the file; A4 until then, so
     nothing below jumps when they do */
  aspect-ratio: var(--page-ratio, 1 / 1.414);
}
.book-page-shell img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  user-select: none; -webkit-user-drag: none;
}
.book-page-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #f6f4ef 30%, #fbfaf7 50%, #f6f4ef 70%);
  background-size: 240% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }
.book-page figcaption {
  text-align: center; font-size: .82rem; color: var(--muted-fg); margin-top: 10px; font-weight: 500;
}

/* where am I in a long book, and a way to any page: stays under the header */
.reader-bar {
  position: sticky; top: calc(var(--nav-h) + 8px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 22px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .92); border: 1px solid var(--border); box-shadow: var(--sh-sm);
  backdrop-filter: blur(8px);
}
.reader-counter { font-family: 'Manrope', sans-serif; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }
.reader-bar .input-sm { width: 140px; }
.reader-status { text-align: center; padding: 28px 24px; margin-bottom: 22px; }
.reader-status .progress { max-width: 360px; margin: 0 auto; }

.progress { height: 8px; border-radius: var(--r-full); background: var(--muted); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .2s var(--ease); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--primary-100); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* segmented choice: the teacher's Lotin / Кирилл switch in the reader */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--muted); border: 1px solid var(--border); border-radius: var(--r-full); }
.seg-btn {
  min-height: 34px; padding: 6px 14px; border-radius: var(--r-full); display: inline-flex; align-items: center;
  font-family: 'Manrope', sans-serif; font-weight: 600; font-size: .85rem; color: var(--muted-fg);
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.on { background: #fff; color: var(--primary-600); box-shadow: var(--sh-xs); }

.script-badge { background: var(--primary-50); color: var(--primary-600); }

/* how long the student's access lasts, under the books page title */
.term-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: -6px 0 22px; color: var(--muted-fg); font-size: .92rem;
}

/* a book card holds a link per edition, so the card itself is not one */
.book-card-static { cursor: default; }
.book-card-static:hover { transform: none; }

/* one block per script in the book form; a fieldset otherwise refuses to
   shrink below its content and widens the dialog on a phone */
.edition-block {
  min-width: 0; margin: 0; padding: 14px 16px 2px;
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.edition-block legend { padding: 0 6px; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: .9rem; color: var(--fg); }
.edition-block .textarea { min-height: 72px; }
.edition-all { border: 0; padding: 0; }
.legend-note { font-weight: 500; color: var(--muted-fg); }
/* .field label makes every label a block; these are segments */
.mode-seg label.seg-btn { display: inline-flex; margin-bottom: 0; cursor: pointer; }
/* the ring for the keyboard only: a mouse click focuses the radio too */
.mode-seg .seg-btn:has(input:focus-visible) { outline: 3px solid var(--primary-400); outline-offset: 2px; }
.field-label { display: block; font-size: .875rem; font-weight: 600; color: var(--fg); margin-bottom: 7px; font-family: 'Manrope', sans-serif; }
.file-pick { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; }
/* .field label makes every label a block; this one is a button */
.file-pick label.btn { display: inline-flex; margin-bottom: 0; flex: none; cursor: pointer; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-input:focus-visible + label { outline: 3px solid var(--primary-400); outline-offset: 2px; }
.file-name { min-width: 0; font-size: .85rem; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name.picked { color: var(--fg); font-weight: 500; }
.input-sm { min-height: 38px; padding: 7px 12px; font-size: .9rem; }

/* a layout class (.row is flex) must not bring back what hidden hides */
[hidden] { display: none !important; }

/* the screenshot check result: the picture beside what it says */
.check-card { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; align-items: start; padding: 18px; border-radius: var(--r-md); border: 1px solid var(--border); }
.check-card.found { border-color: var(--accent); background: var(--accent-50); }
.check-card.none { background: var(--muted); }
.check-card h3 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.check-card.found h3 .icon { color: var(--accent); }
.check-preview { width: 140px; max-height: 200px; object-fit: contain; border-radius: var(--r-sm); border: 1px solid var(--border); background: #fff; }
@media (max-width: 560px) { .check-card { grid-template-columns: minmax(0, 1fr); } }

/* the device that holds a student's seat (server only) */
.device-line { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--muted); color: var(--fg-2); font-size: .92rem; }
.device-line .grow { min-width: 0; overflow-wrap: break-word; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ========================= Admin panel shell ========================= */

.dash { display: grid; grid-template-columns: 258px minmax(0, 1fr); gap: 24px; align-items: start; }
.dash-nav { position: sticky; top: calc(var(--nav-h) + 24px); padding: 16px; }
.dash-user { display: flex; align-items: center; gap: 12px; padding: 8px 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.dash-user .n { font-family: 'Manrope', sans-serif; font-weight: 600; color: var(--fg); font-size: .95rem; line-height: 1.25; }
.dash-user .r { font-size: .8rem; color: var(--muted-fg); }
.dash-link {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; background: none;
  border-radius: var(--r-sm); cursor: pointer; color: var(--fg-2); font-weight: 500; font-size: .93rem;
  text-align: left; min-height: 44px; margin-bottom: 2px; transition: all var(--dur) var(--ease);
}
.dash-link:hover { background: var(--muted); color: var(--fg); }
.dash-link.active { background: var(--primary-50); color: var(--primary-600); font-weight: 600; }
.dash-link.active .icon { color: var(--primary); }
.dash-link .icon { color: var(--faint-fg); }

.dash-link.soon { color: var(--muted-fg); cursor: default; }
.dash-link.soon:hover { background: none; color: var(--muted-fg); }
.dash-link.soon .soon-tag { margin-left: auto; }

.dash-link.danger { color: var(--danger); margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0 0 var(--r-sm) var(--r-sm); padding-top: 14px; }
.dash-link.danger .icon { color: var(--danger); }
.dash-link.danger:hover { background: var(--danger-50); color: var(--danger); }

.dash-main { display: grid; gap: 22px; min-width: 0; }
.dash-main > * { min-width: 0; }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.info-item { padding: 15px 17px; border-radius: var(--r-md); background: var(--muted); }
.info-item .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-fg); font-weight: 600; }
.info-item .v { font-weight: 600; color: var(--fg); margin-top: 3px; word-break: break-word; }

.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .ic { width: 62px; height: 62px; border-radius: 20px; background: var(--muted); color: var(--faint-fg); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-state p { color: var(--muted-fg); max-width: 42ch; margin: 8px auto 20px; }

/* small coloured file mark in the documents table */
.doc-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }

/* Footer */
.footer { border-top: 1px solid var(--border); background: rgba(255, 255, 255, .6); padding: 30px 0; margin-top: 40px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.footer p { color: var(--muted-fg); font-size: .875rem; }

/* ========================= Responsive ========================= */

/* The teacher's header needs about 1060px with Testlar and Videodarslar in
   it (a student's about 950px); below that the links wrapped and pushed the
   profile past the edge. They fold into the menu button instead. Measure
   again whenever a link is added. */
@media (max-width: 1080px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; align-items: stretch; position: absolute; right: 16px; width: 300px;
    top: calc(var(--nav-h) - 6px); background: #fff; border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--sh-lg); padding: 8px; margin: 0; z-index: var(--z-dropdown);
  }
  .icon-btn.nav-toggle { display: grid; }
}

@media (max-width: 1024px) {
  h1 { font-size: 2.1rem; }
  .login-wrap { grid-template-columns: 1fr; gap: 28px; padding: 24px 0; min-height: 0; }
  .login-card { max-width: none; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-nav { position: static; min-width: 0; }
  .dash-user { display: none; }
  /* The section menu stays a list above the content. As a sideways strip
     five items no longer fit and the last ones were cut off; log out is
     already in the profile menu. */
  .dash-link.danger { display: none; }
  /* the list spans the page here: keep "Soon" beside its label, not at the far edge */
  .dash-link.soon .soon-tag { margin-left: 0; }
}

@media (max-width: 760px) {
  .container { padding: 0 16px; }
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.45rem; }
  .page { padding: 26px 0 60px; }
  .nav-links.open { left: 16px; right: 16px; width: auto; }
  .nav-inner { gap: 10px; }
  .info-grid, .book-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px; }
  .usermenu-btn .name { display: none; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .toast-root { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .footer-inner { justify-content: center; text-align: center; }

  /* Admin tables: each row becomes a card. A 640px table scrolled sideways
     inside its frame hid the document chips and the buttons past the edge. */
  .table-cards { min-width: 0; }
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tr { display: grid; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { padding: 0; border: 0; min-width: 0; overflow-wrap: break-word; }
  /* Buttons go on their own line: beside the name they squeezed it to
     140px and split titles and e-mails in the middle */
  .table-cards td.cell-actions .row { justify-content: flex-start !important; }
  /* the name block is a flex child: without this a long e-mail runs past the card */
  .table-cards td:first-child .row > div { min-width: 0; }
  .table-cards td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 6px;
    font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted-fg); font-weight: 600;
  }
  .table-cards td.cell-inline { display: flex; align-items: center; gap: 10px; }
  .table-cards td.cell-inline::before { margin-bottom: 0; }
}

@media (max-width: 560px) {
  .logo-text { display: none; }
  .btn { padding: 11px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ---- the developer's server panel ---- */
.sv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; }
.sv-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--fg); }
.sv-status .icon { color: var(--accent); }
.sv-h { font-size: 1rem; margin: 26px 0 12px; }
.sv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.sv-tile {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
}
.sv-label { font-size: .85rem; color: var(--muted-fg); }
.sv-value { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 1.6rem; line-height: 1.1; color: var(--fg); overflow-wrap: break-word; }
.sv-sub { font-size: .82rem; color: var(--muted-fg); }
/* the fill carries the level, the track is a lighter step of the same hue */
.sv-meter { height: 8px; margin-top: 4px; border-radius: var(--r-full); background: var(--primary-100); overflow: hidden; }
.sv-meter span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.sv-meter.warn { background: var(--warn-50); }
.sv-meter.warn span { background: var(--warn); }
.sv-meter.bad { background: var(--danger-50); }
.sv-meter.bad span { background: var(--danger); }
.sv-level { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--fg-2); }
.sv-level .icon { width: 14px; height: 14px; }
.sv-level.ok .icon { color: var(--accent); }
.sv-level.warn .icon { color: var(--warn); }
.sv-level.bad .icon { color: var(--danger); }
.sv-spark { margin-top: 8px; touch-action: pan-y; }
.sv-plot { position: relative; height: 56px; }
.sv-plot svg { display: block; width: 100%; height: 100%; }
.sv-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sv-area { fill: var(--primary); opacity: .1; }
/* round dots in HTML: the drawing itself stretches with the tile */
.sv-dot {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 2px var(--card); pointer-events: none;
}
.sv-cap { margin-top: 2px; font-size: .72rem; color: var(--faint-fg); }
.sv-cap.on { color: var(--fg); font-weight: 600; }
.sv-spark-empty { margin-top: 8px; font-size: .78rem; color: var(--faint-fg); }
