/* The panel and handle share the responsive width set by sidebar-ui. */
#pm-sidebar-panel {
  --toc-ink: #cfc9bd;
  --toc-gold: #f4d59a;
  --toc-pad: 17px;
  --toc-gap: 5px;
  container-type: inline-size;
  background: linear-gradient(152deg, #1b1a17, #161513);
}
#pm-sidebar-panel .pm-toc-header {
  flex: none;
  display: flex;
  align-items: center;
  height: 63px;
  padding: 0 var(--toc-pad);
}
#pm-sidebar-panel .pm-sidebar-title {
  color: #efdfbf;
  font: normal 32px/1 HYSinMyeongJo, serif;
  letter-spacing: -.035em;
  border: 0;
  padding: 0;
  text-align: left;
}
#pm-sidebar-panel .pm-section-list {
  display: flex;
  flex-direction: column;
  container-type: normal;
  min-height: 0;
  overflow: hidden auto;
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y pinch-zoom;
  scrollbar-width: none;
  gap: var(--toc-gap);
  padding: 0 10px;
}
#pm-sidebar-panel .pm-section-list::-webkit-scrollbar { display: none; }
#pm-sidebar-panel .pm-section-list[hidden],
#pm-sidebar-panel .pm-toc-inline-grades[hidden] { display: none; }
#pm-sidebar-panel .pm-toc-entry {
  flex: none;
  width: 100%;
  min-width: 0;
}
#pm-sidebar-panel .pm-toc-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 78px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 14px 10px;
  border: 0;
  border-radius: 0;
  color: #f1e9d9;
  background: #141310;
  box-shadow: none;
  text-align: left;
  font: normal 19px/1.15 HYSinMyeongJo, serif;
  letter-spacing: .01em;
}
#pm-sidebar-panel .pm-toc-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  object-fit: cover;
  object-position: 50% var(--toc-focus, 50%);
}
/* Each wide illustration has its own focal height in the 78px crop. */
#pm-sidebar-panel [data-choice-id="M1"] { --toc-focus: 43%; }
#pm-sidebar-panel :is([data-choice-id="M2"], [data-choice-id="M11"]) { --toc-focus: 26%; }
#pm-sidebar-panel :is([data-choice-id="M3"], [data-choice-id="M6"]) { --toc-focus: 25%; }
#pm-sidebar-panel :is([data-choice-id="M5"], [data-choice-id="M7"]) { --toc-focus: 38%; }
#pm-sidebar-panel [data-choice-id="M8"] { --toc-focus: 36%; }
#pm-sidebar-panel [data-choice-id="M4"] { --toc-focus: 35%; }
#pm-sidebar-panel [data-choice-id="M9"] { --toc-focus: 32%; }
#pm-sidebar-panel :is([data-choice-id="M10"], [data-choice-id="M13"]) { --toc-focus: 28%; }
#pm-sidebar-panel [data-choice-id="M12"] { --toc-focus: 27%; }
#pm-sidebar-panel [data-choice-id="M14"] { --toc-focus: 24%; }
#pm-sidebar-panel .pm-toc-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(13,13,13,.30), transparent 65%),
    linear-gradient(0deg, rgba(10,9,8,.82), rgba(10,9,8,.38) 35%, rgba(10,9,8,.04) 76%);
}
#pm-sidebar-panel .pm-toc-label {
  white-space: normal;
  text-shadow: 0 1px 3px #080706;
}
#pm-sidebar-panel .pm-toc-card[data-pm-work-status="unstarted"] { color: #aaa69e; }
#pm-sidebar-panel .pm-toc-card[aria-current="page"],
#pm-sidebar-panel .pm-toc-card.is-active { color: var(--toc-gold); }
#pm-sidebar-panel .pm-toc-card[data-choice-id="M9"]::after {
  content: "";
  align-self: flex-end;
  width: 7px;
  height: 7px;
  margin: 0 5px 3px auto;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
}
#pm-sidebar-panel .pm-toc-card[data-choice-id="M9"][aria-expanded="true"]::after {
  margin-bottom: 0;
  transform: rotate(225deg);
}
#pm-sidebar-panel .pm-toc-inline-grades {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: var(--toc-gap);
  padding: 4px 8px 5px 16px;
  background: #211f1b;
}
#pm-sidebar-panel .pm-toc-inline-grades::before {
  content: "";
  position: absolute;
  inset: 9px auto 9px 13px;
  width: 1px;
  background: #a088593d;
}
#pm-sidebar-panel .pm-toc-submenu {
  padding: 0 19px 12px;
  overflow: hidden;
}
#pm-sidebar-panel .pm-toc-items {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
#pm-sidebar-panel .pm-toc-subhead {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  margin-bottom: 8px;
}
#pm-sidebar-panel .pm-toc-subhead :is(.pm-submenu-title, .pm-submenu-back) {
  position: static;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
