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

:root { --transition: 0.35s ease; }

[data-theme="dark"] {
  --bg: #1a1917;
  --surface: #23221f;
  --border: #33312c;
  --text: #e8e4dc;
  --muted: #8a857b;
  --accent: #9b6fd4;
  --hover: #2a2926;
  --scroll-thumb: #3d3a34;
}

[data-theme="light"] {
  --bg: #f4f1eb;
  --surface: #ece8e0;
  --border: #d4cfc6;
  --text: #1a1a1a;
  --muted: #7a756d;
  --accent: #7c4dba;
  --hover: #e4e0d7;
  --scroll-thumb: #c4bfb6;
}

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--text); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

.page {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
}

/* NAV */
nav {
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition);
  position: relative;
}

.logo { font-weight: 500; font-size: 14px; letter-spacing: -0.3px; }
.logo span { color: var(--accent); }

.nav-right { display: flex; align-items: center; gap: 24px; }

.theme-toggle {
  width: 28px;
  height: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

/* MOBILE TAB BAR (hidden on desktop) */
.mobile-tabbar { display: none; }

/* MAIN */
.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding: 28px 0;
  overflow: hidden;
  min-height: 0;
  align-items: center;
}

/* LEFT */
.left {
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}

.intro h1 {
  font-family: 'Newsreader', serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.8px;
  margin-bottom: 14px;
}

.intro h1 em { font-style: italic; color: var(--accent); }

.intro p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
  max-width: 400px;
}

/* CONTRIB */
.contrib-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 14px 16px;
  transition: all var(--transition);
}

/* INFO CARDS */
.bottom-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 11px 0;
}

.info-card { }

.section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin-bottom: 8px;
}

.info-card ul {
  list-style: none;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
}

.info-card ul li::before { content: "→ "; color: var(--accent); }

/* RIGHT — tabs */
.right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
}

/* TABS */
.tabs-bar {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  margin-bottom: 0;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 0 8px 0;
  margin-bottom: -1px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

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

.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.tab-panel::-webkit-scrollbar { width: 3px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
.tab-panel::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.tab-panel.active { display: flex; }

.projects-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.project {
  border-top: 1px solid var(--border);
  padding: 11px 6px;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.project:hover { background: var(--hover); }

.proj-num {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.35;
  min-width: 20px;
  flex-shrink: 0;
  padding-top: 1px;
}

.proj-info {
  flex: 1;
  min-width: 0;
}

.proj-status {
  font-size: 9px;
  padding: 0 5px;
  border-radius: 10px;
  border: 1px solid;
  margin-left: 7px;
  letter-spacing: 0.5px;
  vertical-align: middle;
  font-style: normal;
}
.proj-status.live { border-color: var(--accent); color: var(--accent); opacity: 0.8; }
.proj-status.wip  { border-color: var(--muted);  color: var(--muted);  opacity: 0.7; }
.proj-status.oss  { border-color: var(--border); color: var(--muted);  opacity: 0.7; }

.project h3 { font-size: 13px; font-weight: 500; margin-bottom: 2px; }

.project p { color: var(--muted); font-size: 11px; line-height: 1.45; }

.project .meta {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.project-link {
  color: var(--muted);
  font-size: 13px;
  transition: color 0.2s;
  text-decoration: none;
}

.project-link:hover { color: var(--accent); }

.tags { margin-top: 6px; }

.tag {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 3px;
  transition: border-color var(--transition);
}

/* WRITING */
.writing-wrap {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
}

.writing-row {
  border-top: 1px solid var(--border);
  padding: 9px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
}

.writing-row:hover { background: var(--hover); }

.write-date {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.55;
  flex-shrink: 0;
  min-width: 52px;
}

.write-title {
  flex: 1;
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s;
}

.writing-row:hover .write-title { color: var(--accent); }

/* READER */
#readerBack, #readerTitleBar, #readerMeta { display: none; }

.reader-open .logo,
.reader-open .nav-right { display: none; }

.reader-open #readerBack,
.reader-open #readerMeta { display: flex; }
.reader-open #readerTitleBar { display: block; }

.reader-open .main { display: none; }
.reader-open .reader-content-area { display: block; }

#readerBack {
  background: none;
  border: none;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
  padding: 0;
  height: 28px;
  align-items: center;
}
#readerBack:hover { color: var(--accent); }

#readerMeta {
  height: 28px;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

#readerTitleBar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
  pointer-events: none;
}

.reader-content-area {
  display: none;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.reader-content-area::-webkit-scrollbar { width: 3px; }
.reader-content-area::-webkit-scrollbar-track { background: transparent; }
.reader-content-area::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }
.reader-content-area::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.reader-body {
  padding: 40px 0 40px;
  font-family: 'Newsreader', serif;
}

.reader-body > h1 {
  font-size: 30px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 36px;
  color: var(--text);
}

.reader-body h2 {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text);
  margin: 36px 0 14px;
}

.reader-body h3 {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin: 24px 0 10px;
}

.reader-body p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 18px;
  opacity: 0.88;
}

