:root {
  --bg: #0b0f14;
  --bg-soft: #11161d;
  --bg-side: #070b11;   /* sidebar shade, darker than the page */
  --border: #1e2630;
  --text: #d6dde6;
  --muted: #7d8894;
  --heading: #eef3f8;
  --accent: #89cff0;        /* baby blue */
  --accent-dim: #5fa8cc;
  --accent-bg: rgba(137, 207, 240, 0.08);
}

/* light theme (toggled via the sidebar switch) */
[data-theme="light"] {
  --bg: #f2f5f9;
  --bg-soft: #e6edf4;
  --border: #cfdae5;
  --text: #333e4c;
  --muted: #64707e;
  --heading: #16212e;
  --accent: #1f7fb5;
  --accent-dim: #4a9cc9;
  --accent-bg: rgba(31, 127, 181, 0.08);
}

/* the sidebar keeps its dark identity in light mode */
[data-theme="light"] .sidebar {
  --bg-soft: #11161d;
  --border: #1e2630;
  --text: #d6dde6;
  --muted: #7d8894;
  --heading: #eef3f8;
  --accent: #89cff0;
  --accent-dim: #5fa8cc;
  --accent-bg: rgba(137, 207, 240, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.7;
}

/* --- layout: sidebar pinned left, content centered in the rest --- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(5,8,12,.35) 0%, rgba(5,8,12,.78) 34%, rgba(5,8,12,.90) 60%, rgba(5,8,12,.60) 100%),
    url("/static/dc.svg") center / cover no-repeat,
    var(--bg-side);
}
.sb-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  padding: 4.5rem 1.4rem 1.4rem;
  min-height: 100vh;
}

.content {
  flex: 1;
  min-width: 0;
  position: relative;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

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

h1, h2, h3 { color: var(--heading); line-height: 1.3; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; margin-top: 2.5rem; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }

/* section headers: icon + label + dashed rule, terminal style */
.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent);
}
h2, .page-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
h2::after, .page-title::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--border);
  margin-left: 0.5rem;
}
.page-title .ico { width: 22px; height: 22px; }

/* --- sidebar pieces --- */
.avatar {
  width: 175px;
  height: 175px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-dim);
  box-shadow: 0 0 0 5px rgba(137, 207, 240, 0.10), 0 8px 32px rgba(0, 0, 0, 0.55);
}
.avatar.small { width: 80px; height: 80px; }
.avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  color: var(--accent);
  font-size: 3rem;
  font-weight: 700;
}
.avatar.small.placeholder { font-size: 1.8rem; }

.sidebar .brand {
  color: var(--accent);
  font-weight: 700;
  margin: 1rem 0 0.1rem 0;
  font-size: 0.95rem;
}
.sidebar .brand .cursor { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.side-title {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  margin-top: 2.6rem;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.65rem 1.1rem;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
}
.side-nav a .ico { width: 18px; height: 18px; color: currentColor; }
.side-nav a:hover {
  color: var(--text);
  background: rgba(137, 207, 240, 0.05);
  text-decoration: none;
}
.side-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(137, 207, 240, 0.12), rgba(137, 207, 240, 0));
}

/* theme toggle: hanging incandescent bulb — buzzes in the dark, draws moths when lit */
.lamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  margin-top: 3rem;
  background: none;
  border: none;
  padding: 0.4rem 0.6rem;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.lamp:hover { color: var(--accent); }
