/* FunctionServer Theme: Veil (default) */
:root {
  /* Core colors */
  --bg: #09090b;
  --surface: #18181b;
  --surface-raised: #27272a;
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #52525b;
  --shadow-color: rgba(0,0,0,0.5);
  --border: #3f3f46;
  --border-subtle: #27272a;

  /* Accent colors */
  --accent: #a78bfa;
  --accent-dim: #7c3aed;
  --green: #86efac;
  --green-dim: #22c55e;

  /* Window button colors */
  --btn-close: #e94560;
  --btn-minimize: #a78bfa;
  --btn-maximize: #86efac;

  /* Window styles */
  --win-bg: var(--surface);
  --win-border: var(--border);
  --titlebar-active: transparent;
  --titlebar-inactive: transparent;
  --win-btn-position: left; /* left or right */
  --win-titlebar-height: 38px;

  /* Desktop */
  --desktop-bg: var(--bg);

  /* Menu bar (macOS-style for Veil) */
  --menubar-position: top;
  --menubar-bg: rgba(24, 24, 27, 0.85);
  --menubar-blur: blur(20px);
  --menubar-height: 28px;
  --menubar-border: var(--border);

  /* Start menu */
  --menu-bg: var(--surface);
  --menu-hover: var(--accent-dim);
  --menu-sidebar: linear-gradient(var(--accent-dim), var(--accent));
  --menu-sidebar-display: none; /* hidden in Veil */
  --menu-sidebar-width: 0; /* no sidebar space in Veil */
}

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

body {
  background: var(--desktop-bg);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  font-size: 12px;
  color: var(--text);
}

#desktop {
  position: absolute;
  top: var(--menubar-height); left: 0; right: 0; bottom: 0;
  background: var(--desktop-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}
#desktop.bg-tile { background-size: auto; background-repeat: repeat; }
#desktop.bg-stretch { background-size: 100% 100%; }
#desktop.bg-center { background-size: auto; background-repeat: no-repeat; background-position: center; }

/* Desktop Toolbar */
#desktop-toolbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 10;
  border-bottom: 1px solid var(--border-subtle);
}

#desktop-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.breadcrumb {
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.breadcrumb:hover { background: var(--surface-raised); color: var(--text); }
.breadcrumb.active { color: var(--text); cursor: default; }
.breadcrumb.active:hover { background: transparent; }
.breadcrumb-sep { color: var(--text-tertiary); }

#desktop-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.desktop-action {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.desktop-action:hover { background: var(--surface-raised); color: var(--text); }
.desktop-action.active { background: var(--accent-dim); color: var(--text); }

#desktop-icons {
  position: absolute;
  top: 36px; left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

