/**
 * Windows 98 1:1 Authentic Desktop Theme & Responsive Stylesheet
 * Incorporates 98.css, 1j01/98 pixel icons, start menu branding, and dual-screen foldable CSS
 */

:root {
  --target-size: 24px;
  --win-bg: #c0c0c0;
  --win-border-light: #ffffff;
  --win-border-dark: #808080;
  --win-border-darker: #000000;
  --win-title-active-start: #000080;
  --win-title-active-end: #1084d0;
  --win-title-inactive-start: #808080;
  --win-title-inactive-end: #b5b5b5;
  --taskbar-height: 28px;

  /* Windows 98 Authentic Scrollbar Tokens (1j01/98 COMCTL32 Bitmaps) */
  --win-scrollbar-size: 16px;
  --win-scrollbar-checker: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAG0lEQVQYV2P8/////4MHDzIwHjhw4L+9vT0DAHAFCj6esq3FAAAAAElFTkSuQmCC");
  --win-scrollbar-arrows: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAJCAYAAABaMo5wAAAAW0lEQVQ4T2NkGGSAcZC5h4FWDvrPwEC02ShqkR0EkkAHuBxMyEKYWYQ8jKEOXQOyo/A5BuZwqqvBZiA+3xMbilQLIWqlcUJRimwPzjRELcdQZA6hREeR4eRoBgBoXhAK6oiMhwAAAABJRU5ErkJggg==");
}

@media (pointer: coarse) {
  :root {
    --target-size: 44px;
    --taskbar-height: 40px;
  }
}

* {
  box-sizing: border-box;
}

/* 
   Windows 95/98 Authentic Scrollbars (Dakedres Gist - windows93.net)
   Source: https://gist.github.com/Dakedres/0ccda599648833a1c2f65d3967aa131b
   With Universal Smooth Scrolling
    */

/* Universal smooth scrolling across all scroll containers */
html, body, *, *::before, *::after {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html, body, *, *::before, *::after {
    scroll-behavior: auto !important;
  }
}

/* Windows 95/98 Scrollbar by Dakedres (https://gist.github.com/Dakedres/0ccda599648833a1c2f65d3967aa131b) */
::-webkit-scrollbar,
*::-webkit-scrollbar,
body *::-webkit-scrollbar {
  width: 16px;
  height: 16px;
  background: none;
}

::-webkit-scrollbar-thumb,
::-webkit-scrollbar-button,
body *::-webkit-scrollbar-thumb,
body *::-webkit-scrollbar-button {
  width: 16px;
  height: 16px;
  background: silver;
  box-shadow: inset 1px 1px #dfdfdf, inset -1px -1px gray;
  border: 1px solid;
  border-color: silver #000 #000 silver;
}

::-webkit-scrollbar-track,
body *::-webkit-scrollbar-track {
  image-rendering: optimizeSpeed;
  image-rendering: pixelated;
  image-rendering: optimize-contrast;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAyIDIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyI+CjxtZXRhZGF0YT5NYWRlIHdpdGggUGl4ZWxzIHRvIFN2ZyBodHRwczovL2NvZGVwZW4uaW8vc2hzaGF3L3Blbi9YYnh2Tmo8L21ldGFkYXRhPgo8cGF0aCBzdHJva2U9IiNjMGMwYzAiIGQ9Ik0wIDBoMU0xIDFoMSIgLz4KPC9zdmc+");
  background-position: 0 0;
  background-repeat: repeat;
  background-size: 2px;
}

::-webkit-scrollbar-button,
body *::-webkit-scrollbar-button {
  background-repeat: no-repeat;
  background-size: 16px;
}

::-webkit-scrollbar-button:single-button:vertical:decrement,
body *::-webkit-scrollbar-button:single-button:vertical:decrement {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTcgNWgxTTYgNmgzTTUgN2g1TTQgOGg3IiAvPgo8L3N2Zz4=");
}

::-webkit-scrollbar-button:single-button:vertical:increment,
body *::-webkit-scrollbar-button:single-button:vertical:increment {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTQgNWg3TTUgNmg1TTYgN2gzTTcgOGgxIiAvPgo8L3N2Zz4=");
}

