:root {
  --bg: #0c0c11;
  --bg-card: #141419;
  --bg-hover: #1c1c24;
  --border: #222230;
  --border-subtle: #1a1a26;
  --accent: #3b82f6;
  --accent-dim: rgba(59,130,246,0.1);
  --text: #b4b4c8;
  --text-dim: #6b6b80;
  --text-bright: #dcdce8;
  --green: #4ade80;
  --radius: 10px;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-sans: 'LXGW WenKai Lite', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

body.light {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-hover: #f0f0f2;
  --border: #e4e4e8;
  --border-subtle: #ececf0;
  --accent: #2563eb;
  --accent-dim: rgba(37,99,235,0.06);
  --text: #3c3c4a;
  --text-dim: #8c8c9a;
  --text-bright: #1a1a24;
  --green: #16a34a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

::selection { background: var(--accent); color: #fff; }
a { color: var(--accent); text-decoration: none; transition: color .2s, opacity .2s; }
a:hover { opacity: .85; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Top controls ── */
.top-controls {
  position: fixed;
  top: 1rem;
  right: 1.2rem;
  z-index: 100;
  display: flex;
  gap: .5rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: all .3s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  overflow: hidden;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .3s, background .3s;
}

.switch input:checked + .switch-track {
  background: var(--accent-dim);
}

.switch input:checked + .switch-track::after {
  transform: translateX(22px);
  background: var(--accent);
}

.switch-track:hover::after {
  background: var(--accent);
}

.switch-icon { width: 14px; height: 14px; flex-shrink: 0; }

.switch-label {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-dim);
  font-size: .65rem;
}

/* ── Hero ── */
.hero {
  max-width: 860px;
  margin: 0 auto;
  padding: 4rem 2rem 2rem;
}

.hero-content { max-width: 700px; }

.hero h1 {
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: .25rem;
  letter-spacing: -.5px;
}

.hero .subtitle {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: .85rem;
  margin-bottom: .8rem;
  font-style: italic;
}

.hero .bio {
  color: var(--text);
  font-size: .9rem;
  max-width: 540px;
  margin-bottom: 1.2rem;
  line-height: 1.8;
}

.hero-links {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  transition: all .25s;
}

.link-icon { width: 14px; height: 14px; flex-shrink: 0; }

.hero-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  opacity: 1;
}

/* ── Terminal ── */
.terminal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  overflow: hidden;
  max-width: 520px;
  margin: 0 auto;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-dot { width: 10px; height: 10px; border-radius: 50%; }
.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #febc2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-body {
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.8;
  color: var(--text-dim);
}

.terminal-body .prompt { color: var(--green); }
.terminal-body .cmd { color: var(--text-bright); }
.terminal-body .output { color: var(--text-dim); }

.cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

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

/* ── Sections ── */
.section {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 2rem;
}

#terminal-section {
  max-width: 600px;
  padding: 2rem 2rem 3rem;
}

.section-title {
  font-family: var(--font-mono);
  font-size: .95rem;
  color: var(--text-bright);
  letter-spacing: 2px;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ── Timeline ── */
.timeline-item {
  position: relative;
  padding-left: 24px;
  margin-bottom: 2.5rem;
  border-left: 1px solid var(--border-subtle);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .3rem;
}

.timeline-role {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-bright);
}

.timeline-meta {
  font-size: .75rem;
  color: var(--text-dim);
  font-style: italic;
}

.timeline-company {
  font-size: .85rem;
  color: var(--accent);
  margin-bottom: .6rem;
}

.timeline-desc {
  color: var(--text);
  font-size: .85rem;
  line-height: 1.8;
}

.timeline-desc ul { list-style: none; padding: 0; }

.timeline-desc li {
  position: relative;
  padding-left: 1.1rem;
  margin-bottom: .35rem;
}

.timeline-desc li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: bold;
}

.timeline-desc b {
  color: var(--text-bright);
  font-weight: 600;
}

.timeline-links {
  margin-top: .6rem;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: 3px 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  transition: all .25s;
}

.tag-icon { width: 11px; height: 11px; flex-shrink: 0; }

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  opacity: 1;
}

.award-tag {
  background: rgba(250,204,21,0.06);
  border-color: rgba(250,204,21,0.2);
  color: #d4a017;
}

body.light .award-tag { color: #a07800; }

.award-tag:hover {
  background: rgba(250,204,21,0.15);
  border-color: rgba(250,204,21,0.4);
  color: #b8860b;
}

/* ── Education ── */
.edu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .8rem;
  transition: border-color .25s;
}

.edu-item:hover { border-color: var(--accent); }

.edu-degree { font-weight: 600; color: var(--text-bright); font-size: .9rem; }
.edu-school { color: var(--text-dim); font-size: .85rem; }

.edu-date {
  font-size: .75rem;
  color: var(--text-dim);
  text-align: right;
  font-style: italic;
}

/* ── Publications ── */
.pub-list {
  list-style: none;
  padding: 0;
}

.pub-list li {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .35rem 0;
  font-size: .85rem;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
}

.pub-list li:last-child { border-bottom: none; }

.pub-year {
  flex-shrink: 0;
  font-size: .72rem;
  color: var(--text-dim);
  min-width: 2.5rem;
  font-style: italic;
}

.pub-list li a { flex: 1; min-width: 0; }

.pub-venue {
  flex-shrink: 0;
  font-size: .7rem;
  color: var(--text-dim);
  margin-left: auto;
  font-style: italic;
}

.pub-list--2col {
  columns: 2;
  column-gap: 2rem;
}

.pub-list--2col li {
  break-inside: avoid;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 2.5rem 2rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-dim);
}

/* ── Animations ── */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s ease, transform .5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .top-controls { top: .5rem; right: .6rem; gap: .4rem; }
  .switch { width: 42px; height: 22px; }
  .switch-track::after { width: 16px; height: 16px; }
  .switch input:checked + .switch-track::after { transform: translateX(20px); }
  .switch-icon { width: 12px; height: 12px; }
  .switch-label { font-size: .55rem; }

  .hero { padding: 3rem 1.2rem 1rem; }
  .hero h1 { font-size: 1.3rem; margin-top: .5rem; }
  .hero .subtitle { font-size: .8rem; }
  .hero .bio { font-size: .82rem; }
  .hero-links { gap: .4rem; }
  .hero-links a { font-size: .75rem; padding: 5px 10px; }
  .link-icon { width: 12px; height: 12px; }

  .section { padding: 2rem 1.2rem; }
  .section-title { font-size: .7rem; margin-bottom: 1.5rem; }
  .timeline-header { flex-direction: column; }
  .timeline-role { font-size: .88rem; }
  .timeline-company { font-size: .78rem; }
  .timeline-desc, .timeline-desc li { font-size: .8rem; }
  .timeline-links { gap: .3rem; }
  .tag { font-size: .65rem; padding: 2px 6px; }

  .edu-item { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .edu-date { text-align: left; }

  .terminal { max-width: 100%; }
  .terminal-body { font-size: .72rem; padding: 12px 14px; }

  .pub-list--2col { columns: 1; }
}

/* ── Print ── */
@media print {
  * { color: #000 !important; background: #fff !important; box-shadow: none !important; border-color: #ddd !important; }
  .top-controls, .cursor, footer { display: none !important; }
  .hero { padding: 1rem 0; }
  .section { padding: 1rem 0; break-inside: avoid; }
  .fade-in { opacity: 1 !important; transform: none !important; }
  body { font-size: 11pt; line-height: 1.5; }
  a { text-decoration: underline; }
  .terminal { border: 1px solid #ddd; }
  .tag { border: 1px solid #ccc; }
}
