:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-2: #fafaf9;
    --hover: #f1f1ef;
    --border: #e9e9e6;
    --border-strong: #d6d6d2;
    --text: #18181b;
    --text-2: #52525b;
    --muted: #a1a1aa;
    --accent: #18181b;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
    --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px rgba(24, 24, 27, 0.05);
    --shadow-lg: 0 24px 64px rgba(24, 24, 27, 0.14);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

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

body {
    min-height: 100vh;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

body.no-scroll {
    overflow: hidden;
}

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

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

img {
    display: block;
}

svg.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.muted {
    color: var(--muted);
}

.count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* 品牌 */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
}

.logo-mark svg.icon {
    width: 15px;
    height: 15px;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.15s var(--ease);
}

.btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn.primary:hover {
    background: #2e2e33;
}

.btn.sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.btn.lg {
    height: 46px;
    font-size: 15px;
}

.btn.block {
    display: flex;
    width: 100%;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--hover);
    color: var(--text);
}

.icon-btn.danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: var(--text-2);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.link-btn:hover {
    color: var(--text);
}

.link-btn svg.icon {
    width: 14px;
    height: 14px;
}

/* 登录 */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 36px 36px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card .brand {
    margin-bottom: 28px;
}

.field {
    display: block;
    margin-bottom: 16px;
}

.field span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.field input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.prompt-box:focus-within {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}

.form-error {
    min-height: 20px;
    margin: -4px 0 10px;
    color: var(--danger);
    font-size: 13px;
}

/* 顶栏与布局 */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: rgba(247, 247, 245, 0.82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.user-menu {
    position: relative;
}

.avatar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.avatar-btn:hover,
.avatar-btn[aria-expanded="true"] {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform-origin: top right;
    animation: drop-in 0.18s var(--ease);
}

@keyframes drop-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
}

.user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.user-dropdown-info {
    min-width: 0;
}