::-webkit-scrollbar-button:single-button:horizontal:decrement,
body *::-webkit-scrollbar-button:single-button:horizontal:decrement {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTggM2gxTTcgNGgyTTYgNWgzTTUgNmg0TTYgN2gzTTcgOGgyTTggOWgxIiAvPgo8L3N2Zz4=");
}

::-webkit-scrollbar-button:single-button:horizontal:increment,
body *::-webkit-scrollbar-button:single-button:horizontal:increment {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTYgM2gxTTYgNGgyTTYgNWgzTTYgNmg0TTYgN2gzTTYgOGgyTTYgOWgxIiAvPgo8L3N2Zz4=");
}

::-webkit-scrollbar-corner,
body *::-webkit-scrollbar-corner {
  background: silver;
}

/* Firefox Windows 98 Authentic Scrollbar Polyfill */
.win98-scrollable-ff {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.win98-sb-v {
  position: absolute;
  width: 16px;
  display: flex;
  flex-direction: column;
  user-select: none;
  -moz-user-select: none;
  z-index: 99;
  background: silver;
  box-sizing: border-box;
}

.win98-sb-btn {
  width: 16px;
  height: 16px;
  min-height: 16px;
  background: silver;
  box-shadow: inset 1px 1px #dfdfdf, inset -1px -1px gray;
  border: 1px solid;
  border-color: silver #000 #000 silver;
  background-repeat: no-repeat;
  background-size: 16px;
  flex-shrink: 0;
  cursor: default;
  box-sizing: border-box;
}

.win98-sb-btn:active {
  box-shadow: inset 1px 1px #000, inset -1px -1px #dfdfdf;
  border-color: #000 silver silver #000;
}

.win98-sb-up {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTcgNWgxTTYgNmgzTTUgN2g1TTQgOGg3IiAvPgo8L3N2Zz4=");
}

.win98-sb-down {
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAxNiAxNiIgc2hhcGUtcmVuZGVyaW5nPSJjcmlzcEVkZ2VzIj4KPG1ldGFkYXRhPk1hZGUgd2l0aCBQaXhlbHMgdG8gU3ZnIGh0dHBzOi8vY29kZXBlbi5pby9zaHNoYXcvcGVuL1hieHZOajwvbWV0YWRhdGE+CjxwYXRoIHN0cm9rZT0iIzAwMDAwMCIgZD0iTTQgNWg3TTUgNmg1TTYgN2gzTTcgOGgxIiAvPgo8L3N2Zz4=");
}

.win98-sb-track {
  flex: 1 1 auto;
  position: relative;
  width: 16px;
  image-rendering: optimizeSpeed;
  image-rendering: pixelated;
  image-rendering: optimize-contrast;
  background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTAuNSAyIDIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyI+CjxtZXRhZGF0YT5NYWRlIHdpdGggUGl4ZWxzIHRvIFN2ZyBodHRwczovL2NvZGVwZW4uaW8vc2hzaGF3L3Blbi9YYnh2Tmo8L21ldGFkYXRhPgo8cGF0aCBzdHJva2U9IiNjMGMwYzAiIGQ9Ik0wIDBoMU0xIDFoMSIgLz4KPC9zdmc+");
  background-position: 0 0;
  background-repeat: repeat;
  background-size: 2px;
  box-sizing: border-box;
}

.win98-sb-thumb {
  position: absolute;
  left: 0;
  width: 16px;
  min-height: 16px;
  background: silver;
  box-shadow: inset 1px 1px #dfdfdf, inset -1px -1px gray;
  border: 1px solid;
  border-color: silver #000 #000 silver;
  cursor: default;
  box-sizing: border-box;
}

.win98-sb-thumb:active {
  background: silver;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Pixelated MS Sans Serif", "Microsoft Sans Serif", "Segoe UI", Tahoma, sans-serif;
  font-size: 11px;
  background-color: #000000;
  user-select: none;
  -webkit-user-select: none;
}

/* Background Canvas */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: none;
}

/* Desktop Workspace */
#desktop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--taskbar-height);
  z-index: 10;
  overflow: hidden;
  padding: 12px;
}

