:root {
  --max-width: 652px;
  --text-color: #202124;
  --muted: #4d5156;
  --link: #1a0dab;
  --visited: #681da8;
  --bg: #fff;
  --toolbar-bg: rgba(255, 255, 255, 0.82);
  --toolbar-fill: #ec4fa3;
  --toolbar-progress: rgba(236, 79, 163, 0.72);
}

body.dark {
  --bg: #121212;
  --text-color: #e0e0e0;
  --muted: #9aa0a6;
  --link: #8ab4f8;
  --visited: #c58af9;
  --toolbar-bg: rgba(18, 18, 18, 0.74);
  --toolbar-fill: #f06bb4;
  --toolbar-progress: rgba(240, 107, 180, 0.62);
}

body.article-gatekeeper {
  --toolbar-fill: #ec4fa3;
  --toolbar-progress: rgba(236, 79, 163, 0.72);
}

body.article-guyhills {
  --toolbar-fill: #3b82f6;
  --toolbar-progress: rgba(59, 130, 246, 0.66);
}

body.article-understitch {
  --toolbar-fill: #e14d2a;
  --toolbar-progress: rgba(225, 77, 42, 0.66);
}

body.article-hongjiyan {
  --toolbar-fill: #16a36f;
  --toolbar-progress: rgba(22, 163, 111, 0.66);
}

body.article-popaganda {
  --toolbar-fill: #7c5cff;
  --toolbar-progress: rgba(124, 92, 255, 0.64);
}

body.article-moth {
  --toolbar-fill: #a46a2a;
  --toolbar-progress: rgba(164, 106, 42, 0.66);
}

body.dark.article-guyhills {
  --toolbar-fill: #6aa6ff;
  --toolbar-progress: rgba(106, 166, 255, 0.58);
}

body.dark.article-understitch {
  --toolbar-fill: #f27655;
  --toolbar-progress: rgba(242, 118, 85, 0.58);
}

body.dark.article-hongjiyan {
  --toolbar-fill: #34c990;
  --toolbar-progress: rgba(52, 201, 144, 0.58);
}

body.dark.article-popaganda {
  --toolbar-fill: #9d8cff;
  --toolbar-progress: rgba(157, 140, 255, 0.56);
}

body {
  --reader-font-size: 16px;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-color);
  line-height: 1.58;
  transition: background 0.3s, color 0.3s;
  font-size: var(--reader-font-size);
}

body.font-small { --reader-font-size: 15px; }
body.font-medium { --reader-font-size: 16px; }
body.font-large { --reader-font-size: 18px; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 18px;
  font-size: 13px;
  color: var(--muted);
  background-color: var(--toolbar-bg);
  backdrop-filter: blur(10px);
}

.toolbar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--toolbar-progress);
  z-index: 0;
  width: 0%;
  transition: width 0.1s ease-out, background-color 0.3s ease;
}

.toolbar-left,
.toolbar-right {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.article-search {
  display: flex;
  align-items: center;
  gap: 6px;
}

.article-search-input {
  width: 0;
  max-width: 180px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  outline: none;
  color: var(--text-color);
  background: transparent;
  font: inherit;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.article-search.is-open .article-search-input,
.article-search-input:focus {
  width: min(180px, 34vw);
  padding: 2px 0;
  border-bottom-color: var(--muted);
  opacity: 1;
}

.article-search-input::placeholder {
  color: var(--muted);
}

.toolbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transform: translateY(1px);
}

.toolbar-button:hover {
  color: var(--text-color);
}

body.dark .toolbar-button {
  background: none;
}

body.dark .toolbar-button:hover {
  background: none;
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.font-controls button {
  background: none;
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.font-controls button:hover {
  border-color: var(--muted);
}

.font-controls button.is-active {
  border-color: var(--toolbar-fill);
  color: var(--text-color);
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 20px;
  transition: 0.3s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--link);
}

input:checked + .slider::before {
  transform: translateX(20px);
}

main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: min(var(--max-width), calc(100vw - 32px));
  margin: 38px auto;
  padding: 0 20px 140px;
}

.article-query {
  width: min(560px, 100%);
  margin: 0 0 34px;
  padding: 11px 18px;
  border: 1px solid #dfe1e5;
  border-radius: 999px;
  color: #3c4043;
  background: #fff;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.18);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
  line-height: 1.2;
}

body.dark .article-query {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

h1 {
  max-width: 600px;
  color: var(--text-color);
  font-size: 2.05rem;
  font-weight: 500;
  text-align: left;
  margin: 0 0 10px;
  line-height: 1.16;
}

.subhead {
  max-width: 600px;
  font-size: 1rem;
  color: var(--muted);
  text-align: left;
  margin-bottom: 34px;
}

.result-snippet {
  color: var(--muted);
  line-height: 1.48;
}

.subhead-meta {
  display: inline-block;
  margin-top: 12px;
  color: #70757a;
  font-size: 0.78rem;
}

.subhead-meta::before {
  color: #70757a;
  content: "Writing · ";
}

body.dark .subhead-meta,
body.dark .subhead-meta::before {
  color: var(--muted);
}

.byline {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}

.image-credit {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: left;
  margin: 12px 0 26px;
  max-width: 600px;
  line-height: 1.4;
}

.image-credit em {
  font-style: italic;
}

article {
  width: 100%;
  max-width: 600px;
  font-size: 1rem;
  line-height: 1.72;
}

article p {
  margin: 0 0 22px;
  transition: background-color 0.3s ease;
}

article p.dropcap::first-letter {
  float: none;
  margin-right: 0;
  font-size: inherit;
  line-height: inherit;
  font-weight: inherit;
}

::selection {
  background: var(--toolbar-progress);
}

a {
  color: var(--link);
  text-decoration: none;
  transition: 0.3s ease;
}

a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

.fade-in {
  opacity: 1;
  transform: none;
  transition: none;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

#scroll-percent {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-family: monospace;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: color 0.3s, opacity 0.2s ease;
}

.toolbar:hover #scroll-percent,
.toolbar:focus-within #scroll-percent {
  opacity: 1;
}

#top-btn {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px;
  background: var(--toolbar-fill);
  color: white;
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.2s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#top-btn:hover {
  transform: translateX(-50%) translateY(-2px);
}

