:root {
  --paper: #f8f1e4;
  --ink: #1b1a18;
  --muted: #60584d;
  --accent: #b35c2e;
  --accent-soft: #e8c1aa;
  --panel: rgba(255, 251, 245, 0.82);
  --line: rgba(27, 26, 24, 0.12);
  --shadow: 0 20px 50px rgba(81, 50, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(179, 92, 46, 0.18), transparent 32%),
    radial-gradient(circle at right center, rgba(114, 138, 103, 0.18), transparent 24%),
    linear-gradient(180deg, #fffaf2 0%, var(--paper) 100%);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(179, 92, 46, 0.32);
  outline-offset: 3px;
}

h1,
h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}

p,
li {
  line-height: 1.6;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(18px);
  background: rgba(248, 241, 228, 0.7);
  border-bottom: 1px solid rgba(27, 26, 24, 0.08);
}

.topbar__inner {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.9rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.topnav__link {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
}

.topnav__link:hover {
  background: rgba(179, 92, 46, 0.08);
  color: var(--ink);
}

.topnav__link--active {
  background: rgba(179, 92, 46, 0.12);
  color: var(--ink);
  font-weight: 600;
}

.flash-stack {
  width: min(1120px, calc(100% - 2rem));
  margin: 1rem auto 0;
}

.flash {
  margin: 0 0 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.flash--notice {
  border-color: rgba(51, 132, 94, 0.4);
  background: rgba(51, 132, 94, 0.08);
  color: #1f5c40;
}

.flash--notice::before {
  content: "✓ ";
  font-weight: 700;
}

.flash--alert {
  border-color: rgba(178, 58, 44, 0.4);
  background: rgba(178, 58, 44, 0.08);
  color: #8a2c21;
}

.flash--alert::before {
  content: "✕ ";
  font-weight: 700;
}

mark {
  background: rgba(214, 158, 46, 0.35);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

mark.reader-highlight {
  background: rgba(214, 158, 46, 0.55);
  box-shadow: 0 0 0 3px rgba(214, 158, 46, 0.25);
}

.chunk-card--clickable {
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chunk-card--clickable:hover {
  border-color: rgba(179, 92, 46, 0.45);
  box-shadow: 0 4px 14px rgba(60, 42, 30, 0.08);
}

/* Stretched link: el enlace del título cubre toda la tarjeta */
.chunk-card--clickable .chunk-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.status-badge {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-badge--pending,
.status-badge--extracting {
  background: rgba(214, 158, 46, 0.14);
  border-color: rgba(214, 158, 46, 0.4);
  color: #8a6414;
}

.status-badge--extracting {
  animation: badge-pulse 1.6s ease-in-out infinite;
}

.status-badge--chunked {
  background: rgba(51, 132, 94, 0.12);
  border-color: rgba(51, 132, 94, 0.4);
  color: #1f5c40;
}

.status-badge--failed {
  background: rgba(178, 58, 44, 0.1);
  border-color: rgba(178, 58, 44, 0.4);
  color: #8a2c21;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.shell--narrow {
  width: min(980px, calc(100% - 2rem));
}

.shell--form {
  width: min(780px, calc(100% - 2rem));
}

.shell--wide {
  width: min(1520px, calc(100% - 2rem));
}

.shell--reader {
  width: min(1840px, calc(100% - 2rem));
}

.hero {
  padding: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 242, 231, 0.88));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(3rem, 9vw, 5rem);
}

.lede {
  max-width: 44rem;
  margin: 1rem 0 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.hero-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover,
.stat-card--link:hover,
.panel-link:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.button--primary {
  background: var(--accent);
  color: #fff9f0;
  border-color: transparent;
}

.button--danger {
  background: #8b2e2e;
  color: #fff7f3;
  border-color: transparent;
}

.button--small {
  min-height: 2.35rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.95rem;
}

.button--loading {
  position: relative;
  gap: 0.55rem;
}

.button--loading::after {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: button-spin 0.8s linear infinite;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.breadcrumbs a {
  color: var(--accent);
  font-weight: 600;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.stats-grid,
.panel-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.panel-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.stat-card,
.panel {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.stat-card--link {
  display: block;
}

.stat-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 2.1rem;
  font-weight: 700;
}

.stat-value--small {
  font-size: 1.2rem;
  text-transform: uppercase;
}

.stat-card__action,
.text-link {
  display: inline-flex;
  margin-top: 0.55rem;
  color: var(--accent);
  font-weight: 700;
  line-height: 1.4;
  text-decoration: underline;
  text-decoration-color: rgba(179, 92, 46, 0.3);
  text-underline-offset: 0.22em;
}

.stat-card__action:hover,
.text-link:hover {
  text-decoration-color: currentColor;
}

.text-link--muted {
  color: var(--muted);
  font-weight: 600;
}

.panel h2 {
  font-size: 1.55rem;
  margin-bottom: 0.75rem;
}

.panel-link {
  display: inline-flex;
  margin-bottom: 0.85rem;
  color: var(--accent);
  font-weight: 700;
}

.panel ul,
.panel ol {
  margin: 0;
  padding-left: 1.1rem;
}

.panel--wide {
  grid-column: span 2;
}

.panel--stack {
  margin-top: 1.5rem;
}

.knowledge-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.reading-home {
  width: min(1080px, calc(100% - 2rem));
}

.reading-home__head {
  margin-bottom: 1.75rem;
}

.reading-home__head h1 {
  font-size: clamp(2.8rem, 7vw, 4.8rem);
}

.reading-browser {
  display: grid;
  grid-template-columns: minmax(250px, 0.72fr) minmax(420px, 1.28fr);
  gap: 1rem;
  align-items: start;
}

.reading-panel {
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.reading-panel__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.25rem 0.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.reading-panel__head h2,
.reading-panel__head p {
  margin: 0;
}

.reading-panel__head--with-action {
  align-items: center;
}

.reading-panel__head--with-action > div {
  min-width: 0;
  margin-right: auto;
}

.reading-panel__add {
  flex: 0 0 auto;
}

.reading-panel__head h2 {
  font-size: 1.45rem;
}

.reading-panel__head p {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 2rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(179, 92, 46, 0.12);
  color: var(--accent);
  font-weight: 800;
}

.reading-options {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.reading-options--resources {
  max-height: min(48vh, 32rem);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.reading-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  min-height: 4rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 15px;
  color: var(--ink);
}

.reading-option:hover {
  background: rgba(255, 255, 255, 0.64);
  border-color: var(--line);
}

.reading-option--active {
  border-color: rgba(179, 92, 46, 0.32);
  background: rgba(179, 92, 46, 0.09);
}

.reading-option > span:first-child {
  display: grid;
  min-width: 0;
}

.reading-option strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.reading-option small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.reading-option__description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.35;
}

.reading-option__arrow {
  color: var(--accent);
  font-weight: 800;
}

.reading-panel__footer-link {
  display: inline-flex;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.reading-panel__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0.25rem 0.2rem;
}

.reading-resource-panels {
  min-width: 0;
}

.continue-reading {
  display: grid;
  gap: 1.1rem;
  min-height: 13rem;
  margin-top: 1rem;
  padding: 1.2rem;
  border-radius: 18px;
  background: rgba(27, 26, 24, 0.045);
}

.continue-reading__label,
.continue-reading h3 {
  margin: 0;
}

.continue-reading__label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.continue-reading h3 {
  margin-top: 0.2rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.45rem;
}

.continue-reading__body {
  align-self: start;
}

.continue-reading__preview {
  display: -webkit-box;
  max-width: 64ch;
  margin: 0.75rem 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--muted);
  line-height: 1.55;
}

.continue-reading__meta {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.continue-reading__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  align-self: end;
}

.reading-home__empty {
  max-width: 42rem;
}

.knowledge-flow > div {
  padding: 1rem;
  border-left: 3px solid var(--accent-soft);
  background: rgba(255, 255, 255, 0.42);
}

.knowledge-flow p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.library-page-head {
  align-items: center;
}

.library-nav {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1.5rem;
  padding: 0.35rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 251, 245, 0.66);
  box-shadow: 0 8px 24px rgba(81, 50, 31, 0.06);
}

.library-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  min-height: 2.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
}

.library-nav__link:hover,
.library-nav__link--active {
  color: var(--ink);
  background: rgba(179, 92, 46, 0.1);
}

.library-nav__link--active {
  font-weight: 700;
}

.library-nav__link span {
  min-width: 1.45rem;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  background: rgba(27, 26, 24, 0.07);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.library-guide {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 251, 245, 0.72);
  box-shadow: var(--shadow);
}

.section-intro {
  max-width: 48rem;
}

.section-intro h2 {
  font-size: 1.8rem;
}

.section-intro > p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.content-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.35rem;
}

.content-type-card {
  padding: 1.2rem;
  border: 1px solid rgba(27, 26, 24, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.54);
}

.content-type-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.content-type-card h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.35rem;
}

.content-type-card h3 small {
  color: var(--muted);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
}

.content-type-card p {
  color: var(--muted);
}

.content-type-card__count {
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 700;
}

.content-type-card__actions,
.card-text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.content-type-card__actions .text-link,
.card-text-actions .text-link {
  margin-top: 0;
}

.library-recent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.plain-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid rgba(27, 26, 24, 0.08);
}

.row-link:hover strong {
  color: var(--accent);
}

.row-link span:first-child {
  display: grid;
}

.row-link small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.action-menu {
  position: relative;
}

.action-menu > summary {
  min-height: 2.9rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 600;
}

.action-menu > summary::-webkit-details-marker {
  display: none;
}

.action-menu > summary::after {
  content: " ···";
  color: var(--muted);
}

.action-menu__content {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 5;
  display: grid;
  min-width: 13rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  box-shadow: var(--shadow);
}

.action-menu__content a,
.action-menu__content button {
  width: 100%;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.action-menu__content a:hover,
.action-menu__content button:hover {
  background: rgba(27, 26, 24, 0.06);
}

.action-menu__content .action-menu__danger {
  color: #8b2e2e;
}

.progress-bar {
  width: 100%;
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(27, 26, 24, 0.08);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(179, 92, 46, 0.92), rgba(114, 138, 103, 0.9));
}

.list-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.two-column-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.2fr);
  gap: 1rem;
}