/* Desktop Icons Container (1:1 Windows 98 Grid) */
.desktop-icons-container {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 16px;
  height: 100%;
  max-width: 280px;
}

.desktop-icon {
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 3px;
  border: 1px dotted transparent;
}

.desktop-icon:hover {
  background: rgba(0, 0, 128, 0.25);
  border: 1px dotted rgba(255, 255, 255, 0.6);
}

.desktop-icon.selected {
  background: #000080;
  border: 1px dotted #ffff84;
}

.desktop-icon.selected .icon-label {
  background: #000080;
  color: #ffffff;
}

.desktop-icon .icon-img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  margin-bottom: 4px;
  filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.8));
}

.desktop-icon .icon-label {
  color: #ffffff;
  font-size: 11px;
  line-height: 1.2;
  text-shadow: 1px 1px 2px #000, 0 0 3px #000;
  word-break: break-word;
  padding: 1px 3px;
  border-radius: 1px;
}

/* Windows Base Styles (Scoped to desktop OS windows with data-window-id, avoiding conflicts with Webamp) */
.window[data-window-id] {
  position: absolute;
  min-width: 280px;
  min-height: 160px;
  max-width: 95vw;
  max-height: calc(95vh - var(--taskbar-height));
  display: flex;
  flex-direction: column;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 100;
  box-sizing: border-box;
  overflow: visible;
}

/* 
 * Authentic Win98 8-way Window Resizing Handles (Inspired by 1j01/98 os-gui)
 *  */
.window-handle {
  position: absolute;
  z-index: 120;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.window-handle-n {
  top: -5px;
  left: 8px;
  right: 8px;
  height: 9px;
  cursor: ns-resize;
}

.window-handle-s {
  bottom: -5px;
  left: 8px;
  right: 8px;
  height: 9px;
  cursor: ns-resize;
}

.window-handle-w {
  left: -5px;
  top: 8px;
  bottom: 8px;
  width: 9px;
  cursor: ew-resize;
}

.window-handle-e {
  right: -5px;
  top: 8px;
  bottom: 8px;
  width: 9px;
  cursor: ew-resize;
}

.window-handle-nw {
  top: -5px;
  left: -5px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 121;
}

.window-handle-ne {
  top: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 121;
}

.window-handle-sw {
  bottom: -5px;
  left: -5px;
  width: 14px;
  height: 14px;
  cursor: nesw-resize;
  z-index: 121;
}

.window-handle-se {
  bottom: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 121;
}

/* 最大化时禁用边缘调整手柄 */
.window[data-window-id].maximized .window-handle {
  display: none !important;
}

@media (max-width: 768px) {
  .window-handle-n, .window-handle-s { height: 16px; top: -8px; bottom: -8px; }
  .window-handle-w, .window-handle-e { width: 16px; left: -8px; right: -8px; }
  .window-handle-nw, .window-handle-ne, .window-handle-sw, .window-handle-se { width: 22px; height: 22px; }
}

.window[data-window-id].hidden {
  display: none !important;
}

.window[data-window-id].minimized {
  display: none !important;
}

.window[data-window-id].maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: calc(100vh - var(--taskbar-height)) !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  box-shadow: none;
}

.window[data-window-id] .title-bar {
  cursor: move;
  padding: 3px 4px 3px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, var(--win-title-active-start), var(--win-title-active-end));
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.window[data-window-id].inactive .title-bar {
  background: linear-gradient(90deg, var(--win-title-inactive-start), var(--win-title-inactive-end));
}

.title-bar-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: bold;
  letter-spacing: 0.5px;
  font-size: 11px;
}

.title-bar-text img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.window[data-window-id] .window-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 2px;
  padding: 6px;
  box-sizing: border-box;
}

/* 自适应卡片与多列容器排布 */
#channel-blog-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px;
  align-content: start;
  flex: 1 1 180px;
  min-height: 140px;
  overflow-y: auto;
  background: #fff;
  border: 1px inset #808080;
  padding: 6px;
}

#nav-bookmarks-container {
  flex: 1 1 0;
  min-height: 140px;
  overflow-y: auto;
  padding-right: 4px;
}

