:root {
  --bg: #e3d7c7;
  --paper: #f0e5d3;
  --paper-deep: #e4d2b8;
  --ink: #2c241c;
  --muted: #857865;
  --faint: #b1a696;
  --line: rgba(105, 84, 56, 0.14);
  --panel: rgba(248, 240, 228, 0.7);
  --brand: #b8965f;
  --brand-dark: #826338;
  --danger: #8d332f;
  --calligraphy: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "SimSun", serif;
  --question-font: "SongpineQuestionFont", serif;
}

@font-face {
  font-family: "SongpineQuestionFont";
  src: url("./assets/fonts/HuiwenMingchao-subset.woff2?v=20260613b") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--calligraphy);
  color: var(--ink);
  background:
    url("./assets/page-background.png?v=20260512") center center / cover fixed no-repeat,
    #eadfcf;
}

button,
textarea {
  font: inherit;
}

.page {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 22px 28px 28px;
  position: relative;
}

.screen {
  position: relative;
  width: min(100%, 1080px);
  height: min(1460px, calc(100vh - 56px));
  height: min(1460px, calc(100svh - 56px));
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto min-content;
  align-content: stretch;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.screen::before {
  content: none;
}

.screen::after {
  content: none;
}

.mode:focus-visible,
.record-btn:focus-visible,
.send-circle:focus-visible {
  outline: 2px solid rgba(179, 145, 86, 0.38);
  outline-offset: 4px;
}

textarea:focus-visible {
  outline: none;
}

.question-panel {
  position: relative;
  z-index: 1;
  align-self: stretch;
  width: 100%;
  max-width: 900px;
  justify-self: center;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 88px 80px clamp(58px, 7.2vh, 112px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.question-panel::-webkit-scrollbar {
  display: none;
}

.question-panel.long-question {
  padding-right: 58px;
  scrollbar-width: thin;
  scrollbar-color: rgba(111, 87, 54, 0.34) rgba(255, 255, 255, 0.08);
}

.question-panel.long-question::-webkit-scrollbar {
  display: block;
  width: 7px;
}

.question-panel.long-question::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

.question-panel.long-question::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(111, 87, 54, 0.34);
}

.question-logo {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 52%;
  width: 124px;
  height: auto;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.58) rotate(0deg);
  transform-origin: center;
  pointer-events: none;
  filter: drop-shadow(0 14px 22px rgba(43, 34, 24, 0.08));
  backface-visibility: hidden;
  will-change: transform, opacity, filter;
}

.question-panel.logo-bridge .question-text {
  animation: questionCollapseToLogo 0.32s ease forwards;
}

.question-panel.logo-bridge .question-logo {
  animation:
    logoBridgeEnter 0.42s cubic-bezier(0.32, 0.02, 0.22, 1) forwards,
    logoBridgeLoop 1.08s linear 0.42s infinite;
}

.question-panel.logo-reveal .question-logo {
  animation: logoExpandToQuestion 0.42s ease forwards;
}

.question-panel.logo-reveal .question-text {
  animation: questionExpandFromLogo 0.42s ease both;
}

.thinking {
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 15px;
}

#thinking.hidden {
  display: flex !important;
  visibility: hidden;
}

.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.3;
  animation: pulse 1.1s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: 0.16s;
}

.thinking span:nth-child(3) {
  animation-delay: 0.32s;
}

.thinking em {
  margin-left: 6px;
  font-style: normal;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-4px);
    opacity: 0.9;
  }
}

@keyframes questionCollapseToLogo {
  0% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.22);
    filter: blur(6px);
  }
}

@keyframes logoBridgeEnter {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.34) rotate(0deg);
  }
  48% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.58) rotate(168deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62) rotate(360deg);
  }
}

@keyframes logoBridgeLoop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62) rotate(360deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62) rotate(720deg);
  }
}

@keyframes logoExpandToQuestion {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62) rotate(0deg);
    filter: blur(0) drop-shadow(0 14px 22px rgba(43, 34, 24, 0.08));
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.25) rotate(0deg);
    filter: blur(10px) drop-shadow(0 14px 22px rgba(43, 34, 24, 0));
  }
}

