:root {
  --agent-title-cn-font:
    "Butterfly Lanting Jixu", "华文楷体", STKaiti,
    "Butterfly WenKai", KaiTi, serif;
  --agent-title-en-font:
    "England hand OB", "England Hand OB", "English Hand",
    "Butterfly Copperplate", "Edwardian Script ITC", "Palace Script MT", "French Script MT",
    "Kunstler Script", "Lucida Calligraphy", cursive;
  --agent-body-font:
    "华文楷体", STKaiti, "Butterfly WenKai", KaiTi, "楷体", "Noto Serif CJK SC",
    "Source Han Serif SC", serif;
  --agent-title-x: 68vw;
  --agent-title-y: 68vh;
  --agent-title-angle: -4deg;
  --agent-title-width: min(520px, 38vw);
  --agent-title-cn-size: clamp(31px, 4.1vw, 64px);
  --agent-title-en-size: clamp(25px, 2.7vw, 44px);
  --agent-title-align: left;
  --agent-title-opacity: 0;
  --agent-reader-reveal: 0;
  --agent-reader-text: 0;
  --agent-reader-butterfly: 1;
}

.document-experience-ui,
.document-experience-ui * {
  box-sizing: border-box;
}

.agent-title-layer {
  z-index: 3;
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.agent-title-card {
  left: var(--agent-title-x);
  top: var(--agent-title-y);
  opacity: var(--agent-title-opacity);
  width: var(--agent-title-width);
  color: rgba(255, 255, 255, 0.96);
  text-align: var(--agent-title-align);
  display: grid;
  position: absolute;
  transform:
    translate(-50%, -50%)
    rotate(var(--agent-title-angle));
  transform-origin: 50% 50%;
  transition:
    opacity 0.48s ease,
    left 0s,
    top 0s,
    transform 0.12s ease-out,
    width 0.12s ease-out;
  filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.46));
}

.agent-title-card::after {
  content: "";
  width: clamp(88px, 11vw, 170px);
  height: 1px;
  margin-top: 10px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0)
  );
  display: block;
  transform: rotate(-5deg);
  transform-origin: left center;
}

.agent-title-card__frame {
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.22em;
  margin-bottom: 4px;
  font:
    500 10px/1.4 SFMono-Regular,
    Consolas,
    monospace;
}

.agent-title-card__cn {
  text-wrap: balance;
  letter-spacing: 0.055em;
  font-family: var(--agent-title-cn-font);
  font-size: var(--agent-title-cn-size);
  font-weight: 400;
  line-height: 1.03;
}

.agent-title-card__en {
  color: rgba(255, 255, 255, 0.76);
  letter-spacing: 0.025em;
  margin-top: 8px;
  font-family: var(--agent-title-en-font);
  font-size: var(--agent-title-en-size);
  font-weight: 400;
  line-height: 1;
}

.agent-title-overview {
  opacity: 0;
  transition: opacity 0.3s ease;
  position: absolute;
  inset: 0;
}

.agent-title-overview.is-visible {
  opacity: 1;
}

.agent-title-overview__item {
  --overview-title-x: 50%;
  --overview-title-y: 50%;
  --overview-title-scale: 1;
  --overview-title-opacity: 0;
  --overview-title-angle: 0deg;
  --overview-title-width: 160px;
  --overview-title-font-size: 16px;
  --overview-title-align: left;
  left: var(--overview-title-x);
  top: var(--overview-title-y);
  opacity: var(--overview-title-opacity);
  color: rgba(255, 255, 255, 0.9);
  text-align: var(--overview-title-align);
  white-space: nowrap;
  width: var(--overview-title-width);
  display: grid;
  position: absolute;
  transform:
    translate(-50%, -50%)
    scale(var(--overview-title-scale))
    rotate(var(--overview-title-angle));
  transform-origin: center;
  transition:
    left 0s,
    top 0s,
    opacity 0.3s ease,
    transform 0.12s ease-out,
    width 0.12s ease-out;
  filter: drop-shadow(0 3px 9px rgba(0, 0, 0, 0.56));
}

.agent-title-overview__item strong {
  letter-spacing: 0.045em;
  font-family: var(--agent-title-cn-font);
  font-size: var(--overview-title-font-size);
  font-weight: 400;
  line-height: 1.08;
}

.agent-title-overview__item small {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.48);
  letter-spacing: 0.14em;
  font:
    500 8px/1.3 SFMono-Regular,
    Consolas,
    monospace;
}

.agent-title-overview__item.is-focus strong {
  color: #fff;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
}

.agent-title-overview__item.is-compact small {
  display: none;
}

body.is-agent-frame-inspect .agent-title-card,
body.is-agent-document-open .agent-title-card,
body.is-agent-document-open .agent-title-overview {
  opacity: 0 !important;
}

