/* ==================== */
/* Global Hidden Element Rules */
/* ==================== */

/* Prevent hidden elements from being clickable */
.hidden,
[hidden],
[aria-hidden="true"] {
  pointer-events: none !important;
}

/* ==================== */
/* System Alert         */
/* ==================== */

.system-alert {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: 0px;
  box-shadow: 0 8px 32px var(--shadow-color);
  padding: 1.5rem 1.5rem;
  max-width: 420px;
  width: calc(100% - 40px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.system-alert.show {
  opacity: 1;
  visibility: visible;
}

.system-alert-content {
  padding: 0;
  padding-right: 2.5rem;
  font-family: 'Doto', var(--font-sans);
}

.system-alert-content h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-md) 0;
  line-height: 1.3;
}

.system-alert-content p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

.system-alert-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
  border-radius: 0px;
}

.system-alert-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.system-alert-close svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 768px) {
  .system-alert {
    padding: 1.25rem 1.25rem;
    max-width: calc(100% - 40px);
    bottom: 20px;
    /* Respect safe area on iOS Safari */
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: 20px;
  }
  
  .system-alert-content {
    padding-right: 2rem;
  }

  .system-alert-content h1 {
    font-size: 1rem;
  }

  .system-alert-content p {
    font-size: 0.75rem;
  }
}

/* ==================== */
/* Info Popup           */
/* ==================== */

