/* ============================================
   NovelAI Relay Console
   Refined minimalism · warm white + ink + iris
   ============================================ */

:root {
  /* 基础色 */
  --bg: #FAFAF7;
  --bg-elev: #FFFFFF;
  --bg-soft: #F4F3EE;
  --ink: #0A0A0A;
  --ink-2: #2A2A28;
  --ink-3: #56554F;
  --muted: #8B897F;
  --line: #E8E6DE;
  --line-2: #DEDCD2;

  /* 强调色:NovelAI 紫粉 */
  --iris: #6B5BFF;
  --iris-soft: #EFEDFF;
  --rose: #FF6B9D;
  --gold: #C9A961;
  --green: #2D8659;
  --red: #C2410C;

  /* 字体 */
  --serif: 'Instrument Serif', 'Georgia', 'Songti SC', serif;
  --sans: 'Geist', -apple-system, 'PingFang SC', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04), 0 0 0 1px rgba(10, 10, 10, 0.04);
  --shadow: 0 4px 20px -8px rgba(10, 10, 10, 0.10), 0 0 0 1px rgba(10, 10, 10, 0.05);
  --shadow-lg: 0 24px 60px -20px rgba(10, 10, 10, 0.20), 0 0 0 1px rgba(10, 10, 10, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(107, 91, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(255, 107, 157, 0.03) 0%, transparent 40%);
}

.serif { font-family: var(--serif); font-weight: 400; }
.italic { font-style: italic; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============ 登录 ============ */

.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 800px 400px at 50% -10%, rgba(107, 91, 255, 0.10), transparent 60%),
    radial-gradient(ellipse 600px 300px at 50% 110%, rgba(255, 107, 157, 0.08), transparent 60%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 380px;
  padding: 44px 40px 32px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.5px;
  margin-bottom: 32px;
  text-transform: uppercase;
  font-weight: 500;
}

.login-brand .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--iris), var(--rose));
  box-shadow: 0 0 0 3px rgba(107, 91, 255, 0.12);
}

.login-title {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 8px;
}

.login-sub {
  color: var(--ink-3);
  font-size: 14px;
  margin-bottom: 32px;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-stack + .field-stack { margin-top: 10px; }

.field {
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}

.field:focus-within {
  border-color: var(--ink);
  background: var(--bg-elev);
}

.field input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.field input::placeholder {
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.2em;
}

.field button {
  width: 44px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--bg-elev);
  border-radius: 8px;
  margin: 4px;
  transition: transform 0.15s, background 0.15s;
}

.field button:hover { background: var(--iris); transform: translateX(2px); }
.field button:active { transform: translateX(0) scale(0.95); }

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 12px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.auth-switch button {
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink-3);
  transition: all 0.15s;
}

.auth-switch button.active {
  background: var(--ink);
  color: var(--bg-elev);
}

.err {
  color: var(--red);
  font-size: 12px;
  margin-top: 12px;
  min-height: 18px;
}

.login-foot {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-2);
}

/* ============ App Shell ============ */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand .dot {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--iris) 0%, var(--rose) 100%);
  flex-shrink: 0;
  box-shadow: 0 4px 12px -2px rgba(107, 91, 255, 0.4);
  position: relative;
}

.brand .dot::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 5px;
}

.brand-title {
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.nav-item svg { width: 16px; height: 16px; opacity: 0.7; }
.nav-item:hover { background: var(--bg-soft); color: var(--ink); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--ink);
  color: var(--bg-elev);
}
.nav-item.active svg { opacity: 1; }

.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
  transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ============ Main ============ */

.main {
  padding: 40px 56px 80px;
  max-width: 1200px;
  width: 100%;
}

.tab { animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.page-title {
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1;
}

.page-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  position: relative;
}
.status-dot.live::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0.5;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}

.primary-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--bg-elev);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 1px 2px rgba(0, 0, 0, 0.1);
}
.primary-btn:hover { background: var(--iris); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

/* ============ Stats ============ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  transition: all 0.2s;
}

.stat-card:hover { border-color: var(--line-2); transform: translateY(-2px); }

.stat-card.accent {
  background: linear-gradient(135deg, var(--ink) 0%, #1a1a1a 100%);
  color: var(--bg-elev);
  border-color: var(--ink);
}
.stat-card.accent .stat-label,
.stat-card.accent .stat-foot { color: rgba(255, 255, 255, 0.5); }

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

.stat-num {
  font-family: var(--serif);
  font-size: 42px;
  line-height: 1.1;
  margin: 8px 0 4px;
  letter-spacing: -0.02em;
  font-weight: 400;
  font-feature-settings: 'tnum';
}

.stat-foot { font-size: 11px; color: var(--ink-3); }

/* ============ Surface (cards) ============ */

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.surface {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.surface-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.surface-head h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}

/* ============ Activity / Health ============ */

.activity-list, .health-list {
  padding: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.15s;
}
.activity-item:hover { background: var(--bg-soft); }

.activity-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
}
.activity-dot.fail { background: var(--red); }