.spotify-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}

/* Taskbar */
#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--taskbar-height);
  background: var(--win-bg);
  border-top: 2px solid var(--win-border-light);
  display: flex;
  align-items: center;
  padding: 2px 3px;
  z-index: 10000;
  box-shadow: inset 0 1px 0 #fff;
}

#start-button {
  height: calc(var(--taskbar-height) - 4px);
  min-height: 22px;
  padding: 2px 6px;
  font-weight: bold;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

#start-button img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

#start-button.active {
  border-style: inset;
  background: #d4d0c8;
}

.taskbar-divider {
  width: 2px;
  height: 20px;
  background: var(--win-border-dark);
  border-right: 1px solid var(--win-border-light);
  margin: 0 4px;
}

#taskbar-tasks {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  overflow-y: hidden;
  height: 100%;
}

.taskbar-item {
  height: calc(var(--taskbar-height) - 4px);
  min-height: 22px;
  max-width: 160px;
  min-width: 80px;
  padding: 2px 6px;
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.taskbar-item.active {
  font-weight: bold;
  background: #e0e0e0;
  border-style: inset;
}

#system-tray {
  display: flex;
  align-items: center;
  gap: 6px;
  height: calc(var(--taskbar-height) - 6px);
  padding: 2px 6px;
  border: 2px inset #fff;
  background: #c0c0c0;
  font-size: 11px;
}

.tray-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  cursor: pointer;
}

#taskbar-sound-toggle {
  cursor: pointer;
  transition: transform 0.1s;
}

#taskbar-sound-toggle:active {
  transform: scale(0.9);
}

#taskbar-sound-toggle.sound-muted {
  filter: grayscale(0.2) contrast(1.1);
}

/* 
 * Windows 98 Authentic Canvas Boot Screen (LOGO.SYS 1:1)
 *  */
#win98-boot-screen {
  position: fixed;
  inset: 0;
  z-index: 99999999 !important;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}

#win98-boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#win98-boot-canvas {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(calc(100vw * 3 / 4), 100vh);
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
}

.win98-boot-skip {
  position: absolute;
  bottom: 38px;
  right: 20px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid #777;
  color: #ccc;
  font-family: "MS Sans Serif", Arial, sans-serif;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
  z-index: 10;
}

.win98-boot-skip:hover {
  background: #222;
  color: #fff;
  border-color: #aaa;
}

/* 
 * Windows 98 Authentic System Tray Balloon Notification
 *  */
.win98-tray-balloon {
  position: fixed;
  bottom: calc(var(--taskbar-height, 28px) + 8px);
  right: 10px;
  width: 245px;
  background: #ffffe1;
  color: #000;
  border: 1px solid #000;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
  font-family: "MS Sans Serif", "Microsoft YaHei", Arial, sans-serif;
  font-size: 11px;
  line-height: 1.45;
  padding: 6px 8px 8px 8px;
  z-index: 999999;
  user-select: none;
  border-radius: 4px;
  cursor: pointer;
  animation: win98-balloon-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes win98-balloon-pop {
  0% { transform: translateY(6px) scale(0.95); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.win98-tray-balloon .win98-balloon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  padding-bottom: 3px;
  border-bottom: 1px dotted #888880;
}

.win98-tray-balloon .win98-balloon-title-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.win98-tray-balloon .win98-balloon-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.win98-tray-balloon .win98-balloon-title {
  font-weight: bold;
  font-size: 11px;
  color: #000080;
}

.win98-tray-balloon .win98-balloon-close {
  background: transparent;
  border: none;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.win98-tray-balloon .win98-balloon-close:hover {
  color: #000;
}

.win98-tray-balloon .win98-balloon-content {
  font-size: 11px;
  color: #111;
}

/* Downward indicator triangle pointing to the tray speaker icon */
.win98-tray-balloon::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 76px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #ffffe1;
}

.win98-tray-balloon::before {
  content: "";
  position: absolute;
  bottom: -10px;
  right: 75px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 9px solid #000000;
}

/* Start Menu (1:1 Windows 98) */
#start-menu {
  position: fixed;
  bottom: var(--taskbar-height);
  left: 2px;
  width: 235px;
  background: var(--win-bg);
  border: 2px outset #fff;
  box-shadow: 3px 3px 10px rgba(0,0,0,0.5);
  display: none;
  flex-direction: row;
  z-index: 10001;
}

#start-menu.open {
  display: flex;
}