.info-button {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  z-index: 1002;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.info-button svg {
  width: 20px;
  height: 20px;
}

.info-button:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.info-popup {
  position: fixed;
  bottom: 68px;
  left: 20px;
  max-width: 320px;
  width: calc(100% - 40px);
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px var(--shadow-color);
  padding: var(--space-md) var(--space-lg);
  z-index: 1002;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.18s ease-out, visibility 0.18s ease-out, transform 0.18s ease-out;
}

.info-popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.info-popup-title {
  font-family: 'Doto', var(--font-sans);
  font-size: 0.9rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.info-popup-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.2rem;
}

.info-popup-content p:last-of-type {
  margin-bottom: 0;
}

.info-label {
  font-weight: 600;
  color: var(--text-primary);
}

.info-popup a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.info-popup a:hover {
  color: var(--accent-hover);
}

@media (max-width: 768px) {
  .info-button {
    bottom: 16px;
    /* Respect safe area on iOS Safari */
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
  }

  .info-popup {
    bottom: 64px;
    /* Respect safe area on iOS Safari */
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 16px;
    width: calc(100% - 32px);
  }
}

/* ==================== */
/* App Version Badge    */
/* ==================== */

.app-version {
  position: fixed;
  right: 20px;
  bottom: 16px;
  font-family: 'Doto', var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  z-index: 1001;
  opacity: 0.8;
  cursor: pointer;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.app-version:hover {
  opacity: 1;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .app-version {
    right: 16px;
    bottom: 12px;
    /* Respect safe area on iOS Safari */
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* ==================== */
/* Changelog Modal       */
/* ==================== */

.changelog-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.changelog-modal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}

.changelog-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.changelog-modal-content {
  position: relative;
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: 0px;
  box-shadow: 0 16px 48px var(--shadow-color);
  max-width: 600px;
  width: calc(100% - 40px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.changelog-modal[aria-hidden="false"] .changelog-modal-content {
  transform: scale(1);
}

.changelog-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.changelog-modal-title {
  font-family: 'Doto', var(--font-sans);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.changelog-modal-close {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
  border-radius: 0px;
}

.changelog-modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.changelog-modal-close svg {
  width: 20px;
  height: 20px;
}

.changelog-modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  flex: 1;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.changelog-modal-body::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.changelog-version {
  margin-bottom: var(--space-xl);
}

.changelog-version:last-child {
  margin-bottom: 0;
}

.changelog-version-header {
  font-family: 'Doto', var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.changelog-version-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.changelog-version-item {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  padding-left: var(--space-md);
  position: relative;
  margin-bottom: var(--space-xs);
}

.changelog-version-item:last-child {
  margin-bottom: 0;
}

.changelog-version-item::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .changelog-modal-content {
    width: calc(100% - 32px);
    max-height: 85vh;
  }

  .changelog-modal-header {
    padding: var(--space-md);
  }

  .changelog-modal-body {
    padding: var(--space-md);
  }

  .changelog-modal-title {
    font-size: 1rem;
  }
}

/* ==================== */
/* Top Menu Bar         */
/* ==================== */

.top-menu-bar {
  position: fixed;
  top: 20px;
  left: 20px;
  right: 20px;
  width: calc(100% - 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xl);
  padding: var(--space-sm) var(--space-lg);
  z-index: 1001;
}

.menu-left,
.menu-center,
.menu-right {
  display: flex;
  align-items: center;
}

.menu-left {
  min-width: 180px;
  gap: var(--space-sm);
}

.menu-time {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: 'Doto', var(--font-sans);
  white-space: nowrap;
}

.menu-divider {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
}

.menu-center {
  justify-content: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.menu-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: 0px;
  box-shadow: 0 4px 24px var(--shadow-color);
}

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 0px;
  color: #ffffff;
  transition: color var(--transition-fast), background var(--transition-fast);
  padding: 0;
  border: none;
  background: transparent;
  cursor: var(--cursor-pointer);
}

.nav-icon-btn:hover {
  color: #ffffff;
  background: var(--bg-hover);
}

.nav-icon-btn.active {
  color: var(--accent);
  background: var(--bg-active);
}

.nav-icon-btn svg,
.nav-icon-btn img {
  width: 26px;
  height: 26px;
  filter: brightness(0) invert(1);
}

.menu-weather {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1rem;
  color: var(--text-secondary);
  font-family: 'Doto', var(--font-sans);
  font-weight: 600;
}

.weather-icon {
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: inherit;
}

.weather-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  color: inherit;
}

.weather-icon svg path[data-arcade-2="on"] {
  stroke-opacity: 0.25;
}

.weather-icon svg path[data-arcade-3="on"] {
  stroke-opacity: 0;
}

.weather-temp {
  font-weight: 500;
  color: var(--text-primary);
}

.menu-right {
  gap: var(--space-sm);
  min-width: 180px;
  justify-content: flex-end;
}

.follow-btn {
  display: none; /* Hidden - functionality moved to hamburger menu */
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 0px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: var(--cursor-pointer);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.follow-btn:hover {
  background: var(--bg-hover);
}

.follow-btn.active {
  background: var(--accent);
  color: var(--bg-primary-solid);
  border-color: var(--accent);
}

.follow-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.follow-btn.active svg {
  transform: rotate(180deg);
}

/* Hide follow button on wider screens - show social icons directly */
@media (min-width: 769px) {
  .follow-btn {
    display: none;
  }
  
  .social-icons {
    display: flex;
  }
}

.social-icons {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* On mobile, hide social icons by default and show them in dropdown */
@media (max-width: 768px) {
  .social-icons {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-xs);
    padding: var(--space-sm);
    background: var(--bg-secondary);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border);
    border-radius: 0px;
    box-shadow: 0 8px 24px var(--shadow-color);
    flex-direction: column;
    align-items: stretch;
    min-width: 200px;
    z-index: 1002;
  }

  .social-icons.show {
    display: flex;
  }

  .menu-right {
    position: relative;
  }
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0px;
  color: var(--text-secondary);
  transition: color var(--transition-fast), background var(--transition-fast);
  gap: var(--space-xs);
}

.social-icon:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.social-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.social-label {
  display: none;
  margin-left: var(--space-xs);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
}


/* Hamburger Menu Button */
.hamburger-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 0px;
  color: #ffffff;
  transition: color var(--transition-fast), background var(--transition-fast);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.hamburger-menu-btn:hover {
  color: #ffffff;
  background: var(--bg-hover);
}

.hamburger-menu-btn.active {
  color: var(--accent);
  background: var(--bg-active);
}

.hamburger-menu-btn svg {
  width: 26px;
  height: 26px;
  filter: brightness(0) invert(1);
}

/* Mobile Header Menu Dropdown */
.mobile-header-menu {
  display: none;
  position: fixed;
  top: 72px;
  right: 20px;
  max-width: 280px;
  width: calc(100% - 40px);
  background: var(--bg-secondary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: 0px;
  box-shadow: 0 16px 48px var(--shadow-color);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.mobile-header-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.mobile-header-menu-content {
  padding: var(--space-md);
}

.mobile-menu-apps {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.mobile-menu-app-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 0px;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  width: 100%;
}

.mobile-menu-app-btn:hover {
  background: var(--bg-hover);
}

.mobile-menu-app-btn.active {
  background: var(--bg-active);
  color: var(--accent);
}

.mobile-menu-app-btn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

.mobile-menu-app-btn span {
  flex: 1;
}

.mobile-menu-socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.mobile-menu-social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 0px;
  color: var(--text-secondary);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.mobile-menu-social-icon:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.mobile-menu-social-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Mobile adjustments for top menu bar */
@media (max-width: 768px) {
  .top-menu-bar {
    padding: var(--space-xs) var(--space-md);
    gap: var(--space-sm);
  }

  .menu-left {
    min-width: auto;
  }

  .menu-time {
    font-size: 0.75rem;
  }

  .menu-weather {
    font-size: 0.75rem;
  }

  .social-icon {
    width: 100%;
    height: auto;
    padding: var(--space-sm);
    justify-content: flex-start;
    gap: var(--space-sm);
    border-radius: 0px;
  }

  .social-icon svg {
    width: 18px;
    height: 18px;
  }

  .social-label {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--text-primary);
  }

  /* Hide desktop nav, show hamburger on mobile */
  .menu-nav {
    display: none;
  }

  .hamburger-menu-btn {
    display: flex;
  }

  .mobile-header-menu {
    display: block;
  }

  /* Hide view mode toggle on mobile */
  .view-mode-toggle {
    display: none;
  }
}

/* CSS Custom Properties */
:root {
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Sizing */
  --sidebar-width: 220px;
  --post-list-width: 300px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Monaco', monospace;
  --cursor-default: url('images/cursor-arcade.svg') 15 15, auto;
  --cursor-pointer: url('images/cursor-arcade-pointer.svg') 15 15, pointer;

  /* Effects */
  --glass-blur: 32px;
  --shell-radius: 16px;

  /* Background image - JS will override with cache-busted version */
  --bg-fill: #06080c;
  --bg-image: url('images/dark.jpg');
  --stars-color: rgba(255, 255, 255, 0.85);

  /* Colors - WCAG AA compliant contrast ratios */
  --bg-primary: rgba(26, 26, 26, 0.82);
  --bg-secondary: rgba(36, 36, 36, 0.92);
  --bg-tertiary: rgba(45, 45, 45, 0.92);
  --bg-hover: rgba(54, 54, 54, 0.95);
  --bg-active: rgba(64, 64, 64, 0.95);

  --bg-primary-solid: #1a1a1a;
  --bg-secondary-solid: #242424;
  --bg-tertiary-solid: #2d2d2d;

  --text-primary: #f5f5f5;
  --text-secondary: #b3b3b3;
  --text-muted: #808080;

  --accent: #5698FB;
  --accent-hover: #78ADFC;

  --border: rgba(61, 61, 61, 0.7);
  --border-light: rgba(74, 74, 74, 0.7);

  --shadow-color: rgba(0, 0, 0, 0.4);
  --overlay-bg: rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* Prevent horizontal scroll globally */
  /* Fix iOS Safari height issues */
  height: 100%;
  height: -webkit-fill-available;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-fill);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: -webkit-fill-available; /* iOS Safari */
  height: 100vh;
  overflow: hidden; /* Prevent body scroll - only windows scroll */
  cursor: var(--cursor-default);
  position: relative;
  /* Extend background behind iOS Safari bottom bar */
  padding-bottom: env(safe-area-inset-bottom);
}

/* Animated background canvas */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Extend into safe areas on iOS */
  height: calc(100% + env(safe-area-inset-bottom));
  z-index: -2;
  pointer-events: none;
}

/* Stars are now rendered in the canvas background (background.js) */

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: var(--cursor-pointer);
}

a {
  cursor: var(--cursor-pointer);
}

ul {
  list-style: none;
}

/* App Layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) var(--post-list-width) 1fr;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* View Mode States */
.notes-view.view-mode-three-column .app {
  grid-template-columns: var(--sidebar-width) var(--post-list-width) 1fr;
}

.notes-view.view-mode-three-column .sidebar,
.notes-view.view-mode-three-column .post-list,
.notes-view.view-mode-three-column .note-view {
  display: flex;
}

.notes-view.view-mode-two-column .app {
  grid-template-columns: var(--post-list-width) 1fr;
}

.notes-view.view-mode-two-column .sidebar {
  display: none;
}

.notes-view.view-mode-two-column .post-list,
.notes-view.view-mode-two-column .note-view {
  display: flex;
}

.notes-view.view-mode-one-column .app {
  grid-template-columns: 1fr;
}

.notes-view.view-mode-one-column .sidebar,
.notes-view.view-mode-one-column .post-list {
  display: none;
}

.notes-view.view-mode-one-column .note-view {
  display: flex;
}

/* Sidebar */
.sidebar {
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.tag-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 6px;
  color: var(--text-secondary);
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tag-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tag-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

.tag-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.tag-item span {
  flex: 1;
}

.tag-item .tag-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Nested Tag Tree */
.tag-tree-item {
  display: flex;
  flex-direction: column;
}

.tag-item-row {
  display: flex;
  align-items: center;
}

.tag-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 0;
  border-radius: 4px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.tag-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tag-toggle .icon-toggle {
  width: 12px;
  height: 12px;
  transition: transform var(--transition-fast);
}

.tag-toggle.expanded .icon-toggle {
  transform: rotate(90deg);
}

.tag-toggle-spacer {
  width: 18px;
  margin-left: 0;
  flex-shrink: 0;
}

.tag-item.nested {
  padding-left: var(--space-xs);
}

.tag-children {
  margin-left: var(--space-md);
  border-left: 1px solid var(--border);
  padding-left: var(--space-xs);
  overflow: hidden;
  transition: max-height var(--transition-normal), opacity var(--transition-normal);
}

.tag-children.collapsed {
  display: none;
}

/* Post List */
.post-list {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.posts {
  flex: 1;
  overflow-y: auto;
}

.post-item {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  cursor: var(--cursor-pointer);
  transition: background var(--transition-fast);
}

.post-item:hover {
  background: var(--bg-hover);
}

.post-item.active {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  padding-left: calc(var(--space-lg) - 3px);
}

.post-item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-item-excerpt {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Note View */
.note-view {
  background: var(--bg-tertiary);
  overflow-y: auto;
  position: relative;
}

.note-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: var(--space-md);
}

.icon-large {
  width: 64px;
  height: 64px;
  opacity: 0.5;
}

.note-content {
  padding: var(--space-xl) var(--space-lg) 4rem;
  max-width: 720px;
  margin: 0 auto;
  animation: fadeIn var(--transition-normal);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.note-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.note-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}

.note-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.note-meta time {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.note-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.note-tag {
  font-size: 0.75rem;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-active);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* Note Body Typography */
.note-body {
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.note-body h1,
.note-body h2,
.note-body h3 {
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.note-body h1 { font-size: 1.5rem; }
.note-body h2 { font-size: 1.25rem; }
.note-body h3 { font-size: 1.125rem; }

.note-body p {
  margin-bottom: var(--space-md);
}

.note-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition-fast);
}

.note-body a:hover {
  color: var(--accent-hover);
}

.note-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.125em 0.375em;
  background: var(--bg-active);
  border-radius: 4px;
}

.note-body pre {
  background: var(--bg-primary);
  padding: var(--space-md);
  border-radius: 8px;
  overflow-x: auto;
  margin: var(--space-md) 0;
  max-width: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.note-body pre code {
  padding: 0;
  background: none;
}

.note-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.note-body ul,
.note-body ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
}

.note-body li {
  margin-bottom: var(--space-xs);
}

.note-body ul li {
  list-style: disc;
}

.note-body ol li {
  list-style: decimal;
}

.note-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: var(--space-md) 0;
  display: block;
}

.note-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--shadow-color);
  z-index: 1100; /* Above everything else for easy mobile access */
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.mobile-menu-toggle:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
  color: var(--bg-primary-solid);
}

/* Responsive Design */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  /* Hide view mode toggle on tablet and smaller */
  .view-mode-toggle {
    display: none !important;
  }

  .note-view {
    display: none;
  }

  .note-view.active {
    display: block;
    position: fixed;
    top: 60px; /* Account for top menu bar */
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--bg-primary-solid); /* Solid background to prevent transparency */
    overflow-y: auto;
    overflow-x: hidden;
  }

  .note-content {
    padding-top: var(--space-xl);
    padding-left: var(--space-md);
    padding-right: var(--space-md);
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }
}

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  /* Notes view app layout - single column on mobile */
  .notes-view .app {
    display: flex;
    flex-direction: column;
  }

  .notes-view .post-list {
    flex: 1;
    border-right: none;
    min-height: 0;
    overflow-y: auto;
  }

  .notes-view .note-view {
    display: none;
  }

  .notes-view .note-view.active {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px; /* Account for top menu bar */
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary-solid);
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 60px; /* Account for top menu bar */
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 999; /* Below top menu bar (1001) */
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: flex;
    /* Respect safe area on iOS Safari */
    bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  /* Ensure mobile menu toggle is visible when notes view is active */
  .notes-view.active .mobile-menu-toggle {
    display: flex;
  }

  .post-item {
    padding: var(--space-md);
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 998; /* Below sidebar but above content */
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

/* Back button for mobile note view */
.note-back {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-primary-solid);
}

