/* ============================================================
   墨生 · 中式美学 AIGC
   Paper, ink, cinnabar and a little jade.
   ============================================================ */

:root {
  --ink: #1d1b17;
  --ink-soft: #35312a;
  --muted: #7c7468;
  --muted-light: #9b9285;
  --paper: #f2ede3;
  --paper-light: #f9f5ec;
  --paper-deep: #e8e0d1;
  --line: rgba(29, 27, 23, 0.12);
  --line-strong: rgba(29, 27, 23, 0.24);
  --cinnabar: #9c3b2d;
  --cinnabar-deep: #7c2d22;
  --jade: #63786b;
  --gold: #b2935f;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --shadow-soft: 0 20px 50px -30px rgba(29, 27, 23, 0.38);
  --shadow-card: 0 30px 80px -40px rgba(29, 27, 23, 0.55);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body.is-locked {
  overflow: hidden;
}

::selection {
  background: rgba(156, 59, 45, 0.18);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 3px;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
  opacity: 0.032;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  padding: 24px 0 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(156, 59, 45, 0.16), transparent 46%),
    #191814;
  color: var(--paper);
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: rgba(242, 237, 227, 0.07);
}

.seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(242, 237, 227, 0.52);
  color: #f3e9d8;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1;
  transition: border-color 0.3s var(--ease), transform 0.4s var(--ease);
}

.seal::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(156, 59, 45, 0.6);
}

.seal i {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 7px;
  height: 7px;
  background: var(--cinnabar);
}

.seal:hover {
  border-color: #f3e9d8;
  transform: rotate(-3deg);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-top: 56px;
}

.side-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 52px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(242, 237, 227, 0.42);
  transition: color 0.3s var(--ease);
}

.side-link svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-link span {
  font-size: 9px;
  letter-spacing: 0.16em;
}

.side-link::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  width: 2px;
  height: 0;
  background: var(--cinnabar);
  transform: translateY(-50%);
  transition: height 0.3s var(--ease);
}

.side-link:hover,
.side-link.is-active {
  color: #f3e9d8;
}

.side-link.is-active::before {
  height: 24px;
}

.side-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: auto;
}

.side-mini {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(242, 237, 227, 0.22);
  border-radius: 50%;
  background: none;
  color: rgba(242, 237, 227, 0.5);
  font-family: var(--serif);
  font-size: 12px;
  transition: 0.3s var(--ease);
}

.side-mini:hover {
  border-color: rgba(242, 237, 227, 0.65);
  color: var(--paper);
}

.side-rule {
  width: 1px;
  height: 28px;
  background: rgba(242, 237, 227, 0.14);
}

.side-mark {
  color: rgba(242, 237, 227, 0.32);
  font-size: 7px;
  line-height: 1.7;
  letter-spacing: 0.16em;
  text-align: center;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 12%, rgba(255, 252, 246, 0.92), transparent 38%),
    radial-gradient(circle at 8% 94%, rgba(222, 210, 189, 0.34), transparent 44%),
    var(--paper);
}

.topbar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  max-width: 1420px;
  height: 78px;
  margin: 0 auto;
  padding: 0 clamp(22px, 3.4vw, 54px);
}

.wordmark {
  display: flex;
  align-items: baseline;
  gap: 13px;
}

.wordmark-cn {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.22em;
}

.wordmark-en {
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.28em;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.engine-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.4);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: 0.3s var(--ease);
}

.engine-pill:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.status-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(99, 120, 107, 0.12);
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid rgba(99, 120, 107, 0.5);
  border-radius: 50%;
  animation: pulse 2.6s ease-out infinite;
}

.engine-pill.is-demo .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(178, 147, 95, 0.14);
}

.engine-pill.is-demo .status-dot::after {
  border-color: rgba(178, 147, 95, 0.55);
}

.knowledge-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 7px 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(29, 27, 23, 0.045);
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  transition: 0.3s var(--ease);
}

.knowledge-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.knowledge-btn b {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-light);
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 500;
}

.knowledge-btn:hover {
  border-color: var(--line);
  background: rgba(255, 252, 246, 0.6);
}

.history-btn b {
  background: var(--jade);
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  max-width: 1420px;
  min-height: 0;
  margin: 0 auto;
  padding: 0 clamp(22px, 3.4vw, 54px);
}

