:root {
  --green: #07c160;
  --green-dark: #06ad56;
  --green-deep: #059048;
  --teal: #0ab5a2;
  --grad: linear-gradient(135deg, #07c160 0%, #0ab5a2 100%);
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2330;
  --muted: #7b8494;
  --border: #e6e9ef;
  --danger: #e5484d;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(27, 35, 48, 0.05), 0 1px 6px rgba(27, 35, 48, 0.04);
  --shadow-md: 0 2px 6px rgba(27, 35, 48, 0.05), 0 12px 32px rgba(27, 35, 48, 0.08);
  --ring: 0 0 0 3px rgba(7, 193, 96, 0.14);
}

* { box-sizing: border-box; }
/* 自定义 display 的元素（如 .qr-skeleton 的 flex）会覆盖浏览器对 [hidden] 的处理，这里强制找回 */
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(900px 420px at 85% -180px, rgba(7, 193, 96, 0.09), transparent 60%),
    radial-gradient(700px 380px at -10% -120px, rgba(10, 181, 162, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
}
a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.6rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(230, 233, 239, 0.9);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 800; font-size: 1.12rem; color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 1.1rem; align-items: center; font-size: 0.95rem; }
.topbar nav a { color: #4a5364; font-weight: 500; }
.topbar nav a:hover { color: var(--green-dark); text-decoration: none; }

.container { max-width: 1020px; margin: 0 auto; padding: 1.8rem 1.2rem 4.5rem; }
.footer { text-align: center; padding: 1.6rem; font-size: 0.85rem; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.card h3 {
  margin: 0 0 0.65rem;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 0.55rem;
}
.card h3::before {
  content: "";
  width: 4px; height: 1.05em; border-radius: 4px;
  background: var(--grad);
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-block; padding: 0.48rem 1.05rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; font-size: 0.95rem; font-weight: 500; font-family: inherit;
  text-decoration: none !important;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.btn:hover { border-color: #c9cfda; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--grad); border: none; color: #fff;
  padding: calc(0.48rem + 1px) calc(1.05rem + 1px);
  box-shadow: 0 2px 10px rgba(7, 193, 96, 0.28);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 4px 16px rgba(7, 193, 96, 0.34); }
.btn-danger { color: var(--danger); border-color: #f3c6c8; background: #fff; }
.btn-danger:hover { border-color: var(--danger); background: #fef5f5; box-shadow: none; }
.btn-lg { padding: 0.75rem 1.8rem; font-size: 1.05rem; border-radius: 12px; }
.btn-primary.btn-lg { padding: calc(0.75rem + 1px) calc(1.8rem + 1px); }
.btn-sm { padding: 0.24rem 0.72rem; font-size: 0.85rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.alert {
  background: #fdecec; color: var(--danger); border: 1px solid #f6d3d4;
  padding: 0.6rem 1rem; border-radius: 10px; font-size: 0.92rem;
}

/* ---------------------------------------------------------------- 徽章 */
.badge {
  font-size: 0.74rem; padding: 0.18rem 0.6rem; border-radius: 999px;
  vertical-align: middle; font-weight: 600; white-space: nowrap;
}
.badge-green { background: #e4f8ee; color: var(--green-deep); }
.badge-green::first-letter { animation: pulse 1.6s ease-in-out infinite; }
.badge-amber { background: #fff4e0; color: #b7791f; }
.badge-gray { background: #eef0f4; color: var(--muted); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------------------------------------------------------------- 首页 */
.hero { text-align: center; padding: 4rem 0 2.4rem; }
.hero h1 {
  font-size: 2.6rem; line-height: 1.3; margin: 0 0 1.1rem;
  font-weight: 800; letter-spacing: -0.02em;
}
.hero h1 .grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.lead { color: var(--muted); font-size: 1.08rem; }
.hero-actions { margin-top: 1.8rem; display: flex; gap: 0.9rem; justify-content: center; flex-wrap: wrap; }

.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1rem; margin-top: 2.6rem;
}
.feature {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.3rem; box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.feature-emoji {
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem;
  background: linear-gradient(135deg, rgba(7, 193, 96, 0.12), rgba(10, 181, 162, 0.12));
}
.feature h3 { margin: 0.75rem 0 0.3rem; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------- 认证 */
.auth-card { max-width: 410px; margin: 3.2rem auto; padding: 2rem 2.1rem; }
.auth-card h2 { margin: 0 0 0.4rem; letter-spacing: -0.01em; }
.auth-card form { display: flex; flex-direction: column; gap: 0.95rem; margin-top: 1.1rem; }
.auth-card .btn-block { margin-top: 0.3rem; }

/* ---------------------------------------------------------------- 表单 */
label { display: block; font-size: 0.88rem; font-weight: 500; color: #3d4657; margin-bottom: 0.7rem; }
input, select, textarea {
  width: 100%; padding: 0.55rem 0.8rem; margin-top: 0.3rem;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fbfcfd;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: #c9cfda; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green); background: #fff; box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: #aab2c0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.form-actions { text-align: center; margin: 1.6rem 0; }

/* ---------------------------------------------------------------- 模板芯片 */
.template-grid { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 0.7rem; }
.template-chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 0.38rem 0.95rem; cursor: pointer; font-size: 0.9rem; font-family: inherit;
  color: #4a5364;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.template-chip:hover { border-color: var(--green); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.template-chip.active {
  background: var(--grad); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(7, 193, 96, 0.3);
}
.chip-emoji { margin-right: 0.3rem; }

/* ---------------------------------------------------------------- 控制台 */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; gap: 0.8rem; flex-wrap: wrap; }
.page-head h2 { margin: 0; letter-spacing: -0.015em; display: flex; align-items: center; gap: 0.6rem; }
.page-head > div { display: flex; gap: 0.5rem; }

.empty { text-align: center; padding: 3.4rem 1rem; }
.empty::before { content: "🤖"; display: block; font-size: 2.6rem; margin-bottom: 0.6rem; }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; }
.bot-card {
  display: block; color: inherit; text-decoration: none !important;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.bot-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(7, 193, 96, 0.35); }
.bot-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.bot-id { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.bot-avatar {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  background: var(--grad); color: #fff; font-size: 1.05rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(7, 193, 96, 0.3);
}
.bot-name {
  font-weight: 650; font-size: 1.05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bot-card p { margin: 0.55rem 0 0; font-size: 0.9rem; }
.bot-meta { font-size: 0.84rem !important; }

/* ---------------------------------------------------------------- 详情页 */
.detail-cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 1rem; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.detail-col .card { margin-bottom: 0; }
@media (max-width: 760px) { .detail-cols { grid-template-columns: 1fr; } }

.persona-dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1.1rem; margin: 0.6rem 0 0; }
.persona-dl dt { color: var(--muted); font-size: 0.86rem; padding-top: 0.08rem; }
.persona-dl dd { margin: 0; font-size: 0.92rem; }

.inst-table { width: 100%; border-collapse: collapse; margin: 0.6rem 0 1.1rem; font-size: 0.9rem; }
.inst-table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.inst-table th, .inst-table td { padding: 0.45rem 0.55rem 0.45rem 0; border-bottom: 1px solid var(--border); }
.inst-table tr:last-child td { border-bottom: none; }
.inst-actions { white-space: nowrap; text-align: right; }
.inst-actions form { display: inline; margin-left: 0.3rem; }

.qr-box { text-align: center; padding: 1rem 0 0.3rem; }
.qr-box img {
  width: 210px; height: 210px; border-radius: 14px; background: #fff;
  border: 1px solid var(--border); padding: 10px;
  box-shadow: var(--shadow-sm);
}
.qr-box p { font-size: 0.9rem; }

/* 出码前的骨架占位：和二维码同尺寸，中间一个旋转圈 */
.qr-skeleton {
  width: 210px; height: 210px; margin: 0 auto;
  border-radius: 14px; border: 1px dashed #cfd6e0;
  background: linear-gradient(110deg, #f4f6f9 30%, #ffffff 45%, #f4f6f9 60%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
  display: flex; align-items: center; justify-content: center;
}
@keyframes shimmer { to { background-position: -120% 0; } }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(7, 193, 96, 0.18);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.event-list { margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: 0.87rem; color: var(--muted); }
.event-list li {
  padding: 0.3rem 0 0.3rem 1rem; position: relative;
  border-left: 2px solid var(--border);
}
.event-list li::before {
  content: ""; position: absolute; left: -4.5px; top: 0.78em;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); opacity: 0.65;
}