.user-name {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-sub {
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}

.menu-item:hover {
    background: var(--hover);
}

.menu-item.danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.menu-item svg.icon {
    width: 16px;
    height: 16px;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.avatar.lg {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    font-size: 14px;
}

.layout {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 28px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

.panel {
    position: sticky;
    top: 88px;
    align-self: start;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel::-webkit-scrollbar,
.select-menu::-webkit-scrollbar {
    width: 6px;
}

.panel::-webkit-scrollbar-thumb,
.select-menu::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: var(--border-strong);
}

.panel::-webkit-scrollbar-track,
.select-menu::-webkit-scrollbar-track {
    background: transparent;
}

/* Chrome 121+ 只要设置了 scrollbar-width 就会忽略 ::-webkit-scrollbar */
@supports not selector(::-webkit-scrollbar) {
    .panel,
    .select-menu {
        scrollbar-width: thin;
    }
}

.tabs {
    display: flex;
    padding: 3px;
    margin-bottom: 22px;
    border-radius: 11px;
    background: var(--hover);
}

.tab {
    flex: 1;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s var(--ease), color 0.2s, box-shadow 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(24, 24, 27, 0.1);
}

.section {
    margin-bottom: 22px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.hint {
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.prompt-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.prompt-box textarea {
    display: block;
    width: 100%;
    min-height: 132px;
    padding: 12px 14px 4px;
    border: none;
    background: transparent;
    outline: none;
    resize: vertical;
    line-height: 1.7;
}

.prompt-box textarea::placeholder {
    color: var(--muted);
}

.prompt-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 34px;
    padding: 0 14px;
}

.prompt-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.optimize-btn {
    color: var(--text);
}

.optimize-btn:disabled {
    color: var(--muted);
    cursor: progress;
}

.optimize-btn:disabled svg.icon {
    animation: pulse 1.2s ease-in-out infinite;
}

.prompt-box.optimizing textarea {
    color: var(--muted);
}

/* 下拉选择 */
.select {
    position: relative;
}

.select-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.select-trigger:hover {
    border-color: var(--border-strong);
}

.select.open .select-trigger {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.06);
}

.select-value {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.select-caret {
    display: inline-flex;
    color: var(--muted);
    transition: transform 0.2s var(--ease);
}

.select.open .select-caret {
    transform: rotate(180deg);
}

.select-menu {
    position: fixed;
    z-index: 20;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.18s var(--ease);
}

.select-menu.up {
    animation-name: pop-up;
}

@keyframes pop-up {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
}

.select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    padding: 0 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}

.select-option:hover {
    background: var(--hover);
}

.select-option.selected {
    background: var(--surface-2);
}

.select-option > svg.icon {
    margin-left: auto;
    color: var(--text);
}

.select-label {
    font-weight: 500;
    white-space: nowrap;
}

.select-desc {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ratio-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-2);
}

.ratio-shape {
    display: block;
    border: 1.5px solid currentColor;
    border-radius: 3px;
}

.ratio-shape.auto {
    display: inline-flex;
    border: none;
}

.generate-btn {
    margin-top: 4px;
}

/* 参考图 */
.refs-section {
    position: relative;
    margin: 0 -8px 22px;
    padding: 8px;
    border: 1.5px dashed transparent;
    border-radius: 14px;
    transition: border-color 0.15s, background 0.15s;
}

.refs-section.dragover {
    border-color: var(--text);
    background: var(--surface-2);
}

.ref-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.ref-item,
.ref-add {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.ref-item {
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.ref-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ref-index {
    position: absolute;
    left: 5px;
    top: 5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.ref-remove {
    position: absolute;
    right: 5px;
    top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(24, 24, 27, 0.7);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}

.ref-remove svg.icon {
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.ref-item:hover .ref-remove {
    opacity: 1;
}

.ref-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1.5px dashed var(--border-strong);
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.ref-add:hover {
    border-color: var(--text);
    background: var(--surface);
    color: var(--text);
}

/* 创作记录 */
.feed-head {
    margin-bottom: 16px;
}

.feed-head-normal,
.feed-head-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 36px;
}

.feed-head-select,
.feed-head.selecting .feed-head-normal {
    display: none;
}

/* 多选时操作栏吸顶，滚动到下方也能操作 */
.feed-head.selecting {
    position: sticky;
    top: 68px;
    z-index: 5;
}

.feed-head.selecting .feed-head-select {
    display: flex;
    padding: 6px 6px 6px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    animation: pop-in 0.2s var(--ease);
}

.select-count {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.select-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.feed-head h2 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.feed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: 14px;
    overflow: hidden;
    background: var(--hover);
    box-shadow: inset 0 0 0 1px var(--border);
    cursor: zoom-in;
    outline: none;
    animation: card-in 0.35s var(--ease);
}

.tile:focus-visible {
    box-shadow: 0 0 0 2px var(--text);
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--ease);
}

.tile:hover img {
    transform: scale(1.04);
}

.tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0%, transparent 30%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.tile:hover::after {
    opacity: 1;
}

.tile-caption {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 10px;
    z-index: 1;
    display: -webkit-box;
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.25s, transform 0.25s var(--ease);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.tile:hover .tile-caption {
    opacity: 1;
    transform: none;
}

.tile-tools {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s, transform 0.2s var(--ease);
}

.tile:hover .tile-tools,
.tile:focus-within .tile-tools {
    opacity: 1;
    transform: none;
}

.tile-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.15s, color 0.15s;
}

.tile-tool:hover {
    background: #fff;
}

.tile-tool.danger:hover {
    color: var(--danger);
}

.tile-tool svg.icon {
    width: 15px;
    height: 15px;
}

.tile-id {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    padding: 2px 7px;
    border-radius: 6px;
    background: rgba(24, 24, 27, 0.55);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 18px;
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.tile-check {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: rgba(24, 24, 27, 0.25);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    transition: background 0.15s, border-color 0.15s;
}

.tile-check svg.icon {
    width: 14px;
    height: 14px;
    opacity: 0;
    stroke-width: 3;
}

.feed-grid.selecting .tile {
    cursor: pointer;
}

.feed-grid.selecting .tile-check {
    display: inline-flex;
}

.feed-grid.selecting .tile-tools {
    display: none;
}

.tile.selected {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.tile.selected img {
    border-radius: 10px;
    transform: scale(0.94);
}

.tile.selected .tile-check {
    border-color: var(--text);
    background: var(--text);
}

.tile.selected .tile-check svg.icon {
    opacity: 1;
}

.tile.failed {
    background: var(--surface);
    cursor: pointer;
}

.tile.failed::after,
.tile.failed .tile-caption {
    display: none;
}

.tile-failed {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.tile-failed svg.icon {
    width: 22px;
    height: 22px;
    color: #f87171;
}

.tile.pending {
    background: linear-gradient(100deg, #efefed 30%, #f7f7f6 50%, #efefed 70%);
    background-size: 200% 100%;
    box-shadow: none;
    cursor: default;
    animation: shimmer 1.4s infinite linear;
}

.tile.pending::after,
.tile.pending .tile-caption {
    display: none;
}

.tile.pending[role="button"] {
    cursor: pointer;
}

.tile-status {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-2);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.badge {
    flex-shrink: 0;
    padding: 2px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 500;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text);
    animation: pulse 1.2s ease-in-out infinite;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 72px 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    text-align: center;
}

.empty.compact {
    padding: 40px 16px;
    border: none;
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-2);
    box-shadow: var(--shadow-sm);
}

.empty-icon svg.icon {
    width: 20px;
    height: 20px;
}

.empty-title {
    font-size: 15px;
    font-weight: 600;
}

.empty-sub {
    margin-top: 4px;
    color: var(--muted);
}

@keyframes shimmer {
    to {
        background-position: -200% 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

/* 作品详情 */
.detail {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(24, 24, 27, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fade-in 0.2s;
}

.detail-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    width: 100%;
    max-width: 1240px;
    height: min(820px, 100%);
    border-radius: 20px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.25s var(--ease);
}

.detail-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 32px 76px;
    background: var(--bg);
}

.detail-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(24, 24, 27, 0.12);
    animation: fade-in 0.25s;
}

.detail-failed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.detail-failed svg.icon {
    width: 28px;
    height: 28px;
    color: #f87171;
}

.detail-failed.running svg.icon {
    display: none;
}

.detail-failed.running::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text);
    animation: pulse 1.2s ease-in-out infinite;
}

.stage-label {
    position: absolute;
    top: 16px;
    left: 50%;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transform: translateX(-50%);
}

.stage-label svg.icon {
    width: 14px;
    height: 14px;
}

.nav-btn {
    position: absolute;
    top: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-top: -21px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s var(--ease);
}

.nav-btn:hover {
    transform: scale(1.06);
}

.nav-btn svg.icon {
    width: 20px;
    height: 20px;
}

.nav-btn.prev {
    left: 18px;
}

.nav-btn.next {
    right: 18px;
}

.detail-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-left: 1px solid var(--border);
}

.detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.detail-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
}

.detail-scroll > * + * {
    margin-top: 22px;
}

.detail-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.detail-prompt {
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid #fee2e2;
    border-radius: var(--radius-sm);
    background: #fef7f7;
    color: #b91c1c;
    font-size: 13px;
    word-break: break-word;
}

.detail-error svg.icon {
    margin-top: 2px;
}

.detail-refs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.detail-ref {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--hover);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.detail-ref img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-ref.active {
    border-color: var(--text);
    box-shadow: 0 0 0 1.5px var(--text);
}

.detail-info {
    display: grid;
    grid-template-columns: 56px 1fr;
    row-gap: 10px;
    font-size: 13px;
}

.detail-info dt {
    color: var(--muted);
}

.detail-info dd {
    font-variant-numeric: tabular-nums;
}

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border);
}

