.rl-section {
  margin-bottom: var(--space-8);
}

.rl-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: var(--space-5);
  overflow: hidden;
}

.rl-section summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: var(--space-4) var(--space-5);
}

.rl-section summary::-webkit-details-marker {
  display: none;
}

.rl-section[open] summary {
  border-bottom: 1px solid var(--border);
}

.rl-section-heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
}

.rl-section-heading::after {
  content: "›";
  font-size: 1.1rem;
  color: var(--muted);
  margin-left: auto;
  transition: transform 0.2s;
  display: inline-block;
}

.rl-section[open] .rl-section-heading::after {
  transform: rotate(90deg);
}

.rl-locked-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.rl-card--locked {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.rl-level-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
}

/* Fade-in when section opens */
@keyframes rl-section-in {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

details.rl-section[open] .rl-section-inner {
  animation: rl-section-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.rl-section-inner {
  padding-bottom: var(--space-3);
}

.rl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5);
  padding-bottom: var(--space-2);
}

/* Card wrapper — holds the card link + complete button */
.rl-card-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.rl-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}

.rl-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Completed card */
.rl-card--done {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.rl-card--done:hover {
  opacity: 0.7;
  border-color: var(--border);
  transform: none;
}

/* "✓ Read" badge on completed card */
.rl-done-card-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: color-mix(in srgb, #10b981 14%, var(--surface));
  color: #10b981;
  border: 1px solid color-mix(in srgb, #10b981 30%, transparent);
  border-radius: 999px;
  padding: 2px 7px;
  pointer-events: none;
  z-index: 2;
}

/* Mark-as-read button below each card */
.rl-complete-btn {
  width: 100%;
  padding: 5px var(--space-3);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.rl-complete-btn:hover {
  color: #10b981;
  border-color: #10b981;
  border-style: solid;
  background: color-mix(in srgb, #10b981 6%, transparent);
}

.rl-complete-btn--done {
  color: #10b981;
  border-color: color-mix(in srgb, #10b981 30%, transparent);
  border-style: solid;
}

.rl-complete-btn--done:hover {
  color: var(--muted);
  border-color: var(--border);
  border-style: dashed;
  background: transparent;
}

/* Completed section divider */
.rl-completed-section {
  padding: 0 var(--space-5) var(--space-3);
}

.rl-completed-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.rl-grid--completed {
  padding: 0;
}

/* "X read" count in section header */
.rl-count-done {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  margin-left: auto;
  margin-right: var(--space-4);
}

.rl-level {
  align-self: flex-start;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}

.rl-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Section header homework indicator */
.rl-section-hw-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #e07c3a;
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  box-shadow: 0 1px 6px rgba(224,124,58,0.5);
  animation: rl-badge-pop 0.2s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes rl-badge-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Homework text card */
.rl-card--hw {
  position: relative;
  border-color: rgba(224,124,58,0.45);
  overflow: hidden;
  animation: rl-card-pulse 3s ease-in-out infinite;
}

.rl-card--hw::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,0.07) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: rl-card-shine 2.6s ease-in-out 0.4s infinite;
  pointer-events: none;
  border-radius: inherit;
}

@keyframes rl-card-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
  50%       { box-shadow: 0 2px 18px rgba(224,124,58,0.18); }
}

@keyframes rl-card-shine {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Homework badge inside card (top-right) */
.rl-hw-card-badge {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #e07c3a;
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  box-shadow: 0 1px 6px rgba(224,124,58,0.5);
  pointer-events: none;
  z-index: 2;
}

.rl-hw-badge {
  display: inline-block;
  margin-left: var(--space-2);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  vertical-align: middle;
  line-height: 1.4;
}

/* Progress bar in section header */
.rl-progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  margin-right: var(--space-4);
}

.rl-progress-bar {
  width: 80px;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.rl-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.rl-progress-label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Word count inside text card */
.rl-word-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: var(--space-1);
}

.rl-preview {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Shelf hub (bento) ────────────────────────────────────────────────────── */

.rl-hub-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

/* Faint stack of titles behind each shelf tile, so the three cards read as
   different places rather than three copies of the same box. */
.rl-bento-bg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  padding: 14px 16px 0;
  overflow: hidden;
  pointer-events: none;
  mask-image: linear-gradient(180deg, #000 0%, transparent 82%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 82%);
}

.rl-bento-slip {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 3px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
}

/* ── Ordered book view ────────────────────────────────────────────────────── */

.rc-book-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 20px;
}

.rc-book-bar {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}

.rc-book-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #ec4899);
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.rc-book-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.rc-chapters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rc-chapter {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.rc-chapter:hover { border-color: var(--accent); }

.rc-chapter .rl-complete-btn { width: auto; flex-shrink: 0; }

.rc-chapter--next {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-2));
}

.rc-chapter--done { opacity: 0.62; }
.rc-chapter--locked { opacity: 0.5; }

.rc-chapter-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.rc-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  background: var(--surface-3);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.rc-num--done { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.rc-num--next { background: var(--accent); color: #fff; }

.rc-chapter-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.rc-chapter-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rc-chapter-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
}

.rc-chapter-level {
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-3);
}

.rc-chapter-hw {
  font-weight: 700;
  color: var(--accent);
}

.rc-chapter-next {
  font-weight: 700;
  color: var(--accent);
}

.rc-lock { flex-shrink: 0; font-size: 0.9rem; }

@media (max-width: 700px) {
  .rc-chapter { flex-wrap: wrap; }
  .rc-chapter .rl-complete-btn { width: 100%; }
}