/* Desktop Icons */
.desktop-icon {
  position: absolute;
  width: 72px;
  text-align: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.desktop-icon:hover { background: rgba(167, 139, 250, 0.15); }
.desktop-icon.selected { background: rgba(167, 139, 250, 0.3); }
.desktop-icon .icon-img {
  font-size: 32px;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.desktop-icon .icon-thumbnail {
  width: 32px;
  height: 32px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.desktop-icon .icon-thumbnail img {
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  border-radius: 4px;
}
.desktop-icon .icon-label {
  display: block;
  font-size: 11px;
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  word-wrap: break-word;
  line-height: 1.3;
}

/* Layered icons (main + sub overlay) */
.layered-icon {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}
.layered-icon .icon-main {
  display: inline-block;
  font-size: inherit;
  line-height: 1;
}
.desktop-icon .icon-img .layered-icon,
.desktop-icon .icon-img .layered-icon span {
  font-size: inherit;
}
.layered-icon .icon-sub {
  position: absolute;
  background: transparent;
  border-radius: 2px;
  padding: 0 2px;
  line-height: 1;
  white-space: pre;
  font-weight: bold;
}
.layered-icon .icon-sub pre {
  font-size: 0.25em;
  background: var(--surface);
  padding: 1px 2px;
  border-radius: 2px;
  color: var(--text);
}

.desktop-icon .icon-rename {
  display: block;
  width: 100%;
  font-size: 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 2px 4px;
  text-align: center;
  outline: none;
}
.desktop-icon.new-folder {
  animation: fadeIn 0.2s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Windows */
.window {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.window.minimized { display: none; }

.window-titlebar {
  background: var(--titlebar-active);
  color: var(--text);
  padding: 0 12px;
  height: var(--win-titlebar-height);
  display: flex;
  align-items: center;
  cursor: move;
  font-weight: 500;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
  flex-direction: row;
}
.window.inactive .window-titlebar {
  background: var(--titlebar-inactive);
  color: var(--text-secondary);
}
.window.inactive .window-btn {
  opacity: 0.5;
}
.window-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.window-controls {
  display: flex;
  gap: 8px;
  order: -1; /* Move to left side */
  margin-right: 12px;
}

/* Window buttons - circles with custom colors */
.window-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  font-size: 0;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.window-btn:hover {
  opacity: 0.9;
}
.window-btn.close { background: var(--btn-close); }
.window-btn.minimize { background: var(--btn-minimize); }
.window-btn.maximize { background: var(--btn-maximize); }

/* Show symbols on hover */
.window:hover .window-btn {
  font-size: 9px;
  color: rgba(0,0,0,0.7);
  font-weight: bold;
}
.window-btn.close::after { content: '×'; }
.window-btn.minimize::after { content: '−'; }
.window-btn.maximize::after { content: '+'; }

.window-content {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border-top: none;
}

/* Window Resize Handles */
.resize-handle {
  position: absolute;
  z-index: 10;
}
/* Edge handles (desktop) */
.resize-n { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.resize-s { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.resize-e { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.resize-w { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
/* Corner handles (desktop) */
.resize-ne { top: -4px; right: -4px; width: 12px; height: 12px; cursor: ne-resize; }
.resize-nw { top: -4px; left: -4px; width: 12px; height: 12px; cursor: nw-resize; }
.resize-se { bottom: -4px; right: -4px; width: 12px; height: 12px; cursor: se-resize; }
.resize-sw { bottom: -4px; left: -4px; width: 12px; height: 12px; cursor: sw-resize; }

/* Mobile grippy (bottom-right corner) - Veil theme styled */
.resize-grippy {
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, var(--border) 50%, var(--border) 60%, transparent 60%, transparent 70%, var(--border) 70%, var(--border) 80%, transparent 80%);
  opacity: 0.6;
  border-radius: 0 0 var(--radius) 0;
  touch-action: none;
}
.resize-grippy:active {
  opacity: 1;
}

.window-menubar {
  background: var(--surface-raised);
  padding: 4px 8px;
  display: flex;
  gap: 4px;
  position: relative;
  border-bottom: 1px solid var(--border-subtle);
}
.window-menubar .menu-item {
  padding: 4px 10px;
  cursor: pointer;
  position: relative;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}
.window-menubar .menu-item:hover {
  background: var(--accent-dim);
  color: white;
}

/* Dropdown menu */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
  z-index: 1000;
  min-width: 160px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.dropdown-menu.visible { display: block; }
.dropdown-item {
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 12px;
}
.dropdown-item:hover {
  background: var(--accent-dim);
  color: white;
}

/* Menu Bar (macOS-style for Veil theme) */
#menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--menubar-height);
  background: var(--menubar-bg);
  backdrop-filter: var(--menubar-blur);
  -webkit-backdrop-filter: var(--menubar-blur);
  border-bottom: 1px solid var(--menubar-border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  z-index: 90000;
  font-size: 13px;
}

#menubar-left {
  display: flex;
  align-items: center;
  gap: 0;
}

#menubar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 12px;
}

#system-icon {
  font-size: 16px;
  padding: 0 10px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
#system-icon:hover { color: var(--accent); }

#active-app-name {
  font-weight: 600;
  color: var(--text);
  padding: 0 12px 0 4px;
  white-space: nowrap;
}

.menubar-menu {
  padding: 4px 10px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: background 0.1s;
}
.menubar-menu:hover {
  background: var(--surface-raised);
  color: var(--text);
}

#menubar-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-icon {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.1s;
}
.status-icon:hover { background: var(--surface-raised); }

#menubar-clock {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#status-eye { color: var(--text-secondary); position: relative; }
#status-eye.connected { color: var(--text); }
#status-eye.connected::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  border: 1px solid var(--menubar-bg);
}
#status-shadow { color: var(--text-secondary); }
#status-shadow.active { color: var(--purple); }
#status-shadow.pulse {
  animation: statusPulse 0.3s ease-out;
}
@keyframes statusPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

#menubar-user {
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  transition: background 0.1s;
}
#menubar-user:hover {
  background: var(--surface-raised);
  color: var(--text);
}