#pm-sidebar-panel .pm-toc-subhead .pm-submenu-title { color: #ecdbb6; font-size: 28px; text-align: left; word-break: keep-all; }
#pm-sidebar-panel .pm-toc-subhead .pm-submenu-back {
  white-space: nowrap;
  flex: none;
  min-height: 32px;
  padding-inline: 4px;
  font-size: 13px;
  color: #beb3a0;
}
#pm-sidebar-panel :is(.pm-toc-items, .pm-toc-inline-grades) .pm-subsection-button {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  width: 100%;
  min-height: 33px;
  padding: 4px 0 4px 21px;
  border: 0;
  color: #cfc9bd;
  background: transparent;
  box-shadow: none;
  text-align: left;
  font: normal 18px/1.15 HYSinMyeongJo, serif;
}
#pm-sidebar-panel :is(.pm-toc-items, .pm-toc-inline-grades) .pm-subsection-button[data-pm-work-status="unstarted"] {
  color: #8e8e8e;
}
#pm-sidebar-panel .pm-toc-inline-grades .pm-subsection-button {
  min-height: 32px;
  padding: 3px 0 3px 12px;
  font-size: 15px;
}
#pm-sidebar-panel :is(.pm-toc-items, .pm-toc-inline-grades) .pm-subsection-button[aria-current="page"] {
  color: var(--toc-gold);
}
#pm-sidebar-panel :is(.pm-toc-items, .pm-toc-inline-grades) .pm-subsection-button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  width: 11px;
  height: 2px;
  background: #c9a464;
}
#pm-sidebar-panel :is(.pm-toc-items, .pm-toc-inline-grades) .pm-subsection-button[aria-current="page"]::after {
  content: "";
  flex: 1;
  min-width: 10px;
  height: 1px;
  margin-left: 12px;
  background: linear-gradient(to right, #8b7349, transparent);
}
#pm-sidebar-panel :is(.pm-toc-card,.pm-submenu-back,.pm-subsection-button):focus-visible {
  outline: 1px solid #f4d59a;
  outline-offset: -2px;
}
/* Seven cards and their gaps take 576px. Leave room for the 143px desktop footer. */
@media (min-width: 561px) and (max-height: 782px) {
  #pm-sidebar-panel .pm-toc-header { height: clamp(46px, calc(100dvh - 720px), 63px); }
}
/* Keep the footer reachable without reducing grade rows or cropping the fold handle. */
@media (max-height: 560px) {
  #pm-sidebar-panel .pm-toc-header { height: 46px; }
  #pm-sidebar-panel .pm-sidebar-footer { padding-block: 4px; }
  #pm-sidebar-panel .pm-build-button { margin-bottom: 4px; min-height: 32px; }
}

/* The close button is hidden as soon as the drawer closes. Let the shell
   finish the fade while the button handles outside clicks only when open. */
#pm-sidebar-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9001;
  pointer-events: none;
  /* The reference darkens the previously open view by 30%: 1 - (1 - .45) * .70. */
  background: rgba(0, 0, 0, 0.615);
  opacity: 0;
  transition: opacity 180ms ease-out;
}
#pm-sidebar-shell.is-open::before { opacity: 1; }
#pm-sidebar-shell > .pm-sidebar-scrim {
  width: 100%;
  height: 100%;
  background: transparent;
}
@media (prefers-reduced-motion: reduce) {
  #pm-sidebar-shell::before { transition: none; }
}
