/* 华图 AI 绘图 · 可视化配置面板 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #24292f;
  --muted: #6b7280;
  --accent: #4f8cff;
  --accent-weak: #e8f0ff;
  --ok: #2fbf71;
  --warn: #e6a23c;
  --err: #e5484d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

html[data-theme="dark"] {
  --bg: #16181d;
  --card: #1e2128;
  --border: #2e323b;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #66a0ff;
  --accent-weak: #22314d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.app-title { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
h1 { font-size: 17px; }
.subtitle { color: var(--muted); font-size: 12px; }

.header-actions { display: flex; align-items: center; gap: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1080px; margin: 20px auto; padding: 0 18px 60px; display: grid; gap: 16px; }

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.section h2 {
  font-size: 15px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section .hint { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.section-head .actions { display: flex; gap: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 16px; }
.grid.wide { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { color: var(--muted); font-size: 12px; }
.field input[type="text"], .field input[type="number"], .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
  width: 100%;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  width: 100%;
  min-height: 62px;
  resize: vertical;
  outline: none;
  font-family: ui-monospace, Consolas, monospace;
  line-height: 1.5;
}
.field textarea:focus { border-color: var(--accent); }

.check-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.check-row label { font-size: 13px; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .num { font-size: 20px; font-weight: 600; }
.stat .name { color: var(--muted); font-size: 12px; }
.token-dots { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.t-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--muted); }
.t-dot.busy { background: var(--accent); }

.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.list-item .time { color: var(--muted); flex-shrink: 0; }
.list-item .model { color: var(--accent); flex-shrink: 0; }
.list-item .prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.ok .mark { color: var(--ok); }
.list-item .mark.err { color: var(--err); }
.list-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 12px; }

.conn-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
}
.conn-result.ok { display: block; background: var(--accent-weak); border: 1px solid var(--ok); }
.conn-result.fail { display: block; background: var(--accent-weak); border: 1px solid var(--err); }

.loading { color: var(--muted); text-align: center; padding: 60px 0; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #24292f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  max-width: 80vw;
}
.toast.hidden { display: none; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

.hidden { display: none; }
/* 参考图库 */
.lib-toolbar {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.lib-toolbar .field { flex: 1; min-width: 120px; }
.lib-toolbar .field.url { flex: 2; }
.lib-toolbar .btn { flex-shrink: 0; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.lib-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lib-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--border);
  display: block;
}
.lib-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.lib-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.lib-tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--accent-weak);
  color: var(--accent);
  flex-shrink: 0;
}
.lib-meta { color: var(--muted); font-size: 11px; }
.lib-weight { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.lib-weight input[type="range"] { flex: 1; accent-color: var(--accent); }
.lib-weight .w-value { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.lib-del {
  border: none;
  background: transparent;
  color: var(--err);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 0;
  text-align: left;
}
.lib-del:hover { text-decoration: underline; }
.lib-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }

/* 添加表单：默认权重滑块组 */
.lib-add-weights {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 200px;
}

/* 二次点击确认态 */
.lib-del.confirming, #btn-clear.confirming {
  color: var(--err);
  font-weight: 600;
  text-decoration: underline;
}

/* 点数消耗排行 */
.rank-summary {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.rank-medal { flex-shrink: 0; width: 28px; text-align: center; font-weight: 600; }
.rank-name {
  flex-shrink: 0;
  min-width: 90px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.rank-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.rank-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #7ad0a0);
  transition: width .3s;
}
.rank-num { flex-shrink: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 提示词预设 */
.ps-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-all;
}
.ps-edit {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  resize: vertical;
  outline: none;
  font-family: ui-monospace, Consolas, monospace;
}
.ps-actions {
  display: flex;
  gap: 14px;
  font-size: 12px;
}
.ps-edit-btn, .ps-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 0;
  color: var(--accent);
  text-align: left;
}
.ps-del { color: var(--err); }
.ps-edit-btn.confirming, .ps-del.confirming { color: var(--err); font-weight: 600; text-decoration: underline; }


/* 独立页：连接状态说明 */
.conn-status {
  background: var(--accent-weak);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
}

/* ============ 美化增强 ============ */
body {
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(79,140,255,.14), transparent 60%),
    radial-gradient(1000px 500px at 90% 0%, rgba(122,208,160,.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

.app-header {
  background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--card) 92%, transparent));
  backdrop-filter: blur(8px);
}

.section {
  transition: box-shadow .2s, transform .15s;
}
.section:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.10);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6aa9ff);
  box-shadow: 0 2px 8px rgba(79,140,255,.35);
}
.btn.primary:hover { filter: brightness(1.08); }

.rank-fill {
  background: linear-gradient(90deg, #4f8cff, #ffb86b, #ff7ac6);
  background-size: 200% 100%;
  animation: rankShift 6s ease infinite;
}
@keyframes rankShift { 0%{background-position:0% 0} 50%{background-position:100% 0} 100%{background-position:0% 0} }

.lib-card { transition: transform .12s, box-shadow .2s; }
.lib-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.12); }

/* ============ 手机适配 ============ */
@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    position: static;
  }
  .header-actions { width: 100%; justify-content: space-between; }
  main { padding: 12px 10px 40px; gap: 12px; margin: 0; }

  .grid { grid-template-columns: 1fr; }
  .grid.wide { grid-template-columns: 1fr; }

  .lib-toolbar { flex-direction: column; align-items: stretch; }
  .lib-toolbar .field, .lib-toolbar .field.url { min-width: 0; }
  .lib-toolbar .btn { width: 100%; padding: 12px; }
  .lib-add-weights { min-width: 0; }

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

  .rank-row { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .rank-name { min-width: 0; max-width: 100%; flex: 1 1 auto; }
  .rank-bar { flex-basis: 100%; order: 5; }
  .rank-num { font-size: 11px; }

  .btn { padding: 9px 14px; }
  .field input[type="text"], .field input[type="number"], .field select,
  .field textarea { padding: 10px 12px; font-size: 15px; }
  input[type="range"] { height: 28px; }
  .section { padding: 14px; border-radius: 12px; }
  .section-head { flex-wrap: wrap; gap: 8px; }
  .section-head .actions { width: 100%; }
  .section-head .actions .btn { flex: 1; }

  .lib-body { padding: 8px; }
  .toast { width: calc(100vw - 32px); max-width: none; }
}
