/* ============================================================
   Celestia · 企业简洁风
   参考：design.md（Corporate Blue / Slate Mist / White Card）
   ============================================================ */

:root {
  /* Colors */
  --color-corporate-blue: #1e40af;
  --color-slate-mist: #f8fafc;
  --color-action-blue: #3b82f6;
  --color-slate: #64748b;
  --color-confirm-green: #10b981;
  --color-hint-violet: #c559f0;

  --color-text: #0f172a;
  --color-border: #e5e7eb;
  --color-border-strong: #d1d5db;
  --color-card: #ffffff;
  --color-danger: #b91c1c;
  --color-blue-50: #eff6ff;
  --color-blue-100: #dbeafe;
  --color-green-50: #ecfdf5;
  --color-slate-100: #f1f5f9;
  --color-slate-200: #e2e8f0;

  /* Typography */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-label: 12px;
  --text-body-sm: 14px;
  --text-body: 16px;
  --text-subheading: 20px;
  --text-heading: 30px;
  --text-heading-lg: 36px;
  --text-display: 60px;

  /* Spacing */
  --spacing-8: 8px;
  --spacing-12: 12px;
  --spacing-16: 16px;
  --spacing-24: 24px;
  --spacing-32: 32px;
  --spacing-48: 48px;
  --spacing-64: 64px;
  --spacing-96: 96px;

  /* Radius */
  --radius-card: 12px;
  --radius-button: 8px;
  --radius-input: 8px;
  --radius-badge: 999px;

  /* Elevation */
  --shadow-rest: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, .08);
  --focus-ring: 0 0 0 2px var(--color-slate-mist), 0 0 0 4px var(--color-action-blue);

  /* Backward-compatible aliases used by older inline styles */
  --bg: var(--color-slate-mist);
  --bg-2: var(--color-card);
  --bg-3: var(--color-slate-100);
  --line: var(--color-border);
  --text: var(--color-text);
  --muted: var(--color-slate);
  --accent: var(--color-corporate-blue);
  --accent-2: var(--color-action-blue);
  --good: var(--color-confirm-green);
  --warn: var(--color-slate);
  --bad: var(--color-danger);
  --shadow: var(--shadow-rest);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--color-slate-mist);
  color: var(--color-text);
  font: 400 16px/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-corporate-blue); text-decoration: none; }
