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

:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --bg-code: #f5f5f0;
  --text: #1c1917;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --border: #e7e5e4;
  --accent: #16a34a;
  --accent-dim: rgba(22,163,74,0.08);
  --red: #dc2626;
  --yellow: #ca8a04;
  --blue: #2563eb;
  --cursor-blink: blink 1s step-end infinite;
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --serif: 'Google Sans Text', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --radius: 8px;
}

body.dark {
  --bg: #0c0a09;
  --bg-card: #1c1917;
  --bg-code: #171412;
  --text: #fafaf9;
  --text-2: #a8a29e;
  --text-3: #78716c;
  --border: #292524;
  --accent: #4ade80;
  --accent-dim: rgba(74,222,128,0.1);
  --red: #f87171;
  --yellow: #facc15;
  --blue: #60a5fa;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

/* ── Animations ── */
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes fadeUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes typeIn { from{width:0} to{width:100%} }
@keyframes scanline { 0%{top:-100%} 100%{top:100%} }
@keyframes grain { 0%,100%{transform:translate(0)} 10%{transform:translate(-1%,-1%)} 30%{transform:translate(1%)} 50%{transform:translate(-1%,1%)} 70%{transform:translate(1%,-1%)} 90%{transform:translate(-1%)} }

/* ── Base ── */
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.015) 2px,
    rgba(0,0,0,0.015) 4px
  );
}

/* Grain texture */
body::before {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.5s steps(1) infinite;
}

.container {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Top Bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.3s, border-color 0.3s;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
}

.topbar-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: blink 2s ease-in-out infinite;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-nav a {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.topbar-nav a:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.theme-btn:hover { color: var(--text); border-color: var(--text-3); }
.theme-btn .moon { display: none; }
body.dark .theme-btn .moon { display: inline; }
body.dark .theme-btn .sun { display: none; }

/* ── Sections ── */
.section {
  padding: 56px 0;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.2s; }
.section:nth-child(5) { animation-delay: 0.25s; }
.section:nth-child(6) { animation-delay: 0.3s; }
.section:nth-child(7) { animation-delay: 0.35s; }

.section + .section {
  border-top: 1px solid var(--border);
}

.section-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head::before {
  content: '//';
  color: var(--text-3);
  font-weight: 400;
}

/* ── Hero ── */
.hero {
  padding: 80px 0 56px;
}

.hero-prompt {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-prompt .caret {
  color: var(--accent);
  font-weight: 700;
}

.hero-name {
  font-family: 'Google Sans Text', sans-serif;
  font-size: clamp(42px, 7vw, 64px);
  font-weight: 700;
  font-style: normal;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.hero-title {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.7;
  max-width: 560px;
  text-align: justify;
}

.hero-title .hl { color: var(--accent); font-weight: 500; }
.hero-title .hl-blue { color: var(--blue); font-weight: 500; }
.hero-title .hl-yellow { color: var(--yellow); font-weight: 500; }
.hero-title .hl-red { color: var(--red); font-weight: 500; }

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  background: var(--bg-code);
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: all 0.2s;
  cursor: default;
  letter-spacing: 0.02em;
}

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

/* ── Status Bar ── */
.status-bar {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.8;
}

.status-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.status-line .key {
  color: var(--text-3);
  min-width: 100px;
  flex-shrink: 0;
  text-align: right;
}

.status-line .val { color: var(--text); }
.status-line .val .g { color: var(--accent); }
.status-line .val .r { color: var(--red); }
.status-line .val .y { color: var(--yellow); }
.status-line .val .b { color: var(--blue); }

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

/* ── Experience ── */
.exp-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.exp-item:last-child { border-bottom: none; padding-bottom: 0; }
.exp-item:first-of-type { padding-top: 0; }

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 4px;
}

.exp-role {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.exp-date {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.exp-company {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 10px;
}

.exp-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.75;
  text-align: justify;
}

/* ── Projects ── */
.projects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 0;
  background: var(--accent);
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.project-card:hover::before { height: 100%; }

.project-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-name .arrow {
  font-size: 12px;
  color: var(--text-3);
  transition: transform 0.2s, color 0.2s;
}

.project-card:hover .arrow {
  transform: translate(2px, -2px);
  color: var(--accent);
}

.project-desc {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 14px;
  text-align: justify;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--bg-code);
  color: var(--text-3);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Research ── */
.research-item {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.research-item:last-child { border-bottom: none; padding-bottom: 0; }
.research-item:first-of-type { padding-top: 0; }

.research-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.research-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--border);
  transition: all 0.2s;
}
.research-title a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.research-venue {
  font-size: 12px;
  font-style: italic;
  color: var(--text-3);
  margin-bottom: 10px;
}

.research-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  text-align: justify;
}

/* ── Links ── */
.links-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all 0.2s;
}

.link-btn:hover {
  color: var(--text);
  border-color: var(--text-3);
  box-shadow: var(--shadow);
}

.link-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Command Palette Hint ── */
.cmd-hint {
  text-align: center;
  padding: 40px 0 48px;
  font-size: 12px;
  color: var(--text-3);
}

.cmd-hint kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: 0 1px 0 var(--border);
  margin: 0 2px;
}

/* ── Command Palette Modal ── */
.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.cmd-palette.open { display: flex; }

.cmd-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: fadeUp 0.2s ease;
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.cmd-input-wrap .prompt-icon {
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.cmd-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
}

.cmd-input::placeholder { color: var(--text-3); }

.cmd-results {
  max-height: 280px;
  overflow-y: auto;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.1s;
}

.cmd-item:hover, .cmd-item.active {
  background: var(--accent-dim);
  color: var(--text);
}

.cmd-item .cmd-label { flex: 1; }
.cmd-item .cmd-shortcut {
  font-size: 11px;
  color: var(--text-3);
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px 0 40px;
  font-size: 11px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}

.footer .heart { color: var(--red); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero { padding: 56px 0 40px; }
  .hero-name { font-size: 36px; }
  .section { padding: 40px 0; }
  .projects-grid { grid-template-columns: 1fr; }
  .exp-header { flex-direction: column; gap: 2px; }
  .exp-date { order: -1; }
  .status-line { flex-direction: column; gap: 2px; }
  .status-line .key { text-align: left; min-width: auto; }
  .topbar-nav a { padding: 6px 8px; font-size: 11px; }
  .cmd-hint { padding: 24px 0 36px; }
}

@media (max-width: 380px) {
  .container { padding: 0 16px; }
  .topbar { padding: 10px 16px; }
}
