:root {
  color-scheme: dark;
  /* Layered graphite-slate — depth via surfaces, not one flat navy */
  --bg: #0e1216;
  --panel: #161b22;
  --panel-2: #1b2129;
  --border: #232b35;
  --hair: #2b3441;
  --text: #e8edf3;
  --muted: #9aa7b4;
  --faint: #6b7885;
  /* One structural signal + one functional live-state */
  --signal: #5b9dff;
  --on-signal: #06101f;
  --live: #3fb950;
  --nav-bg: rgba(14, 18, 22, 0.72);
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --maxw: 1180px;
}

/* Light theme — cool paper, keeps the same structural language */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --border: #dde3ea;
  --hair: #e6eaef;
  --text: #131b24;
  --muted: #55636f;
  --faint: #8592a0;
  --signal: #2563eb;
  --on-signal: #ffffff;
  --live: #1a9c3e;
  --nav-bg: rgba(246, 248, 250, 0.78);
  --shadow: 0 20px 50px -24px rgba(20, 32, 48, 0.28);
}

body { transition: background-color 0.25s ease, color 0.25s ease; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 6px; }

/* ---- Status dot (functional live indicator) ---- */
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live); flex: none;
}
.dot--sm { width: 7px; height: 7px; }
/* Only the live console indicator pulses — one deliberate motion */
.chat-header .dot { animation: pulse 2.4s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(63,185,80,0.45); }
  70% { box-shadow: 0 0 0 7px rgba(63,185,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

/* ---- Nav ---- */
.nav {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem clamp(1rem, 5vw, 3rem);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 0.6rem; }
.brand-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; object-position: center top; border: 1px solid var(--hair);
}
.tabs { display: flex; align-items: center; gap: 0.35rem; }
.tab-link {
  color: var(--muted); font-size: 0.95rem; padding: 0.4rem 0.7rem; border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.tab-link:hover, .tab-link.is-active { color: var(--text); background: var(--panel); }
.status {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-left: 0.6rem; padding: 0.3rem 0.7rem;
  font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--hair); border-radius: 999px;
}
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 0.4rem; width: 36px; height: 36px; padding: 0;
  background: transparent; border: 1px solid var(--hair); border-radius: 9px;
  color: var(--muted); cursor: pointer; transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--signal); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ---- Layout ---- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 5vw, 3rem); }
.section { padding: clamp(3rem, 7vw, 5.5rem) 0; border-top: 1px solid var(--border); }

/* ---- Hero: identity | live twin ---- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(440px, 560px);
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: stretch;
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(2.5rem, 5vw, 3.5rem);
}
.hero-lead {
  display: flex; flex-direction: column; justify-content: flex-start;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.role {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin: 0 0 1.2rem; padding: 0.35rem 0.75rem;
  font-family: var(--mono); font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--hair); border-radius: 999px;
}
.hero h1 {
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  font-weight: 600; line-height: 1.06; letter-spacing: -0.025em;
  margin: 0 0 1.1rem; max-width: 15ch;
}
.lede { color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.12rem); max-width: 54ch; margin: 0; }

/* ---- Metrics: full-width readout strip, real measured data ---- */
.metrics-bar { padding: 0 0 clamp(2.5rem, 5vw, 3.5rem); }
.metrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.metric { padding: 1.5rem 1.6rem 1.5rem 0; }
.metric + .metric { padding-left: 1.6rem; border-left: 1px solid var(--border); }
.metric-num {
  font-family: var(--mono); font-weight: 500;
  font-size: clamp(1.25rem, 2vw, 1.6rem); letter-spacing: -0.02em;
  color: var(--text); line-height: 1.1; white-space: nowrap;
}
.metric-label { margin: 0.5rem 0 0; font-size: 0.82rem; color: var(--faint); line-height: 1.4; }