.two-column-layout--reader {
  grid-template-columns: minmax(0, 1.28fr) minmax(560px, 1.12fr);
  gap: 1.25rem;
}

.reader-layout {
  align-items: stretch;
}

.library-reader-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.5fr) minmax(0, 1.5fr);
  gap: 1.25rem;
  align-items: start;
}

.library-reader-toc {
  position: sticky;
  top: 5.5rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

.library-reader-toc__list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.library-reader-toc__divider {
  height: 1px;
  margin: 1.15rem 0;
  background: rgba(27, 26, 24, 0.08);
}

.library-reader-toc__item {
  display: block;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(27, 26, 24, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.library-reader-toc__item--active {
  border-color: rgba(179, 92, 46, 0.28);
  background: rgba(179, 92, 46, 0.1);
}

.library-reader-toc__eyebrow,
.library-reader-toc__title,
.library-reader-toc__meta {
  margin: 0;
}

.library-reader-toc__eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-reader-toc__title {
  margin-top: 0.35rem;
  font-weight: 700;
}

.library-reader-toc__meta {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.library-reader-main {
  min-width: 0;
}

.reader-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  align-self: start;
  position: sticky;
  top: 5.5rem;
  height: calc(100vh - 7rem);
}

.reader-sidebar {
  display: grid;
  gap: 1rem;
  align-content: start;
  min-width: 0;
}

.study-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(500px, 0.96fr);
  gap: 1.25rem;
  align-items: start;
}

.list-card,
.form-card,
.empty-state {
  padding: 1.35rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 251, 245, 0.84);
  box-shadow: var(--shadow);
}

.list-card h2 {
  margin-bottom: 0.65rem;
  font-size: 1.9rem;
}

.batch-form {
  display: grid;
  gap: 1rem;
}

.batch-toolbar {
  position: sticky;
  top: 4.7rem;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.94);
  box-shadow: 0 10px 28px rgba(81, 50, 31, 0.1);
  backdrop-filter: blur(16px);
}