.note-back svg {
  width: 20px;
  height: 20px;
}

@media (max-width: 1024px) {
  .note-back {
    display: flex;
  }
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  height: 200px;
}

.empty-state .icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* ==================== */
/* View Fade Transition  */
/* ==================== */

/* Simple fade transition for views - works well on mobile */
.view {
  opacity: 0;
  transition: opacity 200ms ease-out;
  pointer-events: none;
}

.view.active {
  opacity: 1;
  pointer-events: auto;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================== */
/* Views & Navigation   */
/* ==================== */

/* View containers - Windowed OS Experience */
.view {
  display: none;
  position: fixed;
  z-index: 1010; /* Above status bar (1001) so windows can be dragged */
  pointer-events: none;
}

.view.active {
  display: flex;
  pointer-events: auto;
}

/* Window dragging cursor */
.view.dragging {
  cursor: grabbing !important;
  user-select: none;
}

.window-titlebar {
  cursor: grab;
  user-select: none;
  position: relative;
  z-index: 20; /* Higher than resize handles to prevent resize when clicking titlebar */
}

/* Window resize handles */
.resize-handle {
  position: absolute;
  z-index: 10;
}

.resize-handle.resize-top {
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}

.resize-handle.resize-right {
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}

.resize-handle.resize-bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
}

