.page-content {
  padding: 28px;
}

.library-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
}

.library-column,
.detail-column,
.stack {
  display: grid;
  gap: 22px;
}

.hero-panel {
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -8% -30% auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(47, 111, 95, 0.22), transparent 70%);
  pointer-events: none;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.hero-copy {
  margin: 0;
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.7;
}

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

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-actions .btn,
.detail-actions a.btn {
  min-height: 46px;
}

.input,
.select {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 0 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(47, 111, 95, 0.22);
  border-color: rgba(47, 111, 95, 0.45);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.8fr;
  gap: 12px;
}

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

.book-card {
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 246, 240, 0.96));
  box-shadow: var(--shadow-soft);
  padding: 18px;
  display: grid;
  gap: 14px;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.book-card:hover,
.book-card:focus-visible,
.book-card.active {
  transform: translateY(-2px);
  border-color: rgba(47, 111, 95, 0.36);
  box-shadow: var(--shadow);
  outline: none;
}

.book-card-head {
  display: grid;
  gap: 8px;
}

.book-folder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-strong);
  background: rgba(47, 111, 95, 0.1);
}

.book-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.28;
  letter-spacing: -0.03em;
}

.book-author {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.book-preview {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.62;
  min-height: 5.3em;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(33, 27, 22, 0.06);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.book-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.book-footer .btn {
  min-height: 44px;
}

.detail-shell {
  min-height: 860px;
}

.detail-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink-soft);
  padding: 24px;
}

.detail-head {
  display: grid;
  gap: 14px;
}

.detail-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 2.2vw, 2.4rem);
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.detail-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.65;
}

.usecase-box {
  border-radius: 20px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(47, 111, 95, 0.1), rgba(47, 111, 95, 0.04));
  border: 1px solid rgba(47, 111, 95, 0.18);
  display: grid;
  gap: 10px;
}

.usecase-title {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
}

.usecase-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.book-content {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  padding: 18px;
  max-height: 540px;
  overflow: auto;
}

.book-content h1,
.book-content h2,
.book-content h3 {
  margin: 1.2em 0 0.5em;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.book-content h1:first-child,
.book-content h2:first-child,
.book-content h3:first-child,
.book-content p:first-child {
  margin-top: 0;
}

.book-content p,
.book-content li {
  color: var(--ink-soft);
  line-height: 1.72;
}

.book-content ul {
  margin: 0.7em 0 1.1em;
  padding-left: 18px;
}

.book-content pre {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
}

.detail-actions a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.empty-results {
  border: 1px dashed var(--line-strong);
  border-radius: 24px;
  padding: 28px;
  text-align: center;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 22px;
}

.editor-layout--focus {
  grid-template-columns: minmax(0, 1fr);
}

.editor-shell {
  display: grid;
  gap: 22px;
}

.editor-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.editor-toolbar .btn,
.editor-toolbar a.btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.editor-textarea {
  width: 100%;
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  padding: 20px;
  resize: vertical;
  line-height: 1.72;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.editor-textarea:focus {
  outline: 2px solid rgba(47, 111, 95, 0.22);
  border-color: rgba(47, 111, 95, 0.45);
}

.editor-preview {
  max-width: none;
  max-height: 72vh;
  overflow: auto;
}

.editor-preview--raw {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font: inherit;
  line-height: 1.8;
}

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

.editor-field {
  display: grid;
  gap: 10px;
}

.editor-field-label {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
}

.editor-side-textarea {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.62;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.editor-side-textarea:focus {
  outline: 2px solid rgba(47, 111, 95, 0.22);
  border-color: rgba(47, 111, 95, 0.45);
}

.stat-box {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.stat-box strong {
  display: block;
  font-size: 1.15rem;
  font-family: var(--font-display);
}

.stat-box span {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.editor-note {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.66;
}

@media (max-width: 980px) {
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    max-width: none;
  }
}

@media (max-width: 1180px) {
  .library-layout {
    grid-template-columns: 1fr;
  }

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

  .detail-shell {
    min-height: 0;
  }
}

@media (max-width: 860px) {
  .page-content {
    padding: 18px;
  }

  .filter-grid,
  .metric-strip.library,
  .shelf-grid {
    grid-template-columns: 1fr;
  }

  .book-footer,
  .panel-actions,
  .detail-actions,
  .editor-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-actions .btn,
  .detail-actions a.btn,
  .editor-toolbar .btn,
  .editor-toolbar a.btn,
  .book-footer .btn {
    width: 100%;
  }

  .book-content,
  .editor-preview,
  .editor-textarea {
    max-height: none;
    min-height: 58vh;
  }
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 2.2rem;
  }

  .book-card,
  .panel-inner,
  .panel-header {
    padding-left: 16px;
    padding-right: 16px;
  }

  .detail-title {
    font-size: 1.45rem;
  }

  .editor-stat-grid {
    grid-template-columns: 1fr;
  }

  .empty-results {
    padding: 22px 18px;
  }
}
