:root {
  --primary: #ff7a18;
  --primary-hover: #ff5e0e;
  --accent-soft: #ff9d4d;
  --text: #f4f4f5;
  --muted: #b4b4bd;
  --subtle: #8b8b95;
  --border: #232329;
  --border-strong: #303038;
  --bg: #09090b;
  --card: #111114;
  --card-hover: #17171c;
  --error: #f87171;
  --success: #34d399;
  --radius-card: 1.25rem;
  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei",
    "Segoe UI", Arial, "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC",
    "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

[data-admin-only] { display: none; }
body[data-role="admin"] [data-admin-only] { display: inline; }

/* ---- 登录页 ---- */
.auth-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 360px;
  padding: 36px 32px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.auth-title { text-align: center; margin-bottom: 4px; }
.auth-subtitle { text-align: center; color: var(--subtle); margin: 0 0 24px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.field input:focus { outline: none; border-color: var(--primary); }

.primary-button {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(120deg, var(--accent-soft), var(--primary-hover));
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.primary-button:hover { filter: brightness(1.08); text-decoration: none; }
.primary-button:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-card .primary-button { width: 100%; margin-top: 8px; }

.form-error { color: var(--error); font-size: 13px; margin: 8px 0; }

/* ---- 头部导航 ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.site-logo { font-weight: 800; font-size: 17px; color: var(--text); }
.site-logo:hover { text-decoration: none; }
.logo-accent { color: var(--primary); }
.site-nav { display: flex; align-items: center; gap: 16px; }
.user-badge {
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}
.link-button {
  border: none;
  background: none;
  color: var(--accent-soft);
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

/* ---- 落地页 Hero ---- */
.landing-main { max-width: 860px; margin: 0 auto; padding: 64px 24px 40px; }
.hero { text-align: center; margin-bottom: 40px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--subtle);
  font-size: 13px;
}
.hero-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}
.hero-title {
  margin: 22px 0 14px;
  font-size: 52px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 1px;
}
.hero-highlight {
  background: linear-gradient(120deg, var(--accent-soft), var(--primary-hover));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-subtitle { color: var(--subtle); font-size: 16px; margin: 0; }

/* ---- 输入卡片 ---- */
.composer {
  background: rgba(17, 17, 20, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 8px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}
#prompt-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  font-family: inherit;
  resize: none;
  padding: 12px 16px;
}
#prompt-input:focus { outline: none; }
#prompt-input::placeholder { color: var(--subtle); }

.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 8px 6px;
}
.composer-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip-select { position: relative; }
.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-hover);
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}
.chip-button:hover { color: var(--text); }
.chip-button svg { transition: transform 0.15s; }
.chip-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.chip-static {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 122, 24, 0.3);
  background: rgba(255, 122, 24, 0.1);
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 500;
}

/* 模式菜单：向上弹出 */
.mode-menu {
  position: absolute;
  z-index: 20;
  bottom: 100%;
  left: 0;
  margin: 0 0 8px;
  padding: 6px;
  list-style: none;
  width: 320px;
  background: rgba(17, 17, 20, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}
.chip-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  border: none;
  background: none;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip-option:hover { background: var(--card-hover); color: var(--text); }
.chip-option .option-text { display: flex; flex-direction: column; min-width: 0; }
.chip-option strong { font-size: 14px; font-weight: 500; color: inherit; }
.chip-option span span { color: var(--subtle); font-size: 12px; line-height: 1.5; }
.chip-option .check-icon { color: var(--primary); flex-shrink: 0; visibility: hidden; }
.chip-option.active { background: rgba(255, 122, 24, 0.1); color: var(--text); }
.chip-option.active .check-icon { visibility: visible; }

.send-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-button:hover { background: var(--accent-soft); }
.send-button:disabled { opacity: 0.6; cursor: not-allowed; }
.send-button .spinner {
  width: 16px; height: 16px;
  border: 3px solid rgba(0, 0, 0, 0.25);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 错误框 ---- */
.error-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.1);
  color: var(--error);
  text-align: left;
}
.error-box svg { flex-shrink: 0; margin-top: 2px; }
.error-title { margin: 0; font-size: 14px; font-weight: 500; }
.error-detail { margin: 2px 0 0; font-size: 12px; line-height: 1.5; opacity: 0.9; word-break: break-word; }

/* ---- 示例提示 ---- */
.suggestion-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}
.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(17, 17, 20, 0.6);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.suggest-chip:hover { border-color: var(--border-strong); color: var(--text); }
.suggest-chip svg { color: var(--primary); flex-shrink: 0; }

