@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;700&family=Noto+Serif+SC:wght@400;700&display=swap');

:root {
  --bg-0: #f6f8fb;
  --bg-gradient: linear-gradient(180deg, #f7fbff 0%, #eef6f8 100%);
  --panel-bg: rgba(255,255,255,0.9);
  --muted: #627084;
  --text: #0f1720;
  --primary: #176f6b;
  --accent: #ff8a5b;
  --border: rgba(22,28,33,0.06);
  --glass: rgba(255,255,255,0.6);
  color-scheme: light;
  font-family: 'Noto Sans SC', 'Noto Serif SC', "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text);
  line-height: 1.6;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-shell,
.dashboard-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-card {
  width: min(100%, 430px);
  background: #ffffff;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
  padding: 26px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.auth-card p {
  margin: 0 0 18px;
  color: #627084;
  line-height: 1.6;
}

.dashboard-shell {
  place-items: start center;
}

.panel {
  width: min(100%, 430px);
  background: #ffffff;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
}

.panel-wide {
  width: min(100%, 980px);
}

.panel-header {
  padding: 24px 26px 16px;
  border-bottom: 1px solid #edf0f4;
}

.panel-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.panel-header p {
  margin: 0;
  color: #627084;
  line-height: 1.6;
}

.form {
  display: grid;
  gap: 16px;
  padding: 24px 26px 26px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-weight: 700;
  font-size: 14px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #c9d2df;
  border-radius: 6px;
  padding: 11px 12px;
  background: #fff;
  color: #1f2933;
  outline: none;
}

.field textarea {
  resize: vertical;
  min-height: 150px;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #2f6fed;
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost {
  border-radius: 6px;
  padding: 10px 14px;
  border: 1px solid transparent;
  min-height: 42px;
}

.primary {
  background: #2f6fed;
  color: #fff;
  font-weight: 700;
}

.secondary {
  background: #ffffff;
  border-color: #c9d2df;
  color: #1f2933;
}

.ghost {
  background: transparent;
  color: #2f6fed;
  padding-inline: 4px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #edf0f4;
}

.tab {
  border: 0;
  background: #fff;
  padding: 14px;
  font-weight: 700;
  color: #627084;
}

.tab.active {
  color: #2f6fed;
  border-bottom: 2px solid #2f6fed;
}

.hidden {
  display: none;
}

.status {
  margin: 0;
  min-height: 22px;
  color: #627084;
  line-height: 1.5;
}

.status.error {
  color: #b42318;
}

.status.ok {
  color: #087443;
}

.topbar {
  width: min(100%, 980px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: #627084;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #c9d2df;
  padding: 5px 10px;
  background: #fff;
  font-size: 13px;
  color: #42526b;
}

.binding-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.binding-card {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #fafbfc;
}

.plugin-qr {
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  border: 1px solid #c9d2df;
  border-radius: 6px;
  background: #fff;
  color: #1f2933;
  text-align: center;
  font-size: 14px;
}

.plugin-qr img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.binding-side {
  display: grid;
  gap: 10px;
  align-content: center;
}

.help {
  color: #627084;
  line-height: 1.6;
  font-size: 14px;
}

.subpanel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #fafbfc;
}

.subpanel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.subpanel-header h2 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.3;
}

.subpanel-header p {
  margin: 0;
  color: #627084;
  line-height: 1.5;
  font-size: 14px;
}

.compact-actions {
  justify-content: flex-start;
}

.trait-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #ffffff;
}

.trait-item {
  display: grid;
  gap: 7px;
}

.trait-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  font-size: 13px;
  color: #42526b;
}

.trait-line span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.trait-line strong {
  color: #1f2933;
  font-size: 13px;
}

.trait-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
}

.trait-fill {
  height: 100%;
  border-radius: inherit;
  background: #2f6fed;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #ffffff;
}

.event-item strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.4;
}

.event-item p,
.empty-state {
  margin: 0;
  color: #627084;
  line-height: 1.5;
  font-size: 14px;
}

.profile-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #ffffff;
}

.profile-card p {
  margin: 0;
  color: #42526b;
  line-height: 1.6;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-grid div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 6px;
  background: #f4f6f8;
}