.resize-handle.resize-left {
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
}

.resize-handle.resize-top-left {
  top: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

.resize-handle.resize-top-right {
  top: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
}

.resize-handle.resize-bottom-left {
  bottom: 0;
  left: 0;
  width: 16px;
  height: 16px;
  cursor: nesw-resize;
}

.resize-handle.resize-bottom-right {
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

/* Add visual indicator on hover for resize handles */
.resize-handle.resize-top-left:hover::after,
.resize-handle.resize-top-right:hover::after,
.resize-handle.resize-bottom-left:hover::after,
.resize-handle.resize-bottom-right:hover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0.3;
  border-radius: 2px;
}

.view.resizing {
  user-select: none;
}

/* Disable dragging and resizing on mobile */
@media (max-width: 768px) {
  .window-titlebar {
    cursor: default;
  }

  .view.dragging {
    cursor: default !important;
  }

  .resize-handle {
    display: none;
  }
}

/* Narrow window views (Tasks) - 500px wide, fills between menu bar and dock */
.tasks-view {
  top: 100px; /* Below top menu bar (20px margin + ~60px height + 20px spacing) */
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 64px));
  height: 600px; /* Reasonable default height - user can resize */
  max-height: calc(100vh - 120px);
  background: var(--bg-primary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px var(--shadow-color);
  overflow: hidden;
  flex-direction: column;
  z-index: 1010; /* Explicitly set to be above status bar */
}

