:root {
  --bg: #111318;
  --panel: #171a21;
  --fg: #f2f0e9;
  --muted: #a6a99f;
  --accent: #6ee7b7;
  --border: #262a34;
  --maxw: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

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

a:hover { text-decoration: underline; }

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
}

nav .brand {
  color: var(--fg);
  font-weight: 700;
}

nav .brand:hover { text-decoration: none; }

nav .links {
  display: flex;
  gap: 1.25rem;
}

nav .links a {
  color: var(--muted);
  font-size: 0.95rem;
}

nav a.active { color: var(--accent); }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

h1, h2, h3 {
  line-height: 1.2;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

p { color: var(--fg); }
.muted { color: var(--muted); }
.dot { color: var(--accent); }

.home-intro {
  max-width: 680px;
  padding: 2.5rem 0 3rem;
}

.home-intro h1 {
  margin-bottom: 1.5rem;
  font-size: clamp(2.4rem, 6vw, 3.25rem);
  letter-spacing: -0.035em;
}

.home-intro p { margin: 0 0 1rem; }

.home-contact {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.home-contact h2 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.home-contact ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-contact li { margin: 0.1rem 0; }

.home-contact li span {
  display: inline-block;
  min-width: 4.9rem;
  color: var(--muted);
}

.home-feedback {
  padding-top: 0.75rem;
  font-size: 0.9rem;
}

.projects-header { margin-bottom: 2.5rem; }

.project-sections { border-top: 1px solid var(--border); }

.project-section {
  padding: 1.75rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.project-section h2 { margin: 0 0 1.25rem; }

.project-list {
  display: grid;
  gap: 1.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-item h3 {
  margin: 0;
  font-size: 1.05rem;
}

.project-item p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.project-item ul {
  margin: 0.6rem 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.profile {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.profile img {
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  object-fit: cover;
}

.cv-section {
  margin-top: 3rem;
}

.feedback-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 2.5rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.feedback-card h2,
.feedback-card p {
  margin: 0;
}

.feedback-card p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.feedback-card > a {
  flex: none;
}

.cv-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.cv-heading h2 { margin-bottom: 0.75rem; }

.cv-viewer {
  display: block;
  width: 100%;
  height: min(78vh, 960px);
  min-height: 620px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.page-header { margin-bottom: 2rem; }

.post-feed {
  display: grid;
  gap: 4rem;
}

.feed-post {
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--border);
}

.feed-post:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.post-header {
  margin-bottom: 1.5rem;
}

.post-header h1,
.post-header h2 {
  margin: 0 0 0.35rem;
}

.post-header h2 { font-size: 1.8rem; }
.post-header h2 a { color: var(--fg); }

.post-header time {
  color: var(--muted);
  font-size: 0.9rem;
}

.post-content h2 {
  margin-top: 2rem;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.post-content pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.post-content code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--panel);
  font-size: 0.9em;
}

.post-content pre code {
  padding: 0;
  background: none;
}

.post-content blockquote {
  margin: 1rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.post-note {
  margin: 1.5rem 0 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.post-note summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.post-note summary::-webkit-details-marker { display: none; }

.post-note summary::after {
  color: var(--muted);
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
}

.post-note[open] summary { border-bottom: 1px solid var(--border); }

.post-note[open] summary::after { content: "−"; }

.post-note-body { padding: 0.25rem 1rem 1rem; }

.post-note-body > :last-child { margin-bottom: 0; }

.key-question {
  margin: 1.75rem 0;
  padding: 1rem 1.15rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--panel);
  color: var(--fg);
}

.scl-tigers {
  display: block;
  width: min(100%, 400px);
  margin: 1rem auto 1.5rem;
}

.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.post-permalink,
.back-link,
.feedback-link {
  display: inline-block;
  color: var(--muted);
  font-size: 0.9rem;
}

footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.correspondence-header {
  max-width: 620px;
  margin-bottom: 3.5rem;
}

.resource-section {
  margin-bottom: 4rem;
}

.resource-section h2,
.section-header h2 {
  margin: 0;
}

.download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
}

.download-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.download-title,
.download-meta {
  display: block;
}

.download-title {
  color: var(--accent);
  font-weight: 700;
}

.download-meta {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.download-action {
  flex: none;
  color: var(--accent);
  font-size: 0.88rem;
}

.section-header {
  margin-bottom: 1.25rem;
}

.section-header p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.references-section {
  margin-top: 4rem;
}

.references-section h2 {
  margin-bottom: 1rem;
}

.reference-list {
  display: grid;
  gap: 0.8rem;
  margin: 0;
  padding-left: 1.25rem;
}

.reference-list li {
  padding-left: 0.25rem;
  color: var(--muted);
}

.message-list {
  border-top: 1px solid var(--border);
}

.message {
  border-bottom: 1px solid var(--border);
}

.message summary {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto 1rem;
  gap: 1rem;
  align-items: center;
  padding: 1.4rem 0;
  cursor: pointer;
  list-style: none;
}

.message summary::-webkit-details-marker { display: none; }

.message summary:hover .message-author { color: var(--accent); }

.message summary:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.message-number,
.message time {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}

.message-heading {
  display: grid;
  gap: 0.15rem;
}

.message-author {
  color: var(--fg);
  font-weight: 700;
  transition: color 120ms ease;
}

.message-subject {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-toggle {
  position: relative;
  width: 1rem;
  height: 1rem;
}

.message-toggle::before,
.message-toggle::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.75rem;
  height: 1px;
  background: var(--accent);
  content: "";
  transform: translate(-50%, -50%);
  transition: transform 160ms ease;
}

.message-toggle::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.message[open] .message-toggle::after {
  transform: translate(-50%, -50%) rotate(0deg);
}

.message-body {
  max-width: 650px;
  padding: 0 0 2.5rem 3rem;
}

.message-body p:first-child { margin-top: 0; }

.message-body p {
  margin: 0 0 1.25rem;
}

.math {
  white-space: nowrap;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

.signature {
  margin-top: 2rem;
}

.signature p { margin-bottom: 0.75rem; }

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

  .feedback-card,
  .post-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .cv-viewer {
    height: 70vh;
    min-height: 480px;
  }

  .correspondence-header { margin-bottom: 2.5rem; }

  .resource-section { margin-bottom: 3rem; }

  .download-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .message summary {
    grid-template-columns: 1.6rem minmax(0, 1fr) 1rem;
    gap: 0.75rem;
  }

  .message time {
    grid-column: 2;
    grid-row: 2;
  }

  .message-toggle {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .message-body { padding-left: 2.35rem; }
}
