:root {
  --black: #11111b;
  --text: #cdd6f4;
  --bright: #e5e9f0;
  --muted: #a6adc8;
  --starry: #a9c9e8;
  --starry-rgb: 169, 201, 232;
  --blue: #91b9dc;
  --amber: #fab387;
  --danger: #f38ba8;
  --line: rgba(166, 173, 200, 0.18);
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
  --surface-0: #313244;
  --surface-1: #45475a;
  --overlay-0: #6c7086;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  background: var(--base) url("desktopwallpaper.png") center / cover no-repeat fixed;
}

body.has-custom-cursor,
body.has-custom-cursor * {
  cursor: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  color: var(--black);
  background: var(--starry);
}

.star-canvas,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.star-canvas {
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.74;
}

.scanlines {
  z-index: 5;
  opacity: 0.08;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 4px);
}

.custom-cursor {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  background: rgba(var(--starry-rgb), 0.92);
  box-shadow: 0 0 8px rgba(var(--starry-rgb), 0.9), 0 0 22px rgba(var(--starry-rgb), 0.48);
  clip-path: polygon(50% 0, 58% 40%, 100% 50%, 58% 60%, 50% 100%, 42% 60%, 0 50%, 42% 40%);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50px, -50px, 0);
  transition: opacity 0.16s ease;
  will-change: transform;
}

body.has-custom-cursor .custom-cursor.is-visible {
  opacity: 1;
}

.desktop-screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: start;
  padding: 64px 28px 28px;
  background:
    radial-gradient(ellipse at 72% 18%, rgba(var(--starry-rgb), 0.25), transparent 35%),
    radial-gradient(ellipse at 20% 82%, rgba(156, 113, 238, 0.19), transparent 40%),
    linear-gradient(135deg, rgba(26, 13, 43, 0.3), rgba(0, 0, 0, 0.34));
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.desktop-screen::before,
.desktop-screen::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.desktop-screen::before {
  inset: 32px 0 0;
  opacity: 0.28;
  background-image:
    radial-gradient(circle, rgba(240, 232, 255, 0.88) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(var(--starry-rgb), 0.72) 0 1px, transparent 1.6px);
  background-position: 0 0, 23px 37px;
  background-size: 157px 163px, 211px 223px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
}

.desktop-screen::after {
  top: 16%;
  right: 12%;
  width: 90px;
  aspect-ratio: 1;
  opacity: 0.42;
  background: rgba(var(--starry-rgb), 0.82);
  clip-path: polygon(50% 0, 55% 44%, 100% 50%, 55% 56%, 50% 100%, 45% 56%, 0 50%, 45% 44%);
  filter: blur(0.2px) drop-shadow(0 0 18px rgba(var(--starry-rgb), 0.75));
  animation: stellar-pulse 4.8s ease-in-out infinite;
}

.desktop-panel,
.desktop-icons,
.desktop-hint {
  z-index: 1;
}

.desktop-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.desktop-panel {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(var(--starry-rgb), 0.18);
  color: rgba(240, 245, 242, 0.76);
  background: rgba(15, 8, 25, 0.78);
  backdrop-filter: blur(10px);
  font-size: 0.76rem;
}

.desktop-panel-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.desktop-music {
  border: 0;
  padding: 2px 0;
  color: var(--starry);
  background: transparent;
  font-size: inherit;
}

.desktop-music:hover,
.desktop-music:focus-visible {
  outline: none;
  color: var(--bright);
  text-decoration: underline;
}

.desktop-icon {
  display: grid;
  justify-items: center;
  gap: 7px;
  width: 94px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 5px;
  color: var(--bright);
  background: transparent;
  text-shadow: 0 1px 4px #000;
}

.desktop-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  border-color: rgba(var(--starry-rgb), 0.34);
  outline: none;
  background: rgba(var(--starry-rgb), 0.1);
}

.app-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 48px;
  border: 1px solid rgba(var(--starry-rgb), 0.62);
  border-radius: 4px;
  color: var(--starry);
  background: rgba(0, 0, 0, 0.86);
  box-shadow: 0 0 24px rgba(var(--starry-rgb), 0.13);
}

.app-icon b {
  font-size: 1rem;
  font-weight: 500;
}

.changelogs-icon {
  color: var(--blue);
  border-color: rgba(114, 167, 255, 0.62);
  background:
    linear-gradient(rgba(114, 167, 255, 0.12), rgba(var(--starry-rgb), 0.06)),
    rgba(0, 0, 0, 0.86);
}

.desktop-hint {
  position: absolute;
  right: 24px;
  bottom: 18px;
  margin: 0;
  color: rgba(215, 221, 217, 0.38);
  font-size: 0.72rem;
}

