:root {
  --bg-page: #f4f1ea;
  --bg-grid: rgba(28, 25, 23, 0.045);
  --bg-surface: #fcfaf6;
  --bg-surface-alt: #f0ece1;
  --text-main: #1c1917;
  --text-body: #44403c;
  --text-muted: #78716c;
  --border-strong: #d6d0c4;
  --border-subtle: #e7e2d8;
  --shadow-card: 0 2px 0 #d6d0c4, 0 8px 20px -8px rgba(28, 25, 23, 0.08);
  --shadow-card-hover: 0 4px 0 #c7bfb0, 0 14px 28px -10px rgba(28, 25, 23, 0.14);
  --mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, Cambria, "Times New Roman", Times, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #0c0e12;
    --bg-grid: rgba(255, 255, 255, 0.035);
    --bg-surface: #13171f;
    --bg-surface-alt: #191f2a;
    --text-main: #f3f1ec;
    --text-body: #b8bfc9;
    --text-muted: #76808f;
    --border-strong: #28303f;
    --border-subtle: #1e2531;
    --shadow-card: 0 2px 0 #07080a, 0 10px 24px -8px rgba(0, 0, 0, 0.5);
    --shadow-card-hover: 0 4px 0 #07080a, 0 16px 32px -8px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  --bg-page: #0c0e12;
  --bg-grid: rgba(255, 255, 255, 0.035);
  --bg-surface: #13171f;
  --bg-surface-alt: #191f2a;
  --text-main: #f3f1ec;
  --text-body: #b8bfc9;
  --text-muted: #76808f;
  --border-strong: #28303f;
  --border-subtle: #1e2531;
  --shadow-card: 0 2px 0 #07080a, 0 10px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 4px 0 #07080a, 0 16px 32px -8px rgba(0, 0, 0, 0.7);
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-page);
  background-image: radial-gradient(var(--bg-grid) 1px, transparent 1px);
  background-size: 20px 20px;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Masthead */
header {
  padding: 2.5rem 0 1.75rem;
}

.masthead-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--text-main);
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.est-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.est-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-body);
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  box-shadow: 0 1px 0 var(--border-strong);
  transition: transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Bilingual Intro Ribbon */
.masthead-intro {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.92rem;
  color: var(--text-body);
}

.intro-col {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
}

.intro-col p {
  margin: 0;
}

.lang-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.42rem;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-alt);
  color: var(--text-main);
  flex-shrink: 0;
}

/* Main Project List */
main {
  flex: 1;
  padding: 1.5rem 0 3.5rem;
}

.projects-list {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

/* Individual Project Showcase */
.project-item {
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  overflow: hidden;
}

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

/* Per-project accents */
.project-sites {
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
}

.project-tools {
  --accent: #0d9488;
  --accent-soft: rgba(13, 148, 136, 0.12);
}

.project-winterdrake {
  --accent: #e11d48;
  --accent-soft: rgba(225, 29, 72, 0.12);
}

.project-fng {
  --accent: #7c3aed;
  --accent-soft: rgba(124, 58, 237, 0.12);
}

.project-zurgl {
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.12);
}

.project-blagtron {
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.13);
}

.project-twokeys {
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
}

.project-qwertydash {
  --accent: #0891b2;
  --accent-soft: rgba(8, 145, 178, 0.12);
}

.project-wushuexpert {
  --accent: #b91c1c;
  --accent-soft: rgba(185, 28, 28, 0.12);
}

/* Top Meta Bar inside each project */
.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.7rem 1.35rem;
  background: var(--bg-surface-alt);
  border-bottom: 1px solid var(--border-subtle);
}

.project-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.project-icon {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.project-icon svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.domain-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.domain-pill {
  color: var(--text-main);
  text-decoration: none;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.domain-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.domain-sep {
  color: var(--text-muted);
}

.project-kind {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* Bilingual Columns inside each project */
.project-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.lang-pane {
  padding: 1.25rem 1.4rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lang-pane+.lang-pane {
  border-left: 1px dashed var(--border-strong);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pane-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.3;
}

.pane-title a {
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.pane-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pane-lang {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.pane-desc {
  margin: 0;
  color: var(--text-body);
  font-size: 0.96rem;
}

.pane-desc a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pane-desc a:hover {
  text-decoration-thickness: 2px;
}

/* Footer */
footer {
  border-top: 1px solid var(--border-strong);
  padding: 1.75rem 0 2.25rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

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

footer a:hover {
  text-decoration: underline;
}

/* Mobile Layout */
@media (max-width: 760px) {
  header {
    padding: 1.75rem 0 1.25rem;
  }

  .masthead-intro {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .project-body {
    grid-template-columns: 1fr;
  }

  .lang-pane+.lang-pane {
    border-left: none;
    border-top: 1px dashed var(--border-strong);
  }

  .project-meta {
    padding: 0.65rem 1.1rem;
  }

  .lang-pane {
    padding: 1.1rem 1.15rem;
  }
}

.theme-icon-hidden {
  display: none;
}