/* Custom Start Menu Sidebar with Vertical Gradient & Copyright */
.start-sidebar-custom {
  width: 26px;
  min-width: 26px;
  background: linear-gradient(180deg, #1084d0 0%, #000080 50%, #050528 100%);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 10px 0;
  box-sizing: border-box;
  user-select: none;
  border-right: 1px solid #808080;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.4);
  overflow: hidden;
}

.start-sidebar-text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'MS Sans Serif', 'Segoe UI', Tahoma, sans-serif;
  color: #ffffff;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
}

.start-sidebar-text .brand-text {
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 2px;
}

.start-sidebar-text .sep-dot {
  color: #ffd700;
  font-weight: bold;
}

.start-sidebar-text .cr-text {
  font-size: 9px;
  color: #ffd700;
  letter-spacing: 1px;
  font-weight: bold;
}

.start-sidebar-img {
  width: 24px;
  background: #000080;
  display: block;
  object-fit: cover;
}

.start-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2px 0;
}

.start-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 11px;
  color: #000;
}

.start-item:hover {
  background: #000080;
  color: #fff;
}

.start-item img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.start-divider {
  height: 1px;
  background: var(--win-border-dark);
  border-bottom: 1px solid var(--win-border-light);
  margin: 2px 3px;
}

/* Desktop Context Menu */
#desktop-context-menu {
  position: fixed;
  width: 180px;
  background: var(--win-bg);
  border: 2px outset #fff;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.4);
  display: none;
  flex-direction: column;
  z-index: 10002;
  padding: 2px;
}

#desktop-context-menu.visible {
  display: flex;
}

.ctx-item {
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.ctx-item:hover {
  background: #000080;
  color: #fff;
}

.ctx-divider {
  height: 1px;
  background: var(--win-border-dark);
  border-bottom: 1px solid var(--win-border-light);
  margin: 2px 0;
}

/* CRT Scanline Filter Overlay */
.crt-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
  background-size: 100% 3px, 4px 100%;
}

body.crt-active .crt-overlay {
  display: block;
}

/* 
 * Application Windows Specific UI
 *  */

/* Navigation Hub */
.nav-search-bar {
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px;
  margin-top: 4px;
}

.nav-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: #ffffff;
  border: 1px inset #808080;
  text-decoration: none;
  color: #000;
  font-size: 11px;
  cursor: pointer;
}

.nav-card:hover {
  background: #000080;
  color: #ffffff;
}

.nav-card:hover .nav-card-desc {
  color: #d8e5ff !important;
}

/* Quick Launch Toolbar (Windows 98 Style) */
.quick-launch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  border-right: 1px solid #808080;
  box-shadow: 1px 0 0 #fff;
  margin-right: 4px;
}

.quick-launch button {
  min-width: 22px !important;
  height: 22px !important;
  padding: 1px 3px !important;
  background: var(--win-surface, #c0c0c0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-launch button:active {
  box-shadow: inset 1px 1px 0px #000, inset -1px -1px 0px #fff !important;
}

/* Recycle Bin Explorer Table */
.recycle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  background: #ffffff;
}

.recycle-table th {
  background: var(--win-surface, #c0c0c0);
  font-weight: normal;
  padding: 3px 6px;
  box-shadow: inset 1px 1px 0px #fff, inset -1px -1px 0px #808080;
  text-align: left;
  user-select: none;
}

.recycle-table td {
  padding: 2px 6px;
  border-bottom: 1px dotted #e8e8e8;
  white-space: nowrap;
  user-select: none;
}

.recycle-table tr {
  cursor: pointer;
}

.recycle-table tr:hover {
  background: #f0f4ff;
}

.recycle-table tr.selected {
  background: #000080 !important;
  color: #ffffff !important;
}

.recycle-table tr.selected td {
  color: #ffffff !important;
}

.recycle-file-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 5px;
  image-rendering: pixelated;
}

