﻿:root {
  --bg-0: #d7c8ae;
  --bg-1: #e6d9c2;
  --bg-2: #efe6d6;
  --paper-0: #faf5ea;
  --paper-1: #f4ecde;
  --paper-2: #eee2cf;
  --ink-0: #2f2418;
  --ink-1: #4b3b2a;
  --ink-2: #75624b;
  --line-0: #dbc5a4;
  --line-1: #c8aa82;
  --gold-0: #c79a5c;
  --gold-1: #9c6f3d;
  --accent: #7a3b2d;
  --shadow-lg: 0 28px 70px rgba(74, 50, 23, 0.22);
  --shadow-md: 0 16px 34px rgba(84, 58, 30, 0.18);
  --shadow-sm: 0 8px 20px rgba(92, 66, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink-0);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1000px 560px at 8% 0%, rgba(255, 246, 220, 0.58), transparent 70%),
    radial-gradient(820px 460px at 92% 100%, rgba(149, 93, 57, 0.15), transparent 72%),
    linear-gradient(140deg, var(--bg-0), var(--bg-1) 40%, var(--bg-2));
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(980px 580px at 90% 8%, rgba(255, 236, 198, 0.18), transparent 72%),
    radial-gradient(620px 360px at 0% 92%, rgba(126, 86, 52, 0.12), transparent 72%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(53, 36, 17, 0.045) 0px,
      rgba(53, 36, 17, 0.045) 1px,
      transparent 1px,
      transparent 4px
    );
}

.app-shell {
  width: min(1240px, 95vw);
  margin: 24px auto;
}

.glass {
  position: relative;
  border: 1px solid rgba(172, 132, 89, 0.4);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(251, 246, 237, 0.96), rgba(243, 233, 217, 0.96)),
    linear-gradient(120deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.glass::before,
.glass::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  pointer-events: none;
  border-radius: 999px;
  z-index: 0;
}

.glass::before {
  top: -108px;
  left: -108px;
  background: radial-gradient(circle, rgba(199, 154, 92, 0.16), transparent 72%);
}

.glass::after {
  bottom: -138px;
  right: -118px;
  background: radial-gradient(circle, rgba(122, 59, 45, 0.11), transparent 72%);
}

.main-panel {
  width: 100%;
  min-height: calc(100vh - 48px);
  position: relative;
  transition: max-width 220ms ease;
}

.main-panel > * {
  position: relative;
  z-index: 1;
}

.main-panel.form-mode {
  max-width: 920px;
  margin: 0 auto;
  min-height: auto;
}

