/* Holy Redeemer · Learning Resource Center
   Static demo. No build step, no backend.
   Palette and typography follow the school: maroon, antique gold, cream. */

:root {
  --maroon-950: #2b0812;
  --maroon-900: #3c0d1a;
  --maroon-800: #571224;
  --maroon-700: #6b1528;
  --maroon-600: #84263b;
  --gold-600: #a8871c;
  --gold-500: #c9a227;
  --gold-300: #e7d08a;
  --cream-50: #fcf8f0;
  --cream-100: #f6efe2;
  --cream-200: #ede2ce;
  --cream-300: #e0d1b6;
  --ink-900: #251a16;
  --ink-700: #463630;
  --ink-500: #6f5c54;
  --ink-400: #907c73;
  --line: rgba(37, 26, 22, 0.1);
  --line-strong: rgba(37, 26, 22, 0.16);
  --green-700: #2c6a4c;
  --green-100: #e4efe7;
  --red-700: #8e2b2b;
  --red-100: #f6e3df;
  --amber-700: #8a5a12;
  --amber-100: #f7ebd3;

  --font-serif: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-morph: cubic-bezier(0.32, 0.72, 0, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #171211;
  color: var(--cream-100);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

svg {
  display: block;
}

/* ---------- Stage ---------- */

.page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
  flex: none;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.demo-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-brand img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.demo-brand-text p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  color: var(--cream-100);
}

.demo-brand-text span {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(246, 239, 226, 0.42);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
}

.seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: rgba(246, 239, 226, 0.6);
  font-size: 11.5px;
  font-weight: 500;
  transition:
    background-color 160ms var(--ease-out),
    color 160ms var(--ease-out),
    transform 120ms var(--ease-out);
}

.seg svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.seg[aria-pressed="true"] {
  background: var(--cream-100);
  color: var(--maroon-950);
}

.seg:active {
  transform: scale(0.97);
}

.seg:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.canvas {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: 22px 16px;
  background:
    radial-gradient(120% 100% at 50% 0%, #241b18 0%, #171211 62%);
}

.device {
  position: relative;
  width: min(390px, 100%);
  height: min(844px, calc(100dvh - 106px));
  max-height: 100%;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 46px;
  background: #0b0908;
  transition:
    width 460ms var(--ease-morph),
    border-radius 460ms var(--ease-morph);
}

.app {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 38px;
  background: var(--cream-50);
  color: var(--ink-900);
  font-size: 13.5px;
  line-height: 1.45;
  container: app / inline-size;
  transition: border-radius 460ms var(--ease-morph);
}

body[data-mode="desktop"] .device {
  width: min(1180px, calc(100vw - 64px));
  border-radius: 24px;
}

body[data-mode="desktop"] .app {
  border-radius: 16px;
}

/* Embed: drop the page bar, float the switch, fill the iframe. */
body.embed .demo-bar {
  display: none;
}

body.embed .device {
  height: min(844px, calc(100dvh - 76px));
}

body.embed .canvas {
  padding: 60px 16px 16px;
}

body.embed .segmented {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 80;
  transform: translateX(-50%);
  background: rgba(23, 18, 17, 0.85);
}

/* Bare: the app alone, for stills and the recording. */
body.bare .canvas {
  padding: 0;
  background: var(--cream-50);
}

body.bare .device {
  width: 100%;
  height: 100%;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.bare .app {
  border-radius: 0;
}

body.bare .segmented {
  display: none;
}

/* ---------- App shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 0px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
  transition: grid-template-columns 460ms var(--ease-morph);
}

.sidebar {
  visibility: hidden;
  overflow: hidden;
  background: var(--maroon-900);
  color: var(--cream-100);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  width: 212px;
  height: 100%;
  padding: 20px 12px 12px;
  opacity: 0;
  transform: translateX(-8px);
  transition:
    opacity 220ms var(--ease-out),
    transform 260ms var(--ease-out);
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--cream-50);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 54px;
  flex: none;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--cream-50);
}

.topbar-mobile {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar-mobile img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
}

.topbar-mobile p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.1;
  color: var(--maroon-900);
}

.topbar-mobile span {
  display: block;
  font-size: 8.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-top: 2px;
}

.topbar-desktop {
  display: none;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar-desktop strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-700);
}

.topbar-desktop span {
  font-size: 11px;
  color: var(--ink-400);
}

.avatar {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  flex: none;
  border-radius: 50%;
  background: var(--maroon-700);
  color: #fbf3e4;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar-btn {
  padding: 0;
  border: 0;
  transition:
    background-color 140ms var(--ease-out),
    transform 110ms var(--ease-out);
}

.avatar-btn:hover {
  background: var(--maroon-800);
}

.avatar-btn:active {
  transform: scale(0.96);
}

.avatar-btn:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

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

/* One-tap sign out next to the account avatar. Phone only: the sidebar owns
   the labelled sign-out once it is visible (container >= 720px). */
.topbar-signout {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-400);
  transition:
    color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    background-color 140ms var(--ease-out),
    transform 110ms var(--ease-out);
}

.topbar-signout svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-signout:hover {
  color: var(--maroon-800);
  border-color: var(--maroon-800);
  background: var(--cream-100);
}

.topbar-signout:active {
  transform: scale(0.96);
}

.topbar-signout:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 92px;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 26, 22, 0.18) transparent;
}