.lamp-label {
  font-size: 0.82rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.lamp-rig {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lamp-cord {
  width: 2px;
  height: 26px;
  background: var(--accent-dim);
  opacity: 0.6;
}
/* SVG incandescent bulb: threaded brass cap, pear glass, filament */
.lamp-glass-wrap {
  position: relative;
  margin-top: -2px;
}
.bulb {
  display: block;
  width: 62px;
  height: 97px;
  overflow: visible;
}
.b-cap {
  fill: #c9a13d;
  stroke: #8a6b23;
  stroke-width: 1;
}
.b-thread {
  stroke: #8a6b23;
  stroke-width: 1.6;
}
.b-glass {
  fill: rgba(137, 207, 240, 0.06);
  stroke: var(--accent-dim);
  stroke-width: 1.6;
  transition: fill 0.3s, stroke 0.3s;
}
.b-fil {
  fill: none;
  stroke: var(--accent-dim);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.55;
  transition: stroke 0.3s, opacity 0.3s;
}
.b-core {
  fill: #d9eefb;
  opacity: 0.2;
  filter: blur(6px);
}
.lamp-glow {
  position: absolute;
  left: 50%;
  top: 56%;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(137, 207, 240, 0.7) 0%, rgba(137, 207, 240, 0) 70%);
  opacity: 0.15;
  pointer-events: none;
}
/* the hard buzz of an old lamp, every ~2 seconds */
@keyframes buzz {
  0%, 78%, 100% { opacity: 0.15; }
  80% { opacity: 1; }
  83% { opacity: 0.25; }
  86% { opacity: 0.95; }
  89% { opacity: 0.3; }
  93% { opacity: 0.85; }
  96% { opacity: 0.2; }
}
html:not([data-theme="light"]) .lamp-glow { animation: buzz 2s infinite; }
html:not([data-theme="light"]) .b-core { animation: buzz 2s infinite; }

[data-theme="light"] .b-glass {
  fill: url(#bulbGrad);
  stroke: #d9a93f;
}
[data-theme="light"] .b-fil {
  stroke: #a86f1a;
  opacity: 0.9;
}
[data-theme="light"] .b-core {
  fill: #ffffff;
  opacity: 1;
  filter: blur(7px);
}
[data-theme="light"] .lamp-glow {
  background: radial-gradient(circle, rgba(255, 215, 106, 0.65) 0%, rgba(255, 215, 106, 0) 70%);
  opacity: 0.9;
  animation: none;
}
/* moths flitting erratically around the lit bulb */
.fly {
  position: absolute;
  top: 55%;
  left: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px;
  border-radius: 50%;
  background: #2b2417;
  opacity: 0;
}
@keyframes flit1 {
  0%   { transform: translate(-30px, -8px);  opacity: 0.9; }
  16%  { transform: translate(-12px, -34px); opacity: 0.5; }
  34%  { transform: translate(20px, -20px);  opacity: 0.85; }
  52%  { transform: translate(34px, 8px);    opacity: 0.6; }
  72%  { transform: translate(6px, 30px);    opacity: 0.9; }
  88%  { transform: translate(-20px, 14px);  opacity: 0.55; }
  100% { transform: translate(-30px, -8px);  opacity: 0.9; }
}
@keyframes flit2 {
  0%   { transform: translate(24px, -14px);  opacity: 0.7; }
  22%  { transform: translate(2px, -26px);   opacity: 0.95; }
  40%  { transform: translate(-26px, -4px);  opacity: 0.5; }
  58%  { transform: translate(-14px, 22px);  opacity: 0.85; }
  80%  { transform: translate(18px, 16px);   opacity: 0.6; }
  100% { transform: translate(24px, -14px);  opacity: 0.7; }
}
@keyframes flit3 {
  0%   { transform: translate(0px, 34px);    opacity: 0.6; }
  20%  { transform: translate(-30px, 12px);  opacity: 0.9; }
  38%  { transform: translate(-18px, -24px); opacity: 0.5; }
  55%  { transform: translate(14px, -32px);  opacity: 0.85; }
  75%  { transform: translate(32px, -2px);   opacity: 0.55; }
  100% { transform: translate(0px, 34px);    opacity: 0.6; }
}
[data-theme="light"] .fly { opacity: 0.85; }
[data-theme="light"] .f1 { animation: flit1 3.1s ease-in-out infinite; }
[data-theme="light"] .f2 { animation: flit2 2.3s ease-in-out infinite; }
[data-theme="light"] .f3 { animation: flit3 3.9s ease-in-out infinite; }
[data-theme="light"] .f4 { animation: flit1 2.7s ease-in-out infinite reverse; animation-delay: -1.2s; }
[data-theme="light"] .f5 { animation: flit2 3.5s ease-in-out infinite reverse; animation-delay: -0.7s; }
[data-theme="light"] .f6 { animation: flit3 2.1s ease-in-out infinite; animation-delay: -1.6s; }
@media (prefers-reduced-motion: reduce) {
  .lamp-glow, .b-core, .fly { animation: none !important; }
}

.side-links {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1.6rem;
}
.side-links a { color: var(--muted); }
.side-links a:hover { color: var(--accent); }
.side-links .ico { width: 17px; height: 17px; }

.side-footer {
  color: #4d5866;
  font-size: 0.68rem;
  margin: 0.9rem 0 0;
}

/* --- hero --- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2.5rem;
}
.hero .prompt { color: var(--muted); margin-bottom: 0; }
.hero h1 { margin: 0.25rem 0; }
.hero .subtitle { color: var(--accent); font-weight: 600; margin: 0; }
.hero .tagline { color: var(--muted); max-width: 52ch; }

/* CV download: a mini terminal window running wget, progress fills on hover */
@keyframes cvfloat {
  0%, 100% {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(137, 207, 240, 0.14);
  }
  50% {
    transform: translateY(-8px);
    box-shadow: 0 18px 34px rgba(137, 207, 240, 0.30);
  }
}
.cv-term {
  display: block;
  width: 236px;
  flex-shrink: 0;
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(137, 207, 240, 0.12), rgba(137, 207, 240, 0.04)),
    var(--bg-soft);
  overflow: hidden;
  font-size: 0.74rem;
  color: var(--muted);
  animation: cvfloat 3.4s ease-in-out infinite;
}
.cv-term:hover {
  text-decoration: none;
  animation-play-state: paused;
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(137, 207, 240, 0.35);
}
/* pin the CV window to the far right of the content area on wide screens */
@media (min-width: 1100px) {
  .cv-term {
    position: absolute;
    top: 3rem;
    right: 2.5rem;
  }
}
.cv-tbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--accent-dim);
  background: rgba(137, 207, 240, 0.10);
}
.cv-tbar i { width: 9px; height: 9px; border-radius: 50%; opacity: 0.85; }
.cv-tbar i:nth-child(1) { background: #e0645f; }
.cv-tbar i:nth-child(2) { background: #e6b455; }
.cv-tbar i:nth-child(3) { background: #71bf68; }
.cv-tbar .cv-title { margin-left: auto; font-size: 0.68rem; color: var(--muted); }
.cv-tbody {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.8rem 0.9rem 0.9rem;
}
.cv-cmd { color: var(--text); white-space: nowrap; }
.cv-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--accent-dim);
  overflow: hidden;
}
.cv-fill {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  box-shadow: 0 0 8px rgba(137, 207, 240, 0.6);
  transition: width 0.9s ease;
}
.cv-term:hover .cv-fill { width: 100%; }
.cv-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.cv-hint .ico { width: 12px; height: 12px; }
@media (prefers-reduced-motion: reduce) {
  .cv-term, .cv-term:hover { animation: none; transform: none; }
  .cv-fill { transition: none; width: 100%; }
}

/* --- buttons --- */
.btn {
  display: inline-block;
  background: var(--accent-bg);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  cursor: pointer;
  font: inherit;
}
.btn:hover { background: var(--accent); color: var(--bg); text-decoration: none; }
.btn.small { font-size: 0.8rem; padding: 0.2rem 0.6rem; vertical-align: middle; }

/* --- about --- */
.about { color: var(--text); max-width: 62ch; }
.about p { margin: 0.5rem 0; }

/* --- skills chips --- */
.chips {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chips li {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.8rem;
  font-size: 0.85rem;
}

/* --- post list --- */
.post-list { list-style: none; padding: 0; }
.post-list li {
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--border);
}
.post-list .date {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 1rem;
}
.post-list .summary { color: var(--muted); margin: 0.25rem 0; font-size: 0.9rem; }
.tag {
  display: inline-block;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  margin-right: 0.4rem;
}
.more { color: var(--accent-dim); }

/* --- post body --- */
.post .meta { color: var(--muted); font-size: 0.9rem; }
.post-body { margin-top: 1.5rem; }
.post-body pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
}
.post-body code {
  background: var(--bg-soft);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.9em;
  color: var(--accent);
}
.post-body pre code { background: none; padding: 0; color: var(--text); }
.post-body blockquote {
  border-left: 3px solid var(--accent-dim);
  margin-left: 0;
  padding-left: 1rem;
  color: var(--muted);
}
.post-body img { max-width: 100%; }
.post-body table { border-collapse: collapse; width: 100%; }
.post-body th, .post-body td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
  text-align: left;
}

