/* =========================================================
 * SenseNova-U1.5 文生图 · Playground 样式
 * 玻璃拟态 + 霓虹辉光 + 网格地板（与平台其他页面风格一致）
 * ========================================================= */

:root {
  --bg-0: #050811;
  --bg-1: #0a0f1d;
  --bg-2: #111a2e;
  --panel: rgba(16, 22, 42, 0.72);
  --panel-border: rgba(120, 160, 255, 0.18);
  --text-0: #e8edff;
  --text-1: #b6c1de;
  --text-2: #7e8aa9;
  --accent: #5b8cff;
  --accent-2: #8b5cff;
  --accent-3: #2dd4bf;
  --danger: #ff5b7a;
  --success: #4ade80;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --glow: 0 0 24px rgba(91, 140, 255, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg-0) 70%);
  color: var(--text-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* 背景装饰 */
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(91, 140, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 140, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(91, 140, 255, 0.18), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 255, 0.16), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(45, 212, 191, 0.10), transparent 50%);
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  background: rgba(5, 8, 17, 0.5);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 16px;
  box-shadow: var(--glow);
}
.brand-text h1 {
  margin: 0; font-size: 18px; font-weight: 600;
  background: linear-gradient(135deg, #fff 30%, var(--accent) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--text-2); }

.status {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  font-size: 13px; color: var(--text-1);
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
  animation: pulse 1.6s infinite;
}
.status.online .dot { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status.offline .dot { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(420px, 1.2fr);
  gap: 20px;
  padding: 24px 32px;
  max-width: 1600px; margin: 0 auto;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

/* 面板 */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex; flex-direction: column;
  gap: 18px;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 14px;
}
.panel-header h2 {
  margin: 0; font-size: 15px; font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-0);
}
.badge {
  font-size: 11px; padding: 4px 10px;
  background: rgba(91, 140, 255, 0.15);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.3);
  border-radius: 999px;
}

/* 字段 */
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field label {
  font-size: 12px; color: var(--text-1); font-weight: 500;
  display: flex; justify-content: space-between; align-items: baseline;
}
.field .hint { font-size: 11px; color: var(--text-2); font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: var(--text-0);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15);
}

.field-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.field-row .field { min-width: 110px; }

.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--text-2);
}
.char-count { font-variant-numeric: tabular-nums; }

.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button {
  flex: 1;
  padding: 7px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  color: var(--text-1);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.presets button:hover { background: rgba(91, 140, 255, 0.15); color: var(--text-0); }

/* 开关 */
.toggle-field { align-items: flex-start; }
.switch {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  transition: background 0.2s;
}
.switch .slider::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: 0.4; cursor: not-allowed; }
.hint.small { font-size: 11px; margin-top: 4px; }

/* 模型选择器高亮 */
.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237e8aa9' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.field select option {
  background: var(--bg-2);
  color: var(--text-0);
  padding: 8px;
}

/* 历史 overlay-meta（多模型标记） */
.history-item .overlay {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
}
.history-item .overlay-meta {
  font-size: 10px;
  color: var(--accent-3);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* 按钮 */
.actions { display: flex; gap: 10px; margin-top: 4px; }
button {
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.primary {
  flex: 1;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--glow);
}
.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(91, 140, 255, 0.5);
}
.primary:active:not(:disabled) { transform: translateY(0); }
.primary .btn-icon { font-size: 16px; }
.ghost {
  padding: 12px 16px;
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.ghost:hover:not(:disabled) {
  background: rgba(91, 140, 255, 0.08);
  color: var(--text-0);
}
.ghost.xs { padding: 5px 10px; font-size: 11px; }

/* 进度条 */
.progress {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  transition: width 0.3s;
  animation: shimmer 2s infinite;
}
@keyframes shimmer {
  0% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}
.progress-text {
  font-size: 12px;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* 思维链 */
.think {
  background: rgba(45, 212, 191, 0.06);
  border: 1px solid rgba(45, 212, 191, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 240px;
  overflow-y: auto;
}
.think-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--accent-3);
  font-weight: 600;
}
.think pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: var(--text-1);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.6;
}

/* 画布（图像预览） */
.canvas {
  position: relative;
  min-height: 380px;
  background:
    repeating-conic-gradient(rgba(255,255,255,0.02) 0% 25%, transparent 0% 50%) 50% / 20px 20px,
    rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: grid; place-items: center;
}
.canvas-empty {
  text-align: center;
  color: var(--text-2);
  padding: 40px;
}
.empty-icon { font-size: 56px; margin-bottom: 14px; opacity: 0.7; }
.empty-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.canvas img {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  border-radius: 4px;
}

/* 结果元数据 */
.result-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px;
  padding: 3px 8px;
  background: rgba(91, 140, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(91, 140, 255, 0.25);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 历史记录 */
.history { margin-top: 4px; }
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.history-header h3 {
  margin: 0; font-size: 13px; font-weight: 600;
  color: var(--text-0);
}
.history-header h3 .hint { color: var(--text-2); font-weight: 400; margin-left: 4px; }
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--text-2);
  font-size: 12px;
}
.history-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  transition: transform 0.15s, border-color 0.15s;
  background: #000;
}
.history-item:hover {
  transform: scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(91, 140, 255, 0.3);
}
.history-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.history-item .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 50%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover .overlay { opacity: 1; }
.history-item .overlay-text {
  font-size: 10px;
  color: var(--text-0);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer */
.footer {
  padding: 20px 32px 40px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.footer code {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--accent);
  font-size: 11px;
}
.footer-version {
  color: var(--text-2);
  padding-left: 8px;
  border-left: 1px solid var(--panel-border);
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(91, 140, 255, 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(91, 140, 255, 0.5); }