/* Fullscreen window view (Notes) - fills between top and dock */
.notes-view.active {
  display: flex;
  top: max(80px, calc(20px + 60px)); /* Start below status bar (20px margin + ~60px height) */
  left: max(48px, 3vw);
  right: max(48px, 3vw);
  bottom: 20px; /* Remove old bottom constraint for footer */
  width: auto;
  height: auto;
  transform: none;
  background: var(--bg-primary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px var(--shadow-color);
  overflow: hidden;
  z-index: 1010; /* Explicitly set to be above status bar */
}

.notes-view {
  flex-direction: column;
}

.notes-titlebar {
  border-radius: 0px;
}

.notes-view .app {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}


/* Window Title Bar */
.window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 40px;
  flex-shrink: 0;
  position: relative;
}

/* View Mode Toggle */
.view-mode-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 0px;
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
}

.view-mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0px;
  color: #ffffff;
  transition: color var(--transition-fast), background var(--transition-fast);
  padding: 0;
  border: none;
  background: transparent;
  cursor: var(--cursor-pointer);
}

.view-mode-btn:hover {
  color: #ffffff;
  background: var(--bg-hover);
}

.view-mode-btn.active {
  color: #ffffff;
  background: var(--bg-active);
}

.view-mode-btn svg {
  width: 16px;
  height: 16px;
}

.window-titlebar h2 {
  flex: 1;
  text-align: center;
}

.window-close {
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: var(--cursor-pointer);
  transition: color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.window-close:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}

.window-close svg {
  width: 20px;
  height: 20px;
}

/* Notes Titlebar with status items */
.notes-titlebar {
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
}

.notes-titlebar h2 {
  text-align: center;
}

.window-titlebar h2 {
  font-family: 'Doto', var(--font-sans);
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

/* Tasks View */
.tasks-view {
  background: var(--bg-primary);
}

.tasks-container {
  width: 100%;
  padding: var(--space-xl);
  overflow-y: auto;
}

.tasks-section {
  margin-bottom: var(--space-xl);
}

.tasks-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.tasks-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text-primary);
}

.task-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-light);
  border-radius: 4px;
  flex-shrink: 0;
}

.task-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  position: relative;
}

.task-checkbox.checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.task-item.completed {
  opacity: 0.6;
}

