:root {
  --divider-color: rgba(28, 28, 28, 0.3);
  --bg: #fff;
  --h1: #000;
  --box-border: #000;
  --box-bg: rgba(243, 243, 243, 0.5);
  --text: #1c1c1c;
  --link: #1c1c1c;
  --hover: #21a5e3;
  --mute: #555;
  --line: #000;
  --ul: #000;
  --em: #000;
  --sel-bg: #1c1c1c;
  --sel-text: #fff;
  --r: #b3261e;
  --rb: #fbe9e7;
  --a: #a85d00;
  --ab: #fff1dc;
  --g: #2e6b34;
  --gb: #e6f2e6;
  --cursor-fill: #000;
}

body[data-theme="dark"] {
  --divider-color: rgba(0, 255, 0, 0.3);
  --bg: #000;
  --h1: #00ff00;
  --box-border: #008000;
  --box-bg: rgba(0, 50, 0, 0.6);
  --text: #00ff00;
  --link: #00ff00;
  --hover: #39ff14;
  --mute: #3fae3f;
  --line: #008000;
  --ul: #00ff00;
  --em: #39ff14;
  --sel-bg: #008000;
  --sel-text: #000;
  --r: #ff6b5f;
  --rb: #3a0d0a;
  --a: #ffb347;
  --ab: #3a2600;
  --g: #6fdc78;
  --gb: #0d2a10;
  --cursor-fill: #00ff00;
}

@media (pointer: fine) {
  *,
  *::before,
  *::after {
    cursor: none !important;
  }
}

.custom-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 11.2px;
  height: 11.2px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 9999;
  transition: transform 0.08s ease-out, opacity 0.15s ease-out, border-color 0.2s ease, background-color 0.2s ease;
  background: var(--cursor-fill);
  border: 1.4px solid var(--cursor-fill);
  opacity: 1;
}

.custom-cursor.is-link {
  background: transparent;
  border-color: var(--cursor-fill);
  transform: translate(-50%, -50%) scale(1.15);
}

.custom-cursor.is-down {
  transform: translate(-50%, -50%) scale(0.85);
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  margin: 0 auto;
  max-width: 60%;
  padding: 6rem 2rem 2rem;
  position: relative;
  transition: background 0.3s ease, color 0.3s ease;
}

::selection,
mark {
  background: var(--sel-bg);
  color: var(--sel-text);
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--box-bg);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.navbar-left {
  display: flex;
  align-items: center;
}

.navbar-left a.logo-link,
.navbar-left a.logo-link:hover {
  display: block;
  color: inherit;
  border: 0;
  background: none;
  text-decoration: none;
  transition: none;
  transform: none;
}

.navbar-ascii {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  color: var(--h1);
  line-height: 1;
  letter-spacing: -0.5px;
  white-space: pre;
  margin: 0;
  padding: 0;
}

.navbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.controls-container {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 2rem;
  align-items: center;
}

.theme-toggle {
  cursor: pointer;
  font-size: 1.8rem;
  padding: 10px;
  display: inline-block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.theme-toggle:hover {
  transform: scale(1.2) rotate(3deg);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.rss-toggle,
.rss-toggle:hover,
.nav-btn,
.nav-btn:hover {
  cursor: pointer;
  font-size: 1.8rem;
  padding: 10px;
  display: inline-block;
  text-decoration: none;
  border-bottom: none;
  background: none;
  color: var(--text);
  transition: none;
}

.rss-toggle svg,
.nav-btn svg {
  fill: var(--text);
  width: 1.3rem;
  height: 1.3rem;
  vertical-align: middle;
}

h1 {
  color: var(--h1);
  font-family: 'Lacquer', 'Courier New', monospace;
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0.67em 0;
}

h2 {
  color: var(--h1);
  font-family: 'Lacquer', 'Courier New', monospace;
  font-size: 1.6em;
  font-weight: 400;
  margin: 1.1em 0 0.4em;
  break-after: avoid;
}

h3 {
  color: var(--h1);
  font-size: 2.3em;
  font-family: 'Lacquer', 'Courier New', monospace;
  font-weight: 400;
}

em {
  font-style: normal;
  font-weight: bold;
  color: var(--em);
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px dashed var(--ul);
  background: linear-gradient(0deg, var(--link), var(--link)) no-repeat right bottom / 0 1px;
  transition: background-size 0.5s, border-color 0.5s, color 0.5s;
}

a:hover {
  border-bottom: 1px solid var(--em);
  background: linear-gradient(0deg, var(--em), var(--em)) no-repeat left bottom / 100% 1px;
}

pre {
  margin: 0;
}

ul {
  list-style-type: "> ";
  padding-left: 1rem;
  margin: 0.3rem 0;
}

li {
  margin-bottom: 0.4rem;
  transition: transform 0.1s ease-out;
}

li:hover {
  transform: translateY(-2px);
}

.meta,
.src {
  color: var(--mute);
  font-size: 0.85em;
}

@media screen {
  h1:has(+.meta) {
    margin-bottom: 0.1em;
    line-height: 1.35;
  }

  h1+.meta {
    margin-top: 0;
  }
}

.small-text {
  color: #808080;
  font-size: 0.7rem;
}

.signature::after {
  content: "_";
  animation: blink 1s step-end infinite;
  color: #808080;
  text-shadow: 0 0 8px #808080, 0 0 12px #808080;
}

.fading-line {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--divider-color), transparent);
  margin: 2rem 0;
}

