:root {
  --library-navigation-width: 17rem;
}

.library-layout {
  min-height: 100vh;
}

.library-navigation {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  width: min(82vw, var(--library-navigation-width));
  height: 100vh;
  padding: 2rem 1.35rem;
  overflow-y: auto;
  border-right: 1px solid #d8dee3;
  background: #f7f8f6;
  box-shadow: 8px 0 24px rgba(28, 43, 34, 0.14);
  color: #26332c;
}

.library-home {
  display: inline-block;
  margin-bottom: 1.35rem;
  color: #17222b;
  font: 750 1.1rem/1.2 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.library-navigation ol {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library-item {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  gap: 0.35rem;
  align-items: baseline;
}

.library-marker {
  font-size: 0.78rem;
  text-align: center;
}

.library-item a {
  padding: 0.5rem 0.45rem;
  border-radius: 0.35rem;
  color: #405249;
  font: 560 0.9rem/1.35 ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
}

.library-item a:hover {
  background: #e9eeea;
  color: #183f2b;
}

.library-item a[aria-current="page"] {
  background: #dce9e0;
  color: #174f33;
  font-weight: 750;
}

.library-content {
  min-width: 0;
}

.library-navigation-toggle.library-navigation-toggle {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 30;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  min-height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  color: #405249;
  box-shadow: 0 1px 6px rgba(28, 43, 34, 0.12);
  font: 0/0 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.38;
  transition: opacity 120ms ease;
}

.library-navigation-toggle::before {
  content: "×";
  font: 500 1.2rem/1 ui-sans-serif, system-ui, sans-serif;
}

.library-navigation-collapsed .library-navigation-toggle::before {
  content: "☰";
  font-size: 0.9rem;
}

.library-navigation-toggle:hover {
  color: #174f33;
  opacity: 0.9;
}

body:not(.library-navigation-collapsed) .library-navigation-toggle {
  color: #174f33;
  opacity: 0.78;
}

.library-navigation-toggle:focus-visible {
  outline: 3px solid rgba(42, 118, 80, 0.25);
  outline-offset: 2px;
}

.library-navigation-collapsed .library-navigation {
  display: none;
}

.library-toggle-open,
.library-toggle-closed {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.library-dialog {
  width: min(calc(100% - 2rem), 34rem);
  max-height: min(80vh, 38rem);
  margin: auto;
  padding: 1.35rem;
  overflow: auto;
  border: 1px solid #c9d1cc;
  border-radius: 0.75rem;
  background: #fff;
  color: #17222b;
  box-shadow: 0 18px 60px rgba(28, 43, 34, 0.18);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.library-dialog::backdrop {
  background: rgba(38, 51, 44, 0.14);
  backdrop-filter: blur(2px);
}

.library-dialog-close.library-dialog-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 1.8rem;
  min-width: 1.8rem;
  height: 1.8rem;
  min-height: 1.8rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef1ef;
  color: #405249;
  font: 500 1.1rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.library-search > label,
.shortcut-help h2 {
  display: block;
  margin: 0 2.5rem 0.8rem 0;
  font-size: 1rem;
  font-weight: 750;
}

.library-search input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid #aeb9b2;
  border-radius: 0.45rem;
  outline: none;
  background: #fff;
  color: #17222b;
  font: 1rem/1.2 ui-sans-serif, system-ui, sans-serif;
}

.library-search input:focus {
  border-color: #44745b;
  box-shadow: 0 0 0 3px rgba(68, 116, 91, 0.15);
}

.library-search ul {
  display: grid;
  gap: 0.2rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.library-search-result {
  display: grid;
  grid-template-columns: 1.35rem 1fr;
  gap: 0.35rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: 0.4rem;
}

.library-search-result[hidden] {
  display: none;
}

.library-search-result[aria-selected="true"] {
  background: #dce9e0;
}

.library-search-result a {
  color: #234b36;
  font-size: 0.92rem;
  font-weight: 620;
  text-decoration: none;
}

.library-search-empty {
  margin: 1rem 0;
  color: #697782;
  font-size: 0.9rem;
}

.library-dialog-hint {
  margin: 0.9rem 0 0;
  color: #7a8780;
  font-size: 0.72rem;
}

.shortcut-help dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.shortcut-help dl > div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #e6eae7;
}

.shortcut-help dl > div:last-child {
  border-bottom: 0;
}

.shortcut-help dt {
  font-weight: 720;
}

.shortcut-help dd {
  margin: 0;
  color: #52615a;
}