.task-item.completed > span:last-child {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-item a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.task-item a:hover {
  color: var(--accent-hover);
}

.task-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.task-status.active {
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .tasks-container {
    padding: var(--space-lg);
  }

  /* Adjust windows for mobile */
  .tasks-view,
  .music-view {
    top: 72px !important;
    left: 12px !important;
    transform: none !important;
    width: calc(100vw - 24px) !important;
    height: calc(100vh - 72px - 24px) !important;
    /* Respect safe area on iOS Safari */
    height: calc(100vh - 72px - 24px - env(safe-area-inset-bottom)) !important;
  }

  .notes-view.active {
    top: 72px !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    /* Respect safe area on iOS Safari */
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }

  
  .menu-nav {
    gap: var(--space-xs);
  }
  
  .nav-icon-btn {
    width: 36px;
    height: 36px;
  }

  .nav-icon-btn svg,
  .nav-icon-btn img {
    width: 22px;
    height: 22px;
  }
  
  .menu-left {
    min-width: auto;
  }
}


/* ==================== */
/* Music View           */
/* ==================== */

.music-view {
  top: 100px; /* Below top menu bar (20px margin + ~60px height + 20px spacing) */
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 64px));
  height: 600px; /* Reasonable default height - user can resize */
  max-height: calc(100vh - 120px);
  background: var(--bg-primary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px var(--shadow-color);
  overflow: hidden;
  flex-direction: column;
  z-index: 1010; /* Explicitly set to be above status bar */
}

.music-folders {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-xl) 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.music-folders::-webkit-scrollbar {
  display: none;
}

.folder-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: var(--cursor-pointer);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.folder-tab:not(.active) {
  box-shadow: inset 0 -1px 0 var(--border);
}

.folder-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.folder-tab.active {
  color: var(--accent);
  background: var(--bg-primary);
  box-shadow: 0 -6px 24px var(--shadow-color);
}

.folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.folder-icon svg {
  width: 18px;
  height: 18px;
}

.folder-label {
  font-size: 0.9375rem;
  white-space: nowrap;
}

.music-container {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  flex: 0 0 auto;
  overflow: hidden;
  max-height: 140px;
}

.music-player {
  flex: 1 1 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-primary);
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.player-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.05);
}

.player-btn:active {
  transform: scale(0.95);
}

.player-prev,
.player-next {
  width: 36px;
  height: 36px;
}

.player-prev svg,
.player-next svg {
  width: 20px;
  height: 20px;
}

.player-play {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  aspect-ratio: 1;
  background: var(--accent);
  color: var(--bg-primary-solid);
}

.player-play:hover {
  background: var(--accent-hover);
}

.player-play svg {
  width: 28px;
  height: 28px;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.player-artist {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.player-progress {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.progress-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  cursor: var(--cursor-pointer);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.music-artwork {
  flex: 0 0 120px;
  width: 120px;
  height: 120px;
  align-self: center;
  display: flex;
  padding: 0;
  box-sizing: border-box;
}

.artwork-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
  position: relative;
}

.artwork-placeholder svg {
  width: 32px;
  height: 32px;
  opacity: 0.5;
}

.artwork-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.artwork-placeholder.is-video {
  background: #000;
  border: none;
  overflow: hidden;
}

.video-frame,
.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.music-playlist {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  min-height: 0;
}

.playlist-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: 0 var(--space-xl) var(--space-sm);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 1;
}

.filter-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: var(--cursor-pointer);
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.filter-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent);
  color: var(--bg-primary-solid);
  border-color: transparent;
}

.playlist-items {
  overflow: hidden;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  cursor: var(--cursor-pointer);
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border);
}

.playlist-item:hover {
  background: var(--bg-hover);
}

.playlist-item.active {
  background: var(--bg-tertiary);
}

.playlist-item.playing {
  color: var(--accent);
}

.playlist-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--bg-secondary);
  overflow: hidden;
  flex-shrink: 0;
}

.playlist-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.playlist-info {
  flex: 1;
  min-width: 0;
}