/* Webamp Retro Winamp Integration */
#webamp {
  position: absolute !important;
  z-index: 10005 !important;
}

/* Ensure Webamp context menu is always above Webamp window and all desktop windows */
#webamp-context-menu {
  position: absolute !important;
  z-index: 9999999 !important;
}

.nav-card img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  image-rendering: pixelated;
}

.nav-tab-btn {
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}

.nav-tab-btn.active {
  font-weight: bold;
  background: #e0ded8;
  box-shadow: inset 1px 1px 0px #000, inset -1px -1px 0px #fff;
}

/* GitHub Profile Window */
.gh-tab-bar {
  display: flex;
  gap: 3px;
  border-bottom: 2px solid #808080;
  padding-bottom: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.gh-tab-btn {
  font-family: inherit;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  background: #c0c0c0;
  border: 2px outset #fff;
}

.gh-tab-btn:hover {
  background: #d4d0c8;
}

.gh-tab-btn.active {
  font-weight: bold;
  background: #ffffff;
  border: 2px inset #808080;
  box-shadow: inset 1px 1px 0px #000;
}

.gh-tab-content {
  display: none;
}

.gh-tab-content.active {
  display: block;
}

.gh-profile-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  background: #ffffff;
  border: 2px inset #808080;
  margin-bottom: 10px;
}

.gh-avatar {
  width: 56px;
  height: 56px;
  border: 2px inset #808080;
  object-fit: cover;
}

/* GitHub Profile External Badges & Icons */
.gh-icon-box {
  background: #ffffff;
  border: 2px inset #dfdfdf;
  box-shadow: inset 1px 1px 0 #808080;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.gh-devicon,
.gh-dashicon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  transition: transform 0.12s ease, filter 0.12s ease;
  cursor: pointer;
}

.gh-devicon:hover,
.gh-dashicon:hover {
  transform: scale(1.2);
  filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.35));
}

.gh-badge-box {
  background: #ffffff;
  border: 2px inset #dfdfdf;
  box-shadow: inset 1px 1px 0 #808080;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}

.gh-badge-box img {
  height: 26px;
  max-width: 100%;
  object-fit: contain;
  transition: transform 0.12s ease, filter 0.12s ease;
  vertical-align: middle;
}

.gh-badge-box img:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.gh-diy-table-wrapper {
  background: #ffffff;
  border: 2px inset #dfdfdf;
  box-shadow: inset 1px 1px 0 #808080;
  overflow-x: auto;
  max-height: 380px;
  overflow-y: auto;
}

.gh-diy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.gh-diy-table thead th {
  background: #c0c0c0;
  border-bottom: 2px solid #808080;
  border-right: 1px solid #808080;
  padding: 5px 8px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 #dfdfdf;
}

.gh-diy-table tbody td {
  padding: 5px 8px;
  border-bottom: 1px solid #e0e0e0;
  border-right: 1px solid #e0e0e0;
  color: #222;
}

.gh-diy-table tbody tr:nth-child(even) {
  background: #f7f7f7;
}

.gh-diy-table tbody tr:hover {
  background: #000080 !important;
  color: #ffffff !important;
}

.gh-diy-table tbody tr:hover td {
  color: #ffffff !important;
}

.gh-stats-badge {
  width: 100%;
  max-width: 440px;
  margin-top: 8px;
  border: 1px solid #808080;
}

.gh-article-card {
  display: flex;
  gap: 10px;
  background: #ffffff;
  border: 1px inset #808080;
  padding: 8px;
  margin-bottom: 8px;
  transition: background 0.15s;
}

.gh-article-card:hover {
  background: #f0f4f8;
}

.gh-article-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: bold;
  background: #000080;
  color: #fff;
  padding: 1px 5px;
  border-radius: 2px;
}

/* Guestbook & Message Cards */
.gb-message-card {
  background: #fdfdfd;
  border: 1px solid #d4d0c8;
  padding: 6px 8px;
  margin-bottom: 6px;
}

.gb-message-card:hover {
  background: #f0f7ff;
}

.gb-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  font-size: 11px;
}

.gb-message-author {
  font-weight: bold;
  color: #000080;
}

