:root {
  /* Light-theme palette intentionally uses industrial blues and steel neutrals
     to match enterprise/manufacturing audiences instead of nature-inspired tones. */
  --page-gradient-start: #eef2f7;
  --page-gradient-mid: #e3e9f1;
  --page-gradient-end: #d4dde8;

  --surface-panel: #ffffff;
  --surface-section: #f8fbff;
  --surface-muted: #f0f5fb;

  --hero-start: #103a66;
  --hero-mid: #165082;
  --hero-end: #1f689e;
  --hero-border: #2b5f8a;

  --text-primary: #152334;
  --text-secondary: #3f5166;
  --text-muted: #5c6f84;
  --text-on-hero: #f4f8fd;
  --text-on-hero-soft: #d3deea;

  --border: #c0ccda;
  --border-strong: #99abc1;

  --accent: #156db7;
  --accent-hover: #0f5a98;
  --accent-strong: #0c4779;

  --link: #0f5f9e;
  --link-hover: #0b4677;

  --code-bg: #edf3fa;
  --code-border: #d6e0ed;
  --code-text: #1e2b3a;

  --pre-bg: #102033;
  --pre-border: #29455f;
  --pre-text: #d8e8f8;

  --terminal-bg: #0b1726;
  --terminal-border: #2f4961;
  --terminal-text: #d6e7f8;

  --success-bg: #e5f4ed;
  --success-border: #9fc9b0;
  --success-text: #1f623e;

  --warn-bg: #fff1e8;
  --warn-border: #e2b194;
  --warn-text: #7c3b1a;

  --shadow-soft: 0 10px 26px rgba(20, 35, 52, 0.1);
  --shadow-hero: 0 18px 40px rgba(14, 31, 52, 0.32);
}