/* ---------- stage ---------- */

.stage {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1.06fr) minmax(320px, 0.94fr);
  align-items: center;
  gap: clamp(24px, 4vw, 70px);
  min-height: 330px;
  padding: clamp(26px, 4.6vh, 58px) 0 18px;
}

.intro {
  max-width: 620px;
  animation: rise 0.9s var(--ease) both;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.26em;
  line-height: 1.4;
  text-transform: uppercase;
}

.eyebrow > span {
  width: 22px;
  height: 1px;
  background: var(--cinnabar);
}

.intro h1 {
  margin: 22px 0 0;
  font-family: var(--serif);
  font-size: clamp(44px, 4.7vw, 72px);
  font-weight: 500;
  line-height: 1.19;
  letter-spacing: 0.01em;
}

.intro h1 em {
  position: relative;
  color: var(--cinnabar);
  font-style: normal;
}

.intro h1 em::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 4%;
  bottom: 3px;
  height: 1px;
  background: linear-gradient(90deg, rgba(156, 59, 45, 0.45), transparent);
}

.intro-copy {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 2.05;
  letter-spacing: 0.03em;
}

.intro-index {
  display: flex;
  gap: 32px;
  margin-top: 38px;
}

.intro-index > div {
  padding-left: 13px;
  border-left: 1px solid var(--line);
}

.intro-index strong {
  display: block;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.2;
}

.intro-index small {
  display: block;
  margin-top: 4px;
  color: var(--muted-light);
  font-size: 8.5px;
  letter-spacing: 0.14em;
}

.ink-stage {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 560px;
  height: clamp(300px, 42vh, 450px);
  animation: rise 1.1s 0.08s var(--ease) both;
}

.sun-disc {
  position: absolute;
  top: 14%;
  left: 48%;
  width: clamp(150px, 17vw, 226px);
  height: clamp(150px, 17vw, 226px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(156, 59, 45, 0.2), rgba(156, 59, 45, 0.09) 58%, transparent 70%);
  filter: blur(1px);
}

.ink-ring {
  position: absolute;
  top: 3%;
  right: 3%;
  width: clamp(180px, 22vw, 290px);
  height: clamp(180px, 22vw, 290px);
  border: 1px solid rgba(29, 27, 23, 0.07);
  border-radius: 50%;
}

.ink-ring::before,
.ink-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(29, 27, 23, 0.045);
}

.ink-ring::before {
  inset: 12%;
}

.ink-ring::after {
  inset: 25%;
}

.mountain {
  position: absolute;
  right: -3%;
  bottom: 0;
  width: 106%;
  height: 78%;
  overflow: visible;
}

.mountain path {
  fill: none;
  stroke: var(--ink);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mountain .m1 {
  stroke-width: 1.15;
  stroke-opacity: 0.36;
}

.mountain .m2 {
  stroke-width: 0.9;
  stroke-opacity: 0.2;
}

.mountain .m3 {
  stroke-width: 0.7;
  stroke-opacity: 0.11;
}

.vertical-poem {
  position: absolute;
  top: 12%;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 13px;
  border-right: 1px solid rgba(29, 27, 23, 0.12);
  color: rgba(29, 27, 23, 0.52);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.18em;
}

.ink-caption {
  position: absolute;
  bottom: 3%;
  left: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted-light);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.ink-caption .caption-line {
  width: 42px;
  height: 1px;
  background: rgba(29, 27, 23, 0.2);
}

.ink-seal {
  position: absolute;
  top: 15%;
  left: 11%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(156, 59, 45, 0.65);
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
  transform: rotate(-5deg);
  opacity: 0.85;
}

/* ---------- composer ---------- */

.workbench {
  flex: none;
  padding-bottom: 16px;
  margin-top: auto;
}

.composer {
  padding: 17px 22px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 246, 0.64);
  box-shadow:
    0 24px 60px -38px rgba(29, 27, 23, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.composer:focus-within {
  border-color: rgba(156, 59, 45, 0.32);
  box-shadow:
    0 26px 64px -38px rgba(29, 27, 23, 0.52),
    0 0 0 3px rgba(156, 59, 45, 0.035);
}

.composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-label {
  color: rgba(29, 27, 23, 0.55);
  font-size: 9.5px;
  letter-spacing: 0.18em;
}

.composer-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-light);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.composer-tip i {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

#charCount {
  font-variant-numeric: tabular-nums;
}

#charCount.is-near {
  color: var(--cinnabar);
}