.box {
  border: 1px solid var(--box-border);
  background: var(--box-bg);
  padding: 8px 12px;
  margin: 10px 0;
  border-radius: 4px;
}

.level {
  border-width: 2px;
  border-color: var(--r);
}

.tag {
  display: inline-block;
  font-weight: 700;
  font-size: 0.8em;
  padding: 0 6px;
  border: 1px solid;
  white-space: nowrap;
}

.R {
  color: var(--r);
  background: var(--rb);
}

.A {
  color: var(--a);
  background: var(--ab);
}

.G {
  color: var(--g);
  background: var(--gb);
}

#sitrep-slot .box {
  margin-top: calc(3rem * 0.67);
}

.wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85em;
}

th,
td {
  border: 1px solid var(--box-border);
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--box-bg);
  color: var(--h1);
}

.foot {
  margin-top: 16px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
  color: var(--mute);
  font-size: 7pt;
  line-height: 1.35;
}

.foot .note {
  font-size: 8pt;
  line-height: 1.35;
  margin: 1.4em 0 0;
}

.logo-container {
  text-align: right;
  margin: 1rem 0;
  max-width: 100%;
  padding-right: 20px;
}

.glitch-logo {
  max-width: 100%;
  height: auto;
  display: inline-block;
  width: 120px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.ascii-container {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  overflow-x: auto;
  margin: 0 auto;
  text-align: start;
}

.ascii-art {
  display: inline-block;
  font-family: 'Courier New', monospace;
  font-size: clamp(0.5rem, 2.5vw, 0.8rem);
  color: var(--h1);
  line-height: 1;
  letter-spacing: -0.5px;
  white-space: pre;
  margin: 0;
  padding: 0.5rem 0;
}

.whoami {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.image-box {
  flex-shrink: 0;
  width: 250px;
  height: 250px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.image-box img {
  width: 100%;
  height: 100%;
  border-radius: 100%;
  object-fit: cover;
}

.accordion-header {
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.accordion-arrow {
  transition: transform 0.3s ease;
}

.accordion-header:hover .accordion-arrow {
  transform: scale(1.2);
}

.accordion-header.active .accordion-arrow {
  transform: rotate(90deg);
}

.accordion-body {
  display: none;
  color: var(--text);
  margin: 0;
  padding-top: 0.2em;
  padding-left: 1.5em;
  opacity: 0;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  transform: translateY(-5px);
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.accordion-body.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.accordion-body.tree pre {
  font-family: monospace;
  font-size: 0.8rem;
  background-color: var(--box-bg, #f9f9f9);
  border: 1px solid var(--box-border, #ccc);
  padding: 1em;
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}

.accordion-body.tree pre::-webkit-scrollbar {
  height: 8px;
}

.accordion-body.tree pre::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.arrow-space {
  width: 0.5em;
}

.featured-projects {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}

.project-box {
  background-color: rgba(248, 248, 248, 0.7);
  border: none;
  padding: 5px;
  font-family: monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
  width: 250px;
  height: 300px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(50px) scale(0.8);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease, outline 0.3s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

body[data-theme="dark"] .project-box {
  background-color: rgba(0, 0, 0, 0.7);
}

.project-box.fly-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.project-box:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
  outline: 1px solid var(--em);
  outline-offset: 2px;
}

.project-box img {
  width: 100%;
  height: 130px;
  object-fit: cover;
  margin-bottom: 5px;
  border-radius: 4px;
}

.project-box p {
  font-size: 0.8rem;
  color: var(--text);
  margin: 0;
  padding-bottom: 10px;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-box a {
  text-decoration: none;
  border-bottom: none;
  background: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  gap: 5px;
  padding: 5px;
  box-sizing: border-box;
}

.project-box a:hover {
  border-bottom: none;
  background: none;
}

.hidden-on-load {
  opacity: 0;
  transition: opacity 0.5s ease;
  visibility: hidden;
  height: 0;
  overflow: hidden;
}

.visible-on-scroll {
  visibility: visible;
  opacity: 1;
  height: auto;
  overflow: visible;
}

.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  left: auto !important;
  right: 2rem !important;
  width: 3rem;
  height: 3rem;
  background: var(--box-bg);
  border: 0.5px solid var(--box-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-to-top:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  background: var(--em);
  border-color: var(--em);
}

.scroll-to-top:hover svg {
  fill: var(--bg);
}

.scroll-to-top:active {
  transform: translateY(-2px) scale(0.95);
}

.scroll-to-top svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: var(--text);
  transition: fill 0.3s ease;
}

.biolinks {
  display: flex;
  gap: 15px;
  margin-top: 1rem;
  align-items: center;
}

.biolinks a {
  display: inline-block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  border-bottom: none;
  background: none;
  color: #808080;
}

.biolinks a:hover {
  transform: scale(1.2) rotate(3deg);
  text-decoration: none;
  border-bottom: none;
  background: none;
}

.biolinks a:active {
  transform: scale(0.95);
}

.biolinks img {
  width: 32px;
  height: 32px;
  display: block;
}

.hidden-flag::before {
  content: "46 4c 41 47 7b 53 54 59 4c 33 5f 53 48 33 33 54 5f 48 34 43 4b 33 52 5f 32 30 32 7d";
  position: absolute;
  left: -9999px;
  top: -9999px;
  visibility: hidden;
  opacity: 0;
  font-size: 0;
  color: transparent;
  z-index: -1;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.fade-out {
  animation: fadeOut 0.4s ease-out forwards;
}

@media (min-width: 601px) {
  .featured-projects {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .project-box {
    margin-right: 8px;
    margin-bottom: 8px;
  }
}

@media (min-width: 769px) {
  .navbar {
    padding: 1rem calc((100% - 60%) / 2);
  }
}

@media (max-width: 768px) {
  body {
    max-width: 95%;
    margin: 8px 20px;
  }

  body > * {
    position: relative;
    z-index: 1;
  }
}

@media (max-width: 600px) {
  body {
    padding: 1rem;
    padding-top: 5rem;
    font-size: 0.9rem;
  }

  h1 {
    font-size: 2.7rem;
  }

  #sitrep-slot .box {
    margin-top: calc(2.7rem * 0.67);
  }

  .box {
    font-size: 1.2rem;
  }

  .featured-projects {
    margin-top: 20vh;
    padding-top: 0.5rem;
  }

  .navbar {
    padding: 0.8rem 1rem;
    width: 100%;
    left: 0;
    right: 0;
    box-sizing: border-box;
  }

  .navbar-ascii {
    font-size: 0.6rem;
  }

  .navbar-right {
    margin-right: 0;
    padding-right: 0;
  }

  .project-box p {
    font-size: 1.0rem;
  }

  .scroll-to-top {
    bottom: 1rem;
    right: 1rem !important;
    width: 2.5rem;
    height: 2.5rem;
  }

  .scroll-to-top svg {
    width: 1rem;
    height: 1rem;
  }

  p,
  li {
    font-size: 1.2rem;
  }

  pre {
    font-size: 0.7rem;
    white-space: pre-wrap;
  }

  ul {
    padding-left: 1.2rem;
  }

  .project-box {
    width: 100%;
    height: auto;
  }

  .project-box img {
    height: auto;
  }

  .glitch-logo {
    width: 120px;
  }

  .controls-container {
    justify-content: center;
    gap: 5px;
  }

  .biolinks {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 10px;
  }

  .biolinks a {
    flex: 0 0 auto;
  }

  .biolinks img {
    width: 28px;
    height: 28px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 9mm;
  }

  body,
  body[data-theme="dark"] {
    --divider-color: rgba(28, 28, 28, 0.3);
    --bg: #fff;
    --h1: #000;
    --box-border: #000;
    --box-bg: rgba(243, 243, 243, 0.5);
    --text: #1c1c1c;
    --link: #1c1c1c;
    --hover: #21a5e3;
    --mute: #555;
    --line: #000;
    --ul: #000;
    --em: #000;
    --r: #b3261e;
    --rb: #fbe9e7;
    --a: #a85d00;
    --ab: #fff1dc;
    --g: #2e6b34;
    --gb: #e6f2e6;
  }

  body {
    font-size: 8.5pt;
    line-height: 1.35;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .navbar {
    position: static;
    padding: 0 0 4px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .navbar-right,
  .theme-toggle,
  .rss-toggle,
  .controls-container,
  .custom-cursor,
  .scroll-to-top,
  .np {
    display: none;
  }

  .signature::after {
    display: none;
  }

  .navbar-ascii {
    font-size: 0.6rem;
    letter-spacing: -0.04em;
  }

  .navbar {
    justify-content: flex-end;
  }

  h1 {
    font-size: 3em;
    margin: 0.2em 0 0.1em;
  }

  h2 {
    font-size: 1.2em;
    margin-top: 0.55em;
  }

  li {
    margin-bottom: 0.15rem;
  }

  th,
  td {
    padding: 2px 4px;
  }

  table {
    font-size: 0.8em;
  }

  .foot {
    font-size: 7pt;
    line-height: 1.25;
    margin-top: 6px;
    padding-top: 4px;
  }

  .foot .note {
    font-size: 8pt;
    line-height: 1.25;
    margin-top: 1.3em;
  }

  .fading-line {
    margin: 10px 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  tr,
  li {
    break-inside: avoid;
  }
}