.reader-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.reader-body ul,
.reader-body ol {
  padding-left: 22px;
  margin-bottom: 18px;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  opacity: 0.88;
}
.reader-body li { margin-bottom: 6px; }

.reader-body strong { color: var(--text); font-weight: 500; opacity: 1; }

.reader-body .code-block {
  position: relative;
  margin: 20px 0;
}

.reader-body .code-block pre {
  margin: 0;
}

.copy-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.6;
}
.copy-btn:hover { color: var(--text); border-color: var(--muted); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

.reader-body pre {
  font-family: 'DM Mono', monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 12px;
  line-height: 1.65;
}

.reader-body :not(pre) > code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

.reader-body img {
  max-width: 100%;
  border-radius: 5px;
  margin: 20px 0;
  display: block;
  border: 1px solid var(--border);
}

.reader-body blockquote {
  border-left: 2px solid var(--accent);
  margin: 20px 0;
  padding: 0 0 0 18px;
  font-style: italic;
  color: var(--muted);
}

.reader-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* Pygments syntax colors */
.reader-body .highlight { background: none; }
.reader-body .highlight .k,
.reader-body .highlight .kd,
.reader-body .highlight .kn,
.reader-body .highlight .kp,
.reader-body .highlight .kr,
.reader-body .highlight .kt { color: var(--accent); }
.reader-body .highlight .s,
.reader-body .highlight .s1,
.reader-body .highlight .s2,
.reader-body .highlight .sb { color: #9fbf78; }
.reader-body .highlight .c,
.reader-body .highlight .c1,
.reader-body .highlight .cm { color: var(--muted); font-style: italic; }
.reader-body .highlight .mi,
.reader-body .highlight .mf { color: #e8a87c; }
.reader-body .highlight .n,
.reader-body .highlight .nn { color: var(--text); }
.reader-body .highlight .p { color: var(--muted); }

/* FOOTER */
footer {
  padding: 14px 0;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color var(--transition);
}

.footer-links { 
  display: flex; 
  gap: 16px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.footer-links a { 
  color: var(--muted); 
  font-size: 11px; 
}

.clock { font-variant-numeric: tabular-nums; }

@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  .page {
    height: auto;
    min-height: 100vh;
    padding: 0 20px;
  }

  /* Mobile tab bar */
  .mobile-tabbar {
    display: flex;
    justify-content: center;
    gap: 28px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding-top: 16px;
  }

  .m-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0 0 8px 0;
    margin-bottom: -1px;
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
  }
  .m-tab:hover { color: var(--text); }
  .m-tab.active { color: var(--text); border-bottom-color: var(--accent); }

  /* Main collapses — panels controlled by JS class on .main */
  .main {
    display: block;
    padding: 0;
    overflow: visible;
  }

  /* Left = about panel (visible by default) */
  .main .left {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 0 24px;
    justify-content: flex-start;
  }

  /* Right panel hidden by default; shown for projects/blog */
  .main .right {
    display: none;
    flex-direction: column;
    max-height: none;
    padding: 20px 0 24px;
  }

  .main.m-projects .left,
  .main.m-blog .left { display: none; }

  .main.m-projects .right,
  .main.m-blog .right { display: flex; }

  /* Hide the desktop projects/blog tab bar — mobile tabbar handles it */
  .right .tabs-bar { display: none; }

  /* Tab panels scroll with page */
  .tab-panel { overflow-y: visible; padding-right: 0; }

  .intro h1 { font-size: 26px; }

  .project { padding: 12px 4px; }

  .writing-row { padding: 10px 4px; }

  .bottom-cards { grid-template-columns: 1fr; gap: 14px; }

  #readerTitleBar {
    max-width: 38%;
    font-size: 12px;
  }

  .footer-links {
    position: static;
    transform: none;
  }

  footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 24px;
  }
}