.scroll::-webkit-scrollbar {
  width: 8px;
}

.scroll::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
  background-color: rgba(37, 26, 22, 0.16);
}

.tabbar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--cream-50);
  transition:
    transform 280ms var(--ease-out),
    opacity 180ms var(--ease-out),
    visibility 0s;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--ink-400);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  transition: color 140ms var(--ease-out);
}

.tab svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab[aria-current="page"] {
  color: var(--maroon-700);
  font-weight: 600;
}

/* Sidebar content */

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px 16px;
  border-bottom: 1px solid rgba(246, 239, 226, 0.13);
}

.brand img {
  width: 33px;
  height: 33px;
  flex: none;
  border-radius: 50%;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.15;
  color: #fbf3e4;
}

.brand-sub {
  margin-top: 3px;
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-300);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 14px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(246, 239, 226, 0.7);
  font-size: 12.5px;
  text-align: left;
  transition:
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fbf3e4;
}

.nav-item[aria-current="page"] {
  background: rgba(201, 162, 39, 0.15);
  box-shadow: inset 2px 0 0 var(--gold-500);
  color: #fbf3e4;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(246, 239, 226, 0.13);
}

.who {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px 10px;
}

.who .avatar {
  background: var(--gold-500);
  color: var(--maroon-950);
}

.who-name {
  font-size: 11.5px;
  font-weight: 600;
  color: #fbf3e4;
  line-height: 1.2;
}

.who-role {
  margin-top: 2px;
  font-size: 9.5px;
  color: rgba(246, 239, 226, 0.55);
}

.signout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(246, 239, 226, 0.62);
  font-size: 11.5px;
  transition:
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}

.signout svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.signout:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fbf3e4;
}

/* ---------- Type and primitives ---------- */

.view {
  max-width: 1040px;
  margin: 0 auto;
}

.view-in {
  animation: viewIn 220ms var(--ease-out) both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-600);
}

h1 {
  margin: 5px 0 3px;
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--maroon-900);
}

.sub {
  margin: 0;
  font-size: 12px;
  color: var(--ink-500);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-700);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    transform 110ms var(--ease-out);
}

.btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover {
  border-color: var(--maroon-700);
  color: var(--maroon-700);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.btn-primary {
  border-color: var(--maroon-700);
  background: var(--maroon-700);
  color: #fdf6e7;
}

.btn-primary:hover {
  border-color: var(--maroon-800);
  background: var(--maroon-800);
  color: #fdf6e7;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn:disabled:hover {
  border-color: var(--line-strong);
  color: var(--ink-700);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-500);
}

.btn-quiet:hover {
  border-color: transparent;
  background: var(--cream-100);
  color: var(--maroon-700);
}

.btn-sm {
  height: 29px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.chip-green {
  background: var(--green-100);
  color: var(--green-700);
}

.chip-red {
  background: var(--red-100);
  color: var(--red-700);
}

.chip-amber {
  background: var(--amber-100);
  color: var(--amber-700);
}

.chip-quiet {
  background: #efe9dd;
  color: var(--ink-500);
}

.chip-gold {
  background: #f5ebc9;
  color: #7a6212;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line);
}

.card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--maroon-900);
}

.card-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-400);
  font-size: 10.5px;
  font-weight: 500;
  transition: color 140ms var(--ease-out);
}

.card-link:hover {
  color: var(--maroon-700);
}

/* Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.stat {
  padding: 11px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.stat-value {
  margin-top: 3px;
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.1;
  color: var(--maroon-900);
}

.stat-note {
  margin-top: 1px;
  font-size: 10px;
  color: var(--ink-400);
}

.stat-alert .stat-value {
  color: var(--red-700);
}

/* Rows */

.row-list {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
}

.row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-900);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 10.5px;
  color: var(--ink-400);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-act {
  flex: none;
}

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

/* Book covers */

.mini-cover {
  display: grid;
  place-items: center;
  width: 32px;
  height: 44px;
  flex: none;
  border-radius: 4px;
  background: linear-gradient(155deg, var(--c1), var(--c2));
  box-shadow:
    inset 6px 0 8px -6px rgba(0, 0, 0, 0.65),
    0 1px 2px rgba(0, 0, 0, 0.16);
  color: rgba(255, 246, 226, 0.92);
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1;
}

.cover {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  padding: 12px 10px 10px;
  border-radius: 5px;
  background: linear-gradient(155deg, var(--c1), var(--c2));
  box-shadow:
    inset 7px 0 10px -8px rgba(0, 0, 0, 0.7),
    0 2px 6px rgba(37, 26, 22, 0.14);
  color: #f8efdb;
}

.cover-kicker {
  font-size: 7px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.62;
}

.cover-title {
  margin-top: auto;
  font-family: var(--font-serif);
  font-size: 13px;
  line-height: 1.18;
  letter-spacing: -0.01em;
}

.cover-rule {
  height: 1px;
  margin: 7px 0 5px;
  background: rgba(248, 239, 219, 0.34);
}

.cover-author {
  font-size: 8px;
  line-height: 1.2;
  opacity: 0.72;
}

.cover-sm .cover-kicker {
  display: none;
}

.cover-sm .cover-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 10.5px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.cover-sm .cover-author {
  font-size: 7.5px;
}

.cover-sm .cover-rule {
  margin: 5px 0 4px;
}

/* Cover grid */

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

.cover-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cover-grid > .empty {
  grid-column: 1 / -1;
}

.cover-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.cover-foot .btn {
  flex: none;
}

/* Search and filters */

.search {
  position: relative;
  margin-bottom: 9px;
}

.search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--ink-400);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--ink-900);
  font-size: 12.5px;
  outline: none;
  transition:
    border-color 140ms var(--ease-out),
    box-shadow 140ms var(--ease-out);
}

.search input::placeholder {
  color: var(--ink-400);
}

.search input:focus {
  border-color: var(--maroon-600);
  box-shadow: 0 0 0 3px rgba(107, 21, 40, 0.1);
}

.filters {
  display: flex;
  gap: 6px;
  margin-bottom: 13px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  height: 27px;
  flex: none;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: #fff;
  color: var(--ink-500);
  font-size: 10.5px;
  white-space: nowrap;
  transition:
    background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}

.filter:hover {
  border-color: var(--cream-300);
  color: var(--ink-700);
}

.filter[aria-pressed="true"] {
  border-color: var(--maroon-700);
  background: var(--maroon-700);
  color: #fdf6e7;
}

.empty {
  padding: 26px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-400);
}

/* ---------- Login ---------- */

.auth {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 14px;
  overflow-y: auto;
  background: #211512 url("shelves.jpg") center / cover no-repeat;
}

.auth::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 38%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.42) 100%);
  pointer-events: none;
}

/* Only shown in the desktop split layout below. */
.auth-brand {
  display: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 372px;
  margin: auto;
  padding: 28px 24px 22px;
  border-radius: 18px;
  background: #f4f1ea;
  box-shadow:
    0 32px 60px -22px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  animation: cardIn 500ms var(--ease-out) both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-crest {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: 0 auto 14px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(37, 26, 22, 0.18);
}

.auth-crest img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.auth-school {
  margin: 0;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-align: center;
  text-transform: uppercase;
  color: var(--maroon-700);
}

.auth-title {
  margin: 7px 0 20px;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-align: center;
  color: var(--maroon-900);
}

.field {
  margin-bottom: 11px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--maroon-700);
}

.field input {
  width: 100%;
  height: 39px;
  padding: 0 11px;
  border: 1px solid #d7d0c2;
  border-radius: 7px;
  background: #fff;
  color: var(--ink-900);
  font-size: 12.5px;
  outline: none;
  transition:
    border-color 150ms var(--ease-out),
    box-shadow 150ms var(--ease-out);
}