.detail-actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-actions .btn {
    width: 100%;
}

.btn.danger {
    color: var(--danger);
}

.btn.danger:hover {
    border-color: #fecaca;
    background: #fef2f2;
}

.btn.danger:disabled:hover {
    border-color: var(--border);
    background: var(--surface);
}

.btn.danger.solid {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.btn.danger.solid:hover {
    border-color: #b91c1c;
    background: #b91c1c;
}

/* 确认弹框 */
.modal.confirm {
    z-index: 60;
}

.confirm-card {
    width: 100%;
    max-width: 380px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.2s var(--ease);
}

.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    border-radius: 12px;
    background: #fef2f2;
    color: var(--danger);
}

.confirm-icon svg.icon {
    width: 19px;
    height: 19px;
}

.confirm-card h3 {
    font-size: 16px;
    font-weight: 600;
    word-break: break-word;
}

.confirm-card p {
    margin-top: 6px;
    color: var(--text-2);
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 22px;
}

.confirm-actions .btn {
    min-width: 76px;
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(24, 24, 27, 0.28);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fade-in 0.2s;
}

.modal-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 760px;
    max-height: min(720px, 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.25s var(--ease);
}

.modal-head,
.modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
}

.modal-head {
    border-bottom: 1px solid var(--border);
}