.playlist-title {
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-artist {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.playlist-duration {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.playlist-channel {
  text-decoration: none;
  color: inherit;
}

.playlist-external {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.playlist-channel:hover .playlist-external {
  color: var(--accent);
}

.playlist-thumb svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

/* Hide player controls when folder only has channels */
.music-container.channels-only .player-controls,
.music-container.channels-only .player-progress,
.music-container.channels-only .music-artwork {
  display: none;
}

.music-container.channels-only .music-player {
  flex: 0 0 auto;
}

.music-container.channels-only .player-info {
  text-align: center;
}

.playlist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-md);
}

.playlist-empty code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border-radius: 4px;
}

/* Mobile adjustments for music view */
@media (max-width: 768px) {
  .music-view {
    top: 72px;
    width: calc(100vw - 24px);
    height: calc(100vh - 72px - 112px);
    display: flex;
    flex-direction: column;
  }

  .window-titlebar {
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  .music-folders {
    padding: var(--space-md) var(--space-lg) 0;
    gap: var(--space-sm);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
  }

  .music-container {
    flex-direction: column;
    gap: var(--space-xs);
    flex-shrink: 0;
    padding: var(--space-sm);
    max-height: none;
  }

  .music-artwork {
    flex: 0 0 auto;
    width: 100px;
    height: 100px;
    max-width: 100px;
    margin: 0 auto;
    order: -1;
  }

  .music-player {
    flex: 1 1 auto;
    padding: 0;
    gap: 4px;
  }

  .player-controls {
    gap: var(--space-sm);
  }

  .music-playlist {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .playlist-filters {
    padding: var(--space-sm) var(--space-lg) var(--space-sm);
  }

  .playlist-item {
    padding: var(--space-md) var(--space-lg);
  }
}


/* ==================== */
/* Timeline View        */
/* ==================== */

.timeline-view {
  top: max(72px, calc(20px + 60px));
  left: max(40px, 3vw);
  right: max(40px, 3vw);
  bottom: 32px;
  width: auto;
  height: auto;
  transform: none;
  background: var(--bg-primary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 0;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px var(--shadow-color);
  flex-direction: column;
  overflow: hidden;
  z-index: 1010;
}

.timeline-window {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(8, 10, 18, 0.98) 0%, rgba(6, 8, 12, 0.98) 100%);
}

.timeline-window::before {
  content: "";
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 5px 5px, 5px 5px;
  opacity: 0.4;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.timeline-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--space-xl) var(--space-xl);
}

.timeline-header {
  max-width: 520px;
  margin-bottom: var(--space-xl);
  color: var(--text-primary);
}

.timeline-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.timeline-title {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-sm);
}

.timeline-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 420px;
}

