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

html,
body {
  width: 100%;
  min-height: 100%;
  background: #000c1f;
  overflow: hidden;
  font-family: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", "Cascadia Mono", "Fira Code", monospace;
}

:root {
  --dashboard-bg: #000c1f;
  --dock-size: 12.8px;
  --dock-gap: clamp(6px, 3vw, 16px);
  --dock-button-size: 5.3em;
  --dock-icon-size: 4.16em;
  --menu-radius: 12px;
  --stage-pad-top: 90px;
  --stage-pad-x: 24px;
  --stage-pad-bottom: 24px;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--stage-pad-top) var(--stage-pad-x) max(var(--stage-pad-bottom), env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(0, 12, 31, 0.2), rgba(0, 12, 31, 0.2)),
    url("../blue-waves.webp") center center / cover no-repeat;
}

.theme-toggle {
  position: fixed;
  top: max(9px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 1001;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 0;
  padding: 1px 2px;
  margin: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.56);
  font: 10px/1 Georgia, serif;
  letter-spacing: 0;
  text-transform: lowercase;
  cursor: pointer;
  opacity: 0.72;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  outline: none;
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 2px;
}

:root[data-theme="light"] .theme-toggle {
  color: rgba(81, 75, 77, 0.58);
}

:root[data-theme="light"] .theme-toggle:hover,
:root[data-theme="light"] .theme-toggle:focus-visible {
  color: rgba(81, 75, 77, 0.92);
}

.top-bar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(0px, env(safe-area-inset-left));
  right: max(0px, env(safe-area-inset-right));
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--dock-gap);
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.dock-btn,
.debian-shortcut,
.scrobble-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--dock-button-size);
  height: var(--dock-button-size);
  border: none;
  border-radius: 0.4em;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  font-size: var(--dock-size);
  padding: 0;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
}

.dock-btn {
  flex-direction: column;
}

.dock-icon,
.debian-stroke,
.scrobble-icon {
  width: var(--dock-icon-size);
  height: var(--dock-icon-size);
  min-width: 0;
  min-height: 0;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform: translateY(-0.02em);
}

.folder-icon {
  filter:
    drop-shadow(0 0 0.18em rgba(250, 172, 39, 0.45))
    drop-shadow(0 0 0.4em rgba(250, 172, 39, 0.2));
}

.home-icon {
  filter:
    drop-shadow(0 0 0.18em rgba(16, 122, 176, 0.45))
    drop-shadow(0 0 0.4em rgba(16, 122, 176, 0.2));
}

.debian-stroke {
  filter:
    drop-shadow(0 0 0.18em rgba(215, 10, 83, 0.45))
    drop-shadow(0 0 0.4em rgba(215, 10, 83, 0.2));
}

.scrobble-icon {
  max-width: var(--dock-icon-size);
  max-height: var(--dock-icon-size);
  filter: none;
}

.folder-btn .active_line,
.start-btn .active_line,
.debian-active-line,
.scrobble-active-line {
  position: absolute;
  bottom: 0;
  width: 0.9em;
  height: 0.4em;
  background-color: #999;
  border: none;
  border-radius: 1em;
  transition: all 0.15s linear;
}

.folder-btn:active .active_line,
.folder-btn:focus .active_line {
  width: 2.3em;
  background-color: #fac227;
}

.start-btn:active .active_line,
.start-btn:focus .active_line,
.start-btn.menu-open .active_line {
  width: 2.3em;
  background-color: #107ab0;
}

.debian-shortcut:active .debian-active-line,
.debian-shortcut:focus .debian-active-line {
  width: 2.3em;
  background-color: #d70a53;
}

.scrobble-toggle.is-open .scrobble-active-line,
.scrobble-toggle:focus .scrobble-active-line,
.scrobble-toggle:active .scrobble-active-line {
  width: 2.3em;
  background-color: #d51007;
}

.folder-btn:focus .dock-icon,
.folder-btn:active .dock-icon,
.start-btn:focus .dock-icon,
.start-btn:active .dock-icon {
  animation: dock-icon-wow 1s forwards;
}

.debian-shortcut:focus .debian-stroke,
.debian-shortcut:active .debian-stroke {
  animation: debian-wow 1s forwards;
}

.scrobble-toggle:focus .scrobble-icon,
.scrobble-toggle:active .scrobble-icon {
  animation: dock-icon-wow 1s forwards;
}

@keyframes dock-icon-wow {
  20% { scale: 0.8; }
  30% { scale: 1; transform: translateY(-0.02em); }
  50% { transform: translateY(-6px); }
  65% { transform: translateY(4px); }
  80% { transform: translateY(-0.02em); }
  100% { scale: 1; }
}

@keyframes debian-wow {
  20% { scale: 0.8; }
  30% { scale: 1; transform: translateY(-0.02em); }
  50% { transform: translateY(-6px) rotate(-7deg); }
  65% { transform: translateY(4px) rotate(5deg); }
  80% { transform: translateY(-0.02em) rotate(0deg); }
  100% { scale: 1; }
}

