:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e2e2e8;
  --text: #1d1e23;
  --muted: #767a8a;
  --accent: #fe2c55;
  --accent-dim: #c91e42;
  --sidebar-w: 220px;
  --success: #2ecc71;
  --danger: #e74c3c;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: #7eb6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #f4f5f7;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(0,0,0,.35);
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 600;
}

.login-box .sub {
  color: var(--muted);
  font-size: .875rem;
  margin-bottom: 24px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: .95rem;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; width: auto; }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.alert-error { background: rgba(231,76,60,.15); color: #ff8a80; border: 1px solid rgba(231,76,60,.3); }
.alert-ok { background: rgba(46,204,113,.12); color: #7dcea0; border: 1px solid rgba(46,204,113,.25); }

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0 20px 20px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-brand span { color: var(--accent); }

.nav a {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.nav a:hover { color: var(--text); background: rgba(0,0,0,.04); }
.nav a.active {
  color: var(--text);
  background: rgba(254,44,85,.08);
  border-left-color: var(--accent);
}

.main {
  flex: 1;
  padding: 32px 40px;
  overflow-x: auto;
  background: var(--bg);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.topbar h2 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.user-meta { color: var(--muted); font-size: .875rem; }
.user-meta a { margin-left: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-card .lbl { color: var(--muted); font-size: .8rem; margin-top: 4px; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 500; background: #f8f9fb; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,.02); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .75rem;
}
.badge-on { background: rgba(46,204,113,.2); color: #7dcea0; }
.badge-off { background: rgba(142,142,160,.2); color: var(--muted); }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.form-panel {
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.form-row { margin-bottom: 18px; }
.form-row label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .85rem; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.actions-inline { display: flex; gap: 8px; flex-wrap: wrap; }

.cover-thumb {
  max-width: 80px;
  max-height: 48px;
  object-fit: cover;
  border-radius: 4px;
  vertical-align: middle;
}

.empty { color: var(--muted); padding: 40px; text-align: center; }

.edit-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: nowrap;
}
@media (max-width: 1024px) {
  .edit-layout {
    flex-wrap: wrap;
  }
  .edit-preview-col {
    width: 100%;
    position: static;
  }
}
.edit-form-col {
  flex: 1;
  min-width: 360px;
}
.edit-preview-col {
  width: 360px;
  flex-shrink: 0;
  position: sticky;
  top: 24px;
}
.preview-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
}
.preview-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 8px;
}
.chat-preview-wrap {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px;
  background: #f0f0f0;
  padding: 30px 20px;
  border-radius: 12px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
}
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: url('https://p3.douyinpic.com/aweme/100x100/aweme-avatar/tos-cn-avt-0015_90d2ba224f86f4cb7e39a3f3a9e1026f.jpeg') center/cover;
  flex-shrink: 0;
}
.chat-bubble {
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 240px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: transform 0.2s ease;
}
.chat-bubble:hover {
  transform: translateY(-2px);
}
.chat-bubble-img {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: #0052d9; /* Default blue like the reference image */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
}
.chat-bubble-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}
.chat-bubble-title {
  font-size: 15px;
  color: #333;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  line-height: 1.2;
}
.chat-bubble-domain {
  font-size: 12px;
  color: #999;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
