:root {
  --bg: #141413;
  --text: #E8E6DF;
  --text-secondary: #9C9A92;
  --accent: #6DBF64;
  --accent-2: #4FB8A6;
  --accent-light: #1E2E1C;
  --glow: rgba(109, 191, 100, 0.13);
  --border: #2C2C2A;
  --card-bg: #1C1C1A;
  --max-width: 680px;
}

html.light {
  --bg: #FAFAF8;
  --text: #1A1A18;
  --text-secondary: #6B6B63;
  --accent: #2D5A27;
  --accent-2: #1F6E63;
  --accent-light: #E8F0E7;
  --glow: rgba(45, 90, 39, 0.10);
  --border: #E2E2DC;
  --card-bg: #FFFFFF;
}

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

html { scrollbar-gutter: stable; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

body::before {
  content: '';
  position: fixed;
  top: -260px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 560px;
  background: radial-gradient(ellipse at center, var(--glow), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.container { position: relative; z-index: 1; }

.theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, border-color 0.3s, transform 0.2s;
  z-index: 100;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: scale(1.1) rotate(20deg);
  box-shadow: 0 4px 18px var(--glow);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html.light .theme-toggle .icon-sun { display: block; }
html.light .theme-toggle .icon-moon { display: none; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 24px 120px;
}

header {
  margin-bottom: 72px;
  animation: fadeUp 0.6s ease both;
}

header h1 {
  font-family: 'Newsreader', serif;
  font-weight: 500;
  font-size: 2.6rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
  color: var(--text);
}

header h1 .name-accent { color: var(--accent); }

.tagline {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

header p {
  font-family: 'Newsreader', serif;
  font-size: 1.12rem;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 560px;
  line-height: 1.8;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  gap: 30px;
  margin-bottom: 44px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp 0.6s ease 0.15s both;
}

.tab {
  position: relative;
  padding: 8px 2px 15px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.25s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }

.tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 1px;
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeUp 0.5s ease both;
}

/* ---- PROJECTS ---- */
.projects {
  margin-bottom: 8px;
}

.projects-label,
.articles-label,
.section-label {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 28px;
}

.projects-label::after,
.articles-label::after,
.section-label::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2) 40%, transparent);
  opacity: 0.4;
  border-radius: 1px;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 14px;
}

.project-tile {
  display: flex;
  align-items: center;
  gap: 15px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.25s ease, background 0.3s;
}

.project-tile:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px var(--glow);
}

.project-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px var(--glow);
  transition: transform 0.25s ease;
}

.project-tile:hover .project-icon {
  transform: scale(1.1) rotate(-5deg);
}

.project-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-name {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.project-name svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s ease;
}

.project-tile:hover .project-name svg {
  transform: translate(2px, -2px);
}

.project-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.project-tile.placeholder {
  background: transparent;
  border-style: dashed;
  border-width: 1.5px;
  justify-content: center;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.project-tile.placeholder:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

/* ---- ABOUT ---- */
.about-block { margin-bottom: 48px; }
.about-block:last-child { margin-bottom: 0; }

.about-intro {
  font-family: 'Newsreader', serif;
  font-size: 1.12rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.8;
}

.hobbies {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hobby {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.3s, transform 0.25s ease, box-shadow 0.3s;
}

.hobby:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--glow);
}

.hobby .emoji {
  font-size: 1.15rem;
  line-height: 1;
}

.timeline { padding-left: 2px; }

.entry {
  position: relative;
  padding-left: 26px;
  padding-bottom: 26px;
  border-left: 1.5px solid var(--border);
}

.entry:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.entry::before {
  content: '';
  position: absolute;
  left: -6.5px;
  top: 5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px var(--bg);
}

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.entry-role {
  font-size: 0.98rem;
  font-weight: 600;
}

.entry-company { color: var(--accent); }

.entry-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.entry-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-top: 5px;
}

/* ---- COLLAPSIBLE ARTICLES ---- */
article {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 20px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.25s ease, background 0.3s;
  overflow: hidden;
}

article:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--glow);
}

.article-header {
  padding: 32px 32px 0;
}

article h2 {
  font-family: 'Newsreader', serif;
  font-weight: 500;
  font-size: 1.3rem;
  line-height: 1.35;
  margin-bottom: 6px;
}

