:root {
  --paper: #F5F3EC;
  --white: #FFFFFF;
  --ink: #252822;
  --muted: #76766E;
  --blue: #BAD3DB;
  --indigo: #4C67B3;
  --cherry: #984C55;
  --line: #2528221C;
  --display: 'Avenir Next', 'Helvetica Neue', 'PingFang SC', sans-serif;
  --body: 'Helvetica Neue', 'PingFang SC', sans-serif;
  --gutter: 12px;
  --chat-space: calc(74px + env(safe-area-inset-bottom, 0px));  /* 聊天框占的底部高度：面板和状态文字要让开 */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-height: 100dvh;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--paper); }
/* 米色底：人物抠成透明 PNG 直接立在上面（keke 第七轮） */
body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font: 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; background: var(--paper); }
button, input, textarea { font: inherit; color: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { padding: 0; border: 0; background: transparent; cursor: pointer; }
button:disabled { opacity: .43; cursor: default; }
button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--cherry); outline-offset: 4px; }
button:focus-visible { border-radius: 3px; }
img { display: block; max-width: 100%; }
svg { width: 21px; height: 21px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
h2, p, ol { margin: 0; }
h2 { font-family: var(--display); font-weight: 500; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 单画布（keke 第九轮）：照片整屏铺满（连状态栏下面），聊天框、候选区、衣橱都是悬浮在照片上的玻璃；高度跟随可视区域，键盘弹起时整体收缩 */
.canvas { position: relative; width: 100%; height: var(--app-height); overflow: hidden; }


/* 天气氛围：只落在四周与页面背景，中央（人物）用蒙版留空 */
.ambience { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.ambience::before, .ambience::after { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity 900ms ease; }
.ambience::before { -webkit-mask-image: radial-gradient(ellipse 58% 62% at 50% 46%, transparent 55%, #000 100%); mask-image: radial-gradient(ellipse 58% 62% at 50% 46%, transparent 55%, #000 100%); }
.ambience::after { -webkit-mask-image: radial-gradient(ellipse 60% 64% at 50% 46%, transparent 64%, #000 100%); mask-image: radial-gradient(ellipse 60% 64% at 50% 46%, transparent 64%, #000 100%); }
.ambience[data-kind="clear-day"]::before { opacity: 1; background: linear-gradient(200deg, rgba(255, 232, 178, .55) 0%, rgba(255, 232, 178, 0) 46%), radial-gradient(circle at 92% 4%, rgba(255, 214, 140, .55), transparent 40%); }
.ambience[data-kind="cloudy"]::before { opacity: 1; background: radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(186, 211, 219, .45) 100%); }
.ambience[data-kind="rain"]::before { opacity: 1; background: radial-gradient(ellipse at 50% 40%, transparent 48%, rgba(118, 138, 148, .32) 100%); }
.ambience[data-kind="rain"]::after { opacity: 1; background: repeating-linear-gradient(104deg, rgba(37, 40, 34, .07) 0 1px, transparent 1px 13px); }
.ambience[data-kind="night"]::before { opacity: 1; background: radial-gradient(ellipse at 50% 42%, transparent 44%, rgba(37, 40, 34, .44) 100%); }
body.no-ambience .ambience { display: none; }

/* 照片：整屏铺满（竖屏按高度铺满、两侧裁掉多余的墙面）。出图中、打开面板时照片不藏，留在背后变模糊 */
.stage { position: absolute; inset: 0; z-index: 1; }
/* 照片底边停在聊天框上方（模型常把鞋画到最底下），下面接一截从照片地面取色的地面，交界处柔和过渡 */
.figure { position: absolute; inset: 0; overflow: hidden; background: var(--floor, var(--paper)); }
.figure-button { position: absolute; top: 0; left: 0; right: 0; bottom: calc(var(--chat-space) - 14px); overflow: hidden; }
.figure-button:disabled { opacity: 1; }
#lookbook-image { width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; transition: filter 600ms ease, transform 600ms ease; -webkit-mask-image: linear-gradient(to bottom, #000 95%, transparent); mask-image: linear-gradient(to bottom, #000 95%, transparent); }
.figure[data-image-state="busy"] #lookbook-image, .canvas:not([data-mode="idle"]) #lookbook-image { filter: blur(16px) saturate(.95) brightness(1.03); transform: scale(1.06); }
.canvas:not([data-mode="idle"]) .thinking, .canvas:not([data-mode="idle"]) .figure-alert { display: none !important; }
@media (min-aspect-ratio: 4/5) { #lookbook-image { object-fit: contain; } }

/* 显示的是上一版：人物上方一条小提示 */
.figure-alert { position: absolute; z-index: 1; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); transform: translateX(-50%); max-width: calc(100% - 8px); padding: 6px 12px; border-radius: 14px; background: var(--white); color: var(--cherry); font-size: 11px; box-shadow: 0 6px 18px rgba(37, 40, 34, .08); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 思考中：衣服卡片扇形展开、轻轻起伏（参考图一）；空与失败时只有一句状态 */
.thinking { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px var(--chat-space); text-align: center; }
.figure[data-image-state="busy"] .stage-note { color: var(--ink); background: rgba(255, 255, 255, .6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); padding: 6px 12px; border-radius: 14px; }
.fan { position: relative; width: min(78vw, 300px); height: min(58vw, 230px); flex: 0 0 auto; }
.fan-card { position: absolute; left: 50%; top: 50%; width: 42%; aspect-ratio: 3 / 4; margin: 0; border-radius: 16px; overflow: hidden; background: var(--white); box-shadow: 0 16px 34px rgba(37, 40, 34, .16), 0 0 0 1px rgba(255, 255, 255, .7) inset; transform: translate(-50%, -50%) translateX(calc(var(--i) * 58%)) translateY(calc(var(--i) * var(--i) * 9%)) rotate(calc(var(--i) * 15deg)); animation: fan-bob 2.8s ease-in-out infinite; animation-delay: calc(var(--i) * .35s); }
.fan-card img { width: 100%; height: 100%; object-fit: contain; background: var(--white); padding: 6%; }
.fan.small { width: 180px; height: 130px; margin: 6px auto 0; }
.fan.small .fan-card { border-radius: 10px; box-shadow: 0 8px 20px rgba(37, 40, 34, .12); }
@keyframes fan-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -9px; } }
.stage-note { color: var(--muted); font-size: 12px; line-height: 1.7; max-width: 300px; overflow-wrap: anywhere; }
.stage-note:empty { display: none; }
.quiet-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 20px; font-size: 12px; background: var(--white); }

/* 面板：候选区与衣橱是悬浮在照片上的玻璃卡片，在聊天框上方；没有标题栏，衣架一键回首页 */
.panel { position: absolute; z-index: 2; left: var(--gutter); right: var(--gutter); top: calc(env(safe-area-inset-top, 0px) + 10px); bottom: var(--chat-space); min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 10px 12px; border-radius: 20px; background: linear-gradient(170deg, rgba(255, 255, 255, .74) 0%, rgba(255, 255, 255, .54) 100%); -webkit-backdrop-filter: blur(26px) saturate(1.6); backdrop-filter: blur(26px) saturate(1.6); border: 1px solid rgba(255, 255, 255, .85); box-shadow: 0 14px 38px rgba(37, 40, 34, .12), inset 0 1px 0 rgba(255, 255, 255, .95); }
.panel-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--blue) transparent; display: grid; gap: 10px; align-content: start; padding: 2px; margin: -2px; }
.message-retry { margin-left: 6px; text-decoration: underline; text-underline-offset: 3px; font-size: 12px; color: inherit; min-height: 28px; }
/* 流式进度：你说的话一行，AI 在做什么逐行出现，最新一行醒目，右侧秒数 */
.compose-progress { position: relative; display: grid; gap: 6px; padding: 2px 0 6px 14px; }
.compose-progress::before { content: ''; position: absolute; left: 3px; top: 8px; bottom: 10px; width: 1px; background: rgba(37, 40, 34, .12); }
.progress-you { font-size: 14px; font-weight: 500; margin-bottom: 4px; overflow-wrap: anywhere; }
.progress-line { position: relative; font-size: 12px; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.progress-line::before { content: ''; position: absolute; left: -14.5px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: rgba(37, 40, 34, .22); }
.progress-line.current { color: var(--ink); }
.progress-line.current::before { background: var(--cherry); animation: pulse 1.2s ease-in-out infinite; }
.progress-elapsed { position: absolute; right: 0; top: 0; font: 400 10px/1.4 var(--display); letter-spacing: .04em; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .55; } }
.compose-reply { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; padding: 2px 2px 4px; }
.compose-reply.hint { color: var(--muted); font-size: 13px; }
.compose-reply.failed { color: var(--cherry); }
.compose-reply:empty { display: none; }
.compose-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; padding-top: 2px; }
.compose-grid:empty { display: none; }
.compose-grid.list { display: block; }
.compose-grid.groups { grid-template-columns: 1fr; gap: 14px; }
.candidate-group { display: grid; gap: 8px; }
.candidate-group-title { margin: 0; display: flex; align-items: baseline; gap: 8px; font: 500 13px/1.4 var(--display); }
.candidate-group-title span { padding: 1px 8px; border-radius: 10px; background: var(--ink); color: var(--white); font-size: 10px; letter-spacing: .04em; }
.candidate-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 8px; }
.candidate { min-width: 0; text-align: center; display: grid; gap: 6px; }
.candidate-image { position: relative; aspect-ratio: 4 / 5; background: var(--white); border: 1.5px solid transparent; border-radius: 14px; overflow: hidden; display: grid; place-items: center; padding: 8px; box-shadow: 0 6px 18px rgba(37, 40, 34, .07); transition: border-color 160ms ease, transform 160ms ease, opacity 160ms ease; }
.candidate-image img { width: 100%; height: 100%; object-fit: contain; }
.candidate[aria-pressed="true"] .candidate-image { border-color: var(--cherry); }
.candidate[aria-pressed="false"] .candidate-image { opacity: .5; transform: scale(.96); }
.candidate[aria-pressed="true"] .selected-mark { opacity: 1; transform: scale(1); }
.candidate.unavailable .candidate-image { opacity: .45; }
.candidate[data-zoom] .candidate-image { opacity: 1; transform: none; }
.candidate[data-zoom] .candidate-name { color: var(--ink); text-decoration: none; }
.candidate-name { font-size: 11px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding: 0 2px; }
.candidate[aria-pressed="false"] .candidate-name { color: var(--muted); text-decoration: line-through; }
.compose-memory { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.7; }
.compose-dock { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid rgba(37, 40, 34, .08); padding-top: 10px; }
.compose-note { min-width: 0; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-dock .primary, .selection-dock .primary { flex: 0 0 auto; border-radius: 22px; padding: 0 18px; }

/* 聊天框：悬浮在照片底部的一条玻璃输入框；衣架在首页开衣橱、在别处回首页 */
.chat { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; padding: 0 var(--gutter) calc(10px + var(--safe-bottom)); }
.composer { position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 5px 5px 5px 7px; border-radius: 28px; background: linear-gradient(160deg, rgba(255, 255, 255, .62) 0%, rgba(255, 255, 255, .34) 55%, rgba(255, 255, 255, .5) 100%); -webkit-backdrop-filter: blur(26px) saturate(1.7) brightness(1.05); backdrop-filter: blur(26px) saturate(1.7) brightness(1.05); border: 1px solid rgba(255, 255, 255, .85); box-shadow: 0 16px 40px rgba(37, 40, 34, .14), 0 2px 6px rgba(37, 40, 34, .06), inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(255, 255, 255, .35), inset 1px 0 0 rgba(255, 255, 255, .5); }
.composer::before { content: ''; position: absolute; inset: 1px; border-radius: 27px; pointer-events: none; background: radial-gradient(120% 90% at 18% 0%, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 55%), radial-gradient(60% 80% at 95% 100%, rgba(186, 211, 219, .28) 0%, rgba(186, 211, 219, 0) 70%); }
.composer::after { content: ''; position: absolute; inset: 0; border-radius: 28px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), inset 0 12px 24px -16px rgba(255, 255, 255, .9), inset 0 -10px 20px -18px rgba(37, 40, 34, .25); }
.composer > * { position: relative; z-index: 1; }
.composer-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .8); transition: background 160ms ease; }
.composer-icon svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.canvas[data-mode="idle"] .icon-close, .canvas:not([data-mode="idle"]) .icon-hanger { display: none; }
.canvas:not([data-mode="idle"]) .composer-icon { background: var(--ink); color: var(--white); border-color: var(--ink); }
#chat-input { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; font-size: 16px; line-height: 1.5; padding: 9px 0; max-height: 132px; outline: none; }
#chat-input::placeholder { color: var(--muted); }
.send { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; background: var(--ink); color: var(--white); display: grid; place-items: center; }
.send svg { width: 18px; height: 18px; stroke-width: 1.8; }
.send:disabled { opacity: .35; }