a:hover { color: #1e3a8a; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-card);
  color: var(--color-text);
  padding: 8px 16px;
  border-radius: var(--radius-button);
  cursor: pointer;
  font: 500 14px/1.4 var(--font-sans);
  transition: background 150ms ease-out, border-color 150ms ease-out,
              color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
button:hover, .btn:hover {
  border-color: var(--color-corporate-blue);
  color: var(--color-corporate-blue);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}
button:active, .btn:active { transform: scale(.98); box-shadow: var(--shadow-rest); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

button.primary, .btn.primary {
  background: var(--color-corporate-blue);
  border-color: var(--color-corporate-blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(30, 64, 175, .18);
}
button.primary:hover, .btn.primary:hover {
  background: #1e3a8a;
  border-color: #1e3a8a;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
button.primary:active, .btn.primary:active { transform: scale(.98); }

button.danger, .btn.danger {
  border-color: #fecaca;
  color: var(--color-danger);
  background: #fff;
}
button.danger:hover, .btn.danger:hover { background: #fef2f2; border-color: var(--color-danger); }

label { font-weight: 500; color: var(--color-text); font-size: 14px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-input);
  background: #fff;
  color: var(--color-text);
  padding: 8px 12px;
  font: 400 16px/1.5 var(--font-sans);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-action-blue);
  box-shadow: var(--focus-ring);
}

h1, h2, h3, h4 { margin: 0; color: var(--color-text); }
h1 { font: 700 36px/1.2 var(--font-sans); letter-spacing: -.01em; }
h2 { font: 600 30px/1.25 var(--font-sans); letter-spacing: -.01em; }
h3 { font: 600 20px/1.4 var(--font-sans); }
h4 { font: 600 16px/1.4 var(--font-sans); }

.muted { color: var(--color-slate); }
.small { font-size: 14px; }
.label {
  display: inline-block;
  font: 500 12px/1.4 var(--font-sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-slate);
}

/* ---------- Top navigation ---------- */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--color-border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 600 18px/1.2 var(--font-sans);
  color: var(--color-text);
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--color-corporate-blue);
  box-shadow: 0 0 0 4px var(--color-blue-100);
}
.brand span {
  color: var(--color-slate);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0;
  margin-left: 2px;
}
.topbar .spacer { flex: 1; }

/* 观察页的轮回切换器 */
.cycle-select {
  width: auto;
  min-width: 210px;
  max-width: 340px;
  padding: 6px 34px 6px 12px;
  font-size: 14px;
  border-radius: var(--radius-badge);
  background-color: #fff;
  cursor: pointer;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-badge);
  padding: 4px 10px;
  background: var(--color-blue-50);
  color: var(--color-corporate-blue);
  font: 500 12px/1.4 var(--font-sans);
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}
.badge.running { background: var(--color-green-50); color: #047857; }
.badge.paused { background: var(--color-slate-100); color: var(--color-slate); }
.badge.ended { background: #fef2f2; color: var(--color-danger); }
.badge.plain::before { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, .9fr);
  gap: 24px;
  padding: 24px 32px;
  height: calc(100vh - 64px);
  max-width: 1120px;
  margin: 0 auto;
}
.chat-pane, .side-pane { min-height: 0; }

.chat-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-card);
  box-shadow: var(--shadow-rest);
  overflow: hidden;
}
.chat-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.chat-head strong { font: 600 16px/1.4 var(--font-sans); }
.messages {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
}
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg .avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--color-blue-50);
  border: 1px solid var(--color-blue-100);
  color: var(--color-corporate-blue);
  font-weight: 600;
}
.msg .body { max-width: 78%; }
.msg .meta { color: var(--color-slate); font-size: 12px; margin-bottom: 4px; }
.msg .bubble {
  padding: 10px 14px;
  border-radius: 12px 12px 12px 4px;
  background: var(--color-slate-100);
  border: 1px solid var(--color-border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}
.msg.system { justify-content: center; }
.msg.system .body { max-width: 92%; }
.msg.system .bubble {
  background: #fff;
  border: 1px dashed var(--color-border-strong);
  color: var(--color-slate);
  font-size: 14px;
  border-radius: 12px;
}
.msg.system .avatar { display: none; }
.msg.system .meta { text-align: center; }
.readonly-bar {
  padding: 12px 24px;
  border-top: 1px solid var(--color-border);
  color: var(--color-slate);
  font-size: 12px;
  text-align: center;
  background: var(--color-slate-mist);
}

.side-pane { overflow: auto; display: flex; flex-direction: column; gap: 16px; padding-right: 2px; }

/* ---------- Panels / cards ---------- */
.panel {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-card);
  padding: 24px;
  box-shadow: var(--shadow-rest);
  transition: box-shadow 150ms ease-out, transform 150ms ease-out;
}
.panel:hover { box-shadow: var(--shadow-hover); }
.panel h3 {
  margin: 0 0 16px;
  font: 500 12px/1.4 var(--font-sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-slate);
}

.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.stat-row .k { color: var(--color-slate); }
.bar {
  height: 8px;
  border-radius: var(--radius-badge);
  background: var(--color-slate-100);
  overflow: hidden;
  margin: 6px 0 12px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--color-corporate-blue);
  border-radius: inherit;
  transition: width 200ms ease-out;
}
.bar.good > i { background: var(--color-confirm-green); }
.bar.soft > i { background: var(--color-action-blue); }
.bar.neutral > i { background: var(--color-slate); }
.bar.violet > i { background: var(--color-hint-violet); }