.profile-grid span {
  color: #627084;
  font-size: 12px;
}

.profile-grid strong {
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.story-item {
  align-items: start;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  background: #f4f6f8;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  border-right: 1px solid #d8dee7;
  background: #ffffff;
}

.admin-sidebar h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.admin-sidebar p {
  margin: 0;
  color: #627084;
  overflow-wrap: anywhere;
}

.admin-tabs {
  display: grid;
  gap: 8px;
}

.admin-tabs .tab {
  border: 1px solid #d8dee7;
  border-radius: 6px;
  text-align: left;
}

.admin-tabs .tab.active {
  border-color: #2f6fed;
  background: #eef4ff;
}

.admin-content {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.admin-section {
  display: none;
  gap: 16px;
}

.admin-section.active {
  display: grid;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.section-head h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.section-head p {
  margin: 0;
  color: #627084;
  line-height: 1.5;
}

.table-wrap,
.editor-panel,
.list-panel,
.audit-list {
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #ffffff;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  vertical-align: top;
}

th {
  color: #42526b;
  font-size: 13px;
}

td span {
  color: #627084;
  font-size: 13px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 16px;
}

.list-panel {
  display: grid;
  align-content: start;
  padding: 10px;
  gap: 8px;
}

.list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid #d8dee7;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  text-align: left;
}

.list-item.active {
  border-color: #2f6fed;
  background: #eef4ff;
}

.list-item span {
  color: #627084;
  font-size: 13px;
  line-height: 1.4;
}

.editor-panel {
  padding: 16px;
}

.editor-panel.form {
  gap: 12px;
}

.editor-panel h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #42526b;
}

.audit-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.audit-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid #edf0f4;
}

.audit-item:last-child {
  border-bottom: 0;
}

.audit-item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.audit-item span,
.audit-item p {
  margin: 0;
  color: #627084;
  line-height: 1.5;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.sticker-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #d8dee7;
  border-radius: 8px;
  background: #ffffff;
}

.sticker-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid #edf0f4;
  border-radius: 6px;
  background: #f4f6f8;
}

.sticker-item strong,
.sticker-item span {
  display: block;
  overflow-wrap: anywhere;
}

.sticker-item span {
  color: #627084;
  font-size: 13px;
  line-height: 1.4;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-height: 42px;
  color: #627084;
  font-size: 13px;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.route-list {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.route-list strong {
  width: 100%;
  color: #1f2933;
}

.audit-card {
  border-bottom: 1px solid #edf0f4;
}

.audit-card header,
.audit-card footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.audit-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audit-columns section {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.audit-columns b {
  color: #1f2933;
  font-size: 13px;
}

.site-footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 16px 24px;
  color: #627084;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 720px) {
  .form-grid,
  .binding-row,
  .binding-card,
  .trait-board,
  .event-item,
  .profile-grid,
  .audit-columns,
  .admin-shell,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-content {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-header,
  .form {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* ---------- 视觉增强覆盖（新增） ---------- */
body::before {
  content: '';
  position: fixed;
  left: -10%;
  top: -20%;
  width: 60vw;
  height: 60vh;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(23,111,107,0.06) 0%, transparent 36%), radial-gradient(circle at 80% 80%, rgba(255,138,91,0.04) 0%, transparent 30%);
}

main, .admin-shell, .dashboard-shell { position: relative; z-index: 1; }

/* 玻璃感面板 */
.panel, .auth-card, .panel-wide, .table-wrap, .list-panel, .editor-panel, .subpanel, .profile-card, .binding-card, .sticker-item, .audit-list {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(23,111,107,0.06);
  border-radius: 12px;
}

.admin-sidebar {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.88));
  box-shadow: inset -6px 0 16px rgba(17,24,39,0.02);
  padding: 28px;
  border-right: 1px solid var(--border);
}

.admin-sidebar h1 { font-family: 'Noto Serif SC', serif; font-weight: 700; letter-spacing: 0.6px; color: var(--primary); margin-bottom: 8px; }

.topbar { background: transparent; padding: 12px 0; align-items: center; }
.topbar h1 { font-family: 'Noto Serif SC', serif; letter-spacing: 0.4px; color: rgba(8,8,8,0.92); }

/* 导航与标签 */
.tab { transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; border-radius: 8px; padding: 12px 14px; text-align: left; background: transparent; }
.admin-tabs .tab:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(23,111,107,0.04); }
.admin-tabs .tab.active { background: linear-gradient(90deg, rgba(23,111,107,0.06), rgba(255,138,91,0.03)); border-color: rgba(23,111,107,0.12); color: var(--primary); }

/* 按钮 */
.primary { background: linear-gradient(90deg, var(--primary), #134f4d); color: #fff; border: 0; box-shadow: 0 10px 26px rgba(23,111,107,0.12); }
.primary:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(23,111,107,0.14); }
.secondary { background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,0.9)); border: 1px solid var(--border); }
.secondary:disabled { transform: none; box-shadow: none; }
.ghost { background: transparent; color: var(--primary); padding-inline: 6px; }