.gb-message-contact {
  color: #555;
  font-size: 10px;
  margin-left: 6px;
  background: #e8e8e8;
  padding: 1px 4px;
  border-radius: 2px;
}

.gb-message-time {
  color: #888;
  font-size: 10px;
}

.gb-message-body {
  font-size: 11px;
  line-height: 1.4;
  color: #222;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Spotify Button Active State */
#spotify-gh-playlist-btns button.active,
#spotify-win-playlist-btns button.active {
  font-weight: bold;
  background: #1DB954;
  color: #000;
  border-color: #1ed760;
  box-shadow: inset 1px 1px 0px #000;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tech-tag {
  background: #e0e0e0;
  border: 1px outset #fff;
  padding: 2px 6px;
  font-size: 10px;
}

/* Music Player UI */
.player-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-display {
  background: #000000;
  color: #00ff00;
  padding: 6px 8px;
  border: 2px inset #808080;
  font-family: monospace;
}

.player-marquee {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: #00ff66;
  font-weight: bold;
}

.player-subinfo {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #00aa44;
  margin-top: 3px;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.player-cover-art {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 2px inset #808080;
  background: #000;
}

/* Butterchurn Visualizer Window & Prominent Preset Display */
.vis-preset-display-bar {
  background: #000000;
  border: 2px inset #808080;
  padding: 4px 8px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vis-preset-led {
  color: #00ffea;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 6px #00ffea;
  flex: 1;
}

.visualizer-wrapper {
  position: relative;
  width: 100%;
  flex: 1 1 200px;
  min-height: 180px;
  background: #000000;
  border: 2px inset #808080;
  overflow: hidden;
}

#visualizer-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#visualizer-osd {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  color: #ffff00;
  font-family: monospace;
  font-size: 12px;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.75);
  padding: 4px 8px;
  border: 1px solid #ffff00;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  text-shadow: 0 0 5px #ffaa00;
}

#visualizer-osd.visible {
  opacity: 1;
}

/* Clippy Widget Styles */
.retro-clippy-widget, .clippy {
  position: fixed;
  bottom: calc(var(--taskbar-height) + 16px);
  right: 20px;
  z-index: 9999;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.clippy-balloon {
  position: absolute;
  bottom: 80px;
  right: 10px;
  background: #ffffcc;
  border: 1px solid #000000;
  border-radius: 4px;
  padding: 8px 12px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
  font-size: 11px;
  line-height: 1.4;
  max-width: 220px;
  min-width: 140px;
  color: #000;
  z-index: 10000;
}

.clippy-tip {
  position: absolute;
  bottom: -6px;
  right: 25px;
  width: 8px;
  height: 8px;
  background: #ffffcc;
  border-bottom: 1px solid #000;
  border-right: 1px solid #000;
  transform: rotate(45deg);
}

.clippy-character {
  width: 60px;
  height: 70px;
  background: radial-gradient(circle, #e6e6e6 0%, #b0b0b0 100%);
  border: 2px solid #333;
  border-radius: 28px 28px 18px 18px;
  position: relative;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.clippy-eyes {
  display: flex;
  gap: 6px;
  margin-top: -8px;
}

.clippy-eyes .eye {
  width: 14px;
  height: 18px;
  background: #fff;
  border: 1px solid #000;
  border-radius: 50%;
  position: relative;
}

.clippy-eyes .pupil {
  width: 6px;
  height: 6px;
  background: #000;
  border-radius: 50%;
  position: absolute;
  top: 5px;
  left: 4px;
}

.clippy-wiggle {
  animation: clippyBounce 0.5s ease;
}

@keyframes clippyBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(-8deg); }
  75% { transform: translateY(-4px) rotate(8deg); }
}

/* Webamp Container (Floating Winamp) */
#webamp-root {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--taskbar-height));
  overflow: visible;
  z-index: 10005;
  pointer-events: none;
}

#webamp {
  pointer-events: auto;
}

/* 
 * Responsive & Mobile Adaptation - Authentic Floating Retro Windows
 *  */