/* --- forms --- */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); }
.form input[type="text"],
.form input[type="password"],
.form textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font: inherit;
}
.form input:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}
.form input[type="file"] { color: var(--muted); }
.form .btn { align-self: flex-start; }

/* --- admin --- */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.cv-preview { margin-top: 1rem; }
.cv-preview summary { color: var(--accent); cursor: pointer; }
.cv-preview iframe {
  width: 100%;
  height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 0.75rem;
  background: #fff;
}

/* --- misc --- */
.flash {
  padding: 0.75rem 2rem 0;
  color: var(--accent);
}
.logout, .edit { font-size: 0.8rem; color: var(--muted); }
.inline { display: inline; }
.link-btn {
  background: none;
  border: none;
  color: #e06c75;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* --- labs --- */
.sec.first { margin-top: 0; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.card {
  background: rgba(17, 22, 29, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.card:hover { border-color: var(--accent-dim); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.card-head h3 { margin: 0; font-size: 0.95rem; color: var(--heading); }
.card-head h3 a { color: var(--heading); }
.card-head h3 a:hover { color: var(--accent); text-decoration: none; }
.card-links { display: flex; gap: 0.6rem; }
.card-links a { color: var(--muted); }
.card-links a:hover { color: var(--accent); }
.card-links .ico { width: 15px; height: 15px; }
.card p { color: var(--muted); font-size: 0.8rem; line-height: 1.65; margin: 0; flex: 1; }
.tech { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tech span {
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.05rem 0.5rem;
  font-size: 0.68rem;
}
.train { list-style: none; margin: 0; padding: 0; }
.train li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.8rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.train > li > .ico { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.train .t-name a { color: var(--text); }
.train .t-name a:hover { color: var(--accent); }
.train .t-org { color: var(--muted); font-size: 0.76rem; }
.train .t-year { margin-left: auto; color: var(--muted); font-size: 0.76rem; }

/* --- blog columns + rail --- */
.blog-cols { display: flex; gap: 2.5rem; }
.blog-main { flex: 1; min-width: 0; }
.blog-rail { width: 210px; flex-shrink: 0; }
.tagfilter { color: var(--accent); font-size: 0.9rem; }
.small { font-size: 0.8rem; }
.bpost { padding: 1.25rem 0; border-bottom: 1px dashed var(--border); }
.bpost h3 { margin: 0 0 0.45rem; font-size: 1.15rem; line-height: 1.4; }
.bpost h3 a { color: var(--accent); }
.bpost p { color: var(--muted); font-size: 0.85rem; line-height: 1.75; margin: 0 0 0.6rem; }
.bmeta { display: flex; align-items: center; gap: 1.2rem; color: var(--muted); font-size: 0.74rem; }
.bmeta span { display: inline-flex; align-items: center; gap: 0.4rem; }
.bmeta .ico { width: 13px; height: 13px; }
.bmeta .tg { color: var(--accent); }
.rail-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.6rem;
  background: rgba(17, 22, 29, 0.5);
}
.rail-h {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 0.8rem;
}
.rail-h .ico { width: 13px; height: 13px; color: var(--accent); }
.tagcloud { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tagcloud a {
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.55rem;
  font-size: 0.72rem;
}
.tagcloud a.on { background: var(--accent); color: var(--bg); }
.rail-box ul { list-style: none; margin: 0; padding: 0; }
.rail-box ul li {
  padding: 0.3rem 0;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-box ul li a { color: var(--text); }
.rail-box ul li a:hover { color: var(--accent); }

/* --- forms: select --- */
.form select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font: inherit;
}

/* --- responsive --- */
@media (max-width: 900px) {
  .blog-cols { flex-direction: column; }
  .blog-rail { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; gap: 1.5rem; }
}
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: 0;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sb-inner { min-height: 0; padding: 2rem 1.25rem; }
  .side-footer { display: none; }
  .side-links { margin-top: 1.2rem; }
  main { padding: 1.5rem 1.25rem; }
  .avatar { width: 100px; height: 100px; }
}