.timeline-scroll {
  position: relative;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: var(--space-md);
  -webkit-overflow-scrolling: touch;
  /* Hide scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.timeline-scroll::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.timeline-track {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  padding: 80px 10vw 80px 4vw;
  min-height: 400px;
}

.timeline-item-top {
  padding-top: 0;
  padding-bottom: 0;
}

.timeline-item-bottom {
  padding-top: 0;
  padding-bottom: 0;
}

.timeline-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent) 10%, var(--accent) 90%, transparent);
  opacity: 0.6;
  transform: translateY(-50%);
  z-index: 0;
}

.timeline-item {
  position: relative;
  flex: 0 0 280px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}

.timeline-item.fade-in {
  opacity: 1;
  transform: translateX(0);
}

.timeline-item-top {
  align-self: flex-start;
  padding-bottom: 0;
}

.timeline-item-bottom {
  align-self: flex-end;
  padding-top: 0;
}

.timeline-icon-year-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
  z-index: 2;
}

.timeline-item-top .timeline-icon-year-group {
  order: 1;
  margin-bottom: var(--space-xs);
  margin-top: 0;
}

.timeline-item-bottom .timeline-icon-year-group {
  order: 3;
  margin-top: var(--space-xs);
  margin-bottom: 0;
}

.timeline-icon {
  width: 48px;
  height: 48px;
  padding: 8px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, rgba(86, 152, 251, 0.3), rgba(86, 152, 251, 0.1));
  border: 2px solid rgba(86, 152, 251, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.timeline-icon svg {
  width: 100%;
  height: 100%;
  color: var(--accent);
  transition: color 0.2s ease;
}

.timeline-icon::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 50%, rgba(86, 152, 251, 0.4), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.timeline-icon:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

.timeline-icon:hover::before {
  opacity: 1;
  animation: pixelGlow 0.6s ease-in-out;
}

.timeline-icon:hover::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 9px;
  background: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(86, 152, 251, 0.1) 2px, rgba(86, 152, 251, 0.1) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(86, 152, 251, 0.1) 2px, rgba(86, 152, 251, 0.1) 4px);
  animation: pixelBreak 0.5s ease-in-out;
  pointer-events: none;
}

@keyframes pixelGlow {
  0%, 100% {
    opacity: 0;
    filter: blur(0px);
  }
  50% {
    opacity: 1;
    filter: blur(8px);
  }
}

@keyframes pixelBreak {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

.timeline-connector {
  width: 2px;
  height: 40px;
  background: linear-gradient(to bottom, rgba(86, 152, 251, 0.5), rgba(86, 152, 251, 0.2));
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  margin: 0;
}

.timeline-item-top .timeline-connector {
  order: 2;
  background: linear-gradient(to bottom, rgba(86, 152, 251, 0.5), rgba(86, 152, 251, 0.2));
}

.timeline-item-bottom .timeline-connector {
  order: 2;
  background: linear-gradient(to top, rgba(86, 152, 251, 0.5), rgba(86, 152, 251, 0.2));
}

.timeline-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  z-index: 2;
}

.timeline-item-top .timeline-content {
  order: 3;
  margin-top: var(--space-md);
  margin-bottom: 0;
}

.timeline-item-bottom .timeline-content {
  order: 1;
  margin-bottom: var(--space-md);
  margin-top: 0;
}

.timeline-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--text-secondary);
}

.timeline-year {
  font-family: 'Doto', var(--font-sans);
  font-size: 1.5rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.timeline-card {
  position: relative;
  padding: var(--space-md) var(--space-lg);
  border-radius: 12px;
  background: radial-gradient(circle at 50% 0%, rgba(86, 152, 251, 0.18), transparent 60%),
              rgba(9, 11, 20, 0.96);
  border: 1px solid rgba(86, 152, 251, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  width: 100%;
  text-align: center;
}

.timeline-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: soft-light;
  opacity: 0.24;
  pointer-events: none;
}

.timeline-item-title {
  font-size: 1rem;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  line-height: 1.3;
}

.timeline-item-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

@media (max-width: 1024px) {
  .timeline-view {
    top: 72px !important;
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
  }

  .timeline-inner {
    padding: var(--space-lg);
  }

  .timeline-track {
    padding: 60px var(--space-md);
    gap: var(--space-lg);
  }

  .timeline-item {
    flex: 0 0 240px;
    width: 240px;
  }

  .timeline-icon {
    width: 40px;
    height: 40px;
  }

  .timeline-connector {
    height: 30px;
  }
}

@media (max-width: 768px) {
  .timeline-inner {
    padding: var(--space-md);
  }

  .timeline-header {
    margin-bottom: var(--space-lg);
  }

  .timeline-title {
    font-size: 1.4rem;
  }

  .timeline-track {
    padding: 50px var(--space-sm);
    gap: var(--space-md);
  }

  .timeline-item {
    flex: 0 0 200px;
    width: 200px;
  }

  .timeline-card {
    padding: var(--space-sm) var(--space-md);
  }

  .timeline-item-title {
    font-size: 0.9rem;
  }

  .timeline-item-description {
    font-size: 0.8rem;
  }

  .timeline-icon {
    width: 36px;
    height: 36px;
  }

  .timeline-connector {
    height: 25px;
  }

  .timeline-year {
    font-size: 1.25rem;
  }
}

/* ==================== */
/* Mini Music Player     */
/* ==================== */

.mini-player {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 200px;
  max-width: 240px;
  height: 64px;
  background: var(--bg-primary);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: 0px;
  box-shadow: 0 8px 32px var(--shadow-color);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-normal), visibility var(--transition-normal), transform var(--transition-normal);
  /* Respect safe area on iOS Safari */
  bottom: calc(20px + env(safe-area-inset-bottom));
}

.mini-player[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.mini-player-content {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  height: 100%;
}

.mini-player-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-player-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mini-player-placeholder {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.mini-player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.mini-player-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.mini-player-artist {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.mini-player-play-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0px;
  color: var(--text-primary);
  cursor: var(--cursor-pointer);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  padding: 0;
}

.mini-player-play-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: scale(1.05);
}

.mini-player-play-btn:active {
  transform: scale(0.95);
  background: var(--bg-active);
}

.mini-player-play-btn svg {
  width: 18px;
  height: 18px;
}

.mini-player-icon-play,
.mini-player-icon-pause {
  display: block;
}

.mini-player-icon-play.hidden,
.mini-player-icon-pause.hidden {
  display: none;
}

/* Mobile adjustments for mini player */
@media (max-width: 768px) {
  .mini-player {
    min-width: 180px;
    max-width: 220px;
    height: 56px;
    bottom: 16px;
    /* Respect safe area on iOS Safari */
    bottom: calc(16px + env(safe-area-inset-bottom));
  }

  .mini-player-content {
    padding: var(--space-xs);
    gap: var(--space-xs);
  }

  .mini-player-thumb {
    width: 36px;
    height: 36px;
  }

  .mini-player-title {
    font-size: 0.75rem;
  }

  .mini-player-artist {
    font-size: 0.625rem;
  }

  .mini-player-play-btn {
    width: 32px;
    height: 32px;
  }

  .mini-player-play-btn svg {
    width: 16px;
    height: 16px;
  }
}
