:root {
  color-scheme: dark;
  --bg: #081012;
  --panel: rgba(245, 247, 238, 0.08);
  --panel-strong: rgba(245, 247, 238, 0.14);
  --text: #f5f7ee;
  --muted: #9fb0aa;
  --line: rgba(245, 247, 238, 0.18);
  --accent: #ffcf5a;
  --accent-two: #31d5c8;
  --accent-three: #ff6f91;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

body.light {
  color-scheme: light;
  --bg: #f4f1e8;
  --panel: rgba(8, 16, 18, 0.06);
  --panel-strong: rgba(8, 16, 18, 0.1);
  --text: #121716;
  --muted: #596662;
  --line: rgba(8, 16, 18, 0.16);
  --shadow: 0 24px 80px rgba(28, 36, 32, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(49, 213, 200, 0.2), transparent 28rem),
    radial-gradient(circle at 86% 8%, rgba(255, 111, 145, 0.14), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

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

button {
  font: inherit;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1180px, calc(100% - 32px));
  margin: 16px auto 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 16, 18, 0.62);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

body.light .topbar {
  background: rgba(244, 241, 232, 0.72);
}

.brand,
nav,
.hero-actions,
.console-header,
.contact {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #111;
}

nav {
  gap: clamp(10px, 3vw, 28px);
  color: var(--muted);
  font-size: 0.95rem;
}

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

.icon-button,
.back-top {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
}

.icon-button span {
  position: absolute;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

body.light .sun,
body:not(.light) .moon {
  opacity: 0;
  transform: scale(0.4) rotate(90deg);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: clamp(28px, 5vw, 80px);
  align-items: center;
  min-height: calc(100vh - 76px);
  padding: 64px 0 36px;
}

.hero > *,
.hero-copy,
.console {
  min-width: 0;
}

.eyebrow,
.section-heading p,
.contact p,
.tag {
  color: var(--accent-two);
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1,
.section-heading h2,
.contact h2 {
  margin: 0;
  max-width: 860px;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
  letter-spacing: 0;
  line-height: 0.98;
}

.hero h1 {
  font-size: clamp(3rem, 8vw, 7.4rem);
}

.intro {
  max-width: 640px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  line-height: 1.75;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  font-weight: 700;
}

.primary-action {
  background: var(--accent);
  color: #111;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel);
}

.console {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--panel-strong), rgba(49, 213, 200, 0.08));
  box-shadow: var(--shadow);
  transform: rotate(2deg);
}

.console::before {
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-two), transparent, var(--accent-three));
  content: "";
  filter: blur(18px);
  opacity: 0.4;
}

.console-header {
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.console-header span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-three);
}

.console-header span:nth-child(2) {
  background: var(--accent);
}

.console-header span:nth-child(3) {
  background: var(--accent-two);
}

.console-header strong {
  margin-left: auto;
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
}

pre {
  max-width: 100%;
  margin: 0;
  padding: clamp(18px, 4vw, 34px);
  overflow-x: auto;
  color: var(--text);
  font: 500 clamp(0.82rem, 1.7vw, 1.05rem) / 1.8 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.terminal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(16px, 3vw, 24px);
}

.terminal-status,
.chat-line,
.chat-form {
  display: flex;
  align-items: center;
}

.terminal-status {
  gap: 8px;
  color: var(--muted);
  font: 700 0.78rem / 1.4 "Space Grotesk", ui-monospace, monospace;
  text-transform: uppercase;
}

.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-two);
  box-shadow: 0 0 16px rgba(49, 213, 200, 0.75);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 190px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 2px;
  scrollbar-width: thin;
}

