:root {
  --sidebar-bg: rgba(255, 255, 255, 0.92);
  --sidebar-border: rgba(242, 131, 138, 0.35);
  --sidebar-text: #4f4f4f;
  --sidebar-highlight: #f2838a;
  --sidebar-header: #c2515d;
  --sidebar-radius: 0;
  --body-font:
    'Velvelyne', 'Junicode', Georgia, 'PingFang SC', 'Hiragino Sans GB',
    'Apple Symbols', serif;
  --text-scale: 1;
}

html.font-junicode {
  --body-font:
    'Junicode', Georgia, 'PingFang SC', 'Hiragino Sans GB', 'Apple Symbols',
    serif;
}

body.has-sidebar {
  margin-right: 0;
}

.site-sidebar {
  box-sizing: border-box;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: calc(min(340px, 18vw) + 20px);
  padding: calc(min(260px, 18vw) + 24px) 18px 24px;
  border: 1px solid var(--sidebar-border);
  border-top: none;
  border-bottom: none;
  border-radius: var(--sidebar-radius);
  background: var(--sidebar-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
  font-family: var(--body-font);
  color: var(--sidebar-text);
  z-index: 100;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
  overflow-y: auto;
  position: fixed;
}

.site-sidebar {
  -webkit-overflow-scrolling: touch;
  padding-right: 12px;
}

.site-sidebar .me {
  position: absolute;
  top: auto;
  left: auto;
  right: 92%;
  bottom: 2rem;
  display: block;
  width: min(260px, 20vw);
  height: auto;
  margin: 0;
  padding: 0;
  max-width: none;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.site-sidebar:has(.sidebar-scroll) {
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding-top: 18px;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.75rem 4px 4rem 0;
  -webkit-mask-image:
    linear-gradient(
      to bottom,
      transparent 0,
      #000 2rem,
      #000 calc(100% - 4rem),
      transparent 100%
    ),
    linear-gradient(to left, #000 10px, transparent 10px);
  -webkit-mask-composite: source-over;
  mask-image:
    linear-gradient(
      to bottom,
      transparent 0,
      #000 2rem,
      #000 calc(100% - 4rem),
      transparent 100%
    ),
    linear-gradient(to left, #000 10px, transparent 10px);
  mask-composite: add;
}

.site-sidebar::-webkit-scrollbar,
.sidebar-scroll::-webkit-scrollbar {
  width: 9px;
}

.site-sidebar::-webkit-scrollbar-track,
.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.site-sidebar::-webkit-scrollbar-thumb,
.sidebar-scroll::-webkit-scrollbar-thumb {
  background-color: transparent;
  box-shadow: inset 0 0 0 1px var(--sidebar-highlight);
  border-radius: 10px;
}

.news::-webkit-scrollbar {
  width: 4px;
}

.news::-webkit-scrollbar-track {
  background: transparent;
}

.news::-webkit-scrollbar-thumb {
  background-color: var(--sidebar-highlight);
  border-radius: 10px;
}

.site-sidebar .sidebar-header {
  margin-top: 32px;
  margin-bottom: 8px;
  font-weight: 700;
}

.site-sidebar .sidebar-header.collapsible {
  cursor: pointer;
  user-select: none;
}

.site-sidebar .sidebar-header.collapsible::after {
  content: ' ✎﹏';
}

.site-sidebar .sidebar-header.collapsible.collapsed::after {
  content: ' ✏';
}

.site-sidebar a.collapsed-link {
  display: none;
}

.site-sidebar a.collapsed-link.party {
  display: none;
}

.site-sidebar .font-controls {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 16px;
}

.site-sidebar .font-toggle {
  padding: 4px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 0.65rem;
  cursor: pointer;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}

.site-sidebar .font-toggle:hover {
  color: var(--sidebar-highlight);
  border-color: var(--sidebar-highlight);
}

.site-sidebar .font-size {
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  overflow: hidden;
}

.site-sidebar .font-size > * {
  margin: 0;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  font-size: 0.7rem;
  line-height: 1;
  padding: 4px 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-sidebar .font-size .font-dec,
.site-sidebar .font-size .font-size-reset {
  border-right: 1px solid var(--sidebar-border);
}

.site-sidebar .font-size .font-dec,
.site-sidebar .font-size .font-inc,
.site-sidebar .font-size .font-size-reset {
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease;
}

.site-sidebar .font-size .font-dec:hover,
.site-sidebar .font-size .font-inc:hover,
.site-sidebar .font-size .font-size-reset:hover {
  color: var(--sidebar-highlight);
  background: rgba(242, 131, 138, 0.08);
}

.site-sidebar a.sidebar-about {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: calc(0.75rem * var(--text-scale));
  font-weight: 700;
  color: var(--sidebar-header);
  margin-bottom: 12px;
}

.site-sidebar a.sidebar-about::before {
  content: none;
}

.site-sidebar a.sidebar-about::after {
  content: ' 𖡎';
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 25px;
  height: 25px;
  color: var(--sidebar-highlight);
  font-size: 1.25rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 105;
  background: transparent;
}

.sidebar-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sidebar-toggle:hover {
  background: transparent;
}

.sidebar-close {
  display: none;
  border: none;
  background: transparent;
  color: var(--sidebar-highlight);
  font-size: 1.3rem;
  font-weight: 700;
  align-self: flex-end;
  cursor: pointer;
  margin-bottom: 14px;
}

.site-sidebar .sidebar-header {
  display: block;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: calc(0.75rem * var(--text-scale));
  margin-bottom: 12px;
  color: var(--sidebar-header);
}

.site-sidebar a {
  display: block;
  margin: 4px 0;
  font-size: calc(0.9rem * var(--text-scale));
  line-height: 1.45;
  color: var(--sidebar-text);
  text-decoration: none;
}

.site-sidebar a::before {
  content: '↪ ';
  color: var(--sidebar-highlight);
}

.site-sidebar a.party::before {
  content: ' ';
}

.site-sidebar a.party {
  display: flex;
  gap: 5px;
  image-rendering: -moz-crisp-edges; /* Fallback for older Firefox versions */
  image-rendering: pixelated; /* Standard modern property */
}

.site-sidebar a:hover,
.site-sidebar a.active {
  color: var(--sidebar-highlight);
  text-decoration: underline;
  text-decoration-color: rgba(255, 128, 111, 0.6);
}

.page-layout {
  display: block;
  padding: 4vh 4vw 4vw 4vw;
  max-width: 100%;
}

.page-main {
  max-width: calc(100% - 20vw);
  min-width: 280px;
}

.page-main h1,
.page-main h2 {
  color: #ee5e7d;
  font-family: 'VG5000', 'Junicode', 'PingFang SC', 'Hiragino Sans GB', serif;
}

.page-main h1 {
  margin-bottom: 0.5rem;
  font-size: 3rem;
}

.page-main p {
  color: #555;
  line-height: 1.75;
  max-width: 50rem;
  font-size: calc(1rem * var(--text-scale));
}

.page-main .research-citation {
  font-family: var(--body-font);
  color: #555;
  line-height: 1.75;
  font-size: calc(1.1rem * var(--text-scale));
  max-width: 50rem;
}

.page-main .comic-title {
  margin-bottom: 0.4rem;
}

.page-main .comic-meta {
  font-family: var(--body-font);
  font-style: italic;
  color: #9b9b9b;
  line-height: 1.5;
  margin: 0 0 1rem;
  font-size: calc(1rem * var(--text-scale));
}

.page-main .comic-desc {
  font-family: var(--body-font);
  color: #555;
  line-height: 1.75;
  font-size: calc(1.1rem * var(--text-scale));
  max-width: 50rem;
}

.page-main .comic-pages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.page-main .comic-pages img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

@media only screen and (min-width: 1025px) {
  .subpage-body {
    height: auto;
    min-height: 100vh;
    justify-content: flex-start;
  }

  .subpage-body .main-container {
    height: auto;
    min-height: 70vh;
    margin-top: 15vh;
  }

  .subpage-body .page-layout {
    flex: 1 1 auto;
    width: 100%;
    padding: 0;
    max-width: 100%;
  }

  .subpage-body .page-main {
    margin-left: 30vw;
    width: 42vw;
    max-width: 42vw;
    padding-bottom: calc(max(15vh, 240px));
  }
}

@media only screen and (max-width: 1024px) {
  .site-sidebar .me {
    position: absolute;
    top: auto;
    left: auto;
    right: 92%;
    bottom: 2rem;
    display: block;
    width: min(450px, 60vw);
    height: auto;
    margin: 0;
    padding: 0;
    max-width: none;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
  }
  body.has-sidebar {
    margin-right: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .site-sidebar .font-controls {
    justify-content: flex-start;
  }

  .site-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(280px, 75vw);
    margin: 0;
    border: none;
    border-left: 1px solid rgba(242, 131, 138, 0.18);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.12);
    background: rgba(253, 253, 253, 0.98);
    padding: 24px 18px;
    transform: translateX(110%);
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    max-height: 100vh;
    overflow-y: auto;
    z-index: 104;
  }

  .site-sidebar.open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
  }

  .page-layout {
    padding-bottom: 6rem;
  }

  .page-main {
    max-width: 100%;
  }
}