#top-btn.show {
  opacity: 1;
}

.article-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px 0 12px;
  border-radius: 4px;
  box-shadow: none;
}

.article-standard .article-image--hero {
  width: min(600px, calc(100vw - 40px));
  position: static;
  left: auto;
  transform: none;
  margin-left: 0;
  margin-right: 0;
}

.article-wide .article-image {
  width: min(600px, calc(100vw - 40px));
  max-width: none;
  position: static;
  left: auto;
  transform: none;
  margin: 24px 0;
}

.article-wide .article-image--hero,
.article-full .article-image--hero {
  width: min(600px, calc(100vw - 40px));
  position: static;
  left: auto;
  transform: none;
  margin-left: 0;
  margin-right: 0;
}

.article-wide .article-image--mid {
  margin: 32px 0 40px;
}

.article-compact .article-image {
  width: 100%;
  max-width: 600px;
}

.article-full .article-image {
  width: min(600px, calc(100vw - 40px));
  max-width: none;
  position: static;
  left: auto;
  transform: none;
  border-radius: 0;
  box-shadow: none;
}

.article-full .article-image--hero {
  position: static;
  left: auto;
  transform: none;
  margin-left: 0;
  margin-right: 0;
}

.exhibit-heading {
  margin: 44px 0 4px;
  font-size: 1rem;
  line-height: 1.4;
  letter-spacing: 0.035em;
}

.exhibit-prompt {
  color: var(--muted);
  font-style: italic;
}

.aside {
  color: var(--muted);
}

.article-moth .article-image {
  width: min(900px, calc(100vw - 40px));
  max-width: none;
  position: relative;
  left: min(300px, 50%);
  transform: translateX(-50%);
  margin-top: -36px;
}

.article-guyhills .article-image,
.article-understitch .article-image {
  width: min(760px, calc(100vw - 40px));
  max-width: none;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.article-guyhills main > .article-image,
.article-understitch main > .article-image {
  left: min(300px, 50%);
}

.pull-quote {
  position: relative;
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 400;
  font-style: normal;
  color: var(--text-color);
  margin: 30px 0;
  max-width: 600px;
  padding-left: 14px;
  border-left: 3px solid var(--toolbar-fill);
  text-align: left;
}

.pull-quote::before {
  content: none;
}

.read-next {
  width: min(600px, calc(100vw - 40px));
  margin: 58px 0 0;
  padding-top: 22px;
  border-top: 1px solid #dadce0;
}

.read-next h2 {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.read-next-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.read-next-card {
  display: flex;
  flex-direction: column;
  color: var(--text-color);
}

.read-next-card:hover {
  text-decoration: none;
  opacity: 1;
}

.read-next-title {
  display: block;
  color: var(--link);
  font-size: 1.02rem;
  line-height: 1.3;
  order: 2;
}

.read-next-card:visited .read-next-title {
  color: var(--visited);
}

.read-next-card:hover .read-next-title {
  text-decoration: underline;
}

body.dark .read-next-card {
  color: var(--text-color);
}

body.dark .read-next {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.related-searches {
  margin-top: 32px;
}

.related-searches-title {
  margin-bottom: 10px;
  color: var(--text-color);
  font-size: 1rem;
}

.related-searches-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.related-searches-list a {
  display: block;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--text-color);
  background: #f1f3f4;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.related-searches-list a:hover {
  text-decoration: none;
  background: rgba(232, 234, 237, 0.96);
  opacity: 1;
}

body.dark .related-searches-list a {
  background: rgba(255, 255, 255, 0.08);
}

body.dark .related-searches-list a:hover {
  background: rgba(255, 255, 255, 0.13);
}

.article-search-mark {
  background: rgba(251, 188, 5, 0.55);
  color: inherit;
  padding: 0 1px;
}

@media (max-width: 680px) {
  main {
    width: min(100%, calc(100vw - 24px));
    margin-top: 28px;
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 1.38rem;
  }

  .read-next {
    margin-top: 52px;
  }

  .related-searches-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in,
  #top-btn,
  .toolbar-fill,
  a,
  .slider,
  .slider::before {
    transition: none !important;
  }

  .fade-in {
    opacity: 1;
    transform: none;
  }
}

/* "Was this result helpful?" feedback widget */
.result-feedback {
  max-width: var(--max-width);
  margin: 44px auto 8px;
  padding-top: 22px;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.result-feedback button {
  background: none;
  border: none;
  color: var(--link);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  margin-left: 18px;
  padding: 4px 6px;
}

.result-feedback button:hover {
  text-decoration: underline;
}

.result-feedback.is-done {
  font-style: italic;
}

/* Select-to-quote floating tip */
.quote-tip {
  position: absolute;
  z-index: 60;
  background: #202124;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.quote-tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #202124;
}

body.dark .quote-tip {
  background: #e8eaed;
  color: #202124;
}

body.dark .quote-tip::after {
  border-top-color: #e8eaed;
}
