:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-strong: #f0f0f2;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-strong: #0066cc;
  --warn: #9a6700;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.08);
  --deep: #101014;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #161617;
  --surface-strong: #242426;
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --line: #303033;
  --accent: #2997ff;
  --accent-strong: #7bc0ff;
  --warn: #ffd36a;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
  --deep: #050506;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0.9)),
    url("assets/niutron-logo-dark.png");
  background-position: center 5.5rem;
  background-repeat: no-repeat;
  background-size: min(1080px, 94vw) auto;
  opacity: 0;
}

:root[data-theme="dark"] body::before {
  opacity: 0.36;
}

[hidden] {
  display: none !important;
}

.app-shell,
.login-screen {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.login-screen {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 2rem;
}

.login-card {
  display: grid;
  gap: 1.25rem;
  width: min(100%, 28rem);
  padding: clamp(1.25rem, 5vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.login-logo {
  position: relative;
  width: 6.25rem;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.login-logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.2rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.login-card p {
  margin: 0.65rem 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 0.75rem;
}

.login-form label {
  font-weight: 800;
}

.login-form input {
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.login-form input:focus,
.chat-form textarea:focus {
  border-color: var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
}

.login-status {
  min-height: 1.4rem;
  color: var(--warn);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 64px;
  padding: 0 5vw;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
}

.brand,
.nav-links,
.course-picker,
.hero-actions,
.header-actions,
.panel-header,
.status-grid,
.terminal-top,
.source-strip {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.75rem;
  font-weight: 800;
}

.brand-logo {
  position: relative;
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
}

.brand-logo img,
.hero-logo-shell img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-dark {
  display: none;
}

:root[data-theme="dark"] .logo-light {
  display: none;
}

:root[data-theme="dark"] .logo-dark {
  display: block;
}

.brand-text {
  letter-spacing: -0.01em;
}

.nav-links {
  gap: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-links a:hover {
  color: var(--text);
}

.course-picker {
  gap: 0.55rem;
  min-width: 13rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.course-picker select {
  min-height: 2.65rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 2.25rem 0 0.9rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.course-picker select:focus {
  border-color: var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent);
}

.theme-toggle,
.logout-button,
.button {
  min-height: 2.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.header-actions {
  gap: 0.55rem;
}

.theme-toggle,
.logout-button {
  padding: 0 1rem;
  background: var(--surface);
  color: var(--text);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.2rem;
  font-weight: 750;
}

.button:hover,
.theme-toggle:hover,
.logout-button:hover {
  border-color: var(--accent);
}

.button:active,
.theme-toggle:active,
.logout-button:active {
  transform: translateY(1px);
}

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

.button-secondary {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--text);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(340px, 0.58fr);
  gap: clamp(2rem, 7vw, 7rem);
  min-height: calc(100dvh - 64px);
  padding: clamp(3.5rem, 7vw, 6rem) 5vw 4.5rem;
  align-items: center;
}

.hero h1,
.section-heading h2,
.drill-copy h2,
.coach-copy h2,
.security-band h2 {
  margin: 0;
  max-width: 11ch;
  font-size: clamp(3.2rem, 6.6vw, 7rem);
  line-height: 0.94;
  letter-spacing: -0.03em;
}

.hero p {
  max-width: 37rem;
  margin: 1.35rem 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.hero-actions {
  gap: 0.8rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.hero-product {
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.hero-logo-shell {
  position: relative;
  width: min(68vw, 17.5rem);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.path-panel,
.lesson-detail,
.study-protocol,
.metric-card,
.progress-panel,
.thesaurus-card,
.playbook-grid article,
.repo-study-list,
.terminal-card,
.chat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .path-panel,
:root[data-theme="dark"] .lesson-detail,
:root[data-theme="dark"] .study-protocol,
:root[data-theme="dark"] .metric-card,
:root[data-theme="dark"] .progress-panel,
:root[data-theme="dark"] .thesaurus-card,
:root[data-theme="dark"] .playbook-grid article,
:root[data-theme="dark"] .repo-study-list,
:root[data-theme="dark"] .chat-card {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.path-panel {
  width: min(100%, 29rem);
  padding: 1rem;
}

.panel-header {
  justify-content: space-between;
  padding: 0.5rem 0.35rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-header strong {
  color: var(--text);
}

.module-list {
  display: grid;
  gap: 0.55rem;
}

.module-row {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: center;
  width: 100%;
  min-height: 3.3rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.module-row span {
  color: var(--muted);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.module-row.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.module-row.done strong::after {
  content: "Complete";
  display: block;
  margin-top: 0.16rem;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
}

.learning-shell,
.progress-section,
.thesaurus-section,
.playbook-section,
.coach-section,
.security-band,
.source-strip {
  margin: 0 auto;
  width: min(90vw, 1220px);
}

.learning-shell,
.progress-section,
.thesaurus-section,
.playbook-section,
.coach-section {
  padding: 5rem 0;
}

.section-heading {
  max-width: 46rem;
}

.section-heading h2,
.drill-copy h2,
.coach-copy h2,
.security-band h2 {
  max-width: 15ch;
  font-size: clamp(2.25rem, 4.5vw, 4.8rem);
  line-height: 1;
}

.section-heading p,
.drill-copy p,
.coach-copy p,
.security-band p {
  max-width: 42rem;
  color: var(--muted);
  line-height: 1.65;
  font-size: 1.05rem;
}

.learning-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  margin-top: 2rem;
}

.lesson-detail,
.study-protocol {
  padding: clamp(1.2rem, 3vw, 2rem);
}

.lesson-count {
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

.lesson-detail h3,
.study-protocol h3 {
  margin: 0.7rem 0 1.2rem;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1;
}

.lesson-detail dl,
.study-protocol ol,
.security-band ul {
  margin: 0;
  padding: 0;
}

.lesson-detail dl {
  display: grid;
  gap: 1rem;
}

.lesson-detail div {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.lesson-detail dt {
  margin-bottom: 0.35rem;
  color: var(--text);
  font-weight: 800;
}

.lesson-detail dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.lesson-complete {
  margin-top: 1.35rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0 1rem;
}

.metric-card {
  min-height: 8.25rem;
  padding: 1.2rem;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-top: 0.8rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.progress-panel {
  padding: 1rem;
}

.progress-chart {
  display: grid;
  gap: 0.55rem;
}

.progress-row {
  display: grid;
  grid-template-columns: 3rem minmax(10rem, 1fr) minmax(9rem, 0.58fr) 4rem;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  min-height: 3.1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 0.7rem;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.progress-row span,
.progress-row em {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-style: normal;
}

.progress-row i {
  position: relative;
  height: 0.48rem;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 60%, transparent);
}

.progress-row i::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--value);
  border-radius: inherit;
  background: var(--accent);
}

.progress-row.active {
  border-color: var(--accent);
}

.progress-row.done em {
  color: var(--accent-strong);
  font-weight: 800;
}

.progress-note {
  min-height: 1.5rem;
  margin: 0.9rem 0 0;
  color: var(--muted);
}

.study-protocol ol,
.security-band ul {
  display: grid;
  gap: 0.85rem;
  list-style-position: inside;
  color: var(--muted);
  line-height: 1.5;
}

.thesaurus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.thesaurus-card {
  min-height: 11rem;
  padding: 1.2rem;
}

.thesaurus-card span {
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.thesaurus-card h3 {
  margin: 0.75rem 0 0.55rem;
  font-size: 1.3rem;
  line-height: 1.08;
}

.thesaurus-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.drill-zone {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 0.7fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  width: min(90vw, 1220px);
  margin: 0 auto;
  padding: 4rem 0 5rem;
}

.terminal-card {
  overflow: hidden;
  background: #111713;
  color: #dff5e7;
}

.terminal-top {
  gap: 0.4rem;
  height: 2.4rem;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.terminal-top span {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.34);
}

pre {
  min-height: 18rem;
  margin: 0;
  padding: 1.4rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.75;
}

.copy-status {
  min-height: 1.4rem;
}

.coach-section {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(360px, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}

.status-grid {
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.status-grid span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 750;
}

.status-grid .ok {
  color: var(--accent-strong);
}

.status-grid .warn {
  color: var(--warn);
}

.chat-card {
  display: grid;
  grid-template-rows: minmax(22rem, 1fr) auto;
  min-height: 36rem;
  overflow: hidden;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 0.8rem;
  padding: 1rem;
  overflow-y: auto;
}

.chat-message,
.chat-empty {
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  background: var(--surface-strong);
}

.chat-message.user {
  justify-self: end;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.chat-message span {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 800;
}

.chat-message p,
.chat-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.chat-form {
  display: grid;
  gap: 0.7rem;
  padding: 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.chat-form label {
  font-weight: 800;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.chat-form button {
  justify-self: end;
}

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.playbook-grid article {
  min-height: 16rem;
  padding: 1.2rem;
}

.playbook-grid span {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.playbook-grid h3,
.repo-study-list h3 {
  margin: 1rem 0 0.7rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.playbook-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.repo-study-list {
  margin-top: 1rem;
  padding: 1.2rem;
}

.repo-study-list ul {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.55;
}

.repo-study-list a {
  color: var(--accent-strong);
  font-weight: 800;
}

.security-band {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 0.75fr);
  gap: 2rem;
  padding: 4rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.source-strip {
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 2rem 0 4rem;
}

.source-strip a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--muted);
  background: var(--surface);
}

.source-strip a:hover {
  color: var(--text);
  border-color: var(--accent);
}

.reference-tooltip {
  position: fixed;
  z-index: 20;
  width: min(24rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 0.95rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.reference-tooltip strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.reference-tooltip p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.reference-tooltip a {
  display: inline-block;
  margin-top: 0.55rem;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 920px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 1rem 5vw;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.3rem;
    scrollbar-width: none;
  }

  .hero,
  .learning-grid,
  .progress-grid,
  .thesaurus-grid,
  .playbook-grid,
  .drill-zone,
  .coach-section,
  .security-band {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 3rem;
  }

  .hero h1 {
    font-size: clamp(3.2rem, 14vw, 5.3rem);
  }

  .path-panel,
  .coach-section {
    width: 100%;
  }

  .progress-row {
    grid-template-columns: 2.2rem minmax(0, 1fr) 4.2rem;
  }

  .progress-row i {
    grid-column: 2 / 4;
  }
}

@media (max-width: 560px) {
  .brand {
    font-size: 0.95rem;
  }

  .hero-actions,
  .button {
    width: 100%;
  }

  .header-actions {
    width: 100%;
  }

  .course-picker {
    width: 100%;
  }

  .nav-links {
    flex-wrap: wrap;
    gap: 0.55rem 0.95rem;
    overflow: visible;
    padding-bottom: 0;
  }

  .theme-toggle,
  .logout-button {
    flex: 1;
  }

  .chat-message,
  .chat-empty {
    max-width: 100%;
  }

  .chat-form button {
    justify-self: stretch;
  }
}