.start-menu {
  width: min(680px, calc(100vw - (var(--stage-pad-x) * 2)));
  height: min(820px, calc(100dvh - var(--stage-pad-top) - var(--stage-pad-bottom) - env(safe-area-inset-bottom)));
  max-height: calc(100dvh - var(--stage-pad-top) - var(--stage-pad-bottom) - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border: none;
  border-radius: var(--menu-radius);
  box-shadow: 4px 6px 12px var(--color-shadow), 0 0 0 1px var(--color-border-secondary);
  font-family: Georgia, serif;
  z-index: 20;
  opacity: 1;
  visibility: visible;
  transform: scaleY(1) translateY(0);
  transform-origin: top center;
  transition:
    opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0s;
}

.start-menu.hidden {
  opacity: 0;
  transform: scaleY(0.96) translateY(-8px);
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0s linear 0.18s;
}

.search-bar {
  flex: 0 0 auto;
  padding: 14px 24px;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-secondary);
}

.search-bar-inner {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  flex-shrink: 0;
  pointer-events: none;
}

.search-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: var(--color-accent-contrast);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.search-bar input {
  width: 100%;
  padding: 11px 20px 11px 48px;
  border: 1px solid var(--color-border-primary);
  border-radius: 10px;
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  font-size: 14.5px;
  font-family: Georgia, serif;
  transition: background 0.15s, border-color 0.15s;
}

.search-bar input::placeholder {
  color: var(--color-text-secondary);
}

.search-bar input:focus {
  outline: none;
  background: var(--color-bg-tertiary);
  border-color: var(--color-accent);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px 28px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

.pinned-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 14.5px;
  color: var(--color-text-primary);
}

.show-all {
  color: var(--color-accent);
  cursor: pointer;
  white-space: nowrap;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 22px 16px;
}

.app-item {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.app-item:hover,
.app-item:focus-within {
  background: rgba(70, 80, 95, 0.3);
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 29px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  flex: 0 0 auto;
}

.app-name {
  max-width: 100%;
  font-size: 13px;
  text-align: center;
  line-height: 1.3;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}

.footer {
  flex: 0 0 auto;
  padding: 14px 24px;
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border-secondary);
  display: flex;
  align-items: center;
  gap: clamp(6px, 3vw, 16px);
}

.user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.user:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-text {
  min-width: 0;
}

.user strong,
.user small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user small {
  color: var(--color-text-secondary);
}

.user-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
}

.ping-link {
  flex: 0 0 auto;
  text-decoration: none;
  color: inherit;
}

.power-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.power-btn:hover {
  background: rgba(244,208,198,0.1);
  color: #9c6454;
}

.scrobble-panel {
  position: fixed;
  top: calc(max(8px, env(safe-area-inset-top)) + 82px);
  right: max(12px, env(safe-area-inset-right));
  z-index: 900;
  width: min(400px, calc(100vw - 24px));
  height: min(640px, calc(100dvh - 108px - env(safe-area-inset-bottom)));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--menu-radius);
  box-shadow: 4px 6px 12px var(--color-shadow);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transform-origin: top right;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0s linear 0s;
}

.scrobble-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    visibility 0s linear 0.16s;
}

.scrobble-panel-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border-secondary);
}

.scrobble-close {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border-primary);
  border-radius: 10px;
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  cursor: pointer;
  font: 18px/1 Georgia, serif;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.scrobble-close:hover,
.scrobble-close:focus-visible {
  outline: none;
  color: var(--color-accent-contrast);
  border-color: var(--color-accent);
  background: var(--color-accent);
}

.scrobble-frame {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
  background: transparent;
}

@media (max-width: 768px) {
  :root {
    --stage-pad-top: 86px;
    --stage-pad-x: 14px;
    --stage-pad-bottom: 12px;
  }

  .top-bar {
    gap: 10px;
  }

  .start-menu {
    width: calc(100vw - (var(--stage-pad-x) * 2));
    height: calc(100dvh - var(--stage-pad-top) - var(--stage-pad-bottom) - env(safe-area-inset-bottom));
    max-height: calc(100dvh - var(--stage-pad-top) - var(--stage-pad-bottom) - env(safe-area-inset-bottom));
  }

  .apps-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px 10px;
  }

  .content {
    padding: 16px 14px;
  }

  .search-bar {
    padding: 11px 14px;
  }

  .footer {
    padding: 9px 10px;
  }

  .user {
    gap: 8px;
    padding: 4px 5px;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .power-btn {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .scrobble-panel {
    top: 86px;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
    height: calc(100dvh - 104px - env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  :root {
    --dock-size: 11.2px;
    --dock-gap: 6px;
    --stage-pad-top: 78px;
    --stage-pad-x: 10px;
    --stage-pad-bottom: 10px;
  }

  .pinned-header {
    font-size: 13.5px;
  }

  .app-icon {
    width: 48px;
    height: 48px;
    font-size: 25px;
  }

  .app-name {
    font-size: 12px;
  }

  .scrobble-panel {
    top: 80px;
    height: calc(100dvh - 96px - env(safe-area-inset-bottom));
  }
}

@media (max-width: 360px) {
  :root {
    --dock-size: 10px;
    --dock-gap: 4px;
    --stage-pad-top: 72px;
  }

  .theme-toggle {
    font-size: 9px;
    padding: 1px 2px;
  }

  .search-bar input {
    font-size: 13.5px;
  }

  .footer {
    padding: 7px 8px;
  }
}

@media (max-height: 620px) and (max-width: 768px) {
  :root {
    --stage-pad-top: 70px;
    --stage-pad-bottom: 8px;
  }

  .content {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .apps-grid {
    gap: 12px 8px;
  }

  .search-bar {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .footer {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .scrobble-panel {
    top: 72px;
    height: calc(100dvh - 84px - env(safe-area-inset-bottom));
  }
}
