* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #20262e;
  --muted: #6b7280;
  --line: #e3e0d8;
  --primary: #1e2a33;
  --primary-ink: #f7f5ef;
  --accent: #b4502f;
  --ok: #21724a;
  --error: #b3261e;
}

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

h1, h2, h3 {
  margin: 0 0 6px;
  font-weight: 650;
}

h1 { font-size: 22px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }

p {
  margin: 4px 0 0;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--error); min-height: 20px; margin-top: 10px; }

code {
  background: #efede6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 48px rgba(32, 38, 46, 0.08);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 700;
}

/* ---------- 顶栏与标签页 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 26px;
  background: var(--primary);
  color: var(--primary-ink);
}

.brand { display: flex; flex-direction: column; line-height: 1.25; }
.brand .eyebrow { color: #e8a377; }
.brand strong { font-size: 15px; letter-spacing: 0.02em; }

.tabs { display: flex; gap: 6px; margin-left: 12px; }

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: #cfd6db;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.tab:hover { color: #fff; }

.tab.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions .muted { color: #9aa6ae; }

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 26px 22px 80px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.panel-head.tight { margin-bottom: 12px; align-items: center; }

/* ---------- 通用控件 ---------- */

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.field em {
  font-style: normal;
  font-weight: 400;
}

.field input,
.field select {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: #9fb0ba;
  background: #fff;
}

textarea {
  width: 100%;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
  background: #fbfaf7;
}

.primary-btn {
  border: none;
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: 9px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover { background: #2c3a45; }
.primary-btn:disabled { opacity: 0.55; cursor: wait; }

.mini-btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}

.mini-btn:hover { border-color: #b9c4cc; }
.mini-btn.danger { color: var(--error); border-color: #e7c9c6; }
.top-actions .mini-btn { background: transparent; color: #dfe5e9; border-color: rgba(255,255,255,0.25); }
.top-actions .mini-btn:hover { background: rgba(255,255,255,0.1); }

/* ---------- 模型卡片 ---------- */

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.model-card { margin-bottom: 0; }

.model-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}

.model-head strong { font-size: 15px; }

.model-actions { margin-top: 4px; }

.probe-result { margin-top: 10px; color: var(--muted); min-height: 18px; }
.probe-result.ok { color: var(--ok); }
.probe-result.error { color: var(--error); }

.model-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.chip {
  border: 1px solid var(--line);
  background: #f5f3ec;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #3c4753;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 兑换码 ---------- */

.code-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  gap: 0 14px;
}

.code-form .primary-btn { margin-bottom: 12px; height: 38px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 9px 8px;
  border-bottom: 1px solid #efede7;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 9px;
  background: #e7f0e8;
  color: var(--ok);
}

.tag.warn { background: #f6e8e4; color: var(--accent); }

/* ---------- 发布 ---------- */

.pubkeys { display: flex; flex-direction: column; gap: 14px; }

.pubkey-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.pubkey-row > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.pubkey-code {
  display: block;
  background: #f2f0e9;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  word-break: break-all;
}

/* ---------- 弹窗与提示 ---------- */

.modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  min-width: 340px;
}

.modal::backdrop { background: rgba(20, 25, 30, 0.45); }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

#toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 13px;
  max-width: 380px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.toast.error { background: var(--error); }

/* ---------- 验证记录 ---------- */

.code-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  word-break: break-all;
}

/* ---------- 登录与明细弹窗 ---------- */

.login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 300;
}

.login-view.hidden {
  display: none;
}

.login-card {
  width: min(400px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card form {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.login-card input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}

.usage-dialog {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}