#user-menu {
  position: fixed;
  top: var(--menubar-height);
  right: 80px;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  display: none;
  z-index: 99998;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
#user-menu.visible { display: block; }

.user-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.1s;
}
.user-menu-item:hover { background: var(--menu-hover); }
.user-menu-item:last-child { border-radius: 0 0 6px 6px; }

.user-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Legacy taskbar (hidden in Veil, shown in Classic) */
#taskbar {
  display: none;
}

/* Taskbar items (for Classic theme) */
#taskbar-windows {
  flex: 1;
  display: flex;
  gap: 4px;
  margin-left: 8px;
  overflow: hidden;
}
.taskbar-item {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.taskbar-item:hover {
  background: var(--border);
  color: var(--text);
}
.taskbar-item.active {
  background: var(--accent-dim);
  color: white;
  border-color: var(--accent);
}

#system-tray {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}
.tray-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
  background: transparent;
  transition: background 0.15s;
}
.tray-icon:hover { background: var(--surface-raised); }

.tray-icon.eye-tray { position: relative; }
.tray-icon.eye-tray .eye-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.tray-icon.eye-tray.connected .eye-indicator { background: var(--green); }
.tray-icon.eye-tray.active { animation: eye-blink 0.3s ease-in-out; }
@keyframes eye-blink {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.2); }
}

.tray-icon.shadow-tray {
  position: relative;
  opacity: 0.4;
  filter: grayscale(1);
  transition: opacity 0.3s, filter 0.3s;
}
.tray-icon.shadow-tray.connected { opacity: 1; filter: none; }
.tray-icon.shadow-tray .shadow-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  opacity: 0;
}
.tray-icon.shadow-tray.connected .shadow-indicator {
  background: var(--green);
  opacity: 1;
}

#clock {
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Start Menu (dropdown from menubar) */
#start-menu {
  position: fixed;
  top: var(--menubar-height);
  left: 0;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  display: none;
  z-index: 99999;
  min-width: 220px;
  max-height: calc(100vh - var(--menubar-height) - 20px);
  overflow: visible;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#start-menu.visible { display: block !important; }

.start-sidebar {
  display: var(--menu-sidebar-display);
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 28px;
  background: var(--menu-sidebar);
  border-radius: 0 0 0 8px;
  writing-mode: vertical-rl;
  color: white;
  font-weight: 600;
  font-size: 14px;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 12px;
}
.start-items {
  margin-left: var(--menu-sidebar-width, 0);
  padding: 8px 0;
  overflow-y: auto;
}
.start-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.15s;
}
.start-item:hover {
  background: var(--menu-hover);
  color: white;
}
.start-separator {
  border-top: 1px solid var(--border-subtle);
  margin: 4px 8px;
}
.start-separator-label {
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 4px 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.start-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
  min-width: 200px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 100000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  padding: 4px 0;
}
.start-submenu .start-item {
  position: relative;
  z-index: 1;
}
.start-item:hover > .start-submenu { display: block; }
.start-item.has-sub.submenu-open > .start-submenu { display: block; }