.field input::placeholder {
  color: #a4988d;
}

.field input:focus {
  border-color: var(--maroon-600);
  box-shadow: 0 0 0 3px rgba(107, 21, 40, 0.1);
}

.auth-submit {
  height: 40px;
  margin-top: 4px;
  border-color: var(--maroon-700);
  background: var(--maroon-700);
  color: #fdf6e7;
  font-size: 12.5px;
}

.auth-submit:hover {
  border-color: var(--maroon-800);
  background: var(--maroon-800);
  color: #fdf6e7;
}

.auth-hint {
  margin: 8px 0 0;
  font-size: 10.5px;
  text-align: center;
  color: var(--red-700);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 13px;
  color: #9c8f83;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: #ded6c8;
}

.roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.role {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 56px;
  border: 1px solid #d7d0c2;
  border-radius: 8px;
  background: #fff;
  color: var(--maroon-800);
  font-size: 10.5px;
  font-weight: 500;
  transition:
    border-color 150ms var(--ease-out),
    background-color 150ms var(--ease-out),
    transform 110ms var(--ease-out);
}

.role svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.role:hover {
  border-color: var(--maroon-600);
  background: #fbf7ec;
}

.role:active {
  transform: scale(0.97);
}

.role:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}

.auth-foot {
  margin: 16px 0 0;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  color: #9c8f83;
}

/* Desktop sign-in: brand panel on the left, form on the right. The phone
   keeps the single centred card, so the brand panel stays hidden below 900px. */
@container app (min-width: 900px) {
  .auth {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    align-items: stretch;
    justify-content: normal;
    padding: 0;
    overflow: hidden;
    background: #1c1311;
  }

  .auth::before {
    display: none;
  }

  .auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 40px 44px;
    background:
      linear-gradient(180deg, rgba(23, 14, 12, 0.34), rgba(23, 14, 12, 0.8)),
      url("shelves.jpg") center / cover no-repeat;
    color: #f6efe2;
  }

  .auth-brand-head {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .auth-brand-head img {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
  }

  .auth-brand-head p {
    margin: 0;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(246, 239, 226, 0.84);
  }

  .auth-brand-body {
    margin: auto 0;
    max-width: 400px;
  }

  .auth-brand-eyebrow {
    margin: 0 0 12px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold-300);
  }

  .auth-brand-body h2 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(28px, 3vw, 38px);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
  }

  .auth-brand-foot {
    margin: 0;
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(246, 239, 226, 0.52);
  }

  .auth-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 44px clamp(36px, 5vw, 64px);
    border-radius: 0;
    background: #f4f1ea;
    box-shadow: none;
    overflow-y: auto;
    animation: none;
  }

  .auth-card > * {
    width: 100%;
    max-width: 368px;
  }

  /* The brand panel carries the crest and school name on desktop. */
  .auth-crest,
  .auth-school {
    display: none;
  }

  .auth-title {
    margin: 0 0 24px;
    text-align: left;
    font-size: 31px;
  }

  .auth-foot {
    display: none;
  }

  .field input {
    height: 44px;
    font-size: 13.5px;
  }

  .auth-submit {
    height: 46px;
    font-size: 13.5px;
  }

  .role {
    height: 62px;
    font-size: 11.5px;
  }
}

/* ---------- Dashboard ---------- */

.dash-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
}

.quick .btn {
  flex: 1;
}

.summary-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #eadfc6;
  border-radius: 10px;
  background: #fdf7e7;
  color: var(--amber-700);
  font-size: 11px;
}

.summary-note svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dash-note {
  margin: 12px 0 0;
  font-size: 10.5px;
  color: var(--ink-400);
}

/* ---------- Catalog ---------- */

.book-list {
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
  background: #fff;
}

.book-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
}

.book-row:first-child {
  border-top: 0;
}

.book-main {
  min-width: 0;
  flex: 1;
}