.badge { background: linear-gradient(180deg,#ffffff,#fafcff); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(17,24,39,0.04); }

/* 表情卡片 */
.sticker-item img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; border: 1px solid rgba(237,240,244,0.9); box-shadow: 0 10px 30px rgba(17,24,39,0.06); background: linear-gradient(180deg,#fbfdff,#f4f8fa); }

/* 表单控件更柔和 */
.field input, .field textarea, .field select { border-color: rgba(20,28,33,0.06); padding: 12px; border-radius: 10px; }
.field input:focus, .field textarea:focus, .field select:focus { box-shadow: 0 0 0 4px rgba(23,111,107,0.08); }

.audit-list { gap: 0; overflow: hidden; }
.audit-card header strong { color: var(--primary); }
.audit-card footer { color: var(--muted); font-size: 13px; }
.audit-columns section { background: rgba(248,250,252,0.78); border: 1px solid rgba(22,28,33,0.04); }
.pager { padding: 2px 0 6px; }
.site-footer { background: transparent; }

/* 动效 */
@keyframes floatIn { from { opacity: 0; transform: translateY(8px) scale(.996); } to { opacity: 1; transform: none; } }
.panel, .auth-card, .list-item, .sticker-item, .event-item { animation: floatIn .42s cubic-bezier(.2,.9,.3,1) both; }

/* 小尺寸优化 */
@media (max-width: 720px) {
  .admin-sidebar { padding: 18px; }
  .panel, .auth-card { border-radius: 10px; }
}

/* 视觉辅助：轻度文本风格 */
.help, .status { color: var(--muted); }
.empty-state { color: var(--muted); font-style: italic; }

/* 兼容性提示：若浏览器不支持 backdrop-filter，也不要影响可用性 */
@supports ((-webkit-backdrop-filter: blur(6px)) or (backdrop-filter: blur(6px))) {
  .panel, .auth-card { background: rgba(255,255,255,0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
}

/* end of visual overrides */

/* ---------- AI API 列表表格 ---------- */
.api-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.api-list-head h3 {
  margin: 0;
}

.api-table-wrap {
  overflow-x: auto;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
}

.api-table th {
  padding: 10px 12px;
  text-align: left;
  color: #627084;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 2px solid #edf0f4;
  white-space: nowrap;
}

.api-table td {
  padding: 12px;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
}

.api-table tbody tr:hover {
  background: #f8fafc;
}

.api-table tbody tr:last-child td {
  border-bottom: 0;
}

.api-url-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #627084;
  font-family: 'Courier New', monospace;
}

.api-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.api-actions .secondary {
  padding: 6px 12px;
  font-size: 13px;
  min-height: auto;
}

.api-actions .ghost {
  padding: 6px 8px;
  font-size: 13px;
}

.api-model-delete {
  color: #b42318 !important;
}

.api-model-delete:hover {
  background: #fff0f0 !important;
  border-radius: 4px;
}

.api-test-btn {
  background: linear-gradient(180deg, #e6f7ed, #d4f1e0) !important;
  border-color: #b7ebd0 !important;
  color: #087443 !important;
  font-weight: 700 !important;
}

.api-test-btn:hover {
  background: linear-gradient(180deg, #d4f1e0, #b7ebd0) !important;
}

.muted {
  color: #627084;
  font-size: 13px;
}
