:root {
  --bg: #12151a;
  --panel: #1a1f27;
  --panel-2: #222833;
  --line: #2e3644;
  --text: #e8eef6;
  --muted: #93a0b4;
  --accent: #6db3ff;
  --accent-2: #9ad7a0;
  --danger: #ff8e8e;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, #243049 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1d2a24 0%, transparent 50%),
    var(--bg);
  color: var(--text);
}

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.9em;
}

a {
  color: var(--accent);
}

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

.rail {
  border-right: 1px solid var(--line);
  background: rgba(18, 21, 26, 0.85);
  backdrop-filter: blur(10px);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: block;
  flex-shrink: 0;
}

.muted {
  color: var(--muted);
}

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

.provider-btn {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}

.provider-btn:hover,
.provider-btn.active {
  border-color: #4d7ec7;
  background: #243247;
}

.provider-btn .id {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.rail-section-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.agent-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid #3a567a;
  border-radius: 14px;
  background: linear-gradient(180deg, #243247 0%, #1a2230 100%);
}

.agent-panel-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ec0ef;
}

.agent-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
}

.agent-link:hover {
  border-color: #4d7ec7;
  background: #243247;
}

.agent-link-primary {
  border-color: #4d7ec7;
  background: #2a4d7a;
}

.agent-link-primary:hover {
  background: #355f94;
}

.agent-link strong {
  font-size: 13px;
}

.agent-link span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.agent-link-primary span {
  color: #c5d8f2;
}

.stage {
  padding: 24px 28px 40px;
}

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

.stage-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.credit {
  max-width: 360px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.view-root {
  min-height: 60vh;
}

.empty,
.error {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.15);
}

.error {
  color: var(--danger);
  border-color: #5a3030;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

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

.field input,
.field select,
.toolbar button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
}

.toolbar button {
  cursor: pointer;
  background: #2a4d7a;
  border-color: #3d6aa0;
}

.toolbar button.secondary {
  background: var(--panel-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.chip.active {
  color: var(--text);
  border-color: #4d7ec7;
  background: #243247;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.card:hover {
  border-color: #4d7ec7;
}

.thumb {
  height: 130px;
  background:
    linear-gradient(45deg, #2a303a 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #2a303a 25%, transparent 25%) 0 0 / 16px 16px,
    #1b2028;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .ph {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
  text-align: center;
}

.glb-preview,
.detail-preview {
  width: 100%;
  background: #151a22;
}

.detail-preview {
  border: 1px solid var(--line);
}

.card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #2b3340;
  color: #c5d0e0;
}

.detail {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 16px;
}

.detail pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: #c9d4e4;
  background: #12161d;
  padding: 12px;
  border-radius: 10px;
  max-height: 320px;
  overflow: auto;
}

.status-bar {
  margin: 8px 0 14px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
