:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-hover: #1d2130;
  --border: #2a2f3d;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-dim: #274a86;
  --mono: "SF Mono", "Fira Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-links { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.nav-links a { color: var(--muted); font-size: 13.5px; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.menu-btn { display: none; }

main { max-width: 900px; margin: 0 auto; padding: 0 20px 60px 20px; }

.hero {
  padding: 72px 0 48px 0;
  text-align: left;
}
.hero h1 { font-size: 40px; margin: 0 0 8px 0; }
.tagline { color: var(--accent); font-size: 16px; margin: 0 0 14px 0; }
.hero-sub { color: var(--muted); max-width: 560px; margin: 0 0 26px 0; }
.hero-links { display: flex; gap: 10px; flex-wrap: wrap; }

.page-header { padding: 48px 0 32px 0; }
.page-header h1 { font-size: 28px; margin: 0 0 8px 0; }
.page-header .section-sub { margin: 0; }

.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #0b0e14; }
.btn-primary:hover { background: #6b9dff; }
.btn-secondary { background: var(--panel); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--panel-hover); }
.btn-outline { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-dim); }

.section { padding: 44px 0; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: none; }
.section h2 { font-size: 22px; margin: 0 0 6px 0; }
.section-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px 0; }

.skills { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.skill-label { color: var(--text); font-weight: 600; margin-right: 8px; }

.demo-grid, .project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}
.featured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 360px));
  justify-content: center;
  gap: 20px;
  align-items: start;
  margin-bottom: 14px;
}
/* Featured cards (CodeBreaker, Taylor-Line) show their media beside the
   text instead of stacked above it -- the media element spans the full
   height of the card in column 1, everything else flows in column 2. */
.featured-grid .project-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  column-gap: 14px;
  row-gap: 4px;
}
.featured-grid .project-card .repo-media {
  grid-column: 1;
  grid-row: 1 / span 8;
  margin-bottom: 0;
  align-self: start;
}
.featured-grid .project-card > *:not(.repo-media) {
  grid-column: 2;
}
@media (max-width: 640px) {
  .featured-grid { grid-template-columns: minmax(0, 320px); }
  .featured-grid .project-card { grid-template-columns: 108px 1fr; }
}
.demo-card, .project-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  color: var(--text);
  cursor: pointer;
}
.demo-card:hover, .project-card:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
  text-decoration: none;
}
.demo-card:focus-visible, .project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.repo-links a { position: relative; z-index: 1; }
.demo-card h3, .project-card h3 { margin: 0 0 8px 0; font-size: 15px; }
.demo-card p, .project-card p { margin: 0; color: var(--muted); font-size: 13px; }
.demo-open { display: inline-block; margin-top: 10px; color: var(--accent); font-size: 12.5px; }
.card-tags { margin-bottom: 2px; }
.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.badge-wip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #ffcf6b;
  background: #3a2f10;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  margin-bottom: 8px;
}
.repo-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.repo-media img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}
.repo-meta {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
  font-family: var(--mono);
}
.repo-links { margin-top: 10px; display: flex; gap: 12px; }
.repo-links a { font-size: 12px; }

.filter-input {
  width: 100%;
  max-width: 340px;
  font-family: var(--sans);
  font-size: 13.5px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  margin-bottom: 20px;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

.state-msg { color: var(--muted); font-size: 13.5px; padding: 20px 0; }
.state-msg.error { color: #ff8a8a; }

.ask-box { display: flex; gap: 8px; flex-wrap: wrap; }
#askInput {
  flex: 1 1 320px;
  font-family: var(--sans);
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
}
#askInput:focus { outline: none; border-color: var(--accent); }
.ask-results { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.ask-result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.ask-result .ask-source {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 6px;
  display: block;
}
.ask-result p { margin: 0; font-size: 13.5px; color: var(--text); }
.ask-empty { color: var(--muted); font-size: 13.5px; }

.contact-section { padding-bottom: 20px; }
.contact-social { display: flex; gap: 10px; margin: 16px 0 4px 0; }
.site-footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12.5px;
}
.footer-social { display: flex; justify-content: center; gap: 10px; margin-bottom: 12px; }

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 15, 0.7);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.search-overlay.hidden { display: none; }
.search-box {
  width: min(560px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
#searchInput {
  width: 100%;
  font-family: var(--sans);
  font-size: 15px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 16px 18px;
}
#searchInput:focus { outline: none; }
.search-results { max-height: 300px; overflow-y: auto; }
.search-result-item {
  display: block;
  padding: 11px 18px;
  color: var(--text);
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result-item:hover, .search-result-item.active { background: var(--panel-hover); text-decoration: none; }
.search-result-item .srch-label { color: var(--muted); font-size: 11.5px; display: block; margin-top: 2px; }

@media (max-width: 560px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    gap: 14px;
    z-index: 30;
  }
  .nav-links.open { display: flex; }
  .nav-links a { font-size: 14px; }
  .menu-btn { display: flex; }
  .hero h1 { font-size: 32px; }
}

/* ---------- Repo detail modal (README + file browser + code viewer) ---------- */
.repo-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.repo-modal.hidden { display: none; }
.repo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 7, 10, 0.75);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.repo-modal.open .repo-modal-backdrop { opacity: 1; }
.repo-modal-panel {
  position: relative;
  width: min(1100px, 100%);
  height: min(820px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.94);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.repo-modal.open .repo-modal-panel { transform: scale(1); opacity: 1; }
.repo-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.repo-modal-header h2 { margin: 0 0 4px 0; font-size: 18px; }
.repo-modal-meta { margin: 0 0 6px 0; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.repo-modal-description { margin: 0; color: var(--muted); font-size: 13px; max-width: 560px; }
.repo-modal-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.repo-modal-body { flex: 1; display: flex; min-height: 0; }
.repo-modal-tree {
  width: 240px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 14px;
  font-size: 12.5px;
  font-family: var(--mono);
}
.repo-modal-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.repo-modal-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.repo-modal-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  font-family: var(--sans);
}
.repo-modal-tab:hover { color: var(--text); }
.repo-modal-tab.active { color: var(--text); background: var(--bg); }
.repo-modal-readme, .repo-modal-file { flex: 1; overflow: auto; padding: 20px 24px; margin: 0; }
.repo-modal-file { font-family: var(--mono); font-size: 12.5px; background: var(--bg); }
.repo-modal-file pre { margin: 0; white-space: pre; }

.repo-tree-list { list-style: none; margin: 0; padding-left: 14px; }
.repo-modal-tree > .repo-tree-list { padding-left: 0; }
.repo-tree-dir summary { cursor: pointer; color: var(--text); padding: 3px 0; }
.repo-tree-dir summary:hover { color: var(--accent); }
.repo-tree-file {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 3px 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12.5px;
}
.repo-tree-file:hover { color: var(--accent); }

.markdown-body h1, .markdown-body h2, .markdown-body h3 { color: var(--text); }
.markdown-body p, .markdown-body li { color: var(--text); font-size: 14px; }
.markdown-body a { color: var(--accent); }
.markdown-body pre { background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto; }
.markdown-body code { font-family: var(--mono); font-size: 12.5px; }
.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13px; }

@media (max-width: 720px) {
  .repo-modal { padding: 0; }
  .repo-modal-panel { border-radius: 0; }
  .repo-modal-body { flex-direction: column; }
  .repo-modal-tree { width: 100%; max-height: 140px; border-right: none; border-bottom: 1px solid var(--border); }
}
