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

:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-border: #262a35;
  --text: #e6e8ec;
  --muted: #8a8f9c;
  --accent: #4f7cff;
  --accent-hover: #6b93ff;
  --error: #ff6b6b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
}
.topbar h1 { font-size: 18px; font-weight: 600; }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: #4ade80; }
.status.err { color: var(--error); }

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px;
}

.panel-input { display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 13px; color: var(--muted); }

textarea, input[type="number"] {
  background: #0f1115;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
textarea:focus, input:focus { outline: 1px solid var(--accent); }

.params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.param { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.param .hint { color: #555b6b; }

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error { color: var(--error); font-size: 13px; }

.panel-result {
  grid-row: span 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.result-wrap {
  flex: 1;
  min-height: 320px;
  background: #0f1115;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.placeholder { color: var(--muted); font-size: 14px; }
#resultImg { max-width: 100%; max-height: 60vh; object-fit: contain; }

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.result-meta a { color: var(--accent); text-decoration: none; }

.panel-history { grid-column: 1 / -1; }
.panel-history h2 { font-size: 14px; margin-bottom: 10px; color: var(--muted); }
.history-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.history-list li {
  background: #0f1115;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.history-list li:hover { border-color: var(--accent); }
.history-list .h-prompt {
  color: var(--text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-list .h-meta { color: var(--muted); font-size: 11px; }

/* 移动端 */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .params { grid-template-columns: 1fr 1fr; }
  .result-wrap { min-height: 240px; }
}