.book-title {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-900);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-meta {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: 10.5px;
  color: var(--ink-400);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.avail {
  font-size: 9.5px;
  color: var(--ink-400);
  white-space: nowrap;
}

/* ---------- Student ---------- */

.loan-strip {
  display: flex;
  gap: 9px;
  margin: 0 -16px 0;
  padding: 0 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.loan-strip::-webkit-scrollbar {
  display: none;
}

.strip-item {
  width: 96px;
  flex: none;
}

.strip-title {
  margin-top: 5px;
  overflow: hidden;
  font-size: 9.5px;
  line-height: 1.25;
  color: var(--ink-500);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fine-card {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
  padding: 12px 13px;
  border: 1px solid #e7cfc6;
  border-radius: 13px;
  background: #fdf1ec;
}

.fine-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: #f3dcd4;
  color: var(--red-700);
}

.fine-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fine-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.fine-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--red-700);
}

.fine-meta {
  font-size: 10.5px;
  color: #8d5a4d;
}

.fine-amount {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--red-700);
  font-variant-numeric: tabular-nums;
}

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.profile .avatar {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.profile-name {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--maroon-900);
}

.profile-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-400);
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
}

.kv dt {
  color: var(--ink-400);
}

.kv dd {
  margin: 0;
  font-weight: 500;
  color: var(--ink-900);
}

/* ---------- Modal ---------- */

.modal-layer {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(30, 16, 14, 0.44);
  animation: fadeIn 160ms var(--ease-out) both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  position: relative;
  width: 100%;
  max-width: 336px;
  padding: 18px;
  border-radius: 15px;
  background: var(--cream-50);
  box-shadow: 0 26px 50px -18px rgba(0, 0, 0, 0.45);
  animation: modalIn 220ms var(--ease-out) both;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--maroon-900);
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--ink-400);
}

.modal-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--cream-100);
  color: var(--ink-500);
  transition:
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}

.modal-close:hover {
  background: var(--cream-200);
  color: var(--ink-900);
}

.modal-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal-field {
  margin-bottom: 10px;
}

.modal-field label {
  display: block;
  margin-bottom: 4px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.modal-field select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-900);
  font-size: 12px;
  outline: none;
}

.modal-field select:focus {
  border-color: var(--maroon-600);
  box-shadow: 0 0 0 3px rgba(107, 21, 40, 0.1);
}

.modal-book {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.modal-note {
  margin: 0 0 12px;
  font-size: 10.5px;
  color: var(--ink-400);
}

.modal-actions {
  display: flex;
  gap: 7px;
  margin-top: 14px;
}

.modal-actions .btn {
  flex: 1;
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  bottom: 78px;
  left: 50%;
  z-index: 70;
  max-width: calc(100% - 28px);
  overflow: hidden;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 99px;
  background: var(--maroon-900);
  color: #fbf3e4;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.5);
  animation: toastIn 220ms var(--ease-out) both;
}

.toast.is-leaving {
  animation: toastOut 160ms var(--ease-in) both;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}

/* ---------- Wide layout ----------
   Container query on .app, so the whole layout responds to the device's own
   width. This is what makes the phone → desktop morph work without reloading. */

@container app (min-width: 720px) {
  .shell {
    grid-template-columns: 212px minmax(0, 1fr);
  }

  .sidebar-inner {
    opacity: 1;
    transform: none;
  }

  .sidebar {
    visibility: visible;
  }

  .topbar {
    height: 60px;
    padding: 0 28px;
  }

  .topbar-mobile {
    display: none;
  }

  .topbar-desktop {
    display: flex;
  }

  .topbar-signout {
    display: none;
  }

  .scroll {
    padding: 26px 30px 32px;
  }

  .tabbar {
    transform: translateY(110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 280ms var(--ease-out),
      opacity 180ms var(--ease-out),
      visibility 0s linear 280ms;
  }

  .page-head {
    margin-bottom: 20px;
  }

  h1 {
    font-size: 29px;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 11px;
    margin-bottom: 18px;
  }

  .stat {
    padding: 13px 14px 14px;
  }

  .stat-value {
    font-size: 25px;
  }

  .dash-grid {
    gap: 14px;
  }

  .quick {
    max-width: 340px;
  }

  .cover-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .loan-strip {
    margin: 0;
    padding: 0;
    gap: 12px;
  }

  .strip-item {
    width: 116px;
  }

  .strip-title {
    font-size: 10px;
  }

  .modal {
    max-width: 380px;
    padding: 20px;
  }

  .toast {
    bottom: 22px;
  }
}

@container app (min-width: 940px) {
  .dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    align-items: start;
  }

  .cover-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .book-row {
    padding: 10px 14px;
  }

  .stack-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}
