/* 画室 · 移动优先深色主题
   中性色统一往主色（蓝紫）偏一点，避免纯灰的「未经设计感」。
   深色是实质决策而非偏好：中性暗底不干扰对生成图颜色的判断。 */
:root {
    --bg: #0b0d11;
    --surface: #151920;
    --surface-2: #1c2129;
    --surface-3: #242a34;
    --line: #272d37;
    --line-soft: #1e232b;
    --text: #e9edf3;
    --muted: #89939f;
    --faint: #5f6875;
    --accent: #6c8cff;
    --accent-press: #5878f0;
    --accent-soft: rgba(108, 140, 255, .14);
    --danger: #ff6b6b;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;

    --tabbar-h: 54px;
    --topbar-h: 46px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* iOS Safari 会给 button / input 套一层原生外观，只写 background 压不住，
   必须显式关掉，否则在部分 iOS 版本上会露出系统默认的浅灰圆角块。 */
button, input, textarea, select {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
}

html, body {
    margin: 0; height: 100%;
    background: var(--bg); color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.55;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 48px 16px; }
.grow { flex: 1; }
.view { height: 100%; }

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

/* ---------- 通用控件 ---------- */
input, textarea, button, select { font-family: inherit; font-size: 16px; color: var(--text); }

input[type="text"], input[type="password"] {
    width: 100%; padding: 13px 14px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-md); outline: none;
}
input:focus { border-color: var(--accent); }

.btn {
    border: none; border-radius: var(--r-md); padding: 13px 18px;
    font-weight: 600; background: var(--surface-2); cursor: pointer;
    /* 有的 .btn 是 <a>，必须显式压掉浏览器默认的蓝色下划线链接样式 */
    color: var(--text); text-decoration: none; text-align: center;
    transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }

.link { background: none; border: none; padding: 4px 2px; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: none; }
.link.danger { color: var(--danger); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0 0; }
.hint-line { margin: 12px 2px 0; font-size: 12px; color: var(--faint); line-height: 1.6; }