/* 衣橱：分类、网格、已选与看上身 */
.wardrobe { grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 6px; }
.category-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; border-bottom: 1px solid rgba(37, 40, 34, .1); }
.category-tab { min-width: 0; min-height: 40px; position: relative; font-size: 12px; color: var(--muted); }
.category-tab[aria-selected="true"] { color: var(--ink); font-weight: 500; }
.category-tab[aria-selected="true"]::after { content: ''; position: absolute; bottom: -1px; height: 2px; left: 20%; right: 20%; background: var(--cherry); }
.wardrobe-scroll { display: block; padding-bottom: 10px; }
.garment-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.garment-pick { width: 100%; display: block; text-align: left; }
.garment-image { position: relative; aspect-ratio: 4 / 5; padding: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, .72); border: 1.5px solid transparent; border-radius: 8px; overflow: hidden; transition: border-color 160ms ease; }
.garment-image img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.garment-pick[aria-pressed="true"] .garment-image { border-color: var(--cherry); }
.garment-pick:disabled .garment-image { opacity: .45; }
.selected-mark { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; display: grid; place-items: center; color: var(--white); background: var(--cherry); border-radius: 50%; opacity: 0; transform: scale(.8); transition: opacity 130ms ease, transform 130ms ease; }
.selected-mark svg { width: 12px; height: 12px; stroke-width: 1.8; }
.garment-pick[aria-pressed="true"] .selected-mark { opacity: 1; transform: scale(1); }
.garment-name { display: block; padding: 5px 0 0; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-category { padding: 30px 0; color: var(--muted); font-size: 12px; text-align: center; }
.selection-dock { min-width: 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid rgba(37, 40, 34, .08); padding-top: 8px; min-height: 54px; }
.selected-thumbs { display: flex; gap: 5px; overflow-x: auto; min-width: 0; flex: 1; scrollbar-width: thin; padding: 3px; margin: -3px; min-height: 30px; }
.selected-thumb { width: 40px; height: 40px; flex: 0 0 40px; padding: 4px; background: var(--white); border-radius: 6px; position: relative; }
.selected-thumb img { height: 100%; width: 100%; object-fit: contain; }
.selected-thumb::after { content: '−'; position: absolute; top: -3px; right: -2px; font-size: 10px; line-height: 12px; width: 12px; color: var(--cherry); background: var(--paper); border-radius: 50%; }
.selection-note { color: var(--muted); min-height: 18px; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.primary svg { width: 17px; }

/* 提示、弹层 */
.toast { position: fixed; z-index: 10; bottom: calc(84px + var(--safe-bottom)); left: 50%; transform: translate(-50%, 7px); max-width: min(88vw, 440px); width: max-content; border-radius: 4px; padding: 11px 16px; background: var(--ink); color: var(--white); font-size: 12px; text-align: center; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
dialog { color: var(--ink); background: var(--paper); border: 0; padding: 0; }
dialog::backdrop { background: #25282266; }
.sheet { width: min(100%, 480px); max-width: 100%; max-height: min(90dvh, 760px); margin: auto auto 0; border-radius: 12px 12px 0 0; padding: 18px 24px calc(24px + var(--safe-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 16px; margin-bottom: 17px; }
.sheet-header h2 { font-size: 20px; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; flex: 0 0 auto; }
.sheet-header > .icon-button { margin-right: -10px; }
.sheet label { display: block; font-size: 12px; margin-bottom: 8px; }
.sheet input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 12px; background: var(--white); font-size: 16px; line-height: 1.7; }
.form-status { margin-top: 12px; color: var(--cherry); font-size: 12px; overflow-wrap: anywhere; }
.form-status:empty { display: none; }
.primary { display: inline-flex; justify-content: center; align-items: center; gap: 10px; min-height: 44px; padding: 0 19px; background: var(--ink); color: var(--white); border-radius: 3px; font-size: 12px; }
.wide { width: 100%; }
#login-form > .primary { margin-top: 20px; }
.image-sheet { width: min(100%, 1200px); height: 100dvh; max-width: 100%; max-height: 100%; margin: auto; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px calc(16px + var(--safe-bottom)); }
.image-sheet[open] { display: flex; flex-direction: column; }
.image-sheet .sheet-header { flex: 0 0 auto; margin-bottom: 12px; }
.image-sheet .sheet-header h2 { font-size: 16px; }
.full-image-wrap { min-height: 0; flex: 1; display: grid; place-items: center; overflow: hidden; }
#full-image { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
#full-image-error { color: var(--muted); font-size: 12px; }
.image-note { font-size: 11px; color: var(--muted); text-align: center; padding-top: 12px; }
.missing-image { font-size: 10px; color: var(--muted); text-align: center; }
.failed-image { font-size: 10px; color: var(--muted); }
.noscript-note { position: fixed; inset: 30% 20px auto; background: var(--paper); padding: 30px; text-align: center; }

@media (hover: hover) {
  .candidate:hover .candidate-image { border-color: var(--blue); }
  .message-retry:hover { color: var(--cherry); }
  .send:not(:disabled):hover { background: var(--cherry); }
}
@media (min-width: 700px) {
  :root { --gutter: 24px; }
  .chat { left: 50%; right: auto; width: min(100%, 720px); transform: translateX(-50%); }
  .panel { left: 50%; right: auto; width: min(calc(100% - 2 * var(--gutter)), 720px); transform: translateX(-50%); }
  .compose-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sheet { margin: auto; border-radius: 8px; padding-bottom: 28px; }
  .garment-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px 12px; }
}
@media (max-height: 600px) {
  .fan { height: 150px; }
}
@media (max-width: 359px) {
  :root { --gutter: 10px; }
  .compose-grid { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { transition: none !important; animation: none !important; }
