:root {
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --muted-dark: #94a3b8;
  --accent: #2563eb;
  --border: #e2e8f0;
  --badge-bg: #f8fafc;
  --badge-border: #cbd5e1;
  --correct: #16a34a;
  --incorrect: #dc2626;
  --subtle: #cbd5e1;
  --yellow: #d97706;
  --sidebar-bg: #f8fafc;
}

[data-theme="dark"] {
  --bg: #090d16;
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-dark: #64748b;
  --accent: #00a3ff;
  --border: #131b2e;
  --badge-bg: #0d1526;
  --badge-border: #1e293b;
  --correct: #22c55e;
  --incorrect: #ef4444;
  --subtle: #334155;
  --yellow: #eab308;
  --sidebar-bg: #0d1322;
}

[data-theme="solarized"] {
  --bg: #fdf6e3;
  --text: #657b83;
  --muted: #93a1a1;
  --muted-dark: #b58900;
  --accent: #d33682;
  --border: #eee8d5;
  --badge-bg: #f5eef0;
  --badge-border: #cb4b16;
  --sidebar-bg: #f5eef0;
}

[data-theme="oled"] {
  --bg: #000000;
  --text: #ffffff;
  --muted: #94a3b8;
  --muted-dark: #475569;
  --accent: #38bdf8;
  --border: #1e293b;
  --badge-bg: #111827;
  --badge-border: #1f2937;
  --sidebar-bg: #0a0a0a;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
}

.site-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.brand-text h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.role-badge {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.nav-link.active, .nav-link:hover {
  color: var(--accent);
  background: var(--bg);
}

.cmd-kbd {
  margin-left: auto;
  font-size: 0.7rem;
  font-family: ui-monospace, monospace;
  background: var(--border);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 4px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.theme-btn {
  width: 100%;
  text-align: center;
}

.sidebar-status {
  width: 100%;
  justify-content: center;
}

.main-content {
  margin-left: 260px;
  flex: 1;
  max-width: 720px;
  padding: 40px 48px;
}

main {
  display: none;
}

main.active {
  display: block !important;
}

header { margin-bottom: 32px; }

h1 {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 12px;
}

.bio {
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 20px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--badge-bg);
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid var(--badge-border);
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--correct);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--correct);
}

.btn-action {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.drawer {
  display: none;
  background: var(--badge-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.drawer-row { display: flex; justify-content: space-between; margin-bottom: 8px; }

.drawer-exit {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: flex-end;
}

.drawer-exit-btn {
  color: var(--muted-dark);
  text-decoration: none;
  font-size: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: color 0.15s ease;
  cursor: pointer;
}

.drawer-exit-btn:hover { color: var(--incorrect); }

.game-box {
  display: none;
  background: var(--badge-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.game-exit-btn {
  background: none;
  border: none;
  color: var(--muted-dark);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}

.game-exit-btn:hover { color: var(--incorrect); }

#snake-board {
  background: #000;
  border: 1px solid var(--border);
  display: block;
  margin: 12px auto;
  border-radius: 6px;
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
  font-size: 0.85rem;
  line-height: 1.8;
}

.code-line {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.code-line:hover { background: rgba(0, 0, 0, 0.05); }

.game-feedback {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.typing-config {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  margin-bottom: 20px;
  color: var(--muted-dark);
}

.config-group { display: flex; gap: 12px; }
.config-opt { cursor: pointer; transition: color 0.15s; }
.config-opt.active { color: var(--yellow); font-weight: 600; }
.timer-display { font-size: 1rem; color: var(--yellow); font-weight: 600; }

.typing-words-wrapper {
  position: relative;
  font-size: 1.25rem;
  line-height: 1.8;
  height: 90px;
  overflow: hidden;
  margin-bottom: 16px;
  user-select: none;
}

.word { display: inline-block; margin-right: 12px; color: var(--subtle); }
.char { position: relative; transition: color 0.05s; }
.char.correct { color: var(--text); }
.char.incorrect { color: var(--incorrect); }

.caret {
  position: absolute;
  width: 2px;
  height: 1.2em;
  background: var(--yellow);
  animation: blink 1s infinite;
  transition: left 0.05s, top 0.05s;
  display: none;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.typing-hidden-input { position: absolute; opacity: 0; pointer-events: none; }

.results-card {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 10px;
}

.stat-block { display: flex; flex-direction: column; }
.stat-block .lbl { font-size: 1.1rem; color: var(--muted-dark); letter-spacing: 0.05em; }
.stat-block .val { font-size: 3.2rem; font-weight: 700; color: var(--yellow); line-height: 1.1; }

.res-type-text {
  color: var(--yellow);
  font-size: 0.9rem;
  margin-top: 8px;
}

.restart-btn {
  display: block;
  margin: 16px auto 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--yellow);
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

.section { margin-top: 40px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tag-filters { display: flex; gap: 6px; }
.tag-btn {
  background: none;
  border: none;
  color: var(--muted-dark);
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}
.tag-btn.active { color: var(--accent); background: var(--badge-bg); }

.project-list { display: flex; flex-direction: column; gap: 16px; }

.project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.project-item a { font-weight: 600; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.project-desc { font-size: 0.9rem; color: var(--muted-dark); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.article-item:hover { opacity: 0.85; }

.links { display: flex; gap: 18px; }
.links a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 1rem; }

footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding-top: 120px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  width: 90%;
  max-width: 520px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.modal-input {
  width: 100%;
  padding: 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}

.modal-list { list-style: none; max-height: 280px; overflow-y: auto; }
.modal-item {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-item:hover { background: var(--badge-bg); color: var(--accent); }

.modal-badge { opacity: 0.5; }

#matrix-canvas {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .site-wrapper {
    flex-direction: column;
  }
  .sidebar {
    position: relative;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 20px;
  }
  .main-content {
    margin-left: 0;
    padding: 24px;
    max-width: 100%;
  }
}