article .date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.article-preview {
  padding: 0 32px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.article-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease, opacity 0.4s ease;
  opacity: 0;
}

.article-body.expanded {
  /* max-height is set inline by JS to the actual content height so long
     articles never get clipped, on any viewport. */
  opacity: 1;
}

.article-body-inner {
  padding: 12px 32px 0;
}

.article-body-inner p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 12px;
}

.article-body-inner p:last-of-type {
  margin-bottom: 0;
}

.article-body-inner .takeaway {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
}

.article-body-inner .paper-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1.5px solid var(--border);
  transition: border-color 0.25s;
}

.article-body-inner .paper-link:hover {
  border-color: var(--accent);
}

.article-body-inner .tech-used {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
}

.article-body-inner h3 {
  font-family: 'Newsreader', serif;
  font-weight: 500;
  font-size: 1.05rem;
  color: var(--text);
  margin: 22px 0 6px;
}

.article-body-inner pre {
  margin: 14px 0;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}

.article-body-inner pre code {
  font-family: 'Consolas', 'SF Mono', 'Menlo', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
}

.article-body-inner :not(pre) > code {
  font-family: 'Consolas', 'SF Mono', 'Menlo', monospace;
  font-size: 0.85em;
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
}

.read-toggle {
  display: inline-block;
  padding: 16px 32px 28px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  border: none;
  background: none;
  font-family: 'DM Sans', sans-serif;
  transition: opacity 0.2s;
}

.read-toggle:hover {
  opacity: 0.7;
}

.read-toggle .arrow {
  display: inline-block;
  transition: transform 0.3s ease;
  margin-left: 4px;
}

.read-toggle.expanded .arrow {
  transform: rotate(180deg);
}

/* ---- DIAGRAMS ---- */
.diagram-container {
  margin: 20px 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 8px;
}

.diagram-container svg text {
  font-family: 'DM Sans', sans-serif;
}

.diagram-container svg .box-label {
  font-size: 12px;
  font-weight: 500;
  fill: var(--text);
}

.diagram-container svg .box-sub {
  font-size: 10.5px;
  fill: var(--text-secondary);
}

.diagram-container svg .annotation {
  font-size: 10.5px;
  font-weight: 500;
}

/* Dark mode diagram overrides */
.diagram-container svg .box-blue { fill: #1A2E3D; stroke: #2A5070; }
.diagram-container svg .box-green { fill: #1A2D1A; stroke: #2D5A27; }
.diagram-container svg .box-gray { fill: #252523; stroke: #444441; }
.diagram-container svg .box-red { fill: #2D1616; stroke: #6B2A2A; }
.diagram-container svg .box-purple { fill: #221F38; stroke: #4A4580; }
.diagram-container svg .box-green-light { fill: #1A2D1A; stroke: #3B6D11; }
html.light .diagram-container svg .box-blue { fill: #E6F1FB; stroke: #85B7EB; }
html.light .diagram-container svg .box-green { fill: #E1F5EE; stroke: #5DCAA5; }
html.light .diagram-container svg .box-gray { fill: #F1EFE8; stroke: #B4B2A9; }
html.light .diagram-container svg .box-red { fill: #FCEBEB; stroke: #F09595; }
html.light .diagram-container svg .box-purple { fill: #EEEDFE; stroke: #AFA9EC; }
html.light .diagram-container svg .box-green-light { fill: #EAF3DE; stroke: #97C459; }

/* ---- FOOTER ---- */
footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  animation: fadeUp 0.6s ease 0.4s both;
}

footer .links {
  display: flex;
  gap: 20px;
}

footer a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 1.5px solid var(--border);
  transition: border-color 0.25s;
}

footer a:hover {
  border-color: var(--accent);
}

footer .colophon {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 600px) {
  .container { padding: 48px 20px 80px; }
  header h1 { font-size: 2rem; }
  header { margin-bottom: 48px; }
  .tabs { gap: 22px; }
  .project-grid { grid-template-columns: 1fr; }
  .article-header { padding: 24px 24px 0; }
  .article-preview { padding: 0 24px; }
  .article-body-inner { padding: 12px 24px 0; }
  .read-toggle { padding: 16px 24px 24px; }
}