.chat-line {
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font: 500 0.95rem / 1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-line .prompt {
  flex: 0 0 auto;
  min-width: 44px;
  color: var(--accent);
  font-family: "Space Grotesk", ui-monospace, monospace;
  font-weight: 700;
}

.chat-line.user .prompt {
  color: var(--accent-two);
}

.chat-line.system .prompt {
  color: var(--accent-three);
}

.chat-line p {
  min-width: 0;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-line.thinking p::after {
  content: "";
  display: inline-block;
  width: 0.65em;
  height: 1em;
  margin-left: 2px;
  border-right: 2px solid var(--accent-two);
  vertical-align: -0.12em;
  animation: cursor-blink 0.8s steps(2, start) infinite;
}

.chat-form {
  gap: 8px;
}

.chat-form input {
  min-width: 0;
  flex: 1;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 16, 18, 0.34);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

body.light .chat-form input {
  background: rgba(244, 241, 232, 0.72);
}

.chat-form input:focus {
  border-color: rgba(49, 213, 200, 0.72);
}

.chat-form button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: #111;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-form label {
  color: var(--accent-two);
  font: 700 1rem / 1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-form.loading button {
  opacity: 0.7;
  cursor: wait;
}

.ticker {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-block: 1px solid var(--line);
  color: var(--muted);
  font-family: "Space Grotesk", sans-serif;
  white-space: nowrap;
  contain: paint;
}

.ticker div {
  display: flex;
  width: max-content;
  animation: marquee 22s linear infinite;
}

.ticker span {
  padding: 18px 34px;
}

.section {
  padding: clamp(72px, 10vw, 128px) 0;
}

.section-heading {
  margin-bottom: 34px;
}

.section-heading h2,
.contact h2 {
  font-size: clamp(2.1rem, 5vw, 4.7rem);
}

.about-grid,
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.about-grid article,
.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.about-grid article {
  padding: 24px;
}

.metric {
  color: var(--accent);
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 700;
}

.about-grid h3,
.project-card h3 {
  margin: 12px 0 8px;
  font-size: 1.25rem;
}

.about-grid p,
.project-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.project-card {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  padding: 24px;
  transform-style: preserve-3d;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.project-card:hover {
  border-color: rgba(255, 207, 90, 0.65);
}

.coming-soon {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 207, 90, 0.55);
  border-radius: 999px;
  background: rgba(255, 207, 90, 0.14);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.is-upcoming .tag {
  padding-right: 92px;
}

.tag {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 0.78rem;
}

.card-visual {
  position: absolute;
  right: 20px;
  bottom: 20px;
  left: 20px;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.visual-one {
  background:
    linear-gradient(90deg, transparent 24%, rgba(255, 207, 90, 0.8) 25% 27%, transparent 28%),
    repeating-linear-gradient(0deg, rgba(245, 247, 238, 0.16) 0 1px, transparent 1px 34px),
    linear-gradient(135deg, rgba(49, 213, 200, 0.24), transparent);
}

.visual-two {
  background:
    radial-gradient(circle at 28% 48%, var(--accent-three) 0 18px, transparent 19px),
    radial-gradient(circle at 62% 30%, var(--accent-two) 0 28px, transparent 29px),
    conic-gradient(from 120deg, rgba(255, 207, 90, 0.82), transparent, rgba(49, 213, 200, 0.72));
}

.visual-three {
  background:
    radial-gradient(circle at 20% 75%, var(--accent-two) 0 6px, transparent 7px),
    radial-gradient(circle at 54% 42%, var(--accent) 0 6px, transparent 7px),
    radial-gradient(circle at 82% 22%, var(--accent-three) 0 6px, transparent 7px),
    linear-gradient(135deg, rgba(255, 111, 145, 0.22), rgba(49, 213, 200, 0.18));
}

.orbit-lab {
  position: relative;
  display: grid;
  min-height: 520px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--panel);
  background-size: 56px 56px;
  overflow: hidden;
}

.orbit-lab::before,
.orbit-lab::after {
  position: absolute;
  border: 1px dashed var(--line);
  border-radius: 50%;
  content: "";
}

.orbit-lab::before {
  width: 310px;
  height: 310px;
}

.orbit-lab::after {
  width: 460px;
  height: 460px;
}

.orbit-core {
  z-index: 1;
  display: grid;
  width: 126px;
  height: 126px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #111;
  font-family: "Space Grotesk", sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  box-shadow: 0 0 40px rgba(255, 207, 90, 0.42);
}

.skill-chip {
  position: absolute;
  z-index: 2;
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 16, 18, 0.72);
  color: var(--text);
  cursor: pointer;
  animation: floaty 5s ease-in-out infinite;
}

body.light .skill-chip {
  background: rgba(244, 241, 232, 0.82);
}

.chip-a { transform: translate(-190px, -135px); }
.chip-b { transform: translate(155px, -145px); animation-delay: -1s; }
.chip-c { transform: translate(225px, 30px); animation-delay: -2s; }
.chip-d { transform: translate(92px, 170px); animation-delay: -3s; }
.chip-e { transform: translate(-215px, 108px); animation-delay: -4s; }
.chip-f { transform: translate(-70px, -225px); animation-delay: -2.5s; }

.contact {
  justify-content: space-between;
  gap: 24px;
  margin: 40px 0 64px;
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.contact p {
  margin-top: 0;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: -36px auto 82px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer a:hover {
  color: var(--text);
}

.back-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  width: 54px;
  height: 54px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.back-top.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.back-top:hover {
  border-color: rgba(255, 207, 90, 0.65);
}

.back-top svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.spark {
  position: fixed;
  z-index: 30;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--spark-color, var(--accent));
  pointer-events: none;
  animation: burst 680ms ease-out forwards;
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

@keyframes floaty {
  50% {
    margin-top: -14px;
  }
}

@keyframes burst {
  to {
    opacity: 0;
    transform: translate(var(--x), var(--y)) scale(0);
  }
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
  }

  nav {
    display: none;
  }

  .hero,
  .about-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 72px;
  }

  .hero h1,
  .intro,
  .eyebrow {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .console {
    transform: none;
  }

  .project-card {
    min-height: 380px;
  }

  .orbit-lab {
    min-height: 430px;
  }

  .orbit-lab::after {
    width: 330px;
    height: 330px;
  }

  .orbit-lab::before {
    width: 220px;
    height: 220px;
  }

  .skill-chip {
    min-width: 78px;
    font-size: 0.88rem;
  }

  .chip-a { transform: translate(-118px, -105px); }
  .chip-b { transform: translate(100px, -114px); }
  .chip-c { transform: translate(118px, 36px); }
  .chip-d { transform: translate(52px, 132px); }
  .chip-e { transform: translate(-126px, 96px); }
  .chip-f { transform: translate(-34px, -162px); }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