html[data-theme="dark"] {
  /* Dark-theme palette keeps the same blue/steel identity with higher contrast
     for machine-floor and low-light viewing conditions. */
  --page-gradient-start: #0e1723;
  --page-gradient-mid: #121f2f;
  --page-gradient-end: #17293c;

  --surface-panel: #1a2736;
  --surface-section: #1c2c3d;
  --surface-muted: #223448;

  --hero-start: #0a2239;
  --hero-mid: #10314f;
  --hero-end: #184268;
  --hero-border: #2b5277;

  --text-primary: #e6eef8;
  --text-secondary: #c4d2e1;
  --text-muted: #a9bdcf;
  --text-on-hero: #f0f6fd;
  --text-on-hero-soft: #c8d7e7;

  --border: #3b5066;
  --border-strong: #4f6882;

  --accent: #3d9ced;
  --accent-hover: #2b86d1;
  --accent-strong: #1f6cae;

  --link: #83c0ff;
  --link-hover: #a8d4ff;

  --code-bg: #24374b;
  --code-border: #3a536d;
  --code-text: #d9e9f7;

  --pre-bg: #0a1421;
  --pre-border: #26425d;
  --pre-text: #d4e5f8;

  --terminal-bg: #08111c;
  --terminal-border: #2a4560;
  --terminal-text: #d3e7fb;

  --success-bg: #1b3a2b;
  --success-border: #3f7a5a;
  --success-text: #bfe8cd;

  --warn-bg: #44271b;
  --warn-border: #86513a;
  --warn-text: #f2c7b1;

  --shadow-soft: 0 10px 26px rgba(2, 7, 12, 0.45);
  --shadow-hero: 0 20px 44px rgba(1, 5, 10, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Trebuchet MS", "Arial", sans-serif;
  color: var(--text-primary);
}

/* Paint the gradient on the root canvas and keep it at least viewport-sized so
   short pages never show a cut-off background near the bottom of the screen. */
html {
  min-height: 100%;
  background: linear-gradient(
    160deg,
    var(--page-gradient-start) 0%,
    var(--page-gradient-mid) 45%,
    var(--page-gradient-end) 100%
  );
}

/* Body is stretched to viewport height and uses column flow so the page wrapper
   can grow to fill empty vertical space when content is shorter than the screen. */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* Sensitive pages keep body hidden until the partner gate script validates
   access, preventing protected content from briefly flashing on screen. */
html.locked body {
  display: none;
}

/* Theme transitions are intentionally subtle so mode switches feel responsive
   without becoming distracting in an operational interface. */
body,
.hero,
.card,
.content,
.demo-panel,
.taskbar,
.mock-window,
.theme-toggle,
.mock-btn,
.terminal {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.page {
  width: 100%;
  flex: 1 0 auto;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Global theme switch remains fixed so users can change mode from any page,
   including restricted docs and the interactive demo portal. */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1200;
  border: 1px solid var(--border-strong);
  background: var(--surface-panel);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.theme-toggle:hover {
  background: var(--surface-muted);
}

.hero {
  background: linear-gradient(130deg, var(--hero-start), var(--hero-mid) 65%, var(--hero-end));
  color: var(--text-on-hero);
  border-radius: 16px;
  padding: 28px;
  border: 1px solid var(--hero-border);
  box-shadow: var(--shadow-hero);
}

.hero h1 {
  margin: 0 0 10px 0;
  font-size: 36px;
  letter-spacing: 0.2px;
}

.hero p {
  margin: 0;
  color: var(--text-on-hero-soft);
}

.nav {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav a {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-on-hero);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-on-hero);
  text-decoration: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.card {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.card h2 {
  margin-top: 0;
  font-size: 20px;
}

.card p {
  margin-bottom: 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.content {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-top: 20px;
  padding: 22px;
  box-shadow: var(--shadow-soft);
}

.content h1,
.content h2,
.content h3 {
  margin-top: 0;
}

.content p,
.content li,
.content ol {
  line-height: 1.6;
  color: var(--text-secondary);
}

.content code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 1px 6px;
  font-family: "Consolas", "Courier New", monospace;
  color: var(--code-text);
}

.content pre {
  overflow: auto;
  background: var(--pre-bg);
  color: var(--pre-text);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--pre-border);
}

.content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}

.cta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cta a {
  display: inline-block;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 700;
}

.cta .primary {
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  color: #ffffff;
}

.cta .primary:hover {
  background: var(--accent-hover);
  color: #ffffff;
  text-decoration: none;
}

.cta .secondary {
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.cta .secondary:hover {
  background: var(--surface-section);
  text-decoration: none;
}

.footer {
  margin: 20px 0 28px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Demo portal layout keeps controls and terminal side-by-side on desktop while
   collapsing to one column on mobile so the simulator remains usable. */
.demo-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr);
  gap: 16px;
}

/* Demo panels intentionally reuse the same card language as docs pages so the
   experience feels like one unified product site. */
.demo-panel {
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.demo-panel h3 {
  margin-top: 0;
}

.demo-panel label {
  display: block;
  color: var(--text-secondary);
  font-weight: 600;
}

.section-gap {
  margin-top: 14px;
}

/* Form controls in the demo share a single class so light/dark theming remains
   consistent without inline hardcoded colors. */
.field-input {
  width: 100%;
  margin: 8px 0 10px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-section);
  color: var(--text-primary);
}

.stack-gap {
  margin-top: 12px;
}

/* Control grid mirrors machine control clusters while staying touch-friendly. */
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.mock-btn {
  display: inline-block;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--text-primary);
  padding: 10px;
  font-weight: 700;
  cursor: pointer;
}

.mock-btn:hover {
  background: var(--surface-section);
}

.mock-btn.primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.mock-btn.primary:hover {
  background: var(--accent-hover);
}

.mock-btn.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

/* Status pills present simulator state at a glance. */
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-primary);
}

.pill.ok {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.pill.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

/* Terminal pane keeps a fixed-height monospace output area like machine logs. */
.terminal {
  background: var(--terminal-bg);
  color: var(--terminal-text);
  border: 1px solid var(--terminal-border);
  border-radius: 12px;
  height: 360px;
  overflow: auto;
  padding: 12px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Mock startup window demonstrates the new taskbar-visible non-modal behavior. */
.mock-window {
  margin-top: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-section);
  box-shadow: var(--shadow-soft);
}

.mock-window.hidden {
  display: none;
}

.mock-window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, var(--hero-start), var(--hero-mid));
  color: var(--text-on-hero);
  padding: 8px 10px;
  font-size: 13px;
}

.mock-window-actions {
  display: flex;
  gap: 6px;
}

.window-icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-on-hero);
  border-radius: 6px;
  width: 26px;
  height: 24px;
  cursor: pointer;
}

.window-icon-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.mock-window-body {
  padding: 12px;
  color: var(--text-primary);
}

/* Taskbar strip keeps the welcome-window entry available after minimize. */
.taskbar {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 8px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.taskbar-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-section);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

.taskbar-btn.hidden {
  display: none;
}

.taskbar-btn.active {
  background: var(--surface-panel);
  border-color: var(--accent-strong);
}

@media (max-width: 700px) {
  .theme-toggle {
    top: 10px;
    right: 10px;
    padding: 7px 12px;
    font-size: 12px;
  }

  .hero {
    padding: 20px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .page {
    padding: 14px;
  }

  .demo-layout {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }
}