.agent-article-reader {
  z-index: 5;
  opacity: calc(var(--agent-reader-reveal) * 1);
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  transition: opacity 0.16s linear;
}

.agent-article-reader[aria-hidden="true"] {
  visibility: hidden;
}

.agent-article-reader__veil {
  opacity: calc(var(--agent-reader-reveal) * 0.84);
  background:
    radial-gradient(
      circle at var(--agent-title-x) var(--agent-title-y),
      rgba(0, 0, 0, 0.08) 0,
      rgba(0, 0, 0, 0.24) 30%,
      rgba(0, 0, 0, 0.7) 100%
    ),
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.2),
      rgba(0, 0, 0, 0.48) 48%,
      rgba(0, 0, 0, 0.72)
    );
  position: absolute;
  inset: 0;
}

.agent-article-reader__viewport {
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
  scrollbar-width: thin;
  height: 100%;
  padding:
    max(64px, calc(var(--safe-area-top) + 36px))
    clamp(26px, 8vw, 150px)
    max(110px, calc(var(--safe-area-bottom) + 72px));
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
}

.agent-article-reader__viewport::-webkit-scrollbar {
  width: 6px;
}

.agent-article-reader__viewport::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.agent-article-reader.is-readable {
  pointer-events: none;
}

.agent-article-reader__header {
  z-index: 2;
  opacity: var(--agent-reader-text);
  color: rgba(255, 255, 255, 0.52);
  letter-spacing: 0.15em;
  pointer-events: none;
  justify-content: space-between;
  align-items: center;
  width: min(820px, 100%);
  margin: 0 auto 58px;
  font:
    500 10px/1.4 SFMono-Regular,
    Consolas,
    monospace;
  display: flex;
  position: relative;
  transform: translateY(calc((1 - var(--agent-reader-text)) * 14px));
}

.agent-article-content {
  opacity: var(--agent-reader-text);
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.58);
  user-select: text;
  -webkit-user-select: text;
  width: min(820px, 100%);
  min-height: calc(100vh - 210px);
  margin: 0 auto;
  padding: 0 2px 20vh;
  font-family: var(--agent-body-font);
  font-size: clamp(18px, 1.55vw, 23px);
  line-height: 1.9;
  position: relative;
  transform: translateY(calc((1 - var(--agent-reader-text)) * 52px));
  transition:
    opacity 0.12s linear,
    transform 0.18s ease-out;
}

.agent-article-content::selection,
.agent-article-content *::selection {
  color: #0b0b0b;
  background: rgba(255, 255, 255, 0.88);
}

.agent-article-content__eyebrow {
  color: rgba(255, 255, 255, 0.48);
  letter-spacing: 0.28em;
  margin: 0 0 16px;
  font:
    500 10px/1.5 SFMono-Regular,
    Consolas,
    monospace;
}

.agent-article-content h1 {
  text-wrap: balance;
  letter-spacing: 0.045em;
  max-width: 15em;
  margin: 0;
  font-family: var(--agent-title-cn-font);
  font-size: clamp(45px, 6.7vw, 92px);
  font-weight: 400;
  line-height: 1.03;
}

.agent-article-content__english {
  color: rgba(255, 255, 255, 0.64);
  max-width: 22em;
  margin: 14px 0 66px;
  font-family: var(--agent-title-en-font);
  font-size: clamp(31px, 4vw, 58px);
  line-height: 1;
}

.agent-article-content__body {
  max-width: 36em;
}

.agent-article-content__body > :first-child {
  margin-top: 0;
}

.agent-article-content__body p {
  margin: 0 0 1.35em;
}

.agent-article-content__body h2,
.agent-article-content__body h3 {
  text-wrap: balance;
  color: rgba(255, 255, 255, 0.97);
  letter-spacing: 0.045em;
  margin: 2.6em 0 0.8em;
  font-family: var(--agent-body-font);
  font-weight: 500;
  line-height: 1.34;
}

.agent-article-content__body h2 {
  font-size: 1.65em;
}

.agent-article-content__body h3 {
  font-size: 1.3em;
}

.agent-article-content__body blockquote {
  color: rgba(255, 255, 255, 0.78);
  border-left: 1px solid rgba(255, 255, 255, 0.52);
  margin: 2em 0;
  padding: 0.2em 0 0.2em 1.3em;
  font-size: 1.08em;
}

.agent-article-content__body ul,
.agent-article-content__body ol {
  margin: 1.4em 0 1.6em;
  padding-left: 1.5em;
}

.agent-article-content__body li {
  margin: 0.58em 0;
}

.agent-article-content__body a {
  color: #fff;
  text-decoration-color: rgba(255, 255, 255, 0.46);
  text-underline-offset: 0.18em;
}

.agent-article-content__body img {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  max-width: 100%;
  height: auto;
  margin: 2em auto;
  display: block;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.38);
}