#promptInput {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 160px;
  margin-top: 5px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(15px, 1.2vw, 16.5px);
  line-height: 1.8;
  resize: none;
}

#promptInput::placeholder {
  color: rgba(29, 27, 23, 0.3);
}

.idea-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-top: 3px;
}

.idea-row > span {
  margin-right: 2px;
  color: var(--muted-light);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.idea {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  transition: 0.25s var(--ease);
}

.idea:hover {
  border-color: rgba(29, 27, 23, 0.3);
  background: rgba(255, 252, 246, 0.65);
  color: var(--ink);
}

.composer-divider {
  height: 1px;
  margin: 13px 0 11px;
  background: var(--line);
}

.composer-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-label {
  color: var(--muted-light);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.segmented {
  display: flex;
  gap: 1px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(29, 27, 23, 0.055);
}

.segmented button {
  min-width: 33px;
  height: 25px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  transition: 0.25s var(--ease);
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--ink);
  color: var(--paper-light);
  box-shadow: 0 2px 7px rgba(29, 27, 23, 0.22);
}

.control-hint {
  color: var(--muted-light);
  font-size: 9px;
  letter-spacing: 0.03em;
  opacity: 0.84;
}

.selects {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  row-gap: 6px;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}

.select-wrap > span {
  color: var(--muted-light);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.select-wrap select {
  max-width: 94px;
  padding: 5px 14px 5px 3px;
  border: 0;
  outline: 0;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M1 1l3 3 3-3' fill='none' stroke='%237c7468' stroke-width='1' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  color: var(--ink-soft);
  font-size: 10.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.select-wrap select option {
  background: var(--paper-light);
  color: var(--ink);
}

.select-wrap--model select {
  max-width: 126px;
  color: var(--ink);
  font-weight: 500;
}

.select-wrap--llm select {
  max-width: 118px;
  color: var(--ink);
  font-weight: 500;
}

.select-wrap--llm select:disabled,
.select-wrap--model select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.polish-btn {
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: rgba(29, 27, 23, 0.72);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  transition: 0.25s var(--ease);
}

.polish-btn:hover {
  border-color: var(--ink);
  background: rgba(255, 252, 246, 0.55);
  color: var(--ink);
}

.generate-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 17px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #f7f1e4;
  font-size: 11px;
  letter-spacing: 0.06em;
  box-shadow: 0 8px 20px -12px rgba(29, 27, 23, 0.9);
  transition: 0.3s var(--ease);
}

.btn-arrow {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(247, 241, 228, 0.26);
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  transition: 0.3s var(--ease);
}

.generate-btn:hover {
  background: #2c2822;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -14px rgba(29, 27, 23, 0.9);
}

.generate-btn:hover .btn-arrow {
  background: var(--cinnabar);
  border-color: var(--cinnabar);
  transform: rotate(45deg);
}

.generate-btn:disabled,
.polish-btn:disabled {
  opacity: 0.5;
  transform: none;
}

.generate-btn.is-busy .btn-text::after {
  content: "…";
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  padding: 10px 0 0;
  color: var(--muted-light);
  font-size: 8.5px;
  letter-spacing: 0.06em;
}

/* ---------- results ---------- */

.result-area {
  padding: 28px 0 24px;
  animation: rise 0.7s var(--ease) both;
}

.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.result-head h2 {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: clamp(27px, 2.8vw, 38px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.result-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 4px;
}

.line-btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: 0.25s var(--ease);
}

.line-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(255, 252, 246, 0.5);
}

.result-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
  gap: clamp(16px, 2vw, 26px);
}

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

.result-grid[data-count="1"] {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.result-grid[data-count="1"] .work-card {
  width: var(--single-width, auto);
  max-width: 100%;
  aspect-ratio: var(--ratio, 1);
}

.result-grid[data-count="1"] .work-card img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
}

.work-card {
  position: relative;
  overflow: hidden;
  margin: 0;
  border: 1px solid rgba(29, 27, 23, 0.1);
  border-radius: 3px;
  background: var(--paper-deep);
  box-shadow: 0 18px 40px -30px rgba(29, 27, 23, 0.65);
  animation: rise 0.8s var(--ease) both;
}