/* Nested submenus (category menus inside Programs) */
.start-submenu .start-submenu {
  left: 100%;
  top: 0;
  bottom: auto;
  position: absolute;
}
.start-submenu .start-item.has-sub:hover > .start-submenu {
  display: block;
}

/* Scroll indicator for long menus */
.scroll-indicator {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.6));
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  margin-top: -24px;
  border-radius: 0 0 6px 6px;
}
.scroll-indicator.visible { opacity: 1; }
.scroll-indicator svg {
  width: 20px;
  height: 8px;
  fill: rgba(255,255,255,0.7);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
.start-item.has-sub::after {
  content: '›';
  position: absolute;
  right: 12px;
  font-size: 14px;
  color: var(--text-tertiary);
}

/* Context Menu */
#context-menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
  z-index: 10000;
  min-width: 160px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
#context-menu.visible { display: block; }
.ctx-item {
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
}
.ctx-item:hover {
  background: var(--accent-dim);
  color: white;
}
.ctx-sep {
  border-top: 1px solid var(--border-subtle);
  margin: 4px 8px;
}
.ctx-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
  min-width: 120px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.ctx-item.has-submenu { position: relative; }
.ctx-item.has-submenu::after { content: '›'; float: right; margin-left: 8px; }
.ctx-item.has-submenu:hover > .ctx-submenu { display: block; }

/* Toast Notifications */
#toast-container {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
}
.algo-toast {
  position: fixed;
  right: 20px;
  bottom: 60px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}
.algo-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-icon { font-size: 20px; }
.toast-text { flex: 1; color: var(--text-secondary); }

/* Login Overlay */
#login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
#login-overlay.hidden { display: none; }
.login-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.login-dialog h2 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--accent);
  font-weight: 500;
}
.login-dialog label {
  display: block;
  margin: 12px 0 6px;
  color: var(--text-secondary);
  font-size: 12px;
}
.login-dialog input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.login-dialog input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-dialog .buttons {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
}
.login-dialog button {
  padding: 10px 24px;
  background: var(--accent-dim);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.login-dialog button:hover { background: var(--accent); }
.login-dialog .error {
  color: var(--btn-close);
  font-size: 12px;
  margin-top: 12px;
  text-align: center;
}
.login-dialog .tabs {
  display: flex;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: 6px;
  padding: 4px;
}
.login-dialog .tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.15s;
}
.login-dialog .tab:hover { color: var(--text); }
.login-dialog .tab.active {
  background: var(--surface-raised);
  color: var(--text);
}

/* ========== APP-SPECIFIC STYLES ========== */