@media (max-width: 768px) {
  .desktop-icons-container {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 100%;
    gap: 8px;
    z-index: 10;
  }

  .desktop-icon {
    width: 64px;
  }

  /* 移动端支持真实的复古悬浮窗口：可任意拖拽、层叠排布、折叠与最大化 */
  .window[data-window-id] {
    max-width: calc(100vw - 12px);
    max-height: calc(100dvh - var(--taskbar-height) - 10px);
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.4);
  }

  /* 点击最大化按钮时全屏铺满 */
  .window[data-window-id].maximized {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: calc(100dvh - var(--taskbar-height)) !important;
    max-width: 100vw !important;
    max-height: calc(100dvh - var(--taskbar-height)) !important;
  }

  .window[data-window-id] .window-body {
    max-height: calc(100dvh - var(--taskbar-height) - 56px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #taskbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #webamp-root {
    top: 0;
    left: 0;
    transform: none;
  }

  .retro-clippy-widget, .clippy {
    bottom: calc(var(--taskbar-height) + 70px) !important;
    right: 14px !important;
  }
}

/* 
 * Foldable Screen Adaptations (CSS Viewport Segments API)
 *  */
@media (horizontal-viewport-segments: 2) {
  #desktop {
    display: flex;
    flex-direction: row;
    width: 100vw;
  }

  body.foldable-dual-book .window[data-window-id="win-navigation"],
  body.foldable-dual-book .window[data-window-id="win-github"],
  body.foldable-dual-book .window[data-window-id="win-channel"],
  body.foldable-dual-book .window[data-window-id="win-contact"] {
    left: env(viewport-segment-left 0 0, 0px) !important;
    top: env(viewport-segment-top 0 0, 0px) !important;
    width: env(viewport-segment-width 0 0, 50vw) !important;
    height: calc(env(viewport-segment-height 0 0, 100vh) - var(--taskbar-height)) !important;
  }

  body.foldable-dual-book .window[data-window-id="win-player"],
  body.foldable-dual-book .window[data-window-id="win-visualizer"] {
    left: env(viewport-segment-left 1 0, 50vw) !important;
    top: env(viewport-segment-top 1 0, 0px) !important;
    width: env(viewport-segment-width 1 0, 50vw) !important;
    height: calc(env(viewport-segment-height 1 0, 100vh) - var(--taskbar-height)) !important;
  }
}

@media (vertical-viewport-segments: 2), (device-posture: folded) {
  body.foldable-laptop-posture .window[data-window-id="win-visualizer"] {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 50vh !important;
  }

  body.foldable-laptop-posture .window[data-window-id="win-player"] {
    top: 50vh !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(50vh - var(--taskbar-height)) !important;
  }
}


/* 
   Windows 98 Authentic Modal Dialog & MessageBox Styles
    */

.win98-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.2);
  user-select: none;
  -webkit-user-select: none;
}

.win98-dialog-box {
  position: absolute;
  min-width: 280px;
  max-width: min(480px, calc(100vw - 16px));
  box-sizing: border-box;
  animation: win98DialogPopup 0.1s ease-out;
}

@keyframes win98DialogPopup {
  from {
    transform: scale(0.96);
    opacity: 0.8;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.win98-dialog-content {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 14px 14px 14px;
  box-sizing: border-box;
}

.win98-dialog-icon-wrap {
  flex-shrink: 0;
}

.win98-dialog-icon-wrap img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
}

.win98-dialog-body {
  flex: 1 1 auto;
  min-width: 0;
}

.win98-dialog-message {
  font-size: 12px;
  line-height: 1.5;
  color: #000;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.win98-dialog-input-wrap {
  margin-top: 10px;
}

.win98-dialog-input {
  width: 100%;
  height: 22px;
  background: #fff;
  border: 1px solid #000;
  box-shadow: inset 1px 1px #808080, inset -1px -1px #dfdfdf;
  font-family: inherit;
  font-size: 12px;
  padding: 2px 5px;
  box-sizing: border-box;
  color: #000;
}

.win98-dialog-input:focus {
  outline: none;
}

.win98-dialog-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 14px 12px 14px;
}

.win98-dialog-buttons button {
  min-width: 75px;
  min-height: 23px;
  cursor: pointer;
}
