:root {
  color-scheme: light;
  --rail-bg: #171721;
  --rail-surface: #1e1e2a;
  --rail-border: rgba(255, 255, 255, 0.09);
  --rail-text: #f1f5f9;
  --rail-muted: #b1b1c3;
  --brand-amber: #f59e0b;
  --brand-coral: #f43f5e;

  --canvas-bg: #f7f7fb;
  --card-bg: #ffffff;
  --subtle-bg: #fbfbff;
  --border: #e8e7ef;
  --border-strong: #d8d7e4;
  --ink: #28253b;
  --ink-secondary: #514c66;
  --ink-muted: #656276;

  --blue: #4658d4;
  --blue-soft: #edecfb;
  --blue-border: #dcdcf7;
  --red: #e11d48;
  --red-soft: #fff1f2;
  --red-border: #fecdd3;
  --teal: #059669;
  --teal-soft: #ecfdf5;
  --teal-border: #a7f3d0;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;

  --shadow-card: 0 3px 16px rgba(40, 37, 59, 0.035);
  --font-sans: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, monospace;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas-bg);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  background: var(--canvas-bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden]:not([hidden="until-found"]) {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* Split-Screen App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100dvh;
}

/* Left Persistent Command Rail (Dark) */
.command-rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  background: var(--rail-bg);
  color: var(--rail-text);
  border-right: 1px solid #1e293b;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rail-brand-card {
  position: relative;
  overflow: hidden;
  padding: 18px 16px;
  border-radius: 14px;
  border: 1px solid var(--rail-border);
  background:
    linear-gradient(155deg, rgba(15, 20, 28, 0.78), rgba(15, 20, 28, 0.94)),
    url("/facility.webp") right center / cover no-repeat;
  flex-shrink: 0;
}

.brand {
  display: grid;
  place-items: center;
  position: relative;
  min-height: 80px;
}

.brand-logo {
  position: absolute;
  width: min(172px, 100%);
  height: auto;
}

/* Rail Navigation */
.rail-nav {
  display: grid;
  gap: 5px;
}

.rail-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--rail-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.rail-nav a:hover {
  color: #ffffff;
  background: var(--rail-surface);
}

.rail-nav a[aria-current="page"] {
  color: #ffffff;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.05));
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: inset 3px 0 0 var(--brand-amber);
}

.rail-nav a[aria-current="page"] .nav-icon {
  color: var(--brand-amber);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.rail-ext-link {
  margin-top: 4px;
  border-top: 1px solid var(--rail-border) !important;
  border-radius: 0 0 10px 10px;
  padding-top: 6px !important;
}

.ext-icon {
  margin-left: auto;
  width: 14px;
  height: 14px;
  opacity: 0.65;
}

.rail-footer {
  margin-block-start: auto;
  font-size: 11.5px;
  color: var(--rail-muted);
  text-align: center;
}

/* Right Daylight Canvas */
.main-canvas {
  min-width: 0;
  padding: 48px clamp(28px, 4vw, 64px) 64px;
}

.canvas-view {
  max-width: 1140px;
  margin-inline: auto;
  display: grid;
  gap: 28px;
}

/* Buttons & Inputs */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 9px;
  font: 600 13.5px/1 var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn svg, button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--ink-secondary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--subtle-bg);
  color: var(--ink);
}

.btn-wiki-jump:hover {
  background: #fef3c7;
}

input, select {
  font: inherit;
  font-size: 14px;
  min-height: 42px;
  width: 100%;
  padding: 8px 13px;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: #94a3b8;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap svg {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  color: #64748b;
  pointer-events: none;
}

.input-wrap input {
  padding-left: 38px;
}

/* Records View Header */
.view-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
}

h1, .wiki-main-title {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.view-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

