@font-face {
  font-family: 'Portfolio Cut';
  src: url('/static/assets/portfolio-cut.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: light;
  /* 参考站实际纸色：#f4f0e9 / #faf6ef，保持深浅交错。 */
  --brown: #4a352d;
  --ink: #32251d;
  --muted: #735e53;
  --line: #bdb1a7;
  --hairline: #d7cec3;
  --paper: #faf6ef;
  --cover-paper: #f4f0e9;
  --thread: #a86d65;
  --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --sans: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, figure, ul { margin: 0; }
html { background: var(--cover-paper); }
body { min-width: 280px; color: var(--ink); font: 1rem / 1.65 var(--sans); }
button, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #955d56; outline-offset: 4px; }

.frame { width: min(100%, 1440px); margin-inline: auto; }
.portfolio-cover {
  --cover-height: clamp(355px, 36vw, 508px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: var(--brown);
  background: var(--cover-paper);
}

.archive-collage, .portfolio-cover::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.archive-collage {
  background: url('/static/assets/archive-collage.webp') center 48% / cover;
  opacity: .24;
  filter: grayscale(1) sepia(.24);
  mix-blend-mode: multiply;
}

.portfolio-cover::after {
  content: '';
  background:
    linear-gradient(90deg, #faf6ef66 0%, transparent 34%, #faf6ef45 65%, transparent 100%),
    repeating-linear-gradient(0deg, #453f3805 0 1px, transparent 1px 3px);
}

.cover-spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 34.5%);
  align-items: center;
  min-height: var(--cover-height);
  padding-left: clamp(58px, 9vw, 131px);
}

.cover-copy { position: relative; z-index: 1; min-width: 0; margin-top: 9px; }
.cover-copy h1 {
  width: max-content;
  font: 400 clamp(3.7rem, 9.4vw, 8.55rem) / .88 'Portfolio Cut', Impact, sans-serif;
  letter-spacing: -.008em;
  text-transform: uppercase;
}

.cover-copy h1 span { display: block; }
.cover-copy h1 span:first-child { font-size: 1.13em; }

.cover-copy p { margin: 2px 0 0 .68em; font-size: clamp(1.4rem, 3.15vw, 2.85rem); font-weight: 650; line-height: 1.25; letter-spacing: .025em; color: #322f2c; }
.cover-print {
  height: calc(var(--cover-height) * .76);
  /* 超过居中容器与视口右侧，仅保留上、下、左三边框。 */
  width: calc(100% + max(0px, (100vw - 1440px) / 2) + 24px);
  margin: 0 -24px 0 0;
  padding: 8px 0 8px 8px;
  overflow: hidden;
  border-radius: 34px 0 0 34px;
  background: var(--brown);
}

.cover-print img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 56% 50%; border-radius: 26px 0 0 26px; }

.about-section { position: relative; background: var(--paper); }
.about-section::before {
  position: absolute;
  top: 43px;
  left: 0;
  width: clamp(11px, 2.5vw, 33px);
  height: clamp(56px, 9vw, 112px);
  border-radius: 0 3px 3px 0;
  background: #87827b;
  content: '';
}

.about-spread {
  display: grid;
  grid-template-columns: minmax(128px, 20%) minmax(0, 1fr) minmax(142px, 18%);
  grid-template-areas: '. label margin' 'profile chat margin';
  column-gap: clamp(23px, 5vw, 67px);
  align-items: start;
  padding: clamp(35px, 5vw, 66px) clamp(40px, 7vw, 102px) clamp(44px, 5vw, 70px);
}

.editorial-title { grid-area: label; margin: 0 0 17px; color: #2c2a28; font: 400 clamp(2.1rem, 3.55vw, 3.18rem) / 1 var(--serif); white-space: nowrap; }
.editorial-title span { display: inline-block; width: 1px; height: .88em; margin-left: .29em; transform: translateY(.12em); background: currentColor; }
.assistant-profile { grid-area: profile; justify-self: center; width: min(100%, 139px); margin-top: 8px; }
.profile-print { position: relative; isolation: isolate; aspect-ratio: 686 / 694; overflow: visible; background: transparent; }
/* 主图和灰色底卡仍是两层真实元素，错位不烘焙进图片。 */
.profile-print::before { position: absolute; z-index: -1; inset: 0; transform: translate(6px, 7px); background: #938d83; content: ''; }
.profile-print svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.profile-caption { margin-top: 18px; text-align: center; }
.profile-caption p { font-size: .875rem; font-weight: 650; }
.profile-caption span { display: block; color: var(--muted); font-size: .8125rem; line-height: 1.5; }

.chat-sheet { grid-area: chat; min-width: 0; }
.square-label { display: flex; align-items: center; gap: .58em; font-size: .875rem; font-weight: 650; line-height: 1.5; }
.square-label::before { width: .53em; height: .53em; flex: none; background: var(--brown); content: ''; }
.chat-sheet > .square-label { margin-bottom: 10px; }
.chat-scroller { height: clamp(159px, 20vw, 222px); overflow-y: auto; overscroll-behavior-y: contain; scrollbar-color: #a89d91 transparent; border-bottom: 1px solid var(--hairline); }
.message-list { display: flex; flex-direction: column; gap: 15px; padding: 0 3px 15px 0; }
.message { max-width: min(93%, 530px); align-self: flex-start; }
.message-label { margin: 0 5px 3px; color: var(--muted); font-size: .8125rem; }
.message-text { padding: 9px 13px; border-left: 2px solid var(--line); background: var(--cover-paper); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.greeting-title { color: var(--brown); font-weight: 650; }
.message.is-user { align-self: flex-end; }
.is-user .message-label { text-align: right; }
.is-user .message-text { color: #fffefa; background: #59483c; border-left: 0; border-right: 2px solid #3f3128; }
.is-pending .message-text { color: var(--muted); }

/* 等待首个文字片段时显示的蒜头采用内联 SVG，轮廓与蒜瓣均是简单弧线。
   42 × 30 的横向画布保持扁胖比例；深灰单色、无填充、无阴影，避免拟物感。 */
.garlic-thinking {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  color: var(--ink);
  vertical-align: middle;
  white-space: normal;
}
.garlic-thinking-label { color: var(--muted); font-size: .8125rem; }
.garlic-growth {
  display: block;
  flex: none;
  width: 42px;
  height: 30px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.garlic-stage {
  opacity: 0;
  /* 三个形态各停留 400ms，用阶跃显隐，避免两幅轮廓重叠成模糊的形状。 */
  animation: garlic-one 1200ms steps(1, end) infinite;
}
.garlic-stage--half { animation-name: garlic-half; }
.garlic-stage--full { animation-name: garlic-full; }
@keyframes garlic-one { 0% { opacity: 1; } 33.333333% { opacity: 0; } 100% { opacity: 0; } }
@keyframes garlic-half { 0% { opacity: 0; } 33.333333% { opacity: 1; } 66.666667% { opacity: 0; } 100% { opacity: 0; } }
@keyframes garlic-full { 0% { opacity: 0; } 66.666667% { opacity: 1; } 100% { opacity: 0; } }

/* 光标是独立的行内元素，始终跟随最后一段文字；完成、失败或取消后由 JS 移除。 */
.stream-cursor {
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  margin-left: 3px;
  background: currentColor;
  vertical-align: -.13em;
  animation: stream-blink 800ms steps(1, end) infinite;
}
@keyframes stream-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.chat-form { margin-top: 13px; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 4px; border: 1px solid #aaa096; background: var(--paper); }
.composer:focus-within { border-color: #7e544a; }
.composer textarea { width: 100%; min-width: 0; min-height: 44px; max-height: 118px; resize: none; padding: 8px 9px; border: 0; outline: none; background: none; color: var(--ink); }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: #6a635c; opacity: 1; }
.send-button { min-height: 44px; padding: 5px 19px; border: 1px solid transparent; background: var(--brown); color: #fff; font-size: .875rem; font-weight: 650; white-space: nowrap; }
.send-button:hover:enabled { background: #5d4537; }
.send-button:disabled { background: #e9e5e1; color: #675749; }
/* 同一个主按钮在输出期间切换成「停止」，方形符号强化即时中止的含义。
   保持与发送按钮相同的触控高度，不对交互本身添加延迟动画。 */
.send-button.is-stop { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-color: var(--brown); background: var(--paper); color: var(--brown); }
.send-button.is-stop::before { width: 7px; height: 7px; border-radius: 1px; background: currentColor; content: ''; }
.send-button.is-stop:hover:enabled { background: #e9e5e1; }
/* 「再生成」附在最新的助手回复下方，视觉上作为次级文字操作。 */
.regenerate-button { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; margin-top: 3px; padding: 3px 7px; border: 0; background: transparent; color: var(--muted); font-size: .75rem; line-height: 1.4; }
.regenerate-button[hidden] { display: none; }
.regenerate-button:hover:enabled { color: var(--brown); text-decoration: underline; text-underline-offset: 3px; }
.regenerate-button:disabled { opacity: .5; }
.composer-note { color: #823f3b; font-size: .875rem; }
.composer-note:not(:empty) { margin-top: 6px; }
.retry-button { padding: 2px 5px; border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.chat-margin { grid-area: margin; margin-top: 7px; }
.source-note { margin-top: 9px; color: var(--muted); line-height: 1.8; font-size: .875rem; }
.new-chat { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin: 11px 0 0 -8px; padding: 4px 8px; border: 0; background: transparent; white-space: nowrap; font-size: .875rem; }
.new-chat:hover { color: #78423b; text-decoration: underline; text-underline-offset: 4px; }

.topic-section { position: relative; isolation: isolate; overflow: hidden; background: var(--cover-paper); }
.topic-section::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(1deg, #4a352d05 0 1px, transparent 1px 4px);
  content: '';
}

.topic-section::after { position: absolute; z-index: -1; left: -2%; right: -2%; bottom: -10px; height: 20px; transform: rotate(-.7deg); background: #cba876; clip-path: polygon(0 20%, 12% 13%, 26% 21%, 47% 0, 63% 14%, 86% 2%, 100% 34%, 100% 100%, 0 100%); content: ''; }
.topic-spread { padding: 36px clamp(33px, 6.8vw, 96px) 24px; }
.topic-orbit { position: relative; isolation: isolate; min-height: 215px; }
.topic-orbit::before, .topic-orbit::after { position: absolute; z-index: -1; width: 73px; height: 29px; background: #d7ba8d; box-shadow: 1px 1px 0 #bca17a; opacity: .72; clip-path: polygon(0 4%, 94% 0, 100% 12%, 99% 96%, 3% 100%); content: ''; }
.topic-orbit::before { left: 5%; bottom: 13px; transform: rotate(-3deg); }
.topic-orbit::after { top: -27px; right: -8.5%; transform: rotate(-5deg); }

.topic-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(5px, 2vw, 27px); align-items: center; justify-items: start; min-height: 196px; padding: 30px 0 20px; list-style: none; }
.topic-list li:nth-child(2) { transform: translateY(-35px); }
.topic-list li:nth-child(4) { transform: translateY(33px); }
.topic-list button { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 3px; border: 0; background: transparent; text-align: left; color: #302d2a; font-weight: 650; white-space: nowrap; }
.topic-list button:hover:not([aria-disabled='true']) { color: #7d453e; }
.topic-list button[aria-disabled='true'] { opacity: .55; cursor: default; }
.topic-list small { display: block; color: var(--muted); font-family: var(--serif); font-size: .8125rem; font-weight: 400; line-height: 1.2; }

.cutout { display: inline-block; flex: none; width: 31px; height: 35px; background: var(--brown); }
.cutout-person { transform: rotate(-5deg); clip-path: polygon(35% 3%, 55% 0, 67% 14%, 83% 100%, 14% 96%, 25% 25%); }
.cutout-work { transform: rotate(4deg); clip-path: polygon(0 1%, 44% 4%, 35% 94%, 21% 100%, 8% 76%, 50% 99%, 52% 18%, 66% 0, 82% 4%, 100% 98%, 50% 99%, 8% 76%); }
.cutout-process { transform: rotate(-4deg); clip-path: polygon(0 12%, 27% 5%, 20% 95%, 10% 97%, 31% 96%, 38% 1%, 55% 3%, 65% 93%, 31% 96%, 69% 93%, 66% 9%, 98% 7%, 90% 94%, 69% 93%, 10% 97%); }
.cutout-tools { transform: rotate(7deg); clip-path: polygon(4% 4%, 29% 0, 31% 99%, 2% 97%, 31% 99%, 36% 3%, 56% 4%, 66% 60%, 79% 0, 100% 9%, 81% 98%, 62% 92%, 36% 3%, 31% 99%); }
.cutout-contact { transform: rotate(6deg); clip-path: polygon(3% 5%, 24% 3%, 48% 60%, 68% 0, 93% 3%, 74% 63%, 59% 94%, 36% 99%, 19% 68%); }

.thread { position: absolute; z-index: -1; display: block; width: 46px; height: 25px; border-top: 1px solid var(--thread); border-radius: 56% 45% 0 0; pointer-events: none; }
.thread::after { position: absolute; top: -3px; left: 40%; width: 10px; height: 8px; transform: rotate(-28deg); border: 1px solid var(--thread); border-radius: 50%; content: ''; }
.thread-one { top: 62px; left: 13%; transform: rotate(-27deg); }
.thread-two { top: 57px; left: 33%; transform: rotate(40deg); }
.thread-three { top: 141px; left: 52%; transform: rotate(-136deg); }
.thread-four { top: 142px; left: 72%; transform: rotate(-57deg); }
.page-footer { display: flex; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid #bdb6ad; color: var(--muted); font-size: .8125rem; }
.page-footer [lang] { letter-spacing: .095em; font-family: var(--serif); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }


@media (max-width: 810px) {
  .portfolio-cover { --cover-height: clamp(189px, 51vw, 370px); }
  .cover-spread { grid-template-columns: minmax(0, 1fr) minmax(0, 34.5%); padding-left: 7.4vw; }
  .cover-copy h1 { font-size: clamp(1.65rem, 9.8vw, 5.05rem); }
  .cover-copy p { margin-top: 3px; font-size: clamp(1.05rem, 4.45vw, 2.04rem); }
  .cover-print { margin-right: -24px; padding: 5px 0 5px 5px; border-radius: 18px 0 0 18px; }
  .cover-print img { border-radius: 13px 0 0 13px; }
  .about-spread { grid-template-columns: minmax(93px, 20%) minmax(0, 1fr) minmax(117px, 19%); column-gap: 23px; padding-inline: 37px; }
  .topic-spread { padding-inline: 35px; }
  .topic-list button { gap: 6px; font-size: .875rem; }
  .cutout { width: 23px; height: 29px; }
  .thread { width: 33px; }
}

@media (max-width: 600px) {
  .about-section::before { top: 21px; width: 6px; height: 47px; }
  .about-spread { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label margin' 'profile margin' 'chat chat'; gap: 10px 8px; padding: 21px 23px 24px; }
  .editorial-title { margin: 0; font-size: 2.07rem; }
  .assistant-profile { display: flex; align-items: center; gap: 9px; margin: 0; justify-self: start; width: auto; }
  .profile-print { width: 40px; height: 40px; }
  .profile-print::before { transform: translate(3px, 4px); }
  .profile-caption { margin: 0; text-align: left; }
  .profile-caption p { font-size: .8125rem; }
  .profile-caption span { font-size: .75rem; }
  .chat-margin { margin: 0; }
  .chat-margin > p { display: none; }
  .chat-margin .new-chat { margin: -5px -8px 0 0; }
  .chat-sheet > .square-label { margin: 4px 0 7px; }
  .chat-scroller { height: clamp(119px, 20svh, 180px); }
  .message { max-width: 97%; }
  .message-text { padding: 6px 10px; line-height: 1.55; }
  .chat-form { margin-top: 9px; }
  .send-button { padding-inline: 14px; }
  .topic-spread { padding: 20px 23px 21px; }
  .topic-orbit::before { left: auto; right: -31px; bottom: 16px; }
  .topic-orbit::after { display: none; }
  .topic-list { grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: auto; gap: 5px 10px; padding: 11px 0 14px; }
  .topic-list li:nth-child(2), .topic-list li:nth-child(4) { transform: translateY(12px); }
  .thread-one { top: 26px; left: 39%; transform: rotate(-23deg) scale(.6); }
  .thread-two { top: 78px; left: 36%; transform: rotate(153deg) scale(.6); }
  .thread-three { top: 135px; left: 38%; transform: rotate(26deg) scale(.6); }
  .thread-four { display: none; }
}

@media (max-width: 350px) {
  .about-spread, .topic-spread { padding-inline: 17px; }
  .cover-print { padding: 4px 0 4px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  /* 减少动态效果时保留静态完整蒜头与光标，仍明确表达等待/输出状态。 */
  .garlic-stage, .stream-cursor { animation: none; }
  .garlic-stage--one, .garlic-stage--half { opacity: 0; }
  .garlic-stage--full, .stream-cursor { opacity: 1; }
}

/* 合并页沿用原有纸面和墨色，只加入共享聊天模板和作品页的结构适配。 */
a { color: inherit; text-underline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 9px 14px; transform: translateY(-160%); background: var(--paper); color: var(--ink); }
.skip-link:focus { transform: none; }
.chat-greeting .message-text { white-space: normal; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.chat-suggestions[hidden] { display: none; }
.chat-suggestions button { min-height: 32px; padding: 2px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: .8125rem; color: var(--muted); }
.chat-suggestions button:disabled { opacity: .5; }
.works-shortcut { display: block; width: fit-content; margin-top: 10px; color: var(--muted); font-size: .875rem; }
#main-chat { scroll-margin-top: 24px; }
#main-chat .chat-scroller { height: clamp(190px, 18vw, 220px); }
.portfolio-works { background: var(--paper); }
.portfolio-footer { max-width: 1320px; margin-inline: auto; padding: 23px 54px 35px; }
.portfolio-footer a { text-decoration: none; }
.portfolio-footer a:hover { text-decoration: underline; }
.noscript { padding: 24px; text-align: center; }
@media (max-width: 1050px) { .portfolio-footer { padding-inline: 34px; } }
@media (max-width: 760px) { .portfolio-footer { padding-inline: 24px; } }
@media (max-width: 600px) {
  #main-chat .chat-scroller { height: clamp(150px, 22svh, 200px); }
  .chat-suggestions { gap: 3px 12px; }
  .works-shortcut { display: none; }
}
@media (max-width: 480px) { .portfolio-footer { padding-inline: 20px; } }