@keyframes questionExpandFromLogo {
  0% {
    opacity: 0;
    transform: scale(0.84);
    filter: blur(7px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.question-text {
  max-width: 700px;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  align-content: start;
  gap: 13px;
  text-align: left;
  font-family: var(--question-font) !important;
  font-size: 31px;
  line-height: 1.42;
  letter-spacing: 0;
  font-weight: 400;
  overflow-wrap: anywhere;
  word-break: normal;
}

.question-panel.long-question .question-text {
  max-width: 760px;
  font-size: 27px;
  line-height: 1.34;
  gap: 9px;
}

.question-group {
  display: grid;
  gap: 0;
}

.question-line {
  display: block;
  font-family: var(--question-font) !important;
  text-align: left;
}

.question-text.streaming::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 1em;
  margin-left: 0.08em;
  border-right: 1px solid rgba(23, 23, 19, 0.55);
  transform: translateY(0.12em);
  animation: caretBlink 0.8s steps(1) infinite;
}

@keyframes caretBlink {
  50% {
    opacity: 0;
  }
}

.answer-box {
  position: relative;
  z-index: 1;
  width: calc(100% - 96px);
  justify-self: center;
  display: grid;
  gap: 0;
  margin-bottom: clamp(24px, 4vh, 62px);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.options-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.option-btn {
  min-height: 54px;
  border: 1px solid rgba(83, 67, 46, 0.14);
  border-radius: 16px;
  padding: 0 18px;
  background: rgba(255, 253, 247, 0.6);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.option-btn.selected {
  border-color: rgba(155, 123, 67, 0.48);
  background: rgba(155, 123, 67, 0.12);
}

textarea {
  width: 100%;
  min-height: 84px;
  max-height: 142px;
  display: block;
  resize: none;
  border: 1px solid rgba(132, 102, 58, 0.24);
  border-radius: 30px;
  padding: 24px 94px 18px 30px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(250, 242, 231, 0.76)),
    rgba(255, 253, 247, 0.78);
  color: var(--ink);
  outline: none;
  line-height: 1.75;
  font-size: 20px;
  box-shadow:
    0 30px 70px rgba(67, 56, 43, 0.16),
    0 8px 22px rgba(67, 56, 43, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    color 0.18s ease;
}

.text-panel {
  position: relative;
  display: grid;
  margin-top: 0;
}

textarea:focus {
  border-color: rgba(179, 145, 86, 0.56);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 253, 247, 0.7)),
    rgba(255, 253, 247, 0.82);
  box-shadow:
    0 0 0 2px rgba(179, 145, 86, 0.18),
    0 0 0 7px rgba(179, 145, 86, 0.055),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 34px 78px rgba(67, 56, 43, 0.18),
    0 10px 26px rgba(67, 56, 43, 0.1);
}

textarea::placeholder {
  color: var(--faint);
}

textarea:disabled {
  background: rgba(239, 234, 224, 0.54);
  color: rgba(42, 36, 29, 0.46);
  border-color: rgba(83, 67, 46, 0.12);
}

.hidden {
  display: none !important;
}

.validation-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translate(-50%, 8px);
  margin: 0;
  width: min(100% - 16px, 660px);
  min-height: 0;
  display: block;
  color: var(--danger);
  font-size: 15px;
  text-align: center;
  line-height: 1.48;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.36s ease,
    transform 0.36s ease;
}

.validation-hint.visible {
  opacity: 1;
  transform: translate(-50%, 0);
  padding: 7px 16px;
  border: 1px solid rgba(141, 51, 47, 0.14);
  border-radius: 18px;
  background: rgba(255, 248, 242, 0.94);
  box-shadow:
    0 12px 26px rgba(91, 54, 38, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.answer-box:focus-within textarea {
  border-color: rgba(179, 145, 86, 0.52);
}

.answer-box:has(.validation-hint:not(:empty)) textarea {
  border-color: rgba(141, 51, 47, 0.38);
  box-shadow:
    0 0 0 4px rgba(141, 51, 47, 0.055),
    0 30px 70px rgba(67, 56, 43, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.send-circle {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent !important;
  color: transparent;
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  overflow: hidden;
  clip-path: circle(50% at 50% 50%);
  -webkit-mask-image: radial-gradient(circle at center, #000 70%, #000 99%, transparent 100%);
  mask-image: radial-gradient(circle at center, #000 70%, #000 99%, transparent 100%);
  padding: 0;
  box-shadow:
    0 10px 24px rgba(126, 99, 54, 0.1),
    0 2px 8px rgba(126, 99, 54, 0.06);
  transform: scale(1);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease,
    opacity 0.18s ease;
}

.send-circle::after {
  content: none;
}

.send-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 999px;
  clip-path: circle(50% at 50% 50%);
  transform: scale(1);
  transform-origin: center;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.send-circle:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 20px 34px rgba(126, 99, 54, 0.28);
}

.send-circle:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.screen:has(#thinking:not(.hidden)) .send-circle {
  background-color: rgba(177, 150, 101, 0.76);
}

.screen:has(#thinking:not(.hidden)) .send-icon {
  opacity: 0;
}

.screen:has(#thinking:not(.hidden)) .send-circle::after {
  opacity: 0;
}

.screen:has(#thinking:not(.hidden)) .send-circle::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 253, 247, 0.38);
  border-top-color: #fffdf7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
}

button:disabled {
  opacity: 0.5;
  filter: saturate(0.7);
}

.result {
  position: relative;
  z-index: 2;
  width: calc(100% - 96px);
  justify-self: center;
  margin: 0 0 20px;
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 22px 70px rgba(23, 23, 19, 0.1);
}

.result h2 {
  margin: 0 0 14px;
  font-size: 28px;
  font-weight: 400;
}

.result-grid {
  display: grid;
  gap: 10px;
}

.result-card {
  padding: 14px;
  border: 1px solid rgba(23, 23, 19, 0.09);
  border-radius: 8px;
  line-height: 1.65;
}

.result-card strong {
  color: var(--brand-dark);
}

@media (max-width: 560px) {
  .page {
    padding: 8px 8px 12px;
    place-items: stretch;
  }

  .screen {
    width: 100%;
    height: calc(100vh - 20px);
    height: calc(100svh - 20px);
    grid-template-rows: minmax(0, 1fr) auto min-content;
    border-radius: 18px;
  }

  .screen::after {
    inset: 9px;
    border-radius: 14px;
  }

  .question-panel {
    align-self: stretch;
    padding: 66px 24px 20px;
    max-width: 100%;
  }

  .question-panel.long-question {
    padding-right: 18px;
    padding-left: 20px;
  }

  .thinking {
    justify-content: center;
    font-size: 13px;
  }

  .question-text {
    min-height: 0;
    max-width: 100%;
    display: grid;
    gap: 10px;
    font-size: 24px;
    line-height: 1.42;
    word-break: normal;
  }

  .question-panel.long-question .question-text {
    font-size: 20px;
    line-height: 1.34;
    gap: 7px;
  }

  .question-group {
    gap: 0;
  }

  .answer-box {
    width: calc(100% - 28px);
    margin-bottom: 48px;
    padding: 0;
    border-radius: 0;
  }

  .options-panel {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 70px;
    max-height: 112px;
    padding: 18px 74px 14px 22px;
    border-radius: 24px;
    font-size: 17px;
  }

  .validation-hint {
    bottom: calc(100% + 9px);
    font-size: 13px;
  }

  .validation-hint.visible {
    padding: 5px 12px;
  }

  .send-circle {
    width: 58px;
    height: 58px;
    right: 12px;
    bottom: 12px;
  }

  .result {
    width: calc(100% - 28px);
    margin-bottom: 22px;
  }
}

@media (max-height: 860px) {
  .page {
    padding: 14px 18px 18px;
  }

  .screen {
    height: calc(100svh - 32px);
  }

  .question-panel {
    padding-top: 62px;
    padding-bottom: clamp(48px, 6vh, 84px);
    gap: 10px;
  }

  .question-text {
    font-size: 27px;
    line-height: 1.33;
    gap: 10px;
  }

  .question-panel.long-question .question-text {
    font-size: 23px;
    line-height: 1.3;
    gap: 7px;
  }

  .answer-box {
    margin-bottom: clamp(16px, 3vh, 44px);
  }

  textarea {
    min-height: 76px;
    max-height: 126px;
    padding: 20px 86px 16px 24px;
    line-height: 1.68;
    font-size: 18px;
  }

  .validation-hint {
    bottom: calc(100% + 10px);
  }

  .validation-hint.visible {
    padding: 5px 12px;
  }

  .send-circle {
    right: 14px;
    bottom: 12px;
    width: 58px;
    height: 58px;
  }
}

@media (max-height: 740px) {
  .page {
    padding: 10px 14px 14px;
  }

  .screen {
    height: calc(100svh - 24px);
  }

  .question-panel {
    padding-top: 48px;
    padding-bottom: clamp(40px, 5vh, 70px);
    gap: 8px;
  }

  .question-text {
    font-size: 24px;
    line-height: 1.28;
    gap: 8px;
  }

  .question-panel.long-question .question-text {
    font-size: 20px;
    line-height: 1.26;
    gap: 6px;
  }

  .answer-box {
    margin-bottom: clamp(12px, 2.4vh, 30px);
  }

  textarea {
    min-height: 66px;
    max-height: 104px;
    padding: 16px 76px 12px 22px;
    line-height: 1.6;
    font-size: 17px;
  }

  .validation-hint {
    bottom: calc(100% + 8px);
    font-size: 13px;
  }

  .validation-hint.visible {
    padding: 5px 12px;
  }

  .send-circle {
    right: 12px;
    bottom: 10px;
    width: 54px;
    height: 54px;
  }
}