.agent-article-content__body table {
  border-collapse: collapse;
  width: 100%;
  margin: 2em 0;
  font-size: 0.8em;
}

.agent-article-content__body th,
.agent-article-content__body td {
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 0.65em 0.8em;
}

.agent-article-reader__scroll-mark {
  opacity: calc(var(--agent-reader-text) * 0.65);
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.8),
    rgba(255, 255, 255, 0)
  );
  width: 1px;
  height: 62px;
  position: fixed;
  right: 34px;
  bottom: 36px;
  transform: scaleY(var(--agent-reader-reveal));
  transform-origin: bottom;
}

.agent-document-toggle {
  z-index: 20;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing: 0.12em;
  cursor: pointer;
  background: rgba(4, 5, 9, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  min-width: 72px;
  height: 34px;
  padding: 0 16px;
  font:
    500 12px/1 SFMono-Regular,
    Consolas,
    monospace;
  position: fixed;
  top: max(20px, calc(var(--safe-area-top) + 12px));
  right: max(20px, calc(var(--safe-area-right) + 14px));
  transition:
    color 0.2s,
    background 0.2s,
    border-color 0.2s,
    opacity 0.2s;
}

.agent-document-toggle:hover,
.agent-document-toggle:focus-visible,
body.is-agent-document-open .agent-document-toggle {
  color: #111;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(255, 255, 255, 0.94);
}

body.is-agent-frame-inspect .agent-document-toggle {
  opacity: 0.26;
}

.agent-document-studio {
  z-index: 40;
  color: #1d1c1a;
  user-select: text;
  -webkit-user-select: text;
  background:
    linear-gradient(rgba(250, 248, 243, 0.985), rgba(243, 239, 230, 0.985)),
    #f7f4ed;
  border-left: 1px solid rgba(255, 255, 255, 0.4);
  width: min(560px, 100vw);
  height: 100dvh;
  padding:
    max(28px, calc(var(--safe-area-top) + 18px))
    max(28px, calc(var(--safe-area-right) + 24px))
    max(28px, calc(var(--safe-area-bottom) + 22px))
    28px;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
  position: fixed;
  top: 0;
  right: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: -28px 0 90px rgba(0, 0, 0, 0.42);
}

.agent-document-studio[hidden] {
  display: none;
}

.agent-document-studio button,
.agent-document-studio input {
  font: inherit;
}

.agent-document-studio button {
  color: #282622;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(42, 38, 30, 0.2);
  border-radius: 4px;
  min-height: 36px;
  padding: 7px 12px;
}

.agent-document-studio button:hover,
.agent-document-studio button:focus-visible {
  background: #fff;
  border-color: rgba(42, 38, 30, 0.44);
}

.agent-document-studio__header {
  border-bottom: 1px solid rgba(42, 38, 30, 0.16);
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  display: flex;
}

.agent-document-studio__kicker {
  color: rgba(42, 38, 30, 0.5);
  letter-spacing: 0.18em;
  font:
    600 10px/1.5 SFMono-Regular,
    Consolas,
    monospace;
}

.agent-document-studio__header h2 {
  letter-spacing: 0.04em;
  margin: 4px 0 5px;
  font-family: var(--agent-body-font);
  font-size: 30px;
  font-weight: 500;
}

.agent-document-studio__header p {
  color: rgba(42, 38, 30, 0.68);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.agent-document-studio .agent-document-studio__close {
  flex: none;
  border-radius: 50%;
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 24px;
  font-weight: 300;
}

.agent-document-studio__actions {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  display: grid;
}

.agent-document-studio__actions button:first-child {
  color: #fff;
  background: #22201d;
  border-color: #22201d;
}

.agent-document-studio__mapping {
  color: rgba(42, 38, 30, 0.66);
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(42, 38, 30, 0.12);
  border-radius: 5px;
  gap: 3px;
  margin-bottom: 16px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.45;
  display: grid;
}

.agent-document-studio__mapping strong {
  color: #282622;
  margin-bottom: 3px;
}

.agent-document-studio__chapter-nav {
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  display: grid;
}

.agent-document-studio__chapter-nav span {
  color: rgba(42, 38, 30, 0.72);
  text-align: center;
  letter-spacing: 0.08em;
  font:
    600 11px/1.4 SFMono-Regular,
    Consolas,
    monospace;
}

.agent-document-studio__chapter-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: -6px 0 16px;
  display: grid;
}

.agent-document-studio__chapter-actions button {
  min-width: 0;
  min-height: 31px;
  padding: 5px 6px;
  font-size: 11px;
}

.agent-document-studio__chapter-actions
  #agent-document-delete:not(:hover):not(:focus-visible) {
  color: rgba(112, 34, 34, 0.82);
}