.batch-toolbar__count {
  margin: 0 auto 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.selection-control {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-weight: 600;
}

.selection-control input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}

.selection-control--card {
  margin-bottom: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.list-card--selectable {
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.list-card--selectable.is-selected {
  border-color: rgba(179, 92, 46, 0.5);
  background: rgba(255, 246, 235, 0.96);
  box-shadow: 0 0 0 3px rgba(179, 92, 46, 0.08), var(--shadow);
}

.weakness-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-badge--weakness-active {
  background: rgba(179, 92, 46, 0.1);
  border-color: rgba(179, 92, 46, 0.28);
  color: #8d4523;
}

.status-badge--weakness-resolved {
  background: rgba(51, 132, 94, 0.1);
  border-color: rgba(51, 132, 94, 0.3);
  color: #1f5c40;
}

.status-badge--weakness-archived {
  background: rgba(27, 26, 24, 0.06);
  border-color: rgba(27, 26, 24, 0.14);
  color: var(--muted);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.quiz-generator-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 0.75rem;
}

.quiz-generator-form .field {
  margin: 0;
}

.collapse-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  padding: 0.9rem 1.1rem;
}

.collapse-panel > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.collapse-panel > summary:hover {
  color: var(--ink);
}

.collapse-panel[open] > summary {
  margin-bottom: 1rem;
}

.meta-line {
  margin: 0.15rem 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.stack-form.is-loading {
  opacity: 0.88;
}

.form-split {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field--wide {
  grid-column: 1 / -1;
}

.field span {
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(27, 26, 24, 0.15);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  font: inherit;
}

.field select[multiple] {
  min-height: 10rem;
}

.search-form {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1.6fr 0.8fr auto;
  align-items: end;
}

.form-errors {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(179, 92, 46, 0.08);
  border: 1px solid rgba(179, 92, 46, 0.18);
}

.form-errors ul {
  margin: 0.5rem 0 0;
}

.assistant-meta {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(27, 26, 24, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.assistant-meta p {
  margin: 0.35rem 0;
}

.iterate-form {
  margin-top: 1rem;
}

.chunk-list {
  display: grid;
  gap: 0.9rem;
}

.chunk-card {
  padding: 1rem;
  border: 1px solid rgba(27, 26, 24, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.tip-box {
  padding: 1rem;
  border: 1px dashed rgba(27, 26, 24, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.tip-box p {
  margin-bottom: 0;
}

.reader-surface {
  flex: 1 1 auto;
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow: auto;
  padding: 1.5rem 1.65rem;
  border: 1px solid rgba(27, 26, 24, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
}

.reader-surface .markdown-body {
  font-size: 1.08rem;
  max-width: 92ch;
}

.reader-surface .markdown-paragraph,
.reader-surface .markdown-body p {
  line-height: 1.8;
}

.reader-surface .markdown-codeblock {
  max-width: 100%;
}

.reader-surface--book {
  min-height: 76vh;
}

.reader-outline__list {
  display: grid;
  gap: 0.5rem;
}

.reader-outline-panel {
  position: relative;
  padding: 1rem 1.15rem;
  overflow: visible;
}

.reader-outline-panel__summary {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
}

.reader-outline-panel__summary::-webkit-details-marker {
  display: none;
}

.reader-outline-panel__summary h2,
.reader-outline-panel__summary p {
  margin: 0;
}

.reader-outline-panel__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 5.6rem;
  min-height: 2.2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(27, 26, 24, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.reader-outline-panel[open] .reader-outline-panel__toggle::before {
  content: "Ocultar";
}

.reader-outline-panel:not([open]) .reader-outline-panel__toggle::before {
  content: "Mostrar";
}

.reader-outline-panel__body {
  position: absolute;
  top: calc(100% + 0.55rem);
  left: 0;
  right: 0;
  display: none;
  max-height: 28rem;
  overflow: auto;
  padding: 1rem;
  border: 1px solid rgba(27, 26, 24, 0.08);
  border-radius: 18px;
  background: rgba(255, 251, 245, 0.98);
  box-shadow: var(--shadow);
  z-index: 4;
}

.reader-outline-panel[open] .reader-outline-panel__body {
  display: block;
}

.reader-outline__list--compact {
  margin-top: 0.85rem;
}

.reader-outline__item {
  display: block;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.reader-outline__item:hover {
  color: var(--ink);
}

.reader-outline__item--level-2 {
  font-weight: 700;
}

.reader-outline__item--level-3 {
  padding-left: 0.9rem;
}

.reader-outline__item--level-4 {
  padding-left: 1.6rem;
  font-size: 0.9rem;
}

.quiz-question-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(27, 26, 24, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
}

.quiz-question-card + .quiz-question-card {
  margin-top: 0.85rem;
}

.quiz-question-card__index {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.quiz-question-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.1rem;
}

.quiz-question-card .field {
  margin-top: 0.25rem;
}

.quiz-answer-input {
  width: 100%;
  min-height: 9.5rem;
  padding: 1rem 1.05rem;
  border: 1px solid rgba(27, 26, 24, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  font: inherit;
  line-height: 1.6;
  resize: vertical;
}

.quiz-answer-input:focus {
  outline: 2px solid rgba(184, 100, 52, 0.18);
  outline-offset: 2px;
  border-color: rgba(184, 100, 52, 0.45);
}

.quiz-result {
  margin-top: 0.9rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.quiz-result--correct {
  background: rgba(51, 132, 94, 0.1);
}

.quiz-result--partial {
  background: rgba(179, 92, 46, 0.1);
}

.quiz-result--needs_work {
  background: rgba(139, 46, 46, 0.1);
}

.quiz-result__status {
  margin: 0 0 0.45rem;
  font-weight: 700;
}

.session-progress {
  display: grid;
  gap: 0.55rem;
  max-width: 44rem;
  margin-top: 1rem;
}

.prose-block {
  white-space: pre-wrap;
}

.markdown-body {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-paragraph,
.markdown-body p {
  margin: 0.8rem 0;
  line-height: 1.65;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1rem 0 0.55rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  letter-spacing: -0.02em;
}

.markdown-h2 {
  font-size: 1.35rem;
}

.markdown-h3 {
  font-size: 1.15rem;
}

.markdown-h4 {
  font-size: 1rem;
}

.markdown-list {
  margin: 0.8rem 0 0.8rem 1.25rem;
  padding: 0;
}

.markdown-list li {
  margin: 0.35rem 0;
}

.markdown-inline-code {
  padding: 0.12rem 0.38rem;
  border-radius: 8px;
  background: rgba(27, 26, 24, 0.08);
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.94em;
}

.markdown-codeblock {
  margin: 0.95rem 0;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 18px;
  background: #f3ede4;
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.markdown-codeblock__code {
  display: block;
  white-space: pre;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.markdown-mermaid {
  margin: 0.95rem 0;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.markdown-mermaid__source {
  margin: 0;
  white-space: pre;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.95rem;
  line-height: 1.6;
}

.markdown-mermaid--rendered {
  background: #fffdfa;
}

.markdown-mermaid--rendered svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.markdown-mermaid__error {
  margin: 0.75rem 0 0;
  color: #8b2e2e;
  font-size: 0.95rem;
}

.markdown-blockquote {
  margin: 0.95rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 4px solid rgba(179, 92, 46, 0.38);
  color: var(--muted);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.markdown-body--compact {
  font-size: 1rem;
}

.markdown-body--subtle {
  color: var(--muted);
}

.study-context,
.study-answer {
  margin-top: 1.2rem;
}

.study-chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-content: start;
  min-height: 0;
}

.grade-strip {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 1rem;
}

.grade-chip {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(27, 26, 24, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.grade-chip--active {
  border-color: transparent;
  box-shadow: inset 0 0 0 2px rgba(27, 26, 24, 0.06);
}

.grade-chip--again.grade-chip--active {
  background: rgba(139, 46, 46, 0.16);
}

.grade-chip--hard.grade-chip--active {
  background: rgba(179, 92, 46, 0.16);
}

.grade-chip--good.grade-chip--active {
  background: rgba(114, 138, 103, 0.18);
}

.grade-chip--easy.grade-chip--active {
  background: rgba(51, 132, 94, 0.18);
}

.grade-chip__label,
.grade-chip__copy {
  margin: 0;
}

.grade-chip__label {
  font-weight: 700;
}

.grade-chip__copy {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.study-chat__head h2,
.study-context h2,
.study-answer h2 {
  margin-bottom: 0.35rem;
}

.study-chat__history {
  display: grid;
  flex: 1 1 auto;
  gap: 0.85rem;
  min-height: 18rem;
  max-height: min(56vh, 44rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 0.1rem;
}

.chat-turn {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(27, 26, 24, 0.1);
  background: rgba(255, 255, 255, 0.56);
  overflow: hidden;
}

.chat-turn--user {
  background: rgba(179, 92, 46, 0.09);
  border-color: rgba(179, 92, 46, 0.2);
}

.chat-turn--pending {
  opacity: 0.86;
}

.chat-turn--failed {
  border-color: rgba(139, 46, 46, 0.24);
  background: rgba(139, 46, 46, 0.08);
  opacity: 1;
}

.chat-turn__role,
.chat-turn__meta {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.chat-turn__tables {
  margin-top: 0.9rem;
}

.chat-turn__meta-block {
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(27, 26, 24, 0.08);
}

.study-chat .markdown-codeblock {
  overflow-x: visible;
}

.study-chat .markdown-codeblock__code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.empty-state--soft {
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}

.example-table-card {
  margin-top: 0.9rem;
  padding: 1rem;
  border: 1px solid rgba(27, 26, 24, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.example-table-card__head h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.example-table-card__head p {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

.example-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

.example-table th,
.example-table td {
  padding: 0.8rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid rgba(27, 26, 24, 0.08);
}

.example-table thead th {
  background: rgba(27, 26, 24, 0.06);
  font-weight: 700;
}

.markdown-table {
  margin: 1rem 0;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 1rem, 1120px);
    padding-top: 1rem;
  }

  .hero {
    padding: 1.5rem;
  }

  .topbar__inner,
  .page-head,
  .search-form {
    display: grid;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .knowledge-flow,
  .content-map,
  .library-recent-grid,
  .reading-browser {
    grid-template-columns: 1fr;
  }

  .reading-home__head h1 {
    font-size: 2.8rem;
  }

  .continue-reading {
    min-height: 0;
  }

  .continue-reading__actions {
    display: grid;
    justify-content: stretch;
  }

  .reading-panel__head--with-action {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .reading-panel__add {
    width: 100%;
  }

  .library-guide {
    padding: 1rem;
  }

  .batch-toolbar {
    top: 4.4rem;
    flex-wrap: wrap;
  }

  .batch-toolbar__count {
    order: 3;
    flex-basis: 100%;
  }

  .action-menu__content {
    right: auto;
    left: 0;
  }

  .panel--wide {
    grid-column: span 1;
  }

  .form-split {
    grid-template-columns: 1fr;
  }

  .two-column-layout {
    grid-template-columns: 1fr;
  }

  .study-layout {
    grid-template-columns: 1fr;
  }

  .library-reader-layout {
    grid-template-columns: 1fr;
  }

  .library-reader-toc {
    position: static;
    max-height: none;
  }

  .reader-pane {
    position: static;
    top: auto;
    height: auto;
  }

  .reader-surface {
    height: auto;
    min-height: 24rem;
  }
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}