.work-card:nth-child(2) {
  animation-delay: 0.07s;
}

.work-card:nth-child(3) {
  animation-delay: 0.14s;
}

.work-card:nth-child(4) {
  animation-delay: 0.21s;
}

.work-card img {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 1);
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s var(--ease), transform 1.2s var(--ease);
}

.work-card img.is-loaded {
  opacity: 1;
}

.work-card:hover img {
  transform: scale(1.015);
}

.work-shade {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 13px;
  background: linear-gradient(180deg, rgba(20, 18, 15, 0.18), transparent 30%, transparent 62%, rgba(20, 18, 15, 0.5));
  opacity: 0.75;
  transition: opacity 0.35s var(--ease);
}

.work-card:hover .work-shade {
  opacity: 1;
}

.work-index {
  align-self: flex-start;
  color: rgba(255, 251, 242, 0.82);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.16em;
}

.work-tools {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.work-tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 251, 242, 0.3);
  border-radius: 50%;
  background: rgba(20, 18, 15, 0.28);
  color: #fffaf0;
  backdrop-filter: blur(8px);
  transition: 0.25s var(--ease);
}

.work-tool svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.work-tool:hover {
  border-color: rgba(255, 251, 242, 0.7);
  background: rgba(20, 18, 15, 0.55);
}

.work-note {
  position: sticky;
  top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 252, 246, 0.36);
}

.note-kicker {
  margin: 0;
  color: var(--cinnabar);
  font-size: 8px;
  letter-spacing: 0.28em;
}

.note-prompt {
  max-height: 232px;
  margin: 12px 0 0;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 12.5px;
  line-height: 1.95;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 27, 23, 0.2) transparent;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 14px;
}

.note-meta span {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.05em;
}

.note-block {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.note-label {
  margin: 0 0 8px;
  color: var(--muted-light);
  font-size: 8.5px;
  letter-spacing: 0.17em;
}

.note-label.spaced {
  margin-top: 18px;
}

.label-count {
  color: var(--cinnabar);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 252, 246, 0.4);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.note-refs {
  display: grid;
  gap: 8px;
}

.ref-item {
  padding-left: 8px;
  border-left: 1px solid rgba(156, 59, 45, 0.34);
}

.ref-item strong {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-item p {
  display: -webkit-box;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ref-empty {
  color: var(--muted-light);
  font-size: 9px;
}

.note-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 16px;
  padding: 13px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: var(--ink-soft);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.note-link span {
  color: var(--cinnabar);
  transition: transform 0.3s var(--ease);
}

.note-link:hover span {
  transform: translate(2px, -2px);
}

.result-warning {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px dashed rgba(156, 59, 45, 0.35);
  background: rgba(156, 59, 45, 0.04);
  color: #7e3a2e;
  font-size: 10px;
  line-height: 1.75;
  word-break: break-word;
}

.dialog-warning {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: 1px dashed rgba(156, 59, 45, 0.35);
  background: rgba(156, 59, 45, 0.05);
  color: #7e3a2e;
  font-size: 11px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- loading ---------- */

.loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.loading-scrim {
  position: absolute;
  inset: 0;
  background: rgba(242, 237, 227, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.loading-card {
  position: relative;
  width: min(370px, 100%);
  padding: 34px 32px 22px;
  border: 1px solid var(--line);
  background: rgba(250, 247, 240, 0.96);
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: rise 0.55s var(--ease) both;
}

.loading-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(29, 27, 23, 0.055);
  pointer-events: none;
}

.loading-seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border: 1px solid rgba(156, 59, 45, 0.55);
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 25px;
  animation: breathe 3.4s ease-in-out infinite;
}

.loading-seal i {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 8px;
  height: 8px;
  background: var(--cinnabar);
}

.loading-kicker {
  margin: 0;
  color: var(--muted-light);
  font-size: 7.5px;
  letter-spacing: 0.3em;
}

.loading-card h3 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.loading-steps {
  display: grid;
  gap: 8px;
  max-width: 236px;
  margin: 22px auto 0;
  text-align: left;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-light);
  font-size: 10px;
  letter-spacing: 0.03em;
  opacity: 0.48;
  transition: 0.4s var(--ease);
}

.loading-step i {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transition: 0.4s var(--ease);
}

.loading-step.is-active {
  color: var(--ink);
  opacity: 1;
}

.loading-step.is-active i {
  border-color: var(--cinnabar);
  background: var(--cinnabar);
  box-shadow: 0 0 0 4px rgba(156, 59, 45, 0.1);
}

.loading-step.is-done {
  color: var(--muted);
  opacity: 1;
}

.loading-step.is-done i {
  border-color: var(--jade);
  background: var(--jade);
}

.loading-quote {
  margin: 24px 0 0;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.loading-time {
  margin: 8px 0 0;
  color: var(--muted-light);
  font-size: 8px;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}

/* ---------- prompt dialog ---------- */

.prompt-dialog {
  width: min(1040px, calc(100vw - 40px));
  max-width: none;
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f6f1e7;
  color: var(--ink);
  box-shadow: 0 40px 120px -30px rgba(20, 18, 15, 0.7);
  overflow: hidden;
}

.prompt-dialog::backdrop {
  background: rgba(20, 18, 15, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.prompt-dialog[open] {
  animation: dialogIn 0.4s var(--ease) both;
}

.dialog-inner {
  max-height: 90vh;
  padding: 28px 34px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 27, 23, 0.22) transparent;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  margin: 9px 0 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 300;
  line-height: 1;
  transition: 0.25s var(--ease);
}

.dialog-close:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  transform: rotate(90deg);
}

.prompt-compare {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) 32px minmax(0, 1.35fr);
  align-items: stretch;
  gap: 10px;
  margin: 22px 0 26px;
}

.compare-block {
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.38);
}

.compare-block p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.95;
  white-space: pre-wrap;
}

.compare-block.is-polished {
  border-color: rgba(156, 59, 45, 0.26);
  background: rgba(156, 59, 45, 0.035);
}

.compare-block.is-polished p {
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: 12.5px;
}

.compare-block .note-label {
  margin-bottom: 8px;
  color: var(--muted-light);
}

.compare-arrow {
  display: grid;
  place-items: center;
  color: var(--cinnabar);
  font-size: 15px;
}

.dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.dialog-refs {
  display: grid;
  gap: 0;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 27, 23, 0.2) transparent;
}