.terminal-shell {
  position: relative;
  z-index: 6;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 78% 18%, rgba(var(--starry-rgb), 0.07), transparent 42%),
    radial-gradient(ellipse at 16% 88%, rgba(137, 91, 218, 0.06), transparent 38%),
    rgba(0, 0, 0, 0.7);
  transition: opacity 0.22s ease;
}

body.desktop-active .terminal-shell {
  opacity: 0;
  pointer-events: none;
}

.app-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(var(--starry-rgb), 0.28);
  border-radius: 3px;
  padding: 0;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.68);
  line-height: 1;
}

.app-close:hover,
.app-close:focus-visible {
  border-color: var(--starry);
  outline: none;
  color: var(--bright);
  background: rgba(var(--starry-rgb), 0.12);
}

.terminal-close {
  position: fixed;
  z-index: 8;
  top: 10px;
  right: 12px;
}

.app-overlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 52px 22px 22px;
  background: rgba(14, 7, 24, 0.42);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.app-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-window {
  width: min(760px, 100%);
  max-height: min(680px, calc(100vh - 74px));
  border: 1px solid rgba(var(--starry-rgb), 0.36);
  border-radius: 4px;
  background:
    linear-gradient(145deg, rgba(var(--starry-rgb), 0.045), transparent 38%),
    rgba(5, 2, 9, 0.94);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.68), 0 0 42px rgba(var(--starry-rgb), 0.08);
  overflow: hidden;
}

.app-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  padding: 5px 6px 5px 12px;
  border-bottom: 1px solid rgba(var(--starry-rgb), 0.22);
  color: var(--muted);
  background: rgba(var(--starry-rgb), 0.06);
  font-size: 0.78rem;
}

.changelog-content {
  max-height: calc(min(680px, 100vh - 74px) - 40px);
  padding: clamp(20px, 5vw, 42px);
  overflow: auto;
  scrollbar-color: rgba(var(--starry-rgb), 0.35) transparent;
}