.modal-head h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-foot {
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.modal-body {
    flex: 1;
    min-height: 0;
    padding: 16px 20px;
    overflow-y: auto;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 10px;
}

.picker-item {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--hover);
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.picker-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.picker-item.selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--text);
}

.picker-item .check {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 22px;
    text-align: center;
}

#picker-more {
    margin-top: 12px;
}

/* 提示 */
.toast {
    position: fixed;
    left: 50%;
    top: 76px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--text);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    transform: translateX(-50%);
    word-break: break-word;
    animation: pop-in 0.25s var(--ease);
}

.toast::before {
    content: "";
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a1a1aa;
}

.toast.success::before {
    background: #4ade80;
}

.toast.error::before {
    background: #f87171;
}

/* 触屏设备没有悬停，常驻显示操作按钮 */
@media (hover: none) {
    .ref-remove {
        opacity: 1;
    }

    .tile-tools {
        opacity: 1;
        transform: none;
    }
}

/* 移动端 */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 16px 14px 32px;
    }

    .panel {
        position: static;
        max-height: none;
        overflow: visible;
        padding: 16px;
    }

    .topbar {
        height: 56px;
        padding: 0 14px;
    }

    .feed-grid {
        grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
        gap: 6px;
    }

    .tile {
        border-radius: 10px;
    }

    .tile-caption {
        display: none;
    }

    .tile-tools {
        top: 5px;
        right: 5px;
        gap: 4px;
    }

    .tile-tool {
        width: 26px;
        height: 26px;
        border-radius: 7px;
    }

    .tile-tool svg.icon {
        width: 13px;
        height: 13px;
    }

    .tile-id {
        top: 5px;
        left: 5px;
        padding: 0 5px;
        border-radius: 5px;
        font-size: 10px;
    }

    .tile-check {
        top: 5px;
        right: 5px;
        width: 22px;
        height: 22px;
    }

    .feed-head.selecting {
        top: 62px;
    }

    .feed-head.selecting .feed-head-select {
        padding: 6px 6px 6px 12px;
    }

    .select-actions {
        gap: 4px;
    }

    .select-actions .btn {
        padding: 0 10px;
    }

    .select-actions .btn svg.icon {
        display: none;
    }

    .detail {
        padding: 0;
    }

    .detail-card {
        display: flex;
        flex-direction: column;
        max-width: none;
        height: 100%;
        border-radius: 0;
        overflow-y: auto;
    }

    .detail-stage {
        flex: 0 0 auto;
        height: 56vh;
        padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    }

    .detail-side {
        flex: 1 0 auto;
        min-height: auto;
        border-left: none;
    }

    .detail-head {
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .detail-scroll {
        overflow: visible;
    }

    .detail-actions {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .nav-btn {
        display: none;
    }

    .login-card {
        padding: 32px 24px 28px;
    }
}