.dialog-ref {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.dialog-ref:last-child {
  border-bottom: 0;
}

.dialog-ref-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.dialog-ref strong {
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 500;
}

.dialog-ref-head span {
  flex: none;
  color: var(--cinnabar);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.dialog-ref p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.75;
}

.rationale {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rationale li {
  position: relative;
  padding-left: 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.8;
}

.rationale li::before {
  content: "";
  position: absolute;
  top: 0.8em;
  left: 0;
  width: 5px;
  height: 1px;
  background: var(--cinnabar);
}

.negative-text {
  margin: 0;
  padding: 9px 11px;
  background: rgba(29, 27, 23, 0.035);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.8;
}

.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px -34px 0;
  padding: 15px 34px;
  border-top: 1px solid var(--line);
  background: rgba(246, 241, 231, 0.96);
  backdrop-filter: blur(8px);
}

.dialog-foot p {
  margin: 0;
  color: var(--muted-light);
  font-size: 8.5px;
  letter-spacing: 0.03em;
}

.dialog-foot > div {
  display: flex;
  gap: 8px;
}

.dialog-primary {
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper-light);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  transition: 0.25s var(--ease);
}

.dialog-primary:hover {
  background: var(--cinnabar-deep);
}

/* ---------- knowledge drawer ---------- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 170;
  pointer-events: none;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 15, 0.32);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
  backdrop-filter: blur(2px);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  height: 100%;
  padding: 24px 24px 0;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 252, 246, 0.8), transparent 40%),
    #f6f1e7;
  box-shadow: -30px 0 80px -40px rgba(20, 18, 15, 0.6);
  transform: translateX(102%);
  transition: transform 0.45s var(--ease);
}

.drawer.is-open {
  pointer-events: auto;
}

.drawer.is-open .drawer-scrim {
  opacity: 1;
}

.drawer.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drawer-head h2 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.kb-stats {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 0 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.kb-stats > div {
  padding-left: 13px;
  border-left: 1px solid var(--line);
}

.kb-stats > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.kb-stats strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.25;
}

.kb-stats span {
  display: block;
  margin-top: 1px;
  color: var(--muted-light);
  font-size: 8px;
  letter-spacing: 0.13em;
}

.kb-tools {
  display: flex;
  flex: none;
  gap: 7px;
}

.search-field {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 252, 246, 0.55);
  transition: border-color 0.25s var(--ease);
}

.search-field:focus-within {
  border-color: rgba(156, 59, 45, 0.45);
}

.search-field svg {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted-light);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.search-field input {
  width: 100%;
  padding: 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 10.5px;
}

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

.small-btn {
  flex: none;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  transition: 0.25s var(--ease);
}

.small-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.category-chips {
  display: flex;
  flex: none;
  gap: 5px;
  margin: 9px 0 0;
  padding: 0 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-chips::-webkit-scrollbar {
  display: none;
}

.category-chips button {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  transition: 0.2s var(--ease);
}

.category-chips button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.category-chips button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-light);
}

.manual-form {
  display: grid;
  flex: none;
  gap: 7px;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.46);
  animation: rise 0.3s var(--ease);
}

.form-row {
  display: flex;
  gap: 6px;
}

.manual-form input,
.manual-form textarea {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 1px;
  outline: 0;
  background: rgba(255, 252, 246, 0.6);
  font-size: 10.5px;
  line-height: 1.6;
  transition: border-color 0.2s var(--ease);
}

.manual-form input:focus,
.manual-form textarea:focus {
  border-color: rgba(156, 59, 45, 0.45);
}

.manual-form textarea {
  resize: vertical;
  min-height: 66px;
}

.form-actions {
  display: flex;
  flex: none;
  gap: 4px;
}

.text-btn {
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
}

.small-primary {
  flex: none;
  padding: 6px 11px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
  color: var(--paper-light);
  font-size: 9.5px;
  white-space: nowrap;
}

.small-primary:hover {
  background: var(--cinnabar-deep);
}

.upload-zone {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 11px 13px;
  border: 1px dashed rgba(29, 27, 23, 0.24);
  background: rgba(255, 252, 246, 0.28);
  cursor: pointer;
  transition: 0.25s var(--ease);
}

.upload-zone:hover,
.upload-zone.is-dragging {
  border-color: rgba(156, 59, 45, 0.5);
  background: rgba(156, 59, 45, 0.035);
}

.upload-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 15px;
  font-weight: 300;
  transition: 0.25s var(--ease);
}

.upload-zone:hover .upload-icon {
  border-color: var(--cinnabar);
  color: var(--cinnabar);
}

.upload-zone strong {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.upload-zone p {
  margin: 2px 0 0;
  color: var(--muted-light);
  font-size: 8.5px;
  line-height: 1.5;
}

.kb-list-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted-light);
  font-size: 8px;
  letter-spacing: 0.15em;
}

.kb-list {
  flex: 1;
  min-height: 0;
  margin-right: -6px;
  padding: 2px 6px 14px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 27, 23, 0.2) transparent;
}

.kb-item {
  position: relative;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.kb-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kb-cat {
  color: var(--cinnabar);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.kb-delete {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-light);
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transition: 0.2s var(--ease);
}

.kb-item:hover .kb-delete {
  opacity: 1;
}

.kb-delete:hover {
  background: rgba(156, 59, 45, 0.08);
  color: var(--cinnabar);
}

.kb-item h4 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
}

.kb-item > p {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.kb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.kb-tags span {
  padding: 1px 5px;
  background: rgba(29, 27, 23, 0.045);
  color: var(--muted-light);
  font-size: 7.5px;
  line-height: 1.6;
}

.kb-source {
  display: block;
  margin-top: 5px;
  color: var(--muted-light);
  font-size: 7.5px;
  letter-spacing: 0.03em;
  opacity: 0.8;
}

.kb-empty {
  padding: 34px 10px;
  color: var(--muted-light);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.8;
  text-align: center;
}

.kb-empty strong {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- history drawer ---------- */