.changelog-heading {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.changelog-heading p {
  margin: 0;
  color: var(--muted);
}

.changelog-heading p:first-child {
  color: var(--starry);
}

.changelog-heading h1 {
  margin: 5px 0 8px;
  color: var(--bright);
  font-size: clamp(2rem, 7vw, 4.5rem);
  font-weight: 500;
  line-height: 0.95;
}

.changelog-entry {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.changelog-entry time {
  color: var(--blue);
}

.changelog-entry h2 {
  margin: 0 0 7px;
  color: var(--starry);
  font-size: 1rem;
  font-weight: 500;
}

.changelog-entry p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.console-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
}

.console-screen {
  min-height: 0;
  overflow: auto;
  padding: 24px 28px 8px;
  scrollbar-color: rgba(var(--starry-rgb), 0.35) transparent;
  scrollbar-width: thin;
}

.boot-log {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.log-line,
.terminal-view p {
  margin: 0;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.log-line::before {
  content: "";
}

.log-line.is-error {
  color: var(--danger);
}

.log-line.is-system {
  color: var(--muted);
}

.terminal-view {
  display: none;
  max-width: 940px;
  padding-bottom: 20px;
}

.terminal-view.is-active {
  display: block;
  animation: terminal-in 0.12s ease-out;
}

.terminal-view p + p {
  margin-top: 2px;
}

.inline-command,
.command-list button,
.submit-button,
.page-button {
  border: 0;
  padding: 0;
  color: var(--starry);
  background: transparent;
  text-align: left;
}

.inline-command:hover,
.command-list button:hover span,
.submit-button:hover,
.page-button:hover:not(:disabled) {
  color: var(--bright);
  text-decoration: underline;
}

.command-list {
  display: grid;
  gap: 3px;
  margin-top: 8px;
}

.command-list button {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 22px;
  width: fit-content;
  max-width: 100%;
}

.command-list span {
  color: var(--starry);
}

.command-list small {
  color: var(--muted);
  font-size: inherit;
}

.profile-output {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: clamp(34px, 5vw, 64px);
  align-items: start;
  max-width: min(1120px, calc(100vw - 72px));
  margin-top: clamp(20px, 7vh, 78px);
  padding-left: clamp(0px, 4vw, 58px);
}

.avatar-frame {
  width: 260px;
  padding: 6px;
  border: 1px solid rgba(var(--starry-rgb), 0.38);
  background: rgba(0, 0, 0, 0.5);
}

.avatar-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  filter: grayscale(0.18) contrast(1.05);
}

.profile-data strong {
  color: var(--starry);
}

.profile-data {
  padding-top: 4px;
  font-size: clamp(1rem, 1.4vw, 1.28rem);
}

.profile-data p {
  line-height: 1.82;
}

.profile-data span {
  color: var(--blue);
}

.profile-data b {
  color: var(--text);
  font-weight: 400;
}

.profile-data .profile-bio {
  max-width: 580px;
  margin-top: 14px;
  color: var(--muted);
}

.comments-header {
  display: flex;
  gap: 18px;
  margin-bottom: 12px;
}

.comments-header > p:first-child {
  color: var(--starry);
}

.comment-status {
  color: var(--amber);
}

.comments-form {
  display: grid;
  gap: 8px;
  max-width: 720px;
  margin-bottom: 18px;
}

.comments-form label {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.comments-form label span {
  padding-top: 6px;
  color: var(--blue);
}

.comments-form input,
.comments-form textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 5px 0;
  outline: none;
  resize: vertical;
  color: var(--bright);
  background: transparent;
}

.comments-form input:focus,
.comments-form textarea:focus {
  border-color: var(--starry);
}

.comments-form ::placeholder {
  color: #48514c;
}

.submit-button {
  justify-self: start;
  margin-left: 88px;
}

.submit-button::before {
  content: "[ ";
}

.submit-button::after {
  content: " ]";
}

.comments-list {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.comment {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.comment-meta {
  display: flex;
  gap: 12px;
}

.comment-name {
  color: var(--starry);
}

.comment-time {
  color: var(--muted);
}

.comment-message {
  margin: 3px 0 0;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-pagination {
  display: flex;
  gap: 14px;
  margin-top: 14px;
  color: var(--muted);
}

.page-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.command-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 4px 28px 18px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.95) 28%);
}

.command-line label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.prompt {
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.prompt-user {
  color: var(--starry);
}

.prompt-path {
  color: var(--blue);
}

.input-wrap {
  position: relative;
  min-width: 0;
}

.command-line input {
  width: 100%;
  height: 38px;
  border: 0;
  padding: 7px 12px 7px 0;
  outline: none;
  caret-color: transparent;
  color: var(--bright);
  background: transparent;
}

.terminal-caret {
  position: absolute;
  top: 50%;
  left: var(--caret-x, 0px);
  width: 9px;
  height: 1.15em;
  transform: translateY(-50%);
  background: var(--text);
  animation: blink 1s steps(1) infinite;
  pointer-events: none;
}

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

  49%,
  100% {
    opacity: 0;
  }
}

@keyframes terminal-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes stellar-pulse {
  0%,
  100% {
    opacity: 0.22;
    transform: scale(0.78) rotate(0deg);
  }

  50% {
    opacity: 0.54;
    transform: scale(1) rotate(12deg);
  }
}

/* Static Catppuccin Mocha desktop */
.star-canvas,
.scanlines {
  display: none;
}

.custom-cursor {
  display: block;
  width: 22px;
  height: 22px;
  background: var(--bright);
  box-shadow:
    0 0 0 1px rgba(169, 201, 232, 0.26),
    0 0 8px rgba(var(--starry-rgb), 0.88),
    0 0 18px rgba(var(--starry-rgb), 0.42);
}

.desktop-screen {
  padding: 54px 24px 92px;
  background: transparent;
  transition: opacity 0.14s ease, visibility 0.14s ease;
}

.desktop-screen::before,
.desktop-screen::after {
  display: none;
}

.desktop-panel {
  inset: 10px 12px auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(var(--starry-rgb), 0.16);
  border-radius: 8px;
  color: var(--text);
  background: rgba(24, 24, 37, 0.92);
  backdrop-filter: none;
  box-shadow:
    0 3px 14px rgba(17, 17, 27, 0.28),
    inset 0 1px rgba(var(--starry-rgb), 0.05);
  font-size: 0.75rem;
}

.desktop-panel > span {
  color: var(--starry);
  font-weight: 600;
}

.desktop-panel-actions {
  gap: 16px;
}

.desktop-music {
  color: var(--muted);
}

.desktop-music:hover,
.desktop-music:focus-visible {
  color: var(--text);
  text-decoration: none;
}

.desktop-icons {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: flex;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(var(--starry-rgb), 0.2);
  border-radius: 14px;
  background: rgba(24, 24, 37, 0.95);
  box-shadow:
    0 8px 28px rgba(17, 17, 27, 0.48),
    inset 0 1px rgba(var(--starry-rgb), 0.07);
  transform: translateX(-50%);
}

.desktop-icon {
  gap: 4px;
  width: 64px;
  border-radius: 9px;
  padding: 5px 4px 3px;
  color: var(--text);
  text-shadow: none;
  font-size: 0.66rem;
  transition: background-color 0.14s ease, transform 0.14s ease;
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  border-color: transparent;
  background: rgba(var(--starry-rgb), 0.1);
  transform: translateY(-2px);
}

.app-icon {
  width: 42px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  color: var(--starry);
  background: linear-gradient(145deg, rgba(var(--starry-rgb), 0.13), rgba(49, 50, 68, 0.82));
  box-shadow: inset 0 0 0 1px rgba(var(--starry-rgb), 0.12);
}

.terminal-icon {
  color: var(--starry);
}

.changelogs-icon {
  color: var(--starry);
  border: 0;
  background: linear-gradient(145deg, rgba(var(--starry-rgb), 0.13), rgba(49, 50, 68, 0.82));
}

.desktop-hint {
  display: none;
}

.terminal-shell {
  background: rgba(17, 17, 27, 0.95);
  transition: opacity 0.14s ease;
}

.terminal-close {
  top: 11px;
  right: 13px;
}

.app-close {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-0);
}

.app-close:hover,
.app-close:focus-visible {
  border-color: transparent;
  color: var(--crust);
  background: var(--danger);
}

.console-screen {
  padding-top: 48px;
  scrollbar-color: var(--surface-1) transparent;
}

.command-line {
  border-top: 1px solid rgba(var(--starry-rgb), 0.14);
  background: var(--mantle);
}

.terminal-caret {
  background: var(--starry);
}

.app-overlay {
  padding: 58px 22px 22px;
  background: rgba(17, 17, 27, 0.56);
}

.app-window {
  border: 1px solid rgba(var(--starry-rgb), 0.24);
  border-radius: 10px;
  background: var(--base);
  box-shadow:
    0 18px 60px rgba(17, 17, 27, 0.62),
    inset 0 1px rgba(var(--starry-rgb), 0.05);
}

.app-titlebar {
  min-height: 42px;
  border-bottom: 1px solid var(--surface-0);
  color: var(--text);
  background: var(--mantle);
}

.changelog-content {
  scrollbar-color: var(--surface-1) transparent;
}

.changelog-heading h1 {
  color: var(--text);
  font-size: clamp(2rem, 6vw, 4rem);
}

.avatar-frame {
  border: 1px solid var(--surface-1);
  border-radius: 8px;
  background: var(--mantle);
  overflow: hidden;
}

.avatar-frame img {
  filter: none;
}

.comments-form input,
.comments-form textarea {
  border-color: var(--surface-1);
}

.comments-form ::placeholder {
  color: var(--overlay-0);
}

.comment {
  border-left-color: var(--surface-1);
}

/* Terminal-only layout */
body {
  background-position: center;
}

.terminal-shell {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 27, 0.92);
}

