/* InfiniCard 制卡界面：入口的对话框，和「左边对话、右边预览」的工作台。

   设计上对齐 Material 3 的做法，品牌还是 InfiniCard 自己的：
   · 颜色按角色取（primary / container / surface / outline…），浅色深色各一套，组件里不写死色值；
   · 层次靠色调和很轻的投影，不靠粗边框；
   · 能点的东西都有状态层（悬停 8%、聚焦 10%、按下 12%）和水波，键盘聚焦有清楚的焦点环；
   · 动效只用三条曲线：emph（位移）、decel（进场）、accel（离场），时长四档；
   · 触屏上可点区域不小于 44px，输入框字号不小于 16px（避免 iOS 自动放大）。 */
@font-face { font-family: "Urbanist Variable"; src: url(/engine/fonts/urbanist-latin-wght-normal.woff2) format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono Variable"; src: url(/engine/fonts/geist-mono-latin-wght-normal.woff2) format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@view-transition { navigation: auto; }

/* ---------- 令牌 ---------- */
html {
  color-scheme: light;
  --primary: #4f5bd5; --on-primary: #fff;
  --primary-container: #e0e1ff; --on-primary-container: #2a3592;
  --secondary-container: #e2e3f8; --on-secondary-container: #3b3e58;
  --page: #f1f2fa; --surface: #fff; --raised: #fff;
  --fill-1: #f5f5fb; --fill-2: #ecedf6; --fill-3: #e2e3ee;
  --ink: #1b1b22; --ink-2: #46464f; --ink-3: #6a6b76;
  --outline: #777781; --outline-2: #c7c7d2; --hair: rgba(27, 27, 40, .09);
  --inverse: #303037; --on-inverse: #f2f0f9; --inverse-primary: #bec2ff;
  --error: #b3261e; --on-error: #fff; --error-container: #f9dedc; --on-error-container: #7d1a15;
  --note-container: #ffefcf; --on-note-container: #5b4300;
  --scrim: rgba(22, 22, 34, .42);
  --sh: 60, 64, 90;
  --e1: 0 1px 2px rgba(var(--sh), .14), 0 1px 3px 1px rgba(var(--sh), .07);
  --e2: 0 1px 2px rgba(var(--sh), .16), 0 2px 8px 2px rgba(var(--sh), .1);
  --e3: 0 2px 4px rgba(var(--sh), .16), 0 8px 24px 4px rgba(var(--sh), .14);
  --grad: linear-gradient(92deg, #4f5bd5, #7a5fe6 55%, #b266d6);
  --sans: "Urbanist Variable", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, monospace;
  --emph: cubic-bezier(.2, 0, 0, 1); --decel: cubic-bezier(.05, .7, .1, 1); --accel: cubic-bezier(.3, 0, .8, .15);
  --t1: .1s; --t2: .2s; --t3: .3s; --t4: .45s;
  --bar: 64px;
}
html[data-mode='dark'] {
  color-scheme: dark;
  --primary: #bec2ff; --on-primary: #1c2686;
  --primary-container: #37429e; --on-primary-container: #e0e1ff;
  --secondary-container: #42455c; --on-secondary-container: #e0e1f9;
  --page: #111217; --surface: #1b1c22; --raised: #25262e;
  --fill-1: #202128; --fill-2: #292a32; --fill-3: #34353e;
  --ink: #e5e2ea; --ink-2: #c7c6d1; --ink-3: #9a9aa6;
  --outline: #91909b; --outline-2: #44454e; --hair: rgba(255, 255, 255, .08);
  --inverse: #e5e2ea; --on-inverse: #303037; --inverse-primary: #4f5bd5;
  --error: #f2b8b5; --on-error: #601410; --error-container: #8c1d18; --on-error-container: #f9dedc;
  --note-container: #4a3a10; --on-note-container: #ffdf9e;
  --scrim: rgba(0, 0, 0, .6);
  --sh: 0, 0, 0;
  --e1: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px 1px rgba(0, 0, 0, .2);
  --e2: 0 1px 2px rgba(0, 0, 0, .45), 0 2px 8px 2px rgba(0, 0, 0, .28);
  --e3: 0 2px 4px rgba(0, 0, 0, .5), 0 8px 24px 4px rgba(0, 0, 0, .36);
  --grad: linear-gradient(92deg, #a9b0ff, #c3a6ff 55%, #e7a8f0);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { font: 400 15px/1.6 var(--sans); color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--primary) 26%, transparent); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.grow { flex: 1; }
.logo { flex: none; width: 28px; height: 28px; }
.bg { position: fixed; inset: 0; z-index: -1; background: var(--page); }
html[data-view='home'] .bg { background: radial-gradient(70% 55% at 50% -12%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 72%), radial-gradient(40% 40% at 92% 4%, color-mix(in srgb, #b266d6 10%, transparent), transparent 70%), var(--page); }
html[data-view='home'] .work, html[data-view='work'] .home { display: none; }

/* 状态层：悬停、聚焦、按下时盖一层当前文字色；水波由 app.js 在按下的位置放出来 */
:where(.btn, .ib, .chip, .opt, .send, .seg button, .tabs button, .avatar, .made, .menu-i, a.card-i, .card-a, .jump) { position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent; }
:where(.btn, .ib, .chip, .opt, .send, .seg button, .tabs button, .avatar, .made, .menu-i, a.card-i, .card-a, .jump)::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: currentColor; opacity: 0; pointer-events: none; transition: opacity var(--t1); }
@media (hover: hover) { :where(.btn, .ib, .chip, .opt, .send, .seg button, .tabs button, .avatar, .made, .menu-i, a.card-i, .card-a, .jump):hover::after { opacity: .08; } }
:where(.btn, .ib, .chip, .opt, .send, .seg button, .tabs button, .avatar, .made, .menu-i, a.card-i, .card-a, .jump):focus-visible::after { opacity: .1; }
:where(.btn, .ib, .chip, .opt, .send, .seg button, .tabs button, .avatar, .made, .menu-i, a.card-i, .card-a, .jump):active::after { opacity: .12; }
.rp { position: absolute; z-index: -1; border-radius: 50%; background: currentColor; opacity: .14; transform: scale(0); pointer-events: none; animation: rp .55s var(--decel) forwards; }
@keyframes rp { 60% { opacity: .14; } to { transform: scale(1); opacity: 0; } }

/* ---------- 按钮 ---------- */
.btn { height: 40px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 500; letter-spacing: .01em; white-space: nowrap; text-decoration: none; color: var(--primary); transition: background var(--t2), color var(--t2), box-shadow var(--t2), border-color var(--t2); }
.btn .i { width: 18px; height: 18px; margin-left: -4px; }
.btn.filled { background: var(--primary); color: var(--on-primary); }
@media (hover: hover) { .btn.filled:hover { box-shadow: var(--e1); } }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { border-color: var(--outline-2); }
.btn.danger { background: var(--error); color: var(--on-error); }
.btn.text { padding: 0 12px; }
.btn.sm { height: 32px; padding: 0 16px; font-size: 13px; }
.btn.sm .i { width: 16px; height: 16px; }
.btn:disabled, .btn[aria-disabled='true'] { color: color-mix(in srgb, var(--ink) 38%, transparent); pointer-events: none; }
.btn:is(.filled, .tonal):is(:disabled, [aria-disabled='true']) { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::before { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px; border-radius: 50%; border: 2px solid var(--on-primary); border-top-color: transparent; animation: spin .8s linear infinite; }
.ib { flex: none; width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink-2); text-decoration: none; transition: color var(--t2); }
.ib:disabled, .ib[aria-disabled='true'] { color: color-mix(in srgb, var(--ink) 34%, transparent); pointer-events: none; }
.ib.txt { font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.ib.busy .i { animation: pulse .9s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .35; transform: scale(.9); } }
@keyframes spin { to { transform: rotate(360deg); } }
.chip { height: 36px; padding: 0 16px 0 12px; border-radius: 10px; border: 1px solid var(--outline-2); display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; transition: border-color var(--t2), background var(--t2); }
.chip .i { width: 18px; height: 18px; color: var(--primary); }
/* 分段按钮：对话 / 预览、桌面 / 手机 */
.tabs, .seg { flex: none; display: inline-flex; border-radius: 999px; border: 1px solid var(--outline-2); overflow: hidden; }
.tabs button, .seg button { height: 32px; min-width: 44px; padding: 0 12px; display: inline-grid; place-items: center; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; border-radius: 0; transition: background var(--t2), color var(--t2); }
.tabs button + button, .seg button + button { border-left: 1px solid var(--outline-2); }
.tabs button.on, .seg button.on { background: var(--secondary-container); color: var(--on-secondary-container); }
.seg .i { width: 18px; height: 18px; }
.tabs button.dot::before { content: ""; position: absolute; right: 7px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 14px; font-weight: 600; line-height: 1; background: var(--primary); color: var(--on-primary); }
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }

/* ---------- 顶栏 ---------- */
.bar { position: fixed; inset: 0 0 auto 0; height: var(--bar); z-index: 10; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 20px; transition: background var(--t2), box-shadow var(--t2); }
.bar.scrolled { background: color-mix(in srgb, var(--page) 82%, transparent); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 1px 0 var(--hair); }
.brand { flex: none; display: flex; align-items: center; gap: 10px; text-decoration: none; border-radius: 10px; }
.wordmark { font-size: 19px; font-weight: 500; letter-spacing: -.015em; color: var(--ink-2); }
.wordmark b { font-weight: 650; color: var(--ink); }
.bar-title { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title:not(:empty)::before { content: ""; display: inline-block; width: 1px; height: 16px; margin-right: 12px; vertical-align: -3px; background: var(--outline-2); }
.bar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tabs { display: none; }
html[data-view='home'] #new { display: none; }
#mode .moon, html[data-mode='dark'] #mode .sun { display: none; }
html[data-mode='dark'] #mode .moon { display: block; }

/* ---------- 输入框（入口和工作台共用） ---------- */
.composer { position: relative; border-radius: 28px; background: var(--surface); border: 1px solid var(--hair); box-shadow: var(--e1); transition: box-shadow var(--t2), border-color var(--t2); view-transition-name: composer; }
.composer:focus-within { box-shadow: var(--e2); border-color: color-mix(in srgb, var(--primary) 48%, transparent); }
.composer textarea { display: block; width: 100%; min-height: 52px; max-height: 220px; padding: 16px 20px 4px; border: 0; outline: 0; resize: none; background: transparent; line-height: 1.6; scrollbar-width: thin; }
.composer textarea::placeholder { color: var(--ink-3); }
.composer .row { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 12px 0; }
.files:empty { display: none; }
.file { max-width: 240px; height: 32px; padding: 0 4px 0 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; background: var(--fill-2); color: var(--ink-2); animation: pop var(--t3) var(--decel) both; }
.file img { flex: none; width: 20px; height: 20px; border-radius: 4px; object-fit: cover; }
.file .i { width: 16px; height: 16px; }
.file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file button { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-3); }
.file button:hover { background: var(--fill-3); color: var(--ink); }
.file button .i { width: 14px; height: 14px; }
@keyframes pop { from { opacity: 0; transform: scale(.9); } }
.viewing { min-width: 0; max-width: 190px; height: 28px; padding: 0 10px 0 8px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; background: var(--secondary-container); color: var(--on-secondary-container); }
.viewing .i { width: 15px; height: 15px; }
.viewing span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { display: none; margin-right: 4px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); transition: background var(--t2), color var(--t2), transform var(--t2) var(--emph); }
.send:disabled { background: var(--fill-2); color: color-mix(in srgb, var(--ink) 36%, transparent); cursor: default; }
.send:not(:disabled):active { transform: scale(.94); }
.send .ring { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
.composer.busy .send .i { display: none; }
.composer.busy .send .ring { display: block; }
.drop { position: absolute; inset: -1px; z-index: 2; border-radius: inherit; display: none; align-items: center; justify-content: center; gap: 8px; font-weight: 500; background: color-mix(in srgb, var(--primary-container) 94%, transparent); color: var(--on-primary-container); border: 2px dashed var(--primary); pointer-events: none; }
.composer.drag .drop { display: flex; }
.composer.big { border-radius: 32px; }
.composer.big textarea { min-height: 108px; padding: 22px 26px 8px; font-size: 17px; }
.composer.big .row { padding: 6px 12px 12px 14px; }
.composer.big .files { padding: 16px 18px 0; }
.composer.big .send { width: 44px; height: 44px; }
@media (hover: hover) and (min-width: 700px) { .composer.big:focus-within .hint { display: inline; } }

/* ---------- 入口 ---------- */
.home { height: 100dvh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--outline-2) transparent; }
.home-in { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: var(--bar) 24px 56px; }
.hero { flex: 1 0 auto; width: min(760px, 100%); display: grid; align-content: center; justify-items: center; padding: clamp(28px, 8dvh, 88px) 0 clamp(28px, 6dvh, 64px); }
.hero > * { width: 100%; animation: rise .6s var(--decel) both; }
.hero > :nth-child(2) { animation-delay: .05s; }
.hero > :nth-child(3) { animation-delay: .1s; }
.hero > :nth-child(4) { animation-delay: .16s; }
.hero h1 { text-align: center; font-size: clamp(34px, 5.2vw, 58px); font-weight: 500; letter-spacing: -.025em; line-height: 1.18; text-wrap: balance; }
:lang(en) .hero h1 { letter-spacing: -.035em; line-height: 1.1; }
.hero h1 em { font-style: normal; font-weight: 600; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 20px 0 36px; text-align: center; font-size: clamp(15px, 1.5vw, 17px); color: var(--ink-2); text-wrap: balance; }
.starts { margin-top: 20px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.shelf { width: min(1040px, 100%); margin-top: 40px; animation: rise .6s var(--decel) .2s both; }
.shelf h2 { margin: 0 4px 12px; font-size: 14px; font-weight: 500; letter-spacing: .01em; color: var(--ink-2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 12px; }
.grid.sample-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
/* 示例的封面：底下是按这张卡的主色调出来的色块和一个图标，图片盖在上面；图片取不到时（app.js 会把它拿掉）露出底下这一层 */
.sample-cover { position: relative; display: grid; place-items: center; aspect-ratio: 2 / 1; overflow: hidden; background: linear-gradient(135deg, color-mix(in oklab, var(--c, var(--primary)) 22%, var(--surface)), color-mix(in oklab, var(--c, var(--primary)) 46%, var(--surface))); }
.sample-cover .i { width: 22%; height: auto; aspect-ratio: 1; stroke-width: 1.2; color: color-mix(in oklab, var(--c, var(--primary)) 78%, var(--ink)); opacity: .7; }
.sample-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-i { position: relative; display: grid; border-radius: 16px; overflow: hidden; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--hair); transition: box-shadow var(--t2), border-color var(--t2); }
@media (hover: hover) { .card-i:hover { box-shadow: var(--e2); } }
.card-i:has(.card-a:focus-visible) { outline: 3px solid var(--primary); outline-offset: 2px; }
.card-a { display: grid; text-decoration: none; outline: 0; }
/* 封面：一张缩小的卡（左边几行字，右边一块舞台），颜色按卡片各取一个色相 */
.cover { position: relative; display: block; height: 88px; background: linear-gradient(135deg, oklch(.95 .035 var(--h, 270)), oklch(.9 .065 calc(var(--h, 270) + 36))); }
.cover::before { content: ""; position: absolute; left: 16px; top: 28px; width: 30%; height: 8px; border-radius: 4px; background: oklch(.5 .13 var(--h, 270) / .6); box-shadow: 0 15px 0 -1.5px oklch(.5 .1 var(--h, 270) / .26), 0 27px 0 -1.5px oklch(.5 .1 var(--h, 270) / .26); }
.cover i { position: absolute; right: 16px; top: 16px; bottom: 16px; width: 44%; border-radius: 8px; background: rgba(255, 255, 255, .72); }
html[data-mode='dark'] .cover { background: linear-gradient(135deg, oklch(.36 .05 var(--h, 270)), oklch(.29 .075 calc(var(--h, 270) + 36))); }
html[data-mode='dark'] .cover::before { background: oklch(.88 .07 var(--h, 270) / .75); box-shadow: 0 15px 0 -1.5px oklch(.88 .06 var(--h, 270) / .3), 0 27px 0 -1.5px oklch(.88 .06 var(--h, 270) / .3); }
html[data-mode='dark'] .cover i { background: rgba(255, 255, 255, .13); }
.card-t { display: grid; gap: 2px; align-content: start; padding: 12px 48px 14px 16px; }
/* 标题和说明最多各两行：英文比中文长，窄卡片上一行放不下 */
.card-t b, .card-t small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-t b { font-size: 15px; font-weight: 500; line-height: 1.35; }
.card-t small { font-size: 12.5px; line-height: 1.4; color: var(--ink-3); }
.card-i .go { position: absolute; right: 16px; bottom: 20px; width: 18px; height: 18px; color: var(--ink-3); }
.card-x { position: absolute; right: 6px; bottom: 9px; opacity: 0; transition: opacity var(--t2), color var(--t2); }
.card-x .i { width: 18px; height: 18px; }
.card-x:hover { color: var(--error); }
.card-i:hover .card-x, .card-i:focus-within .card-x { opacity: 1; }
@media (hover: none) { .card-x { opacity: 1; } }
.card-i.sk { height: 150px; border-color: transparent; background: linear-gradient(100deg, var(--fill-2) 40%, var(--fill-1) 50%, var(--fill-2) 60%) 0 0 / 300% 100%; animation: sheen 1.4s linear infinite; }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- 工作台 ---------- */
.work { height: 100dvh; padding: var(--bar) 12px 12px; display: grid; grid-template-columns: var(--chat-w, 420px) 12px minmax(0, 1fr); }
.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 0 0 0 4px; }
.banner { display: flex; gap: 8px; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; background: var(--note-container); color: var(--on-note-container); }
.banner .i { width: 18px; height: 18px; margin-top: 1px; }
.msgs-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.msgs { flex: 1; min-width: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 28px; display: flex; flex-direction: column; gap: 16px; scrollbar-width: thin; scrollbar-color: var(--outline-2) transparent; -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent); mask-image: linear-gradient(#000 calc(100% - 28px), transparent); }
.msgs > * { flex: none; }
.msg { font-size: 15px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; animation: rise var(--t4) var(--decel) both; }
.msg.bot { padding: 0 4px; }
.msg.bot.live::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--primary); animation: pulse .7s ease-in-out infinite alternate; }
.msg.user { align-self: flex-end; max-width: 88%; padding: 10px 16px; border-radius: 20px 20px 4px 20px; background: var(--secondary-container); color: var(--on-secondary-container); }
.msg.err { display: flex; gap: 8px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55; background: var(--error-container); color: var(--on-error-container); }
.msg.err .i { width: 18px; height: 18px; margin-top: 2px; }
.msg.note { align-self: center; padding: 0 12px; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.names { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; white-space: normal; }
.names:first-child { margin-top: 0; }
.names span { max-width: 100%; height: 26px; padding: 0 9px 0 6px; border-radius: 7px; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; background: color-mix(in srgb, currentColor 10%, transparent); }
.names .i { width: 14px; height: 14px; }
.names b { font-weight: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 「做好了一版」：点一下，右边换成这一版 */
.made { width: 100%; padding: 10px 12px 10px 10px; border-radius: 16px; display: flex; align-items: center; gap: 12px; text-align: left; color: var(--ink); background: var(--surface); border: 1px solid var(--hair); transition: border-color var(--t2), box-shadow var(--t2); animation: rise var(--t4) var(--decel) both; }
.made .thumb { flex: none; width: 52px; height: 40px; border-radius: 9px; display: grid; place-items: center; font: 600 12px var(--mono); background: var(--primary-container); color: var(--on-primary-container); }
.made-t { flex: 1; min-width: 0; display: grid; gap: 1px; }
.made b { font-size: 14px; font-weight: 500; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.made small { font-size: 12.5px; color: var(--ink-3); }
.made > .i { width: 18px; height: 18px; color: var(--ink-3); }
.made.on { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.msgs.loading::before, .msgs.loading::after { content: ""; height: 44px; border-radius: 16px; background: linear-gradient(100deg, var(--fill-2) 40%, var(--fill-1) 50%, var(--fill-2) 60%) 0 0 / 300% 100%; animation: sheen 1.4s linear infinite; }
.msgs.loading::before { align-self: flex-end; width: 62%; }
.msgs.loading::after { width: 84%; height: 96px; }

/* 提问卡片 */
.ask { padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--hair); display: grid; gap: 20px; animation: rise var(--t4) var(--decel) both; }
.ask-intro { font-size: 14.5px; color: var(--ink-2); }
.q { display: grid; gap: 10px; }
.q-t { font-size: 15px; font-weight: 500; line-height: 1.5; }
.q-t small { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { min-height: 36px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--outline-2); display: inline-flex; align-items: center; text-align: left; color: var(--ink-2); transition: background var(--t2), border-color var(--t2), color var(--t2); }
.opt .i { width: 0; height: 18px; opacity: 0; transition: width var(--t2) var(--emph), margin var(--t2) var(--emph), opacity var(--t2); }
.opt.on { background: var(--secondary-container); border-color: transparent; color: var(--on-secondary-container); }
.opt.on .i { width: 18px; margin: 0 6px 0 -4px; opacity: 1; }
.opt span { display: block; font-size: 14px; font-weight: 500; line-height: 1.4; }
.opt small { display: block; font-size: 12.5px; line-height: 1.4; opacity: .76; }
.q input { height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--outline); background: transparent; outline: 0; font-size: 14.5px; transition: border-color var(--t2), box-shadow var(--t2); }
.q input::placeholder { color: var(--ink-3); }
.q input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.ask-go { justify-self: end; }
.ask.done { gap: 10px; padding: 14px 16px; background: transparent; }
.qa { font-size: 14px; line-height: 1.5; }
.qa b { display: block; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }

/* 正在做什么：品牌的 ∞ 一圈一圈地走，文字上有一道光扫过 */
.status { display: flex; align-items: center; gap: 10px; padding: 2px 12px; font-size: 13.5px; }
.think { flex: none; width: 32px; height: 16px; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; }
.think-0 { opacity: .22; }
.think-1 { stroke-dasharray: 26 74; animation: loop 1.5s linear infinite; }
@keyframes loop { to { stroke-dashoffset: -100; } }
.status span { background: linear-gradient(90deg, var(--ink-3) 35%, var(--ink) 50%, var(--ink-3) 65%) 0 0 / 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -66% 0; } }
.jump { position: absolute; left: 50%; bottom: 14px; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); color: var(--ink-2); box-shadow: var(--e2); animation: pop var(--t2) var(--decel) both; }
.jump .i { width: 18px; height: 18px; }
.quota { padding: 0 12px; font-size: 12.5px; color: var(--ink-3); }

/* 分隔条：拖动调整对话区宽度 */
.split { position: relative; cursor: col-resize; touch-action: none; outline: 0; }
.split::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 40px; margin: -20px 0 0 -2px; border-radius: 2px; background: var(--outline-2); opacity: 0; transition: opacity var(--t2), height var(--t2) var(--emph), margin var(--t2) var(--emph), background var(--t2); }
.split:hover::after, .split:focus-visible::after { opacity: 1; }
.resizing .split::after { opacity: 1; height: 64px; margin-top: -32px; background: var(--primary); }
.resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
.resizing iframe { pointer-events: none; }

/* 预览 */
.view { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-radius: 24px; overflow: hidden; background: var(--surface); border: 1px solid var(--hair); }
.tools { flex: none; height: 56px; padding: 0 12px 0 16px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--hair); }
.tools .btn.filled { margin-left: 6px; }
.sel { position: relative; display: inline-flex; min-width: 0; }
.sel select { appearance: none; -webkit-appearance: none; height: 32px; min-width: 0; max-width: 220px; padding: 0 30px 0 12px; border-radius: 8px; border: 1px solid var(--outline-2); background: transparent; font-size: 13px; font-weight: 500; color: var(--ink-2); text-overflow: ellipsis; cursor: pointer; transition: border-color var(--t2), background var(--t2); }
.sel select:hover { background: var(--fill-1); border-color: var(--outline); }
.sel::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border: solid var(--ink-3); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.voicesel { display: inline-flex; gap: 6px; min-width: 0; margin-left: 6px; }
.voicesel select { max-width: 140px; }
.frame { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--fill-1); display: grid; place-items: center; }
.frame iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--page); }
.frame.tall iframe { width: 390px; max-width: calc(100% - 40px); height: min(100% - 44px, 844px); border-radius: 36px; box-shadow: 0 0 0 9px #1c1c22, 0 0 0 10px var(--outline-2), var(--e3); }
.frame.loading::before { content: ""; position: absolute; z-index: 2; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, transparent, var(--primary) 30% 70%, transparent) 0 0 / 40% 100% no-repeat; animation: bar 1.1s var(--emph) infinite; }
@keyframes bar { from { background-position: -70% 0; } to { background-position: 170% 0; } }
.empty { display: grid; justify-items: center; gap: 6px; padding: 24px; text-align: center; font-size: 14px; color: var(--ink-3); }
.empty strong { font-size: 16px; font-weight: 500; color: var(--ink-2); }
.ghost { width: 232px; height: 148px; margin-bottom: 20px; padding: 20px; border-radius: 16px; display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--hair); box-shadow: var(--e1); }
.ghost span { display: grid; gap: 9px; }
.ghost i { height: 8px; border-radius: 4px; background: var(--fill-3); }
.ghost i:first-child { width: 88%; height: 12px; border-radius: 6px; background: var(--outline-2); }
.ghost i:last-child { width: 58%; }
.ghost b { height: 100%; border-radius: 10px; background: var(--primary-container); }
.making .ghost i, .making .ghost b { animation: breathe 1.1s ease-in-out infinite alternate; }
.making .ghost i:nth-child(2) { animation-delay: .15s; }
.making .ghost i:nth-child(3) { animation-delay: .3s; }
.making .ghost b { animation-delay: .45s; }
@keyframes breathe { to { opacity: .35; } }