.activity-main { font-size: 13px; }
.activity-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-family: var(--mono); }
.activity-time { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.health-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.health-item:last-child { border-bottom: none; }

.health-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.health-name { font-size: 13px; font-weight: 500; }
.health-bar {
  height: 4px; background: var(--bg-soft);
  border-radius: 2px; overflow: hidden;
}
.health-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--iris), var(--rose));
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.health-meta { font-size: 11px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }

.anlas-panel { margin-bottom: 32px; }
.anlas-list { padding: 8px; }
.anlas-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.anlas-total .stat-num { margin-bottom: 0; }
.anlas-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 8px;
}
.anlas-item:hover { background: var(--bg-soft); }
.anlas-item.fail { color: var(--red); }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty .serif { font-size: 24px; display: block; margin-bottom: 6px; color: var(--ink-3); }

/* ============ Tables ============ */

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 12px 20px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}

.data-table.compact td { padding: 10px 20px; font-size: 12px; }

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--bg-soft); }

.mono { font-family: var(--mono); font-size: 12px; }

.copy-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--ink-2);
}
.copy-chip:hover { border-color: var(--ink); color: var(--ink); }
.copy-chip svg { width: 11px; height: 11px; opacity: 0.5; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
}
.pill::before { content: ''; width: 5px; height: 5px; border-radius: 50%; }
.pill.ok { background: rgba(45, 134, 89, 0.08); color: var(--green); }
.pill.ok::before { background: var(--green); }
.pill.fail { background: rgba(194, 65, 12, 0.08); color: var(--red); }
.pill.fail::before { background: var(--red); }
.pill.warn { background: rgba(201, 169, 97, 0.12); color: var(--gold); }
.pill.warn::before { background: var(--gold); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.icon-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--ink-3);
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn.danger:hover { background: rgba(194, 65, 12, 0.08); color: var(--red); }

/* ============ Docs ============ */

.docs { display: flex; flex-direction: column; gap: 16px; }

.doc-block { padding: 20px 24px; }

.endpoint {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}

.method {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  background: var(--iris);
  color: white;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.endpoint code {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
}

.badge {
  font-size: 10px;
  padding: 2px 7px;
  background: var(--iris-soft);
  color: var(--iris);
  border-radius: 100px;
  font-weight: 500;
  margin-left: auto;
}

.doc-block p { color: var(--ink-3); margin: 8px 0 12px; font-size: 13px; }

.doc-block pre {
  background: var(--ink);
  color: #E8E6DE;
  padding: 16px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  overflow-x: auto;
  line-height: 1.6;
}

/* ============ Modal ============ */

.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid; place-items: center;
}

.modal-bg {
  position: absolute; inset: 0;
  background: rgba(10, 10, 10, 0.4);
  backdrop-filter: blur(4px);
  animation: fade 0.2s;
}

.modal-card {
  position: relative;
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
}

.modal-body { padding: 24px; }

.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-row input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.15s;
}
.form-row input:focus {
  border-color: var(--ink);
  background: var(--bg-elev);
}
.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 8px;
}

.created-key {
  background: var(--bg-soft);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  margin-bottom: 8px;
}
.created-key-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 500;
}

/* ============ Toast ============ */

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 200;
  padding: 12px 18px;
  background: var(--ink);
  color: var(--bg-elev);
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Scrollbar ============ */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 100px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============ 响应式 ============ */

@media (max-width: 480px) {
  .login-card {
    width: calc(100vw - 32px);
    padding: 36px 24px 28px;
  }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    flex-direction: row; align-items: center;
    padding: 12px 16px;
  }
  .nav { flex-direction: row; margin-left: auto; }
  .page-head { align-items: flex-start; }
  .page-actions { align-items: flex-end; flex-direction: column; }
  .nav-item { padding: 6px 10px; }
  .side-foot { display: none; }
  .main { padding: 24px 20px 60px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .page-title { font-size: 30px; }
}