/* ---- 界面风格对话框 ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.style-dialog {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  background: rgba(17, 17, 20, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.style-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 8px 8px;
}
.style-dialog-head p { margin: 0; font-size: 14px; font-weight: 600; }
.style-dialog-sub { margin-top: 2px !important; font-size: 12px !important; font-weight: 400 !important; color: var(--subtle); line-height: 1.5; }
.dialog-close {
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 50%;
  padding: 4px;
  cursor: pointer;
}
.dialog-close:hover { background: var(--card-hover); color: var(--text); }
.style-dialog-body { overflow-y: auto; padding: 0 2px 2px; }

.style-auto {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 17, 20, 0.5);
  color: var(--muted);
  padding: 10px 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.style-auto:hover { border-color: var(--border-strong); background: var(--card-hover); color: var(--text); }
.style-auto.selected { border-color: rgba(255, 122, 24, 0.4); background: rgba(255, 122, 24, 0.1); color: var(--text); }
.style-auto .check-icon { color: var(--primary); flex-shrink: 0; visibility: hidden; }
.style-auto.selected .check-icon { visibility: visible; }
.style-auto-text { min-width: 0; }
.style-auto-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); }
.recommend-badge {
  border-radius: 999px;
  background: rgba(255, 122, 24, 0.15);
  color: var(--accent-soft);
  padding: 2px 8px;
  font-size: 10px;
}
.style-auto-desc { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--subtle); }

.style-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
#style-toggle-all {
  border: none;
  background: none;
  color: var(--accent-soft);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
#style-toggle-all:hover { color: var(--text); }

.style-grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px) { .style-grid { grid-template-columns: 1fr; } }
.style-card {
  display: flex;
  flex-direction: column;
  min-height: 128px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 17, 20, 0.55);
  padding: 12px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.style-card:hover { border-color: var(--border-strong); background: var(--card-hover); }
.style-card.selected { border-color: rgba(255, 122, 24, 0.45); background: rgba(255, 122, 24, 0.1); }
.style-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.style-card-title { font-size: 14px; font-weight: 600; }
.style-card-ref { display: block; margin-top: 2px; font-size: 10px; color: var(--subtle); }
.style-card-meta { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.style-theme-tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 9px;
  color: var(--subtle);
}
.style-card .check-icon { color: var(--primary); visibility: hidden; }
.style-card.selected .check-icon { visibility: visible; }
.style-card-summary { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: var(--subtle); }
.style-card-tags { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.style-card-tags span {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
  padding: 2px 6px;
  font-size: 10px;
  color: var(--muted);
}

/* ---- 进度面板 ---- */
.progress-panel, .runs-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-top: 20px;
}

.progress-head { display: flex; align-items: center; gap: 12px; }
.progress-head h2 { margin: 0; }
.status-chip {
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 122, 24, 0.12);
  color: var(--accent-soft);
}
.status-chip[data-state="complete"] { background: rgba(52, 211, 153, 0.14); color: var(--success); }
.status-chip[data-state="failed"],
.status-chip[data-state="cancelled"] { background: rgba(248, 113, 113, 0.14); color: var(--error); }

.stage-text { color: var(--muted); font-size: 13px; }

.event-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  font-size: 13px;
}
.event-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--subtle);
  word-break: break-all;
}
.event-list li:last-child { border-bottom: none; color: var(--text); }

#preview-link-row { margin-top: 16px; }

/* ---- 问答面板 ---- */
.question-box {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid rgba(255, 122, 24, 0.35);
  border-radius: 12px;
  background: rgba(255, 122, 24, 0.06);
}
.question-title { margin: 0 0 10px; font-size: 14px; }
.question-item { margin-bottom: 14px; }
.question-text { font-size: 14px; margin: 0 0 8px; }
.question-options { display: flex; flex-direction: column; gap: 6px; }
.question-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.question-option small { color: var(--subtle); }
.question-option.selected { border-color: var(--primary); background: rgba(255, 122, 24, 0.12); }
.question-other {
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.question-box .primary-button { margin-top: 4px; }

/* ---- 我的应用 ---- */
.runs-list { list-style: none; margin: 0; padding: 0; }
.runs-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.runs-list li:last-child { border-bottom: none; }
.runs-list .run-name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runs-list .run-time { color: var(--subtle); font-size: 12px; }
.muted { color: var(--subtle); font-size: 13px; }

/* ---- 通用主内容（管理页） ---- */
.page-main { max-width: 860px; margin: 0 auto; padding: 24px; }
.detail-main { max-width: 1080px; margin: 0 auto; padding: 24px; }

.create-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

/* ---- 预览页 ---- */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.detail-head h1 { margin: 0; }
.preview-container {
  margin: 16px 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
#preview-frame { width: 100%; height: 72vh; border: none; display: block; background: #fff; }

/* ---- 账号管理 ---- */
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input, .inline-form select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}
.inline-form input { flex: 1; min-width: 180px; }

.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th, .users-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.users-table th { color: var(--subtle); font-weight: 500; font-size: 13px; }
.users-table .actions button {
  margin-right: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.users-table .actions button.danger { color: var(--error); border-color: rgba(248, 113, 113, 0.4); }
.users-table .actions button:disabled { opacity: 0.4; cursor: not-allowed; }