/* ---------- 对话框、菜单、提示条、气泡提示 ---------- */
.dlg { width: min(420px, calc(100vw - 32px)); margin: auto; padding: 0; border: 0; border-radius: 28px; background: var(--raised); color: var(--ink); box-shadow: var(--e3); opacity: 0; transform: translateY(16px) scale(.96); transition: opacity var(--t2), transform var(--t3) var(--decel), overlay var(--t3) allow-discrete, display var(--t3) allow-discrete; }
.dlg[open] { opacity: 1; transform: none; }
.dlg::backdrop { background: var(--scrim); opacity: 0; transition: opacity var(--t3), overlay var(--t3) allow-discrete, display var(--t3) allow-discrete; }
.dlg[open]::backdrop { opacity: 1; }
@starting-style { .dlg[open] { opacity: 0; transform: translateY(16px) scale(.96); } .dlg[open]::backdrop { opacity: 0; } }
.dlg-in { display: grid; gap: 16px; padding: 24px; }
.dlg .logo { width: 36px; height: 36px; margin-bottom: 4px; }
.dlg h2 { font-size: 24px; font-weight: 500; letter-spacing: -.01em; line-height: 1.3; overflow-wrap: anywhere; }
.dlg-sub { margin-top: -8px; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.dlg-sub:empty { display: none; }
.dlg-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dlg-row .btn.text:first-child { margin-left: -12px; }
.dlg-err { padding: 10px 14px; border-radius: 12px; font-size: 13.5px; background: var(--error-container); color: var(--on-error-container); }
/* 描边输入框：标签平时在框里，聚焦或有内容时浮到边框上 */
.field { position: relative; display: block; }
.field input { width: 100%; height: 56px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--outline); background: transparent; outline: 0; font-size: 16px; transition: border-color var(--t2), box-shadow var(--t2); }
.field.has-btn input { padding-right: 52px; }
.field span { position: absolute; left: 12px; top: 28px; padding: 0 4px; font-size: 16px; line-height: 1; color: var(--ink-2); background: var(--raised); pointer-events: none; transform: translateY(-50%); transform-origin: 0 50%; transition: top var(--t2) var(--emph), font-size var(--t2) var(--emph), color var(--t2); }
.field input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.field input:focus + span, .field input:not(:placeholder-shown) + span, .field input:autofill + span { top: 0; font-size: 12px; }
.field input:focus + span { color: var(--primary); }
.field-wrap { position: relative; display: grid; gap: 4px; }
.field-wrap small { padding-left: 16px; font-size: 12px; color: var(--ink-3); }
.field-btn { position: absolute; right: 8px; top: 8px; }
.field-btn[aria-pressed='true'] { color: var(--primary); }
.copy { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: 999px; background: var(--fill-2); }
.copy input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 13px var(--mono); color: var(--ink-2); text-overflow: ellipsis; }
.menu { position: fixed; inset: calc(var(--bar) - 6px) 12px auto auto; width: min(320px, calc(100vw - 24px)); margin: 0; padding: 8px; border: 0; border-radius: 20px; background: var(--raised); color: var(--ink); box-shadow: var(--e3); opacity: 0; transform: translateY(-8px) scale(.96); transform-origin: 100% 0; transition: opacity var(--t2), transform var(--t2) var(--decel), overlay var(--t2) allow-discrete, display var(--t2) allow-discrete; }
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: translateY(-8px) scale(.96); } }
.acct-who { display: flex; align-items: center; gap: 12px; padding: 12px; }
.acct-who div { min-width: 0; display: grid; }
.acct-who b { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who small { font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; padding: 8px 12px; font-size: 13px; color: var(--ink-2); }
.meter em { font: 12.5px var(--mono); color: var(--ink-3); }
.meter i { grid-column: 1 / -1; height: 4px; border-radius: 2px; overflow: hidden; background: var(--fill-3); }
.meter u { display: block; width: var(--p, 0%); height: 100%; border-radius: 2px; background: var(--primary); transition: width var(--t4) var(--emph); }
.meter.full u { background: var(--error); }
.menu hr { margin: 8px 0; border: 0; border-top: 1px solid var(--hair); }
.menu-i { width: 100%; height: 44px; padding: 0 12px; border-radius: 12px; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink); }
.menu-i .i { color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 40; translate: -50% 0; min-height: 48px; max-width: min(560px, calc(100vw - 32px)); padding: 4px 8px 4px 16px; border-radius: 12px; display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 1.45; background: var(--inverse); color: var(--on-inverse); box-shadow: var(--e3); opacity: 0; transform: translateY(12px) scale(.96); pointer-events: none; transition: opacity var(--t2), transform var(--t3) var(--decel); overflow-wrap: anywhere; }
.toast span { padding: 8px 8px 8px 0; }
.toast.on { opacity: 1; transform: none; pointer-events: auto; }
.toast .btn { height: 36px; color: var(--inverse-primary); }
.tip { position: fixed; left: 0; top: 0; z-index: 50; max-width: 240px; padding: 5px 9px; border-radius: 6px; font-size: 12px; line-height: 1.4; background: var(--inverse); color: var(--on-inverse); pointer-events: none; opacity: 0; transform: scale(.94); transition: opacity var(--t1), transform var(--t1); }
.tip.on { opacity: 1; transform: none; }