.history-panel {
  width: min(500px, 100vw);
}

.history-summary {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 17px 0 5px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.history-summary b {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 12px;
  font-weight: 500;
}

.history-list {
  flex: 1;
  min-height: 0;
  margin-right: -6px;
  padding: 3px 6px 14px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(29, 27, 23, 0.2) transparent;
}

.history-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 13px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  outline: 0;
  transition: 0.25s var(--ease);
}

.history-card:hover,
.history-card:focus-visible {
  background: rgba(255, 252, 246, 0.5);
}

.history-thumb {
  position: relative;
  align-self: start;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 252, 246, 0.7), rgba(29, 27, 23, 0.05)),
    var(--paper);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.55s var(--ease), opacity 0.3s var(--ease);
}

.history-card:hover .history-thumb img {
  transform: scale(1.035);
}

.history-thumb.is-empty::before {
  content: "无图";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted-light);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.history-thumb.is-empty img {
  display: none;
}

.history-info {
  min-width: 0;
}

.history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-time {
  flex: none;
  color: var(--muted-light);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.history-info h4 {
  margin: 5px 0 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-prompt {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 7px;
}

.history-actions .text-btn,
.history-actions .small-btn {
  padding: 3px 7px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.38);
  font-size: 8.5px;
}

.history-actions .text-btn:hover,
.history-actions .small-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.history-actions .history-delete {
  margin-left: auto;
}

.history-empty {
  padding: 36px 10px;
  color: var(--muted-light);
  font-family: var(--serif);
  font-size: 11px;
  line-height: 1.9;
  text-align: center;
}

.history-empty strong {
  display: block;
  color: var(--muted);
  font-weight: 500;
}

.drawer-foot {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0 13px;
  border-top: 1px solid var(--line);
}

.drawer-foot > span {
  max-width: 225px;
  color: var(--muted-light);
  font-size: 7.5px;
  line-height: 1.5;
}

.text-danger {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cinnabar);
  font-size: 8.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- toast ---------- */

.toast-stack {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(430px, calc(100vw - 36px));
  padding: 9px 15px;
  border-left: 2px solid var(--cinnabar);
  background: rgba(29, 27, 23, 0.94);
  color: #f3ecdf;
  font-size: 10.5px;
  line-height: 1.65;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 34px -20px rgba(20, 18, 15, 0.8);
  animation: toastIn 0.35s var(--ease) both;
}

.toast.is-success {
  border-left-color: var(--jade);
}

.toast.is-error {
  border-left-color: #c05a48;
}

.toast.is-out {
  animation: toastOut 0.3s var(--ease) both;
}

/* ---------- animations ---------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.55;
    transform: scale(0.8);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(156, 59, 45, 0.06);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(156, 59, 45, 0);
    transform: translateY(-2px);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- responsive ---------- */

@media (max-width: 1240px) {
  .control-hint {
    display: none;
  }

  .result-body {
    grid-template-columns: minmax(0, 1fr) 292px;
  }

  .intro h1 {
    font-size: clamp(42px, 4.4vw, 62px);
  }
}

@media (max-width: 1040px) {
  .app {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .stage {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.72fr);
    gap: 24px;
  }

  .ink-stage {
    height: 340px;
  }

  .composer-controls {
    gap: 12px;
  }

  .selects {
    order: 3;
  }

  .send-actions {
    order: 4;
  }

  .result-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .work-note {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
    gap: 0 25px;
  }

  .work-note > .note-kicker,
  .work-note > .note-prompt,
  .work-note > .note-meta {
    grid-column: 1;
  }

  .work-note > .note-block,
  .work-note > .note-link {
    grid-column: 2;
  }

  .work-note > .note-block--first {
    grid-row: 1 / span 2;
  }

  .work-note > .note-link {
    grid-row: 4;
  }
}

@media (max-width: 860px) {
  .stage {
    display: block;
    min-height: 0;
    padding: 42px 0 30px;
  }

  .intro {
    max-width: 560px;
  }

  .intro h1 {
    font-size: clamp(41px, 8vw, 58px);
  }

  .ink-stage {
    display: none;
  }

  .composer-controls {
    gap: 12px 14px;
  }

  .control-group {
    width: 100%;
  }

  .selects {
    order: 2;
  }

  .send-actions {
    order: 3;
    margin-left: 0;
    width: 100%;
  }

  .polish-btn {
    flex: 0 0 auto;
  }

  .generate-btn {
    flex: 1;
    justify-content: space-between;
  }

  .topbar {
    height: 68px;
  }

  .wordmark-en {
    display: none;
  }

  .work-note {
    display: block;
  }

  .work-note > .note-block--first {
    margin-top: 16px;
  }

  .result-grid[data-count="2"],
  .result-grid[data-count="4"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-inner {
    padding: 22px 22px 0;
  }

  .dialog-foot {
    margin: 22px -22px 0;
    padding: 13px 22px;
  }
}

@media (max-width: 680px) {
  .app {
    display: block;
    padding-bottom: 56px;
  }

  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    z-index: 100;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    height: 56px;
    padding: 0;
    border-top: 1px solid rgba(242, 237, 227, 0.1);
  }

  .sidebar::after,
  .seal,
  .side-bottom {
    display: none;
  }

  .side-nav {
    flex-direction: row;
    gap: 64px;
    margin: 0;
  }

  .side-link {
    gap: 2px;
  }

  .side-link::before {
    top: auto;
    bottom: -9px;
    left: 50%;
    width: 18px;
    height: 1px;
    transform: translateX(-50%) scaleX(0);
    transition: transform 0.3s var(--ease);
  }

  .side-link.is-active::before {
    height: 1px;
    transform: translateX(-50%) scaleX(1);
  }

  .side-link svg {
    width: 18px;
    height: 18px;
  }

  .topbar {
    height: 62px;
    padding: 0 18px;
  }

  .wordmark-cn {
    font-size: 19px;
  }

  .engine-pill {
    padding: 6px 9px;
    font-size: 9px;
  }

  .knowledge-btn {
    padding: 5px;
  }

  .knowledge-btn > span {
    display: none;
  }

  .knowledge-btn b {
    min-width: 22px;
    height: 21px;
  }

  .main {
    padding: 0 16px;
  }

  .stage {
    padding: 28px 0 24px;
  }

  .intro h1 {
    margin-top: 18px;
    font-size: clamp(36px, 10.5vw, 48px);
  }

  .intro-copy {
    margin-top: 20px;
    font-size: 11.5px;
  }

  .intro-index {
    gap: 24px;
    margin-top: 28px;
  }

  .intro-index strong {
    font-size: 18px;
  }

  .composer {
    padding: 14px 14px 13px;
    border-radius: 14px;
  }

  #promptInput {
    font-size: 14px;
    line-height: 1.75;
  }

  .idea-row {
    flex-wrap: nowrap;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .idea-row::-webkit-scrollbar {
    display: none;
  }

  .idea-row > span,
  .idea {
    flex: none;
  }

  .composer-divider {
    margin: 11px 0 10px;
  }

  .select-wrap select {
    max-width: 86px;
  }

  .select-wrap--model select {
    max-width: 112px;
  }

  .composer-foot {
    flex-wrap: wrap;
    padding-top: 8px;
    font-size: 7.5px;
  }

  .result-area {
    padding-top: 20px;
  }

  .result-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .result-actions {
    padding-bottom: 0;
  }

  .result-grid[data-count="2"],
  .result-grid[data-count="4"] {
    gap: 7px;
  }

  .work-note {
    padding: 16px;
  }

  .result-warning {
    font-size: 9px;
  }

  .prompt-dialog {
    width: calc(100vw - 20px);
    max-height: 92vh;
  }

  .dialog-inner {
    max-height: 92vh;
    padding: 19px 16px 0;
  }

  .dialog-head h2 {
    font-size: 22px;
  }

  .prompt-compare {
    grid-template-columns: 1fr;
    gap: 7px;
    margin: 16px 0 20px;
  }

  .compare-arrow {
    justify-self: center;
    transform: rotate(90deg);
    font-size: 13px;
  }

  .dialog-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 16px;
  }

  .dialog-refs {
    max-height: 220px;
  }

  .dialog-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin: 18px -16px 0;
    padding: 12px 16px;
  }

  .dialog-foot > div {
    width: 100%;
  }

  .dialog-foot .line-btn,
  .dialog-primary {
    flex: 1;
  }

  .dialog-primary {
    text-align: center;
  }

  .drawer-panel {
    padding: 18px 16px 0;
  }

  .drawer-head h2 {
    font-size: 22px;
  }

  .kb-stats {
    margin: 12px 0;
    padding: 9px 0;
  }

  .drawer-foot > span {
    max-width: 190px;
  }

  .history-card {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
  }

  .history-summary {
    font-size: 8.5px;
  }

  .loading-card {
    padding: 28px 22px 18px;
  }

  .loading-steps {
    max-width: 220px;
  }

  .toast-stack {
    bottom: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
