:root {
  color-scheme: light;
  --ink: #24221f;
  --muted: #77736a;
  --line: rgba(71, 62, 48, 0.14);
  --paper: #f7f3ea;
  --paper-deep: #ece4d6;
  --panel: rgba(255, 253, 247, 0.78);
  --accent: #a02f3a;
  --accent-dark: #70212a;
  --ink-soft: #4b463d;
  --green: #3f6c54;
  --shadow: 0 26px 80px rgba(52, 42, 31, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(160, 47, 58, 0.08), transparent 28%),
    radial-gradient(circle at 86% 80%, rgba(63, 108, 84, 0.10), transparent 32%),
    linear-gradient(90deg, rgba(71, 62, 48, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(71, 62, 48, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", SimSun, "Microsoft YaHei", serif;
}

button,
textarea,
input {
  font: inherit;
}

.plum-wash {
  position: fixed;
  inset: auto 0 0 auto;
  width: min(54vw, 620px);
  aspect-ratio: 760 / 620;
  background: url("/plum-branch.svg") center / contain no-repeat;
  opacity: 0.9;
  pointer-events: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.92fr);
  gap: 22px;
  align-items: stretch;
}

.workspace,
.result-panel {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 252, 245, 0.58)),
    var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.64);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.15);
}

.workspace::before,
.result-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent),
    repeating-linear-gradient(90deg, rgba(83, 71, 52, 0.028) 0 1px, transparent 1px 6px);
  pointer-events: none;
}

.workspace > *,
.result-panel > * {
  position: relative;
}

.workspace {
  border-radius: 18px;
  padding: 28px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow: auto;
}

.result-panel {
  border-radius: 18px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 64px);
}

.topbar,
.result-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  font-weight: 500;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  font-size: 25px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
}

h2 {
  font-size: 26px;
  line-height: 1.1;
}

.status {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.46);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

.input-panel {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 9px;
}

label span {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 15px 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  line-height: 1.65;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus {
  border-color: rgba(155, 39, 53, 0.7);
  box-shadow: 0 0 0 4px rgba(155, 39, 53, 0.1);
}

input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.66);
  outline: none;
}

input:focus {
  border-color: rgba(155, 39, 53, 0.7);
  box-shadow: 0 0 0 4px rgba(155, 39, 53, 0.1);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 4px;
}

button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 42px;
  padding: 0 18px;
  font-weight: 600;
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #b13b47, var(--accent-dark));
  box-shadow: 0 10px 22px rgba(112, 33, 42, 0.2);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.icon-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(71, 62, 48, 0.16);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: rgba(155, 39, 53, 0.45);
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  min-height: 340px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(71, 62, 48, 0.18);
  border-radius: 16px;
  padding: 28px;
  line-height: 1.7;
  background:
    linear-gradient(rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.24)),
    url("/plum-branch.svg") right bottom / 260px auto no-repeat;
}

.empty-state.has-answer {
  display: block;
  white-space: pre-wrap;
  text-align: left;
  place-items: initial;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.82;
  border-style: solid;
  border-color: rgba(160, 47, 58, 0.18);
  border-left: 5px solid var(--accent);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 248, 0.54)),
    rgba(255, 255, 255, 0.34);
  box-shadow: 0 14px 34px rgba(112, 33, 42, 0.08);
}

.empty-state.has-answer::first-line {
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 700;
}

.empty-state.has-answer {
  display: block;
  text-align: left;
  white-space: normal;
  overflow: auto;
  min-height: 0;
  max-height: none;
  color: var(--ink-soft);
}

.empty-state.has-answer p {
  margin: 0 0 14px;
}

.empty-state.has-answer p:last-child {
  margin-bottom: 0;
}

.empty-state.has-answer h1,
.empty-state.has-answer h2,
.empty-state.has-answer h3 {
  margin: 22px 0 10px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.35;
}

.empty-state.has-answer h1 {
  font-size: 24px;
}

.empty-state.has-answer h2 {
  font-size: 22px;
}

.empty-state.has-answer h3 {
  font-size: 19px;
}

.empty-state.has-answer h1:first-child,
.empty-state.has-answer h2:first-child,
.empty-state.has-answer h3:first-child {
  margin-top: 0;
}

.empty-state.has-answer ul,
.empty-state.has-answer ol {
  margin: 0 0 14px;
  padding-left: 24px;
}

.empty-state.has-answer li {
  margin: 6px 0;
}

.empty-state.has-answer blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 4px solid rgba(160, 47, 58, 0.55);
  background: rgba(255, 255, 255, 0.44);
  color: var(--ink-soft);
}

.empty-state.has-answer code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(71, 62, 48, 0.08);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.empty-state.has-answer strong {
  color: var(--ink);
  font-weight: 700;
}

.empty-state.has-answer em {
  font-style: normal;
  color: var(--accent-dark);
}

.empty-state.has-answer .conclusion-block {
  display: block;
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid rgba(160, 47, 58, 0.14);
  border-left: 4px solid rgba(160, 47, 58, 0.72);
  border-radius: 12px;
  background: rgba(255, 250, 247, 0.74);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.78;
  font-weight: 700;
}

.empty-state.has-answer .conclusion-block strong {
  color: var(--accent-dark);
}

.empty-state.has-answer .conclusion-title,
.empty-state.has-answer .conclusion-text {
  display: block;
}

.empty-state.has-answer .conclusion-title {
  margin-bottom: 6px;
}

.answer {
  white-space: pre-wrap;
  line-height: 1.82;
  font-size: 18px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 248, 248, 0.54)),
    rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(160, 47, 58, 0.18);
  border-left: 5px solid var(--accent);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 14px 34px rgba(112, 33, 42, 0.08);
}

.process-panel {
  flex: 0 0 auto;
  margin-top: 14px;
  border: 1px solid rgba(71, 62, 48, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.process-panel summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink-soft);
  font-weight: 700;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

.process-panel[open] summary {
  border-bottom: 1px solid rgba(71, 62, 48, 0.1);
}

.thinking-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border: 1px solid rgba(71, 62, 48, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-soft);
}

.thinking-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1100ms ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.86);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.gua-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.gua-item {
  min-height: 78px;
  padding: 13px 14px;
  border: 1px solid rgba(71, 62, 48, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.38);
}

.gua-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

.gua-value {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.45;
}

.gua-wide {
  grid-column: 1 / -1;
}

.answer strong {
  color: var(--accent-dark);
}

.notice {
  color: var(--accent-dark);
}

@media (max-width: 900px) {
  .plum-wash {
    width: 86vw;
    opacity: 0.5;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    width: min(100% - 22px, 680px);
    padding: 16px 0;
  }

  .workspace,
  .result-panel {
    padding: 20px;
    max-height: none;
  }

  .topbar,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .status {
    max-width: none;
    text-align: left;
  }

  .title-lockup {
    gap: 10px;
  }

  .seal {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 22px;
  }

  .actions {
    flex-direction: column-reverse;
  }

  .gua-summary {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