.agent-document-studio__field {
  gap: 5px;
  margin-bottom: 10px;
  display: grid;
}

.agent-document-studio__field > span {
  color: rgba(42, 38, 30, 0.65);
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 650;
}

.agent-document-studio__field input,
.agent-document-studio__field select {
  color: #181714;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(42, 38, 30, 0.18);
  border-radius: 4px;
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  outline: none;
}

#agent-document-title {
  font-family: var(--agent-title-cn-font);
  font-size: 22px;
}

#agent-document-english {
  font-family: var(--agent-title-en-font);
  font-size: 25px;
}

.agent-document-studio__field input:focus,
.agent-document-studio__field select:focus {
  background: #fff;
  border-color: rgba(42, 38, 30, 0.52);
}

.agent-document-toolbar {
  flex-wrap: wrap;
  gap: 5px;
  margin: 16px 0 7px;
  display: flex;
}

.agent-document-toolbar button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

.agent-document-editor {
  color: #201e1a;
  scrollbar-color: rgba(42, 38, 30, 0.28) transparent;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(42, 38, 30, 0.18);
  border-radius: 4px;
  min-height: 360px;
  max-height: 48vh;
  padding: 26px 30px 90px;
  font-family: var(--agent-body-font);
  font-size: 17px;
  line-height: 1.85;
  overflow-y: auto;
  outline: none;
  box-shadow: inset 0 1px 5px rgba(42, 38, 30, 0.045);
}

.agent-document-editor:focus {
  background: #fff;
  border-color: rgba(42, 38, 30, 0.52);
}

.agent-document-editor h2,
.agent-document-editor h3 {
  line-height: 1.35;
}

.agent-document-editor img {
  max-width: 100%;
  height: auto;
}

.agent-document-fonts {
  color: rgba(42, 38, 30, 0.7);
  border-top: 1px solid rgba(42, 38, 30, 0.14);
  border-bottom: 1px solid rgba(42, 38, 30, 0.14);
  margin-top: 18px;
  padding: 12px 0;
  font-size: 12px;
}

.agent-document-fonts summary {
  color: #282622;
  cursor: pointer;
  font-weight: 650;
}

.agent-document-fonts p {
  line-height: 1.55;
}

.agent-document-fonts > div {
  flex-wrap: wrap;
  gap: 6px;
  display: flex;
}

.agent-document-fonts button {
  min-height: 32px;
  font-size: 11px;
}

.agent-document-studio__footer {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  display: grid;
}

.agent-document-studio__footer p {
  color: rgba(42, 38, 30, 0.62);
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
}

.agent-document-studio__footer #agent-document-save {
  color: #fff;
  background: #22201d;
  border-color: #22201d;
}

body.is-agent-document-open::before {
  content: "";
  z-index: 35;
  background: rgba(0, 0, 0, 0.34);
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body.is-agent-document-open .interaction-hint {
  opacity: 0;
}

body.is-agent-reading .mobile-experience-title,
body.is-agent-reading .interaction-hint {
  display: none !important;
}

@media (max-width: 760px) {
  .agent-title-card {
    width: min(78vw, 440px);
  }

  .agent-title-card__cn {
    font-size: clamp(28px, 9.2vw, 48px);
  }

  .agent-title-card__en {
    font-size: clamp(23px, 7vw, 38px);
  }

  .agent-article-reader__viewport {
    padding:
      max(72px, calc(var(--safe-area-top) + 52px))
      24px
      max(100px, calc(var(--safe-area-bottom) + 62px));
  }

  .agent-article-reader__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 42px;
  }

  .agent-article-content {
    font-size: 18px;
    line-height: 1.82;
  }

  .agent-article-content h1 {
    font-size: clamp(42px, 13vw, 70px);
  }

  .agent-article-content__english {
    margin-bottom: 48px;
    font-size: clamp(30px, 9vw, 48px);
  }

  .agent-document-toggle {
    top: max(14px, calc(var(--safe-area-top) + 8px));
    right: max(14px, calc(var(--safe-area-right) + 10px));
  }

  .agent-document-studio {
    padding:
      max(20px, calc(var(--safe-area-top) + 14px))
      max(18px, calc(var(--safe-area-right) + 16px))
      max(22px, calc(var(--safe-area-bottom) + 16px))
      max(18px, calc(var(--safe-area-left) + 16px));
  }

  .agent-document-editor {
    min-height: 320px;
    max-height: 46vh;
    padding: 20px 18px 70px;
  }

  .agent-document-studio__chapter-actions {
    grid-template-columns: 1fr 1fr;
  }

  .agent-document-studio__footer {
    grid-template-columns: 1fr 1fr;
  }

  .agent-document-studio__footer p {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-title-card,
  .agent-title-overview,
  .agent-title-overview__item,
  .agent-article-content {
    transition-duration: 0.01ms !important;
  }
}