/* 登录 / 注册 切换 */
.seg {
    display: flex; gap: 4px; padding: 4px; margin-bottom: 16px;
    background: rgba(255, 255, 255, .05); border-radius: 999px;
}
.seg-item {
    flex: 1 1 0; min-width: 0;
    border: none; background-color: transparent; cursor: pointer;
    padding: 9px 0; border-radius: 999px;
    font-size: 14px; line-height: 1.4; text-align: center; color: var(--muted);
}
.seg-item.active { background-color: var(--accent); color: #fff; font-weight: 600; }

/* ---------- 登录 ---------- */
.login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; }
.brand { text-align: center; margin-bottom: 30px; }
.brand-mark {
    width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
    background: linear-gradient(140deg, var(--accent), #9d6cff);
    display: grid; place-items: center; font-size: 29px; font-weight: 700; color: #fff;
}
.brand h1 { margin: 0 0 3px; font-size: 23px; }
.brand p { margin: 0; font-size: 14px; }

/* ---------- 顶栏 ---------- */
.topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 20;
    height: calc(var(--topbar-h) + var(--safe-t));
    padding: var(--safe-t) 12px 0;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(11, 13, 17, .88); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line-soft);
}
.topbar-side { display: flex; align-items: center; gap: 8px; min-width: 76px; }
.topbar-side.right { justify-content: flex-end; }
.topbar-title { margin: 0; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.ico-frame {
    width: 14px; height: 11px; border: 1.5px solid var(--muted); border-radius: 3px; display: inline-block;
}
.quota-pill {
    font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
    background: var(--surface); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px;
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
    background: linear-gradient(140deg, var(--accent), #9d6cff);
    color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center;
}

/* ---------- 滚动区 ---------- */
.stream {
    position: absolute; left: 0; right: 0;
    top: calc(var(--topbar-h) + var(--safe-t));
    bottom: calc(var(--tabbar-h) + var(--safe-b));
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 12px 12px 0;
    /* 给悬浮输入区留出净空，由 JS 按实际高度写入 */
    padding-bottom: var(--composer-space, 190px);
}

/* ---------- 空状态：可点的完整示例词 ---------- */
.empty { padding: 8px 0 4px; }
.empty-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.sample-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sample {
    text-align: left; background: var(--surface); border: 1px solid var(--line-soft);
    border-radius: var(--r-md); padding: 12px; font-size: 13px; line-height: 1.5;
    color: var(--muted); cursor: pointer;
}
.sample:active { background: var(--surface-2); }

/* ---------- 批次卡片 ---------- */
.batch { margin-bottom: 18px; }
.shots { display: grid; gap: 6px; }
.shots.n2 { grid-template-columns: 1fr 1fr; }
.shots.n4 { grid-template-columns: 1fr 1fr; }
.shot {
    width: 100%; display: block; border-radius: var(--r-md);
    background: var(--surface); object-fit: cover; cursor: pointer;
}

/* 占位块：写死目标比例，原位显影，布局零跳动 */
.placeholder {
    width: 100%; border-radius: var(--r-md);
    background: linear-gradient(100deg, rgba(255,255,255,.05) 30%, rgba(255,255,255,.11) 50%, rgba(255,255,255,.05) 70%);
    background-size: 220% 100%;
    animation: shimmer 1.6s linear infinite;
    display: grid; place-items: center;
}
@keyframes shimmer { from { background-position: 140% 0; } to { background-position: -40% 0; } }
.placeholder span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .placeholder { animation: none; } }

.meta-row {
    display: flex; align-items: center; gap: 6px; margin-top: 8px;
    overflow-x: auto; scrollbar-width: none; padding-bottom: 2px;
}
.meta-row::-webkit-scrollbar { display: none; }
.mchip {
    flex: 0 0 auto; font-size: 11.5px; color: var(--muted);
    background: var(--surface); border: 1px solid var(--line-soft);
    padding: 3px 8px; border-radius: 999px; white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.mchip.act { color: var(--accent); border-color: rgba(108,140,255,.35); background: var(--accent-soft); cursor: pointer; }
.mchip.crop { cursor: pointer; }
.batch-prompt {
    margin: 7px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.batch-prompt.open { -webkit-line-clamp: unset; }

/* ---------- 资产：两列瀑布流，按原图比例不裁切 ---------- */
.filter-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; }
.filter-row::-webkit-scrollbar { display: none; }
.masonry { columns: 2; column-gap: 8px; }
.masonry .cardw { break-inside: avoid; margin-bottom: 8px; position: relative; }
.masonry img { width: 100%; display: block; border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
.card-tag {
    position: absolute; left: 6px; bottom: 6px; font-size: 10px; color: rgba(255,255,255,.85);
    background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
.card-same {
    position: absolute; right: 6px; bottom: 6px; font-size: 11px; color: #fff;
    background: rgba(0,0,0,.5); padding: 3px 9px; border-radius: 999px; border: none; cursor: pointer;
}

/* ---------- 悬浮输入区 ---------- */
.composer {
    position: absolute; left: 10px; right: 10px; z-index: 25;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
    background: rgba(28, 33, 41, .93); backdrop-filter: blur(18px);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: 10px 10px 6px;
    box-shadow: 0 12px 34px -14px rgba(0,0,0,.75);
}
.composer textarea {
    width: 100%; border: none; background: none; outline: none; resize: none;
    padding: 4px 4px 6px; line-height: 1.5; max-height: 116px;
}
.composer textarea::placeholder { color: var(--faint); }

/* 参考图行 */
.refs { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; }
.refs::-webkit-scrollbar { display: none; }
.ref {
    position: relative; flex: 0 0 auto;
    width: 54px; height: 54px; border-radius: var(--r-sm);
    background: var(--surface); overflow: hidden;
}
.ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-x {
    position: absolute; top: -2px; right: -2px;
    width: 19px; height: 19px; border-radius: 50%;
    background: rgba(0,0,0,.72); color: #fff; border: none;
    font-size: 12px; line-height: 1; cursor: pointer;
    display: grid; place-items: center;
}

.chip-row { display: flex; align-items: center; gap: 7px; }
.icon-chip { padding: 6px 10px; font-weight: 600; }
.icon-chip.on { background: var(--accent-soft); color: var(--accent); }
.vchip {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,.07); border: 1px solid transparent;
    color: rgba(233,237,243,.78); font-size: 13px;
    padding: 6px 11px; border-radius: 999px; cursor: pointer;
    white-space: nowrap; font-variant-numeric: tabular-nums;
}
.vchip:active { background: rgba(255,255,255,.12); }
.ratio-ico { display: inline-block; border: 1.5px solid currentColor; border-radius: 2px; opacity: .9; }

.send {
    width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: #fff;
    display: grid; place-items: center; position: relative; flex: 0 0 auto;
}
.send:active { background: var(--accent-press); }
.send[disabled] { opacity: .5; }
.send-arrow { font-size: 17px; line-height: 1; }
.send-cost {
    position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
    background: var(--surface-3); border: 1px solid var(--line);
    border-radius: 999px; font-size: 10px; line-height: 14px; text-align: center;
    color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 3px;
}
.notice { margin: 6px 2px 0; font-size: 10.5px; color: var(--faint); text-align: center; }

/* ---------- 底部导航 ---------- */
.tabbar {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: flex; background: rgba(11,13,17,.94); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-soft);
}
.tab {
    flex: 1; border: none; background: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--faint); font-size: 10.5px;
}
.tab .ico { font-size: 16px; line-height: 1; }
.tab.active { color: var(--accent); }

/* ---------- 弹层 ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.sheet {
    position: fixed; left: 10px; right: 10px; z-index: 45;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 14px;
    box-shadow: 0 20px 50px -18px rgba(0,0,0,.8);
    max-height: 68vh; overflow-y: auto;
}
.sheet-title { font-size: 12px; color: var(--muted); margin: 2px 2px 10px; }
.sheet-title + .sheet-title { margin-top: 16px; }
.sheet-hint {
    margin: 12px 2px 0; font-size: 11.5px; color: var(--faint);
    font-variant-numeric: tabular-nums; min-height: 17px;
}

/* 比例网格：形状即比例，数值写在框内 */
.ratio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ratio-cell {
    aspect-ratio: 1; border-radius: var(--r-sm);
    background: rgba(255,255,255,.05); border: 1px solid transparent;
    display: grid; place-items: center; cursor: pointer; padding: 0;
}
.ratio-cell:active { background: rgba(255,255,255,.1); }
.ratio-cell.active { background: var(--accent-soft); border-color: var(--accent); }
.ratio-box {
    border: 1px solid rgba(255,255,255,.4); border-radius: 2px;
    display: grid; place-items: center;
    font-size: 10.5px; color: rgba(255,255,255,.72); font-variant-numeric: tabular-nums;
}
.ratio-cell.active .ratio-box { border-color: var(--accent); border-width: 1.5px; color: var(--accent); }
.ratio-box.dashed { border-style: dashed; }

/* 质量：档位带一句人话解释 */
.quality-list { display: flex; flex-direction: column; gap: 7px; }
.qitem {
    display: flex; align-items: baseline; gap: 9px; text-align: left;
    background: rgba(255,255,255,.05); border: 1px solid transparent;
    border-radius: var(--r-md); padding: 11px 13px; cursor: pointer; width: 100%;
}
.qitem.active { background: var(--accent-soft); border-color: var(--accent); }
.qitem b { font-size: 14px; font-weight: 600; }
.qitem span { font-size: 12px; color: var(--muted); }
.qitem.active b { color: var(--accent); }

.preset-row { display: flex; gap: 8px; margin-bottom: 16px; }
.preset {
    flex: 1; background: rgba(255,255,255,.05); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 10px; cursor: pointer;
    display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 600;
}
.preset span { font-size: 11px; color: var(--muted); font-weight: 400; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
    padding: 8px 14px; border-radius: 999px; border: 1px solid transparent;
    background: rgba(255,255,255,.07); color: rgba(233,237,243,.7); font-size: 13.5px; cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.info-card { background: rgba(255,255,255,.04); border-radius: var(--r-md); padding: 2px 14px; }
.info-card .row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.info-card .row:last-child { border-bottom: none; }
.info-card .row span { color: var(--muted); flex: 0 0 auto; }
.info-card .row b { font-weight: 500; text-align: right; word-break: break-all; }

/* ---------- 大图预览 ---------- */
.viewer { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }
.viewer-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: calc(10px + var(--safe-t)) 14px 8px;
}
.viewer-actions { display: flex; gap: 15px; }
.viewer-body { flex: 1; display: grid; place-items: center; overflow: auto; padding: 6px; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-meta { padding: 12px 16px calc(16px + var(--safe-b)); max-height: 36vh; overflow-y: auto; }
.viewer-meta p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.6; white-space: pre-wrap; }
.viewer-meta dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 12px; }
.viewer-meta dt { color: var(--faint); }
.viewer-meta dd { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 提示 ---------- */
.toast {
    position: fixed; left: 50%; transform: translateX(-50%); z-index: 70;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px);
    background: var(--surface-3); border: 1px solid var(--line);
    padding: 10px 17px; border-radius: 999px; font-size: 13.5px;
    max-width: 84vw; text-align: center;
}