/* ---- Twin console (the one elevated, bold surface) ---- */
.chat {
  display: flex; flex-direction: column;
  background: linear-gradient(var(--panel), var(--panel-2));
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  height: clamp(460px, 62vh, 600px);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.08s both;
}
.chat-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border);
}
.chat-title { font-weight: 500; font-size: 0.95rem; }
.chat-sub { margin-left: auto; font-family: var(--mono); font-size: 0.68rem; color: var(--faint); }
.messages {
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 1.1rem; overflow-y: auto; flex: 1 1 0; min-height: 0;
}
.msg {
  padding: 0.7rem 0.95rem; border-radius: 14px; max-width: 88%;
  white-space: pre-wrap; word-wrap: break-word; font-size: 0.95rem;
  text-align: left; line-height: 1.55;
}
.msg.assistant { background: var(--bg); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg.user { background: var(--signal); color: var(--on-signal); font-weight: 500; align-self: flex-end; border-bottom-right-radius: 5px; }
.msg.assistant.streaming::after { content: "▍"; color: var(--faint); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.suggestions { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0 1.1rem 0.9rem; }
.chip {
  background: transparent; border: 1px solid var(--hair); color: var(--muted);
  font: inherit; font-size: 0.8rem; padding: 0.35rem 0.7rem; border-radius: 8px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--signal); }

.chat-input { display: flex; gap: 0.5rem; padding: 0.85rem 1.1rem; border-top: 1px solid var(--border); }
.chat-input input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 0.65rem 0.9rem; font: inherit;
}
.chat-input input:focus { outline: none; border-color: var(--signal); }
.chat-input button {
  background: var(--signal); color: var(--on-signal); border: 0; font: inherit; font-weight: 600;
  padding: 0 1.2rem; border-radius: 10px; cursor: pointer; transition: opacity 0.15s;
}
.chat-input button:hover { opacity: 0.9; }
.chat-input button:disabled { opacity: 0.5; cursor: default; }

/* ---- Section headings ---- */
.section-head { margin-bottom: 2rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.section-note { color: var(--muted); margin: 0.6rem 0 0; max-width: 60ch; }

/* ---- Work: divider + left-rule rows, not shadowed cards ---- */
.timeline { display: grid; gap: 0; }
.job {
  display: grid; grid-template-columns: minmax(180px, 220px) 1fr; gap: clamp(1.25rem, 3vw, 3rem);
  padding: 1.9rem 0; border-top: 1px solid var(--border);
}
.job:first-child { border-top: 0; }
.job-meta h3 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.role-title { color: var(--signal); font-size: 0.92rem; margin: 0.3rem 0 0.4rem; }
.when { font-family: var(--mono); font-size: 0.74rem; color: var(--faint); margin: 0; line-height: 1.5; }
.job-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.6rem; }
.job-points li { color: var(--muted); padding-left: 1.1rem; position: relative; }
.job-points li::before { content: ""; position: absolute; left: 0; top: 0.65em; width: 6px; height: 6px; border-radius: 50%; background: var(--hair); }

/* ---- About: asymmetric, fills width ---- */
.about { display: grid; grid-template-columns: 220px 1fr; gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.about-photo {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: center top;
  border-radius: 14px; border: 1px solid var(--border);
}
.about-body p { margin: 0 0 1.6rem; font-size: 1.05rem; max-width: 62ch; }
.about-body strong { color: var(--text); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--hair); border-radius: 10px; overflow: hidden; }
.facts > div { padding: 0.9rem 1.1rem; border-top: 1px solid var(--hair); }
.facts > div:nth-child(-n+2) { border-top: 0; }
.facts > div:nth-child(odd) { border-right: 1px solid var(--hair); }
.facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.facts dt { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); margin-bottom: 0.25rem; }
.facts dd { margin: 0; color: var(--text); font-size: 0.95rem; }

/* ---- Contact ---- */
.contact { display: flex; align-items: center; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.links { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.link-btn {
  display: inline-block; background: var(--panel); border: 1px solid var(--border);
  padding: 0.7rem 1.3rem; border-radius: 10px; color: var(--text); font-weight: 500;
  transition: border-color 0.15s, transform 0.15s;
}
.link-btn:hover { border-color: var(--signal); }
.link-btn.primary { background: var(--signal); color: var(--on-signal); border-color: var(--signal); }

.foot {
  max-width: var(--maxw); margin: 0 auto; border-top: 1px solid var(--border);
  color: var(--faint); font-size: 0.82rem; padding: 1.6rem clamp(1rem, 5vw, 3rem);
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .chat { height: auto; min-height: 440px; }
  .chat .messages { min-height: 200px; max-height: 46vh; }
  .job { grid-template-columns: 1fr; gap: 0.6rem; }
}
@media (max-width: 720px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 1.2rem 1.2rem 1.2rem 0; border-top: 1px solid var(--border); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric + .metric { padding-left: 0; border-left: 0; }
  .metric:nth-child(even) { padding-left: 1.4rem; border-left: 1px solid var(--border); }
}
@media (max-width: 560px) {
  .tabs .tab-link { padding: 0.4rem 0.5rem; font-size: 0.9rem; }
  .status { display: none; }
  .about { grid-template-columns: 1fr; }
  .about-photo { max-width: 200px; }
  .facts { grid-template-columns: 1fr; }
  .facts > div:nth-child(odd) { border-right: 0; }
  .facts > div:nth-child(2) { border-top: 1px solid var(--hair); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}