/* 入口 ↔ 工作台：输入框从页面中间滑到左下角，其余部分交叉淡入 */
::view-transition-group(composer) { animation-duration: .45s; animation-timing-function: cubic-bezier(.2, 0, 0, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }

/* ---------- 窄屏：对话和预览各占一屏，用顶栏的分段按钮切换 ---------- */
@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); padding: var(--bar) 8px max(8px, env(safe-area-inset-bottom)); }
  .split { display: none; }
  .chat { padding: 0; }
  .work[data-tab='chat'] .view, .work[data-tab='view'] .chat { display: none; }
  .bar { padding: 0 8px 0 12px; gap: 8px; }
  .bar-title { display: none; }
  html[data-view='work'] .tabs { display: inline-flex; margin: 0 auto; }
  html[data-view='work'] .wordmark, html[data-view='work'] #lang, #new span { display: none; }
  .bar-r { margin-left: 0; gap: 4px; }
  html[data-view='home'] .bar-r { margin-left: auto; }
  #new { width: 32px; padding: 0; }
  #new .i { margin: 0; }
  .view { border-radius: 20px; }
  /* 工具栏放不下一行：版本选择独占第一行，其余的排第二行 */
  .tools { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 6px; padding: 8px; }
  .tools .ib { width: 40px; height: 40px; }
  .tools .grow { display: none; }
  .tools:has(#versions-wrap:not([hidden])) .grow { display: block; flex: 0 0 100%; height: 0; margin-top: -6px; }
  #versions-wrap { flex: 1; }
  #versions-wrap select { width: 100%; max-width: none; }
  #device { display: none; }
  .voicesel { margin: 0 auto 0 0; }
  .voicesel select { max-width: 104px; }
  .home-in { padding: var(--bar) 16px 40px; }
  .hero { padding-top: 20px; }
  .sub { margin: 16px 0 28px; }
  .composer.big textarea { min-height: 96px; padding: 18px 20px 6px; }
  .shelf { margin-top: 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cover { height: 72px; }
  .cover::before { top: 20px; }
  .card-t { padding-right: 40px; }
  .msg.user { max-width: 92%; }
}
/* 触屏：可点区域放大，输入框字号不小于 16px */
@media (pointer: coarse) {
  .ib { width: 44px; height: 44px; }
  .btn.sm, .tabs button, .seg button, .sel select { height: 40px; }
  .chip, .opt { min-height: 44px; height: auto; }
  .file { height: 36px; }
  .file button { width: 32px; height: 32px; }
  .composer textarea, .q input, .copy input { font-size: 16px; }
  #new { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .status span { background: none; color: var(--ink-3); }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@media (forced-colors: active) {
  .btn, .ib, .send, .chip, .opt, .made, .card-i, .composer, .view, .dlg, .menu, .toast, .tip { border: 1px solid CanvasText; }
  .opt.on, .tabs button.on, .seg button.on, .made.on { outline: 2px solid Highlight; outline-offset: -2px; }
  .hero h1 em, .status span { background: none; color: CanvasText; }
}