.console-screen {
  padding-top: 28px;
}

.terminal-changelogs {
  width: min(760px, 100%);
  padding: 12px 0 28px;
}

.terminal-changelogs .changelog-heading h1 {
  font-size: clamp(2rem, 7vw, 4.5rem);
}

body.is-booting .terminal-view,
body.is-booting .command-line {
  opacity: 0;
  pointer-events: none;
}

body.is-booting .console-screen {
  padding: 8px 12px;
  font-size: 0.72rem;
}

body.is-booting .boot-log {
  gap: 0;
  margin: 0;
}

body.is-booting .log-line {
  color: rgba(205, 214, 244, 0.68);
  line-height: 1.08;
  white-space: nowrap;
}

.command-line {
  transition: opacity 0.12s ease;
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .desktop-screen {
    padding: 54px 14px 86px;
  }

  .desktop-hint {
    right: 14px;
    bottom: 12px;
  }

  .desktop-icons {
    gap: 5px;
  }

  .app-overlay {
    padding: 42px 10px 10px;
  }

  .app-window {
    max-height: calc(100vh - 52px);
  }

  .changelog-content {
    max-height: calc(100vh - 92px);
    padding: 20px;
  }

  .changelog-entry {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .console-screen {
    padding: 18px 15px 6px;
  }

  .command-line {
    padding: 4px 15px 12px;
  }

  .profile-output {
    grid-template-columns: 1fr;
    gap: 14px;
    max-width: none;
    margin-top: 4px;
    padding-left: 0;
  }

  .avatar-frame {
    width: 140px;
  }

  .profile-data {
    padding-top: 0;
    font-size: inherit;
  }

  .comments-form label {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .comments-form label span {
    padding-top: 0;
  }

  .submit-button {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

@media (pointer: coarse) {
  .custom-cursor {
    display: none;
  }
}