.flow-stage {
  padding: 34px 36px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-hero {
  position: relative;
  min-height: 210px;
}

.panel-head {
  padding-right: 270px;
  margin-bottom: 4px;
}

.panel-head::after {
  content: "";
  display: block;
  width: 112px;
  height: 2px;
  margin-top: 12px;
  background: linear-gradient(90deg, rgba(156, 98, 70, 0.85), rgba(156, 98, 70, 0));
}

.hero-portrait {
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 235px;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.form-hero .ritual {
  margin-top: 8px;
}

.form-hero .ritual,
.form-hero .ritual-form,
.form-hero .question-field,
.form-hero .question-field textarea,
.form-hero .ritual-form select,
.form-hero .advanced-box,
.form-hero .actions,
.form-hero .form-status {
  width: 100%;
  max-width: none;
}

.hero-portrait img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: right top;
  mix-blend-mode: multiply;
  opacity: 0.95;
  filter: saturate(0.9) contrast(1.02);
}

.brand-chip {
  margin: 0;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(160, 119, 76, 0.55);
  border-radius: 999px;
  padding: 6px 15px;
  font-size: 12px;
  letter-spacing: 0.7px;
  color: #6a4a2d;
  background: linear-gradient(180deg, rgba(255, 247, 232, 0.95), rgba(248, 235, 211, 0.92));
}

h1 {
  margin: 14px 0 8px;
  font-family: "Source Han Serif SC", "STSong", serif;
  font-size: clamp(2.45rem, 4.4vw, 3.28rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: 0.5px;
  color: #2f2418;
}

.brand-sub {
  margin: 0;
  color: #695641;
  font-size: 1.08rem;
  letter-spacing: 0.2px;
}

h2 {
  margin: 0;
  font-family: "Source Han Serif SC", "STSong", serif;
  font-size: 2.16rem;
  font-weight: 600;
  color: #332618;
}

.ritual {
  position: relative;
}

.ritual-form {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  margin: 0;
}

label span {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-1);
}

input,
textarea,
select {
  width: 100%;
  border-radius: 15px;
  border: 1px solid var(--line-0);
  background:
    linear-gradient(180deg, rgba(255, 251, 243, 0.96), rgba(246, 236, 219, 0.92));
  color: var(--ink-0);
  font: inherit;
  padding: 12px 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

input::placeholder,
textarea::placeholder {
  color: #9e886b;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--line-1);
  box-shadow:
    0 0 0 3px rgba(188, 144, 92, 0.18),
    0 8px 18px rgba(117, 79, 45, 0.12);
}

textarea {
  resize: vertical;
}

.question-field textarea {
  min-height: 148px;
  padding: 17px;
  font-size: 1.25rem;
  line-height: 1.65;
  border-color: #cfb08a;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.98), rgba(245, 232, 211, 0.94)),
    radial-gradient(circle at 100% 0, rgba(144, 73, 52, 0.11), transparent 52%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 10px 20px rgba(128, 90, 57, 0.1);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #7b6448 50%),
    linear-gradient(135deg, #7b6448 50%, transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0));
  background-position: calc(100% - 20px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px), 0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.advanced-box {
  border: 1px solid #d1b28d;
  border-radius: 15px;
  background: linear-gradient(180deg, #f6ecd9, #efe2cb);
  overflow: hidden;
}

.advanced-box summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 15px;
  font-size: 15px;
  font-weight: 700;
  color: #5a4128;
  background:
    linear-gradient(180deg, rgba(255, 248, 235, 0.95), rgba(241, 225, 196, 0.85));
  border-bottom: 1px solid rgba(190, 157, 118, 0.48);
}

.advanced-box summary::-webkit-details-marker {
  display: none;
}

.advanced-box summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 180ms ease;
}

.advanced-box[open] summary::before {
  transform: rotate(90deg);
}

.advanced-content {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 15px;
  padding: 11px 18px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  transition: transform 170ms ease, box-shadow 170ms ease, filter 170ms ease;
}

.btn:active {
  transform: translateY(1px) scale(0.995);
}

.btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.28);
  box-shadow: none;
  transform: none;
  opacity: 0.7;
}

.btn-main {
  color: #fff8ee;
  background: linear-gradient(142deg, var(--gold-0), var(--gold-1));
  box-shadow:
    0 12px 24px rgba(140, 96, 49, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.btn-main:hover {
  filter: brightness(1.03) saturate(1.03);
  transform: translateY(-1px);
}

.btn-main:disabled {
  color: #efe8da;
  background: linear-gradient(145deg, #b7ac98, #978a74);
}

.btn-ghost {
  color: #604a32;
  border: 1px solid #cfb391;
  background: linear-gradient(180deg, #fdf5e8, #f4e6cf);
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover {
  background: linear-gradient(180deg, #fff8ed, #f5e8d1);
  transform: translateY(-1px);
}

.form-status {
  min-height: 27px;
  margin: 2px 2px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: #6f5b45;
}

.runtime-box {
  margin-top: 18px;
  border: 1px solid rgba(191, 157, 119, 0.52);
  border-radius: 20px;
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.95), rgba(246, 236, 218, 0.9)),
    linear-gradient(90deg, rgba(196, 151, 90, 0.08), rgba(196, 151, 90, 0));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 8px 20px rgba(95, 65, 35, 0.08);
}

.copyright-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.copyright-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 6px;
  font-family: "Source Han Serif SC", "STSong", serif;
  font-size: 15px;
  color: #5b4027;
  border: 1px solid rgba(186, 147, 102, 0.72);
  background: linear-gradient(180deg, #fff3de, #ecd3a8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.copyright-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.copyright-meta {
  min-width: 0;
}

.copyright-name {
  margin: 0;
  color: #3f2d1c;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.copyright-sub {
  margin: 2px 0 0;
  color: #81694f;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copyright-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #5b4026;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid rgba(193, 160, 122, 0.9);
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #fff7e8, #f3dfbd);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 6px 14px rgba(118, 83, 48, 0.12);
}

.copyright-link::after {
  content: "↗";
  font-size: 11px;
  opacity: 0.9;
}

.copyright-link:hover {
  color: #7c3528;
  transform: translateY(-1px);
  filter: brightness(1.015);
  box-shadow: 0 8px 18px rgba(119, 84, 49, 0.18);
}

.chat-stage {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: calc(100vh - 48px);
}

.hidden {
  display: none;
}

.chat-head {
  padding: 22px 24px;
  border-bottom: 1px solid #dec8a9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, rgba(255, 249, 237, 0.82), rgba(249, 239, 221, 0.64));
}

.chat-head p {
  margin: 8px 0 0;
  color: #755f47;
}

.chat-log {
  padding: 22px;
  overflow: auto;
  display: grid;
  gap: 16px;
  align-content: start;
}

.msg-item {
  display: flex;
  gap: 11px;
  max-width: min(92%, 810px);
}

.msg-item.user {
  justify-self: end;
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  flex-shrink: 0;
  border: 1px solid #c8ad85;
  background:
    radial-gradient(circle at 26% 24%, #efd6aa, #a17442 70%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  box-shadow: 0 6px 14px rgba(114, 79, 46, 0.26);
}

.msg-item.user .avatar {
  border-color: #9eb0c3;
  background:
    radial-gradient(circle at 26% 24%, #dbe8f2, #5f7993 72%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
}

.speaker {
  margin: 0 0 6px;
  font-size: 12px;
  color: #79624a;
}

.bubble-wrap {
  min-width: 0;
}

.msg-item.user .bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-item.user .speaker {
  text-align: right;
  margin-right: 2px;
}

.bubble {
  padding: 12px 14px;
  line-height: 1.68;
  border-radius: 16px;
  border: 1px solid #d5be9f;
  background: linear-gradient(180deg, #fff8ee, #f8eedf);
  box-shadow: 0 10px 24px rgba(132, 95, 57, 0.12);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.msg-item.user .bubble {
  background: linear-gradient(180deg, #f3e6d4, #ead8bf);
  border-color: #cfb28c;
}

.msg-item.system .bubble {
  background: linear-gradient(180deg, #fbf5e3, #f2e9c9);
  border-color: #d8ca9e;
}

.bubble > :first-child {
  margin-top: 0;
}

.bubble > :last-child {
  margin-bottom: 0;
}

.bubble p {
  margin: 0.48em 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  margin: 0.28em 0 0.4em;
  font-family: "Source Han Serif SC", "STSong", serif;
  line-height: 1.34;
}

.bubble h1 {
  font-size: 1.2rem;
}

.bubble h2 {
  font-size: 1.12rem;
}

.bubble h3 {
  font-size: 1.04rem;
}

.bubble ul,
.bubble ol {
  margin: 0.4em 0;
  padding-left: 1.14em;
}

.bubble li {
  margin: 0.22em 0;
}

.bubble blockquote {
  margin: 0.45em 0;
  padding-left: 0.74em;
  border-left: 3px solid #d0b28b;
  color: #6f563d;
}

.bubble code {
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: 0.92em;
  border-radius: 6px;
  padding: 0.08em 0.38em;
  border: 1px solid rgba(123, 83, 43, 0.24);
  background: rgba(117, 74, 30, 0.12);
}

.bubble pre {
  margin: 0.5em 0;
  padding: 0.68em 0.74em;
  border-radius: 11px;
  border: 1px solid #d8c09f;
  background: rgba(255, 245, 228, 0.9);
  overflow: auto;
}

.bubble pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.bubble a {
  color: #7d3326;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.chat-composer {
  border-top: 1px solid #dcc7a8;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  background: linear-gradient(180deg, rgba(252, 245, 233, 0.9), rgba(245, 234, 216, 0.92));
}

.chat-composer input {
  min-height: 50px;
}

.typing-dot {
  display: inline-flex;
  gap: 5px;
}

.typing-dot span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #8e7357;
  animation: blink 900ms infinite;
}

.typing-dot span:nth-child(2) {
  animation-delay: 110ms;
}

.typing-dot span:nth-child(3) {
  animation-delay: 220ms;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(95vw, 680px);
    margin: 12px auto;
  }

  .main-panel,
  .flow-stage,
  .chat-stage {
    min-height: calc(100vh - 24px);
  }

  .glass {
    border-radius: 18px;
  }

  .flow-stage,
  .chat-head,
  .chat-log,
  .chat-composer {
    padding: 13px;
  }

  .form-hero {
    min-height: auto;
  }

  .panel-head {
    padding-right: 0;
  }

  .hero-portrait {
    position: static;
    width: 100%;
    height: auto;
    min-height: 220px;
    border-radius: 18px;
  }

  .two-col,
  .actions,
  .chat-composer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .runtime-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .copyright-sub {
    white-space: normal;
  }

  .actions .btn,
  .chat-composer .btn,
  .chat-head .btn {
    width: 100%;
  }

  .chat-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .msg-item {
    max-width: 100%;
  }

  .question-field textarea {
    min-height: 124px;
    font-size: 1.12rem;
  }
}