/* Notepad */
.notepad-container { display: flex; flex-direction: column; height: 100%; }
.notepad-textarea {
  flex: 1;
  border: none;
  resize: none;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.notepad-textarea:focus { outline: none; }

/* IDE */
.ide-container { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.ide-main { display: flex; flex: 1; min-height: 0; }
.ide-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 250px;
}
.ide-editor textarea {
  flex: 1;
  border: none;
  resize: none;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.ide-editor textarea:focus { outline: none; }
.ide-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--surface);
}
.ide-preview-header {
  background: var(--surface-raised);
  padding: 8px 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 12px;
}
.ide-preview-content {
  flex: 1;
  overflow: auto;
  background: var(--bg);
  position: relative;
}
.ide-console {
  height: 120px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.ide-console.collapsed { height: 28px; }
.ide-console-header {
  background: var(--surface-raised);
  padding: 6px 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.ide-console-content {
  flex: 1;
  padding: 8px 12px;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  overflow-y: auto;
  color: var(--text-secondary);
}
.ide-console-content .error { color: var(--btn-close); }
.ide-console-content .warn { color: #fbbf24; }
.ide-console-content .info { color: var(--accent); }
.ide-toolbar {
  background: var(--surface-raised);
  padding: 6px 12px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.ide-toolbar select {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

/* Browser */
.browser-toolbar {
  background: var(--surface-raised);
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.browser-url {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.browser-url:focus { outline: none; border-color: var(--accent); }
.browser-frame { flex: 1; border: none; background: white; }

/* Folder */
.folder-content {
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg);
}
.folder-item {
  width: 80px;
  text-align: center;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.folder-item:hover { background: var(--surface-raised); }
.folder-item .icon-img { font-size: 36px; }
.folder-item span {
  font-size: 11px;
  display: block;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* CHM Help Viewer */
.chm-viewer { display: flex; height: 100%; background: var(--bg); }
.chm-sidebar {
  width: 200px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  font-size: 12px;
}
.chm-tree-item {
  padding: 8px 12px 8px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.chm-tree-item:hover { background: var(--surface-raised); color: var(--text); }
.chm-tree-item.active { background: var(--accent-dim); color: white; }
.chm-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.chm-content h1 { color: var(--accent); font-size: 20px; margin-bottom: 16px; font-weight: 500; }
.chm-content h2 { color: var(--accent); font-size: 16px; margin: 20px 0 12px; font-weight: 500; }
.chm-content a { color: var(--accent); }
.chm-content code {
  background: var(--surface-raised);
  padding: 2px 6px;
  font-family: 'SF Mono', monospace;
  border-radius: 4px;
  font-size: 13px;
}

/* Shade Station */
.shade-station { display: flex; flex-direction: column; height: 100%; background: var(--bg); color: var(--text); }
.shade-station-toolbar {
  background: var(--surface);
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.shade-station-toolbar button {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.shade-station-toolbar button:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.shade-station-toolbar select {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 4px;
}
.shade-station-main { flex: 1; display: flex; overflow: hidden; }
.shade-station-canvas-wrap {
  flex: 1;
  position: relative;
  background: #000;
  min-width: 200px;
}
.shade-station-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.shade-station-editor {
  width: 50%;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}
.shade-station-editor textarea {
  flex: 1;
  background: var(--bg);
  color: var(--green);
  border: none;
  padding: 12px;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
}
.shade-station-status {
  background: var(--surface);
  padding: 6px 12px;
  font-size: 11px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}
.shade-station-status.error { background: var(--btn-close); color: white; }
.shade-station-uniforms {
  background: var(--surface);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-secondary);
}
.shade-station-uniforms label { display: flex; gap: 6px; align-items: center; }
.shade-station-uniforms input[type="range"] { width: 80px; }

/* Sticky Notes */
.sticky-note {
  position: absolute;
  width: 220px;
  min-height: 160px;
  background: #fef08a;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  font-family: -apple-system, system-ui, sans-serif;
  z-index: 50;
  border-radius: 2px;
}
.sticky-note.pink { background: #fda4af; }
.sticky-note.blue { background: #93c5fd; }
.sticky-note.green { background: #86efac; }
.sticky-note-header {
  background: rgba(0,0,0,0.08);
  padding: 6px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  cursor: move;
  color: rgba(0,0,0,0.6);
}
.sticky-note-header .close-btn {
  margin-left: auto;
  cursor: pointer;
  font-weight: bold;
  padding: 0 4px;
}
.sticky-note-header .close-btn:hover { color: #000; }
.sticky-note-content { flex: 1; padding: 10px; }
.sticky-note-content textarea {
  width: 100%;
  height: 100%;
  min-height: 110px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  outline: none;
  color: rgba(0,0,0,0.8);
  line-height: 1.4;
}
.sticky-note-colors {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  border-top: 1px dashed rgba(0,0,0,0.15);
}
.sticky-note-colors span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.2);
  transition: transform 0.15s;
}
.sticky-note-colors span:hover { transform: scale(1.15); }
.sticky-note-colors .c-yellow { background: #fef08a; }
.sticky-note-colors .c-pink { background: #fda4af; }
.sticky-note-colors .c-blue { background: #93c5fd; }
.sticky-note-colors .c-green { background: #86efac; }

/* Music Player */
.winamp-player {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
  color: var(--green);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 11px;
}
.winamp-header {
  background: var(--surface);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.winamp-header .title {
  color: var(--green);
  font-weight: 500;
  font-size: 12px;
}
.winamp-display {
  background: var(--bg);
  margin: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.winamp-display .track-title {
  color: var(--green);
  font-size: 14px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
}
.winamp-display .track-time {
  color: var(--green);
  font-family: 'SF Mono', monospace;
  font-size: 24px;
  font-weight: 500;
}
.winamp-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
}
.winamp-btn {
  width: 36px;
  height: 28px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}
.winamp-btn:hover { background: var(--accent-dim); border-color: var(--accent); }
.winamp-volume {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text-secondary);
}
.winamp-volume input[type="range"] { width: 100px; accent-color: var(--green); }
.winamp-playlist {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  margin: 8px;
  border-radius: 6px;
}
.winamp-track {
  padding: 8px 12px;
  cursor: pointer;
  color: var(--green-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.winamp-track:hover { background: var(--surface-raised); }
.winamp-track.active { background: var(--surface); color: var(--green); }
.winamp-track .track-num { color: var(--text-tertiary); width: 24px; }
.winamp-track .track-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winamp-track .track-dur { color: var(--text-tertiary); font-size: 10px; }
.winamp-status {
  background: var(--surface);
  padding: 6px 12px;
  color: var(--text-tertiary);
  font-size: 10px;
  border-top: 1px solid var(--border);
}

/* Video Player */
.video-player {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}
.video-display {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.video-display iframe { width: 100%; height: 100%; border: none; }
.video-display .no-video { color: var(--text-tertiary); font-size: 14px; }
.video-controls {
  background: var(--surface);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.video-btn {
  padding: 6px 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  border-radius: 4px;
}
.video-btn:hover { background: var(--accent-dim); }
.video-progress {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.video-progress-bar { height: 100%; background: var(--accent); width: 0%; }
.video-playlist {
  max-height: 140px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 8px;
  border-radius: 6px;
}
.video-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.video-item:hover { background: var(--surface-raised); }
.video-item.active { background: var(--accent-dim); color: white; }
.video-item .video-thumb { width: 48px; height: 36px; background: var(--bg); object-fit: cover; border-radius: 4px; }
.video-item .video-info { flex: 1; }
.video-item .video-title { font-weight: 500; color: var(--text); }
.video-item.active .video-title { color: white; }
.video-item .video-source { font-size: 10px; color: var(--text-tertiary); }

/* Ticket Manager */
.ticket-container { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.ticket-toolbar {
  background: var(--surface);
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.toolbar-spacer { flex: 1; }
.icon-btn {
  position: relative;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.icon-btn:hover { background: var(--accent-dim); }
.win-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  margin-bottom: 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}
.icon-btn:hover .win-tooltip { display: block; }
.ticket-list { flex: 1; overflow-y: auto; background: var(--bg); }
.ticket-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: background 0.15s;
}
.ticket-item:hover { background: var(--surface-raised); }
.ticket-item.selected { background: var(--surface); }
.ticket-status {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
}
.ticket-status.open { background: #fbbf24; color: #000; }
.ticket-status.working { background: var(--accent); color: #000; }
.ticket-status.complete { background: var(--green); color: #000; }
.ticket-info { flex: 1; min-width: 0; }
.ticket-title { font-weight: 500; color: var(--text); margin-bottom: 4px; }
.ticket-desc { font-size: 11px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-date { font-size: 10px; color: var(--text-tertiary); margin-top: 4px; }

/* Agents */
.agents-container { padding: 20px; display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.agents-header { margin-bottom: 20px; }
.agents-header h2 { color: var(--accent); margin: 0; font-weight: 500; }
.agents-header p { color: var(--text-tertiary); font-size: 12px; margin: 6px 0 0 0; }
.agents-form { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.agents-form label { font-weight: 500; font-size: 12px; color: var(--text-secondary); }
.agents-row { display: flex; align-items: center; gap: 10px; }
.agents-row label { width: 70px; flex-shrink: 0; }
.agents-row select, .agents-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
}
.agents-row button {
  padding: 8px 16px;
  background: var(--accent-dim);
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
}
.agents-form textarea {
  flex: 1;
  min-height: 140px;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  resize: none;
  border-radius: 4px;
}
.agents-buttons { display: flex; gap: 10px; margin-top: 12px; }
.agents-buttons button {
  padding: 10px 20px;
  background: var(--accent-dim);
  border: none;
  color: white;
  border-radius: 4px;
  cursor: pointer;
}
.agents-output {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  max-height: 120px;
  overflow-y: auto;
  border-radius: 4px;
  color: var(--text-secondary);
}

/* ==================== DOCK SYSTEM ==================== */
:root {
  --dock-reserved-height: 0px;
}

/* Base dock container */
.algo-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #1a1a1f 0%, #0d0d10 100%);
  border-top: 1px solid rgba(255,255,255,0.1);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
  transition: height 0.2s ease, bottom 0.2s ease;
}

/* Traffic light buttons (macOS-style) */
.dock-traffic-lights {
  display: flex;
  gap: 6px;
  padding: 0 4px;
}

.dock-btn {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  position: relative;
}
.dock-btn:hover { opacity: 0.9; }
.dock-btn:active { transform: scale(0.9); }

.dock-btn.dock-close { background: #ff5f57; }
.dock-btn.dock-minimize { background: #ffbd2e; }
.dock-btn.dock-maximize { background: #28c940; }

/* Show symbols on hover */
.algo-dock:hover .dock-btn::after {
  font-size: 9px;
  font-weight: bold;
  color: rgba(0,0,0,0.5);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.dock-btn.dock-close:hover::after { content: '×'; }
.dock-btn.dock-minimize:hover::after { content: '−'; }
.dock-btn.dock-maximize:hover::after { content: '+'; }

/* Compact mode for docks */
.algo-dock.compact {
  max-height: 80px;
}

/* Ivory-specific dock styles */
.ivory-dock {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', sans-serif;
  font-size: 12px;
  color: #fff;
}

.ivory-dock .ivory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}

.ivory-dock .ivory-controls-left,
.ivory-dock .ivory-controls-center,
.ivory-dock .ivory-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ivory-dock .ivory-title {
  font-weight: 600;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  margin: 0 8px;
}

/* Compact mode key styling */
.ivory-dock.compact .ivory-keyboard {
  min-height: 40px;
  padding: 4px 4px 2px 4px;
}

.ivory-dock.compact .ivory-key-white {
  min-height: 40px;
  width: 24px;
}

.ivory-dock.compact .ivory-key-black {
  min-height: 26px;
  width: 16px;
  margin-left: -9px;
  margin-right: -8px;
}

.ivory-dock.compact .ivory-key-label {
  font-size: 7px;
}

.ivory-dock.compact .ivory-key-note {
  display: none;
}

/* Desktop respects dock height */
#desktop {
  bottom: var(--dock-reserved-height, 0);
  transition: bottom 0.2s ease;
}

/* Mobile styles */
@media (max-width: 768px) {
  body { font-size: 14px; }
  #desktop { bottom: 44px; }
  .desktop-icon { width: 90px; padding: 10px; }
  .desktop-icon .icon-img { font-size: 44px; }
  .desktop-icon .icon-label { font-size: 13px; }
  #taskbar { height: 44px; }
  #start-btn { font-size: 14px; padding: 8px 14px; }
  .taskbar-item { font-size: 13px; padding: 6px 12px; }
  #clock { font-size: 13px; padding: 6px 12px; }
  .window-titlebar { padding: 10px 14px; font-size: 14px; }
  .window-btn { width: 18px; height: 18px; }
  #start-menu { width: 260px; font-size: 14px; bottom: 44px !important; }
  .start-item { padding: 12px 16px; }
  .start-submenu {
    left: 0;
    top: 100%;
    max-width: 100vw;
  }
}