/* ---------- Cast ---------- */
.cast { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cast-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  transition: box-shadow 150ms ease-out, transform 150ms ease-out;
}
.cast-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.cast-card .name { font: 600 14px/1.4 var(--font-sans); }
.cast-card .role { color: var(--color-slate); font-size: 12px; margin-top: 2px; }
.cast-card .online { font-size: 12px; margin-top: 4px; }
.cast-card .online.on { color: #047857; }
.cast-card .online.off { color: var(--color-slate); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 12px; max-height: 280px; overflow: auto; }
.timeline-item {
  position: relative;
  border-left: 1px solid var(--color-border);
  padding-left: 16px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-action-blue);
  box-shadow: 0 0 0 3px var(--color-blue-50);
}
.timeline-item .t { color: var(--color-slate); font-size: 12px; }
.timeline-item .title { font-weight: 600; font-size: 14px; }
.timeline-item .body { color: var(--color-slate); font-size: 13px; }

.chronicle-item { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.chronicle-item:last-child { border-bottom: 0; }
.chronicle-item .t { color: var(--color-slate); font-size: 12px; }
.chronicle-item .title { font-size: 14px; font-weight: 600; }
.chronicle-item .body { color: var(--color-slate); font-size: 13px; white-space: pre-wrap; }

/* ---------- Admin ---------- */
.admin-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px;
  height: calc(100vh - 64px);
  max-width: 1120px;
  margin: 0 auto;
}
.world-list { overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.world-item {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;
}
.world-item:hover, .world-item.active {
  border-color: var(--color-corporate-blue);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}
.world-item .name { font-weight: 600; font-size: 14px; }
.world-item .meta { color: var(--color-slate); font-size: 12px; margin-top: 2px; }

.admin-main { overflow: auto; display: flex; flex-direction: column; gap: 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.tabs { display: flex; gap: 8px; align-items: center; }
.tabs button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-slate);
  box-shadow: none;
  padding: 8px 12px;
  border-radius: 8px;
}
.tabs button:hover { background: var(--color-slate-100); color: var(--color-text); transform: none; box-shadow: none; }
.tabs button.active {
  background: var(--color-blue-50);
  color: var(--color-corporate-blue);
  border-color: var(--color-blue-100);
}
.hidden { display: none !important; }

/* ---------- Code / JSON ---------- */
pre {
  background: var(--color-slate-mist);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  max-height: 520px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 400 12px/1.6 ui-monospace, SFMono-Regular, Consolas, 'Cascadia Mono', monospace;
  color: #334155;
}

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .32);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.modal {
  width: min(900px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-hover);
  padding: 24px;
}
.modal h2 { margin: 0 0 12px; font-size: 20px; font-weight: 600; }
.modal .close { float: right; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-corporate-blue);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--color-text);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 150ms ease-out, transform 150ms ease-out;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Landing ---------- */
.landing {
  max-width: 1120px;
  margin: 0 auto;
  padding: 64px 32px 96px;
}
.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 64px;
  align-items: center;
  padding: 48px 0 64px;
}
.hero h1 {
  margin: 16px 0 20px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.hero p {
  margin: 0;
  max-width: 560px;
  color: var(--color-slate);
  font-size: 18px;
  line-height: 1.65;
}
.hero-actions { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.hero-meta { margin-top: 24px; color: var(--color-slate); font-size: 12px; letter-spacing: .04em; }
.hero-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: #fff;
  box-shadow: var(--shadow-hover);
  padding: 24px;
}
.hero-card .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.hero-card .day { font: 700 30px/1.1 var(--font-sans); letter-spacing: -.01em; }
.hero-card .weather { color: var(--color-slate); font-size: 14px; }
.hero-card .row { display: flex; justify-content: space-between; font-size: 14px; margin-top: 14px; }
.hero-card .row span:first-child { color: var(--color-slate); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 32px; }
.feature-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: #fff;
  padding: 24px;
  box-shadow: var(--shadow-rest);
  transition: box-shadow 150ms ease-out, transform 150ms ease-out;
}
.feature-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--color-blue-50);
  color: var(--color-corporate-blue);
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 16px;
}
.feature-card h3 { font-size: 20px; margin-bottom: 8px; }
.feature-card p { margin: 0; color: var(--color-slate); font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .layout, .admin-layout { grid-template-columns: 1fr; height: auto; }
  .side-pane { max-height: none; }
  .grid-2, .hero, .feature-grid { grid-template-columns: 1fr; }
  .hero { gap: 32px; }
  .topbar { padding: 0 16px; gap: 12px; }
  .layout, .admin-layout, .landing { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
