:root {
  color-scheme: dark;
  --brand: #e40a14;
  --brand-dark: #b80810;
  --brand-glow: rgba(228, 10, 20, 0.18);
  --brand-subtle: rgba(228, 10, 20, 0.1);
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-raised: #181818;
  --surface-input: #1a1a1a;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #696969;
  --green: #22c55e;
  --green-subtle: rgba(34, 197, 94, 0.12);
  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.12);
  --blue: #60a5fa;
  --blue-subtle: rgba(96, 165, 250, 0.12);
  --teal: #14b8a6;
  --teal-subtle: rgba(20, 184, 166, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 0 20px rgba(228, 10, 20, 0.18);
  --header-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top right, rgba(228, 10, 20, 0.08), transparent 24%),
    linear-gradient(180deg, #090909 0%, #0a0a0a 100%);
  color: var(--text-primary);
  font-family: "IBM Plex Sans", sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

code,
pre {
  font-family: "IBM Plex Mono", monospace;
}

a {
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 300;
  background: rgba(13, 13, 13, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding-top: var(--safe-top);
}

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 calc(24px + var(--safe-right)) 0 calc(24px + var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  height: 34px;
  width: auto;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}

.brand-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", monospace;
}

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

.progress-bar-wrap {
  height: 3px;
  background: var(--border);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), #ff5a62);
  box-shadow: var(--shadow-brand);
  transition: width 240ms ease;
}

.btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: 150ms ease;
  white-space: nowrap;
}

.btn {
  font-size: 0.92rem;
  font-weight: 600;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  box-shadow: var(--shadow-brand);
}

.btn-ghost,
.icon-btn {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-ghost:hover,
.icon-btn:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
  border-color: #525252;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 30px calc(24px + var(--safe-right)) calc(96px + var(--safe-bottom)) calc(24px + var(--safe-left));
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 28px;
}

.step-sidebar {
  position: sticky;
  top: calc(var(--header-h) + var(--safe-top) + 22px);
  align-self: start;
  background: rgba(17, 17, 17, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: grid;
  gap: 10px;
  max-height: calc(100dvh - var(--header-h) - var(--safe-top) - 52px);
  overflow: auto;
}

.step-sidebar-header {
  padding: 2px 2px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.step-sidebar-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.step-sidebar-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.step-link {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-lg);
  padding: 12px 13px;
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: 160ms ease;
}

.step-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text-primary);
}

.step-link small {
  color: inherit;
  opacity: 0.8;
  font-size: 0.74rem;
}

.step-link strong {
  font-size: 0.92rem;
  line-height: 1.25;
}

.step-link.is-current {
  border-color: var(--brand);
  background: linear-gradient(180deg, rgba(228, 10, 20, 0.13), rgba(228, 10, 20, 0.04));
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.step-link.is-complete {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.12), rgba(34, 197, 94, 0.04));
  color: #d8ffe4;
}

.step-link.is-pending {
  border-color: rgba(245, 158, 11, 0.35);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.04));
  color: #ffe7b0;
}

.step-link.is-future {
  color: var(--text-muted);
}

.app-main {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.hero-panel,
.step-section,
.code-panel,
.stats-panel {
  background: rgba(17, 17, 17, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.hero-panel {
  padding: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(228, 10, 20, 0.25);
  background: rgba(228, 10, 20, 0.1);
  border-radius: 999px;
  color: #ff9298;
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-panel h2 {
  margin: 14px 0 10px;
  font-size: clamp(1.5rem, 2vw, 2rem);
  line-height: 1.15;
  max-width: 720px;
}

.hero-panel p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 760px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.step-container {
  display: grid;
  gap: 18px;
}

.step-section {
  scroll-margin-top: 110px;
  overflow: hidden;
}

.step-section.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px rgba(228, 10, 20, 0.4), var(--shadow-brand);
}

.step-section-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.step-number {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  font-weight: 600;
}

.step-section-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.step-section-header p {
  margin: 5px 0 0;
  color: var(--text-secondary);
}

.step-body {
  padding: 22px 24px 24px;
  display: grid;
  gap: 18px;
}

.stats-grid,
.card-grid,
.mini-grid {
  display: grid;
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mini-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stat-card,
.content-card,
.mini-card,
.callout-card,
.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1;
  color: #fff;
}

.stat-card span {
  display: block;
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.content-card h4,
.mini-card h4,
.preview-card h4 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.content-card p,
.mini-card p,
.preview-card p,
.step-body > p,
.callout-card p {
  margin: 0;
  color: var(--text-secondary);
}

.content-card p + p,
.mini-card p + p,
.step-body > p + p {
  margin-top: 10px;
}

.content-card ul,
.mini-card ul,
.callout-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.content-card li,
.mini-card li,
.callout-card li {
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
}

.content-card li::before,
.mini-card li::before,
.callout-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.callout-card {
  background: linear-gradient(180deg, rgba(228, 10, 20, 0.08), rgba(255, 255, 255, 0.01));
  border-color: rgba(228, 10, 20, 0.2);
}

.callout-card strong {
  color: #fff;
}

.meta-row,
.chip-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-input);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.status-chip {
  border-color: rgba(34, 197, 94, 0.25);
  background: var(--green-subtle);
  color: #d4ffe0;
}

.status-chip.pending {
  border-color: rgba(245, 158, 11, 0.3);
  background: var(--amber-subtle);
  color: #ffe2a6;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-raised);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
}

td {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: none;
}

.code-panel {
  overflow: hidden;
}

.code-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-raised);
}

.code-toolbar p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 820px;
}

.code-block {
  margin: 0;
  padding: 24px;
  background: #080808;
  color: #e8e8e8;
  font-size: 0.84rem;
  line-height: 1.75;
  overflow: auto;
}

.preview-caption {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.link-inline {
  color: #ff9ba0;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 155, 160, 0.25);
}

.link-inline:hover {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.35);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: calc(22px + var(--safe-bottom));
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.95);
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  z-index: 600;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.01);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .step-sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .header-inner {
    padding-left: 18px;
    padding-right: 18px;
    align-items: flex-start;
    padding-top: 12px;
    padding-bottom: 12px;
    min-height: auto;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions .btn {
    flex: 1 1 0;
  }

  .hero-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .step-sidebar {
    display: none;
  }

  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-panel,
  .step-section,
  .code-toolbar,
  .step-body,
  .step-section-header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .step-section-header {
    flex-direction: column;
  }

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

  .code-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn,
  .icon-btn {
    min-height: 44px;
  }
}
