/* ============ 工作台布局 ============ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* 侧边栏 */
.sidebar {
  width: 232px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--bg-soft);
}
.sidebar.collapsed { width: 68px; }
.sidebar .brand {
  height: var(--header-h); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border); flex: none;
}
.side-menu { flex: 1; overflow-y: auto; padding: 12px 10px; display: grid; gap: 4px; align-content: start; }
.side-group { font-size: 11px; color: var(--text-dim); padding: 14px 10px 6px; letter-spacing: 1px; }
.side-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-soft); cursor: pointer; font-size: 14.5px; transition: all 0.14s;
}
.side-item:hover { background: var(--bg-elev); color: var(--text); }
.side-item.on { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,.28); }
.side-item .em { width: 20px; text-align: center; flex: none; }
.sidebar.collapsed .side-item span.lbl, .sidebar.collapsed .side-group, .sidebar.collapsed .brand .txt { display: none; }

.side-foot { border-top: 1px solid var(--border); padding: 12px; flex: none; }
.credit-box {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px;
}
.credit-box .n { font-size: 20px; font-weight: 800; }
.credit-box .t { font-size: 12px; color: var(--text-dim); }

/* 主区 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--header-h); flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--bg-soft);
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 700; }
.topbar .grow { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 12px 5px 5px;
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13.5px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-grad);
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; flex: none;
}
.view { flex: 1; overflow-y: auto; padding: 24px; }
.view[hidden] { display: none; }

/* ============ 聊天 ============ */
.chat-wrap { display: flex; height: 100%; gap: 0; }
.conv-list {
  width: 240px; flex: none; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: var(--bg-soft);
}
.conv-list .hd { padding: 14px; border-bottom: 1px solid var(--border); }
.conv-list .bd { flex: 1; overflow-y: auto; padding: 8px; }
.conv {
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.conv:hover { background: var(--bg-elev); }
.conv.on { background: var(--bg-elev); border: 1px solid var(--border-strong); }
.conv .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.conv .x { color: var(--text-dim); font-size: 15px; line-height: 1; }
.conv .x:hover { color: #f87171; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-bar {
  padding: 10px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex: none; flex-wrap: wrap;
}
.chat-bar .spacer { flex: 1; }
.messages { flex: 1; overflow-y: auto; padding: 24px; display: grid; gap: 20px; align-content: start; }
.msg { display: flex; gap: 12px; max-width: 860px; width: 100%; margin: 0 auto; }
.msg .who { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; font-size: 14px; }
.msg.user .who { background: var(--bg-elev); border: 1px solid var(--border); }
.msg.ai .who { background: var(--accent-grad); color: #fff; }
.msg .bubble { flex: 1; min-width: 0; line-height: 1.8; font-size: 14.5px; word-break: break-word; }
.msg .bubble h2, .msg .bubble h3, .msg .bubble h4 { margin: 12px 0 8px; font-size: 15.5px; }
.msg .bubble pre {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.6;
}
.msg .bubble code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.msg .bubble p code, .msg .bubble li code { background: var(--bg-elev); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.msg .bubble blockquote {
  border-left: 3px solid var(--brand); margin: 8px 0; padding: 4px 14px; color: var(--text-soft);
}
.msg .bubble ul { margin: 8px 0; padding-left: 22px; }
.msg .bubble li { margin: 4px 0; }
.cursor::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--brand); }
@keyframes blink { 50% { opacity: 0; } }

.composer { padding: 16px 24px 22px; border-top: 1px solid var(--border); flex: none; }
.composer .box {
  max-width: 860px; margin: 0 auto; border: 1px solid var(--border-strong);
  border-radius: 14px; background: var(--bg-card); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.composer textarea {
  border: none; background: none; resize: none; outline: none; color: var(--text);
  font-size: 14.5px; line-height: 1.7; max-height: 220px; min-height: 52px;
}
.composer .row { display: flex; align-items: center; gap: 10px; }
.composer .row .spacer { flex: 1; }
.hint { font-size: 12px; color: var(--text-dim); }

.empty {
  max-width: 560px; margin: 8vh auto; text-align: center; color: var(--text-soft);
}
.empty h3 { font-size: 22px; margin: 0 0 10px; color: var(--text); }
.suggest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.suggest {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: left;
  cursor: pointer; background: var(--bg-card); font-size: 13.5px; color: var(--text-soft);
  transition: all .16s;
}
.suggest:hover { border-color: var(--brand); color: var(--text); transform: translateY(-2px); }

/* ============ 生成类视图 ============ */
.gen-layout { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.panel h3 { margin: 0 0 16px; font-size: 15px; font-weight: 700; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; margin-bottom: 8px; color: var(--text-soft); }
.field > label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; }
.field > label.check input { width: 16px; height: 16px; accent-color: var(--accent, #22d3ee); }
.prompt-area {
  width: 100%; min-height: 120px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  outline: none; resize: vertical; line-height: 1.7; font-size: 14px;
}
.prompt-area:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.13); }
select.input, .prompt-area { font-family: inherit; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  padding: 7px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 13px; color: var(--text-soft);
}
.seg button.on { background: var(--accent-grad); color: #fff; border-color: transparent; font-weight: 600; }
.cost-line {
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  padding: 12px 14px; border-radius: 11px; background: var(--bg-elev); margin-bottom: 14px;
}
.cost-line b { color: var(--brand); font-size: 15px; }

.result-area { min-height: 420px; }
.result-empty {
  min-height: 420px; display: grid; place-items: center; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-dim);
}
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.work-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--bg-card); position: relative;
}
.work-card .thumb { aspect-ratio: 1/1; background: var(--bg-elev); position: relative; }
.work-card img { width: 100%; height: 100%; object-fit: cover; }
.work-card .body { padding: 12px 14px; }
.work-card .p {
  font-size: 12.5px; color: var(--text-soft); display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 8px;
}
.work-card .meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-dim); }
.work-card .ops { display: flex; gap: 6px; margin-top: 10px; }
.mini-btn {
  padding: 5px 10px; font-size: 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elev); cursor: pointer; color: var(--text-soft);
}
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }
.badge-type {
  position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(34, 211, 238, 0.18);
  border-top-color: var(--brand); animation: spin 0.8s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { display: grid; place-items: center; min-height: 420px; text-align: center; }

/* 模型广场 */
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.model-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  background: var(--bg-card); transition: all .18s; cursor: pointer; position: relative;
}
.model-card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow); }
.model-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.model-card .vdot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.model-card h4 { margin: 0; font-size: 15px; font-weight: 700; }
.model-card .vname { font-size: 11.5px; color: var(--text-dim); }
.model-card p { margin: 0 0 12px; font-size: 13px; color: var(--text-soft); line-height: 1.7; min-height: 44px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--bg-elev); color: var(--text-soft); border: 1px solid var(--border);
}
.tag.hot { background: rgba(244, 114, 182, 0.14); color: #f472b6; border-color: rgba(244, 114, 182, 0.3); }
.tag.new { background: rgba(34, 211, 238, 0.14); color: var(--brand); border-color: rgba(34, 211, 238, 0.3); }
.model-card .foot { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-dim); }
.price-tag { color: var(--brand); font-weight: 700; }

/* 账户 */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.sc { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; background: var(--bg-card); }
.sc .k { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.sc .v { font-size: 22px; font-weight: 800; }

@media (max-width: 1100px) {
  .gen-layout { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { width: 68px; }
  .sidebar .side-item span.lbl, .sidebar .side-group, .sidebar .brand .txt { display: none; }
  .conv-list { display: none; }
}
