:root {
  --panel-height: 28px;
  --bottom-panel-height: 38px;
  --panel-bg: #2b2b2b;
  --panel-fg: #ececec;
  --panel-border: #1a1a1a;
  --accent: #35bf5c;
  --accent-light: #4cd97a;
  --accent-dark: #2a9c4a;
  --wallpaper: url('../assets/wallpaper.svg');
  --title-active: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 100%);
  --title-inactive: linear-gradient(180deg, #6a6a6a 0%, #555 100%);
  --window-bg: #f0f0f0;
  --window-border: #888;
  --window-active-border: var(--accent);
  --radius: 4px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --popover-bg: #2e2e2e;
  --popover-fg: #eee;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Ubuntu", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100vw; height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  color: var(--panel-fg);
  user-select: none;
  -webkit-user-select: none;
}

.desktop {
  position: fixed;
  top: var(--panel-height);
  left: 0;
  right: 0;
  bottom: var(--bottom-panel-height);
  background: var(--wallpaper) center/cover no-repeat;
  z-index: 0;
}

.icon {
  width: 16px; height: 16px;
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
  fill: currentColor;
  color: currentColor;
}

/* Panels */
.panel {
  position: fixed;
  left: 0; right: 0;
  background: var(--panel-bg);
  color: var(--panel-fg);
  display: flex;
  align-items: center;
  padding: 0 4px;
  border: 1px solid var(--panel-border);
  z-index: 9000;
}
.top-panel {
  top: 0;
  height: var(--panel-height);
  border-bottom: 1px solid #111;
}
.bottom-panel {
  bottom: 0;
  height: var(--bottom-panel-height);
  border-top: 1px solid #111;
}
.panel-spacer { flex: 1; }
.panel-button, .tray-item, .shortcut, .task-button, .ws-button, .win-controls button {
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  min-height: 24px;
  transition: background 120ms, box-shadow 120ms;
}
.panel-button:hover, .tray-item:hover, .shortcut:hover, .task-button:hover, .ws-button:hover {
  background: rgba(255,255,255,0.08);
}
.panel-button:active, .tray-item:active, .shortcut:active, .task-button:active, .ws-button.active {
  background: rgba(255,255,255,0.15);
}

.menu-button { padding: 2px 10px; font-weight: 600; }
.menu-button .manjaro-icon { width: 18px; height: 18px; color: var(--accent); }

.system-tray { display: flex; align-items: center; gap: 2px; }
.tray-item { padding: 2px 6px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; padding: 2px 8px; }
#clock-time { font-weight: 600; font-size: 13px; }
#clock-date { font-size: 10px; color: #aaa; }

.workspace-switcher { display: flex; align-items: center; gap: 3px; }
.ws-button {
  width: 28px; height: 20px;
  padding: 0; font-size: 11px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.ws-button.active {
  background: var(--accent-dark);
  border-color: var(--accent);
  box-shadow: inset 0 0 4px rgba(0,0,0,0.3);
}

.panel-window-buttons { display: flex; gap: 2px; margin-left: 6px; }
.top-win-btn {
  max-width: 160px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
  font-size: 12px; padding: 2px 8px;
  display: flex; align-items: center; gap: 4px;
}
.top-win-btn.active { background: rgba(255,255,255,0.12); box-shadow: inset 0 0 2px rgba(0,0,0,0.3); }
.top-win-btn .icon { width: 14px; height: 14px; flex-shrink: 0; }

.app-shortcuts { display: flex; align-items: center; gap: 2px; }
.shortcut { width: 34px; height: 34px; padding: 0; }
.shortcut .icon { width: 22px; height: 22px; }
.shortcut:active { background: rgba(255,255,255,0.2); }
.task-list { display: flex; align-items: center; gap: 2px; margin-left: 8px; flex: 1; overflow: hidden; }
.task-button {
  height: 30px; min-width: 40px; max-width: 200px;
  padding: 0 10px; gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
}
.task-button.active { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.18); }
.task-button.minimized { opacity: 0.7; }
.task-button .task-count {
  font-size: 10px; background: var(--accent); color: #000; border-radius: 8px;
  padding: 0 5px; line-height: 14px; font-weight: 700;
}
.show-desktop { width: 10px; padding: 0; margin-left: 4px; border-left: 1px solid #444; border-radius: 0; }

/* Windows */
.window-layer { position: fixed; top: var(--panel-height); left: 0; right: 0; bottom: var(--bottom-panel-height); z-index: 100; pointer-events: none; }
.window { position: absolute; display: flex; flex-direction: column; background: var(--window-bg);
  border: 1px solid var(--window-border); border-radius: var(--radius); box-shadow: var(--shadow);
  pointer-events: auto; overflow: hidden; transition: opacity 160ms, transform 160ms;
  min-width: 160px; min-height: 100px;
}
.window.active { border-color: var(--window-active-border); box-shadow: 0 0 0 1px var(--window-active-border), var(--shadow); }
.window.minimized { opacity: 0; transform: scale(0.9); pointer-events: none; }
.window.maximized { border-radius: 0; border-left: none; border-right: none; border-bottom: none; }

.win-titlebar {
  height: 28px; min-height: 28px;
  background: var(--title-inactive);
  color: #eee; display: flex; align-items: center; padding: 0 4px 0 8px; gap: 6px;
  cursor: default; border-bottom: 1px solid rgba(0,0,0,0.3);
}
.window.active .win-titlebar { background: var(--title-active); }
.win-title-icon { display: flex; align-items: center; }
.win-title-icon .icon { width: 16px; height: 16px; }
.win-title-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 500; }
.win-controls { display: flex; gap: 2px; margin-left: 6px; }
.win-controls button {
  width: 22px; height: 18px; min-height: 18px;
  padding: 0; border-radius: 3px; color: #eee;
}
.win-controls button:hover { background: rgba(255,255,255,0.15); }
.win-controls .win-close:hover { background: #e74c3c; color: #fff; }
.win-body { flex: 1; overflow: auto; position: relative; background: var(--window-bg); color: #222; }
.win-resize-handle { position: absolute; right: 0; bottom: 0; width: 14px; height: 14px; cursor: se-resize; z-index: 5; }
.win-resize-handle::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 0; height: 0;
  border-style: solid; border-width: 0 0 7px 7px; border-color: transparent transparent rgba(0,0,0,0.25) transparent; }
.window.maximized .win-resize-handle { display: none; }

/* Popovers / menus */
.popover, .context-menu {
  position: fixed; z-index: 10000;
  background: var(--popover-bg); color: var(--popover-fg);
  border: 1px solid #111; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  overflow: hidden; font-size: 13px;
}
.hidden { display: none !important; }
.popover-title { padding: 8px 12px; font-weight: 600; border-bottom: 1px solid #444; }

/* Whisker Menu */
.whisker { width: 560px; max-width: 90vw; height: 440px; max-height: 70vh; display: flex; flex-direction: column; }
.whisker-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #444; }
.whisker-search .icon { color: #999; }
.whisker-search input { flex: 1; background: #222; border: 1px solid #555; color: #fff; padding: 6px 8px; border-radius: 3px; outline: none; }
.whisker-search input:focus { border-color: var(--accent); }
.whisker-body { flex: 1; display: flex; overflow: hidden; }
.whisker-categories { width: 150px; background: rgba(0,0,0,0.18); border-right: 1px solid #444; overflow-y: auto; }
.whisker-cat { padding: 8px 14px; cursor: pointer; border-left: 3px solid transparent; }
.whisker-cat:hover { background: rgba(255,255,255,0.06); }
.whisker-cat.active { background: rgba(255,255,255,0.1); border-left-color: var(--accent); color: #fff; }
.whisker-apps { flex: 1; overflow-y: auto; padding: 8px; }
.whisker-section-title { font-size: 11px; text-transform: uppercase; color: #aaa; padding: 6px 8px; }
.whisker-app { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 3px; cursor: pointer; }
.whisker-app:hover { background: rgba(255,255,255,0.1); }
.whisker-app .icon { width: 24px; height: 24px; color: #ddd; }
.whisker-app-name { font-weight: 500; }
.whisker-app-desc { font-size: 11px; color: #aaa; }

/* Context menu */
.context-menu { min-width: 180px; padding: 4px 0; }
.context-item { display: flex; align-items: center; gap: 8px; padding: 6px 14px; cursor: pointer; }
.context-item:hover { background: rgba(255,255,255,0.1); }
.context-item.disabled { opacity: 0.4; pointer-events: none; }
.context-sep { height: 1px; background: #444; margin: 4px 0; }
.context-submenu { position: absolute; left: 100%; top: 0; background: var(--popover-bg); border: 1px solid #111; border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0,0,0,0.45); min-width: 160px; padding: 4px 0; }

/* Calendar */
.calendar-popover { width: 280px; padding: 10px; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.calendar-day-label { font-size: 10px; color: #aaa; padding: 4px; text-transform: uppercase; }
.calendar-day { padding: 5px; border-radius: 50%; cursor: pointer; }
.calendar-day:hover { background: rgba(255,255,255,0.1); }
.calendar-day.today { background: var(--accent); color: #000; font-weight: 700; }
.calendar-day.other { color: #777; }

/* Volume & network */
.volume-popover { width: 220px; padding: 12px; }
.volume-popover input[type=range] { width: 100%; margin: 8px 0; }
.network-popover { width: 260px; }
.network-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid #444; }
.network-item:hover { background: rgba(255,255,255,0.06); }
.network-item .icon { width: 18px; height: 18px; }

/* Notifications */
.notifications-popover { width: 320px; max-height: 400px; overflow: auto; }
.notification-item { padding: 10px 12px; border-bottom: 1px solid #444; }
.notification-item h4 { margin: 0 0 4px; font-size: 13px; color: var(--accent-light); }
.notification-item p { margin: 0; font-size: 12px; color: #ccc; }
.toast-stack { position: fixed; right: 12px; bottom: calc(var(--bottom-panel-height) + 12px); z-index: 12000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--popover-bg); border: 1px solid #111; border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.4); padding: 10px 14px; min-width: 220px; animation: slideIn 200ms ease; border-left: 3px solid var(--accent); }
.toast-title { font-weight: 600; color: var(--accent-light); }
.toast-body { font-size: 12px; color: #ddd; margin-top: 3px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Snap preview */
.snap-preview { position: fixed; z-index: 9995; background: rgba(53,191,92,0.25); border: 2px dashed var(--accent); border-radius: var(--radius); transition: all 80ms; pointer-events: none; }

/* Desktop icons */
.desktop-icons { display: grid; grid-template-columns: repeat(auto-fill, 80px); grid-auto-rows: 84px; gap: 8px; padding: 10px; }
.desktop-icon {
  width: 80px; height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 6px 4px; border-radius: 6px; text-align: center; cursor: default; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8); transition: background 120ms;
}
.desktop-icon:hover { background: rgba(255,255,255,0.12); }
.desktop-icon.selected { background: rgba(53,191,92,0.35); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3); }
.desktop-icon .icon { width: 40px; height: 40px; margin-bottom: 4px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.desktop-icon.trash .icon { color: #bdc3c7; }
.desktop-icon label { font-size: 12px; line-height: 1.2; word-break: break-word; max-height: 30px; overflow: hidden; }

/* Thunar */
.thunar { display: flex; flex-direction: column; height: 100%; }
.thunar-toolbar { display: flex; align-items: center; gap: 4px; padding: 5px 8px; background: #e8e8e8; border-bottom: 1px solid #ccc; }
.thunar-toolbar button { background: #fff; border: 1px solid #bbb; border-radius: 3px; padding: 3px 7px; cursor: pointer; }
.thunar-toolbar button:hover { background: #f0f0f0; }
.thunar-toolbar .location-bar { flex: 1; display: flex; align-items: center; background: #fff; border: 1px solid #bbb; border-radius: 3px; padding: 3px 8px; overflow: hidden; }
.thunar-toolbar .path-entry { flex: 1; border: none; outline: none; font: inherit; background: transparent; }
.thunar-main { flex: 1; display: flex; overflow: hidden; }
.thunar-sidebar { width: 150px; background: #f6f6f6; border-right: 1px solid #ccc; overflow-y: auto; padding: 4px 0; }
.thunar-sidebar .place { display: flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: 12px; color: #333; cursor: pointer; }
.thunar-sidebar .place:hover { background: #e0e0e0; }
.thunar-sidebar .place.active { background: #d4d4d4; }
.thunar-sidebar .icon { width: 16px; height: 16px; color: #666; }
.thunar-view { flex: 1; overflow: auto; padding: 8px; background: #fff; }
.thunar-status { padding: 3px 10px; background: #e8e8e8; border-top: 1px solid #ccc; font-size: 11px; color: #555; }
.fm-item { width: 96px; display: inline-flex; flex-direction: column; align-items: center; text-align: center; padding: 6px; border-radius: 4px; cursor: default; color: #333; }
.fm-item:hover { background: #e8f5ec; }
.fm-item.selected { background: #c8ebd2; box-shadow: inset 0 0 0 1px var(--accent); }
.fm-item .icon { width: 44px; height: 44px; margin-bottom: 3px; }
.fm-item label { font-size: 12px; word-break: break-word; max-height: 32px; overflow: hidden; }
.fm-list .fm-row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid #eee; color: #333; }
.fm-list .fm-row:hover { background: #f0f0f0; }
.fm-list .fm-row.selected { background: #d8f0de; }

/* Terminal */
.terminal { height: 100%; padding: 6px 8px; background: #1a1d21; color: #f0f0f0; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 13px; line-height: 1.35; overflow-y: auto; }
.terminal-output { white-space: pre-wrap; word-break: break-word; margin-bottom: 2px; }
.terminal-line { display: block; }
.terminal-prompt { display: flex; align-items: baseline; }
.term-user { color: var(--accent-light); font-weight: 600; }
.term-host { color: var(--accent); }
.term-path { color: #74b9ff; }
.term-cursor { display: inline-block; background: var(--accent); color: #1a1d21; width: 8px; height: 1.1em; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term-ansi-green { color: var(--accent-light); }
.term-ansi-cyan { color: #74b9ff; }
.term-ansi-yellow { color: #f1c40f; }
.term-ansi-red { color: #e74c3c; }

/* Settings */
.settings { display: flex; height: 100%; background: #f5f5f5; }
.settings-sidebar { width: 170px; background: #e8e8e8; border-right: 1px solid #ccc; padding: 6px 0; overflow-y: auto; }
.settings-cat { display: flex; align-items: center; gap: 8px; padding: 8px 14px; color: #333; cursor: pointer; font-size: 13px; }
.settings-cat:hover { background: #ddd; }
.settings-cat.active { background: #fff; border-left: 3px solid var(--accent); }
.settings-panel { flex: 1; overflow-y: auto; padding: 16px 20px; color: #333; }
.settings-panel h2 { margin-top: 0; font-size: 20px; color: #222; border-bottom: 1px solid #ddd; padding-bottom: 8px; }
.settings-section { margin: 16px 0; }
.settings-section h3 { margin: 0 0 10px; font-size: 14px; color: #555; }
.wallpaper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.wp-thumb { height: 70px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; background-size: cover; background-position: center; }
.wp-thumb:hover { border-color: #aaa; }
.wp-thumb.active { border-color: var(--accent); }
.settings-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.settings-row label { min-width: 120px; color: #444; }
.settings-row input[type="text"], .settings-row select, .settings-row input[type="range"] { flex: 1; max-width: 260px; padding: 5px; }
.toggle { position: relative; width: 40px; height: 20px; background: #ccc; border-radius: 10px; cursor: pointer; transition: background 120ms; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 120ms; }
.toggle.on::after { transform: translateX(20px); }
.user-card { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid #ddd; border-radius: 4px; padding: 12px; margin-bottom: 10px; }
.user-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; }

/* Browser */
.browser { display: flex; flex-direction: column; height: 100%; }
.browser-toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: #e8e8e8; border-bottom: 1px solid #ccc; }
.browser-toolbar button { background: #fff; border: 1px solid #bbb; border-radius: 3px; padding: 3px 8px; cursor: pointer; }
.browser-toolbar button:disabled { opacity: 0.4; cursor: default; }
.address-bar { flex: 1; border: 1px solid #bbb; border-radius: 12px; padding: 4px 12px; outline: none; }
.address-bar:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(53,191,92,0.2); }
.browser-content { flex: 1; overflow: auto; background: #fff; }
.browser-page { padding: 24px; color: #333; }
.browser-start { text-align: center; padding-top: 60px; }
.browser-start h1 { color: var(--accent-dark); }
.browser-search { max-width: 480px; margin: 20px auto; display: flex; }
.browser-search input { flex: 1; border: 1px solid #ccc; border-radius: 20px 0 0 20px; padding: 10px 16px; outline: none; }
.browser-search button { border: 1px solid #ccc; border-left: none; border-radius: 0 20px 20px 0; background: var(--accent); color: #fff; padding: 0 18px; cursor: pointer; }
.browser-bookmarks { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.browser-bookmark { color: var(--accent-dark); cursor: pointer; text-decoration: underline; }
.browser-error { color: #c0392b; text-align: center; padding-top: 80px; }

/* Text editor */
.text-editor { display: flex; flex-direction: column; height: 100%; }
.editor-menu { display: flex; gap: 2px; padding: 2px 6px; background: #e8e8e8; border-bottom: 1px solid #ccc; }
.editor-menu button { background: transparent; border: 1px solid transparent; border-radius: 3px; padding: 3px 10px; cursor: pointer; color: #333; }
.editor-menu button:hover { background: #ddd; border-color: #bbb; }
.editor-area { flex: 1; border: none; outline: none; padding: 8px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; resize: none; line-height: 1.4; }
.editor-status { padding: 4px 10px; background: #e8e8e8; border-top: 1px solid #ccc; color: #555; font-size: 11px; }

/* Calculator */
.calculator { display: flex; flex-direction: column; height: 100%; background: #34495e; color: #fff; }
.calc-display { background: #2c3e50; padding: 16px; text-align: right; font-size: 28px; font-weight: 300; word-break: break-all; }
.calc-buttons { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; }
.calc-btn { border: none; background: #4a6074; color: #fff; font-size: 18px; cursor: pointer; transition: background 80ms; }
.calc-btn:hover { background: #5a7084; }
.calc-btn:active { background: #6a8094; }
.calc-btn.ac { background: #e74c3c; }
.calc-btn.op { background: #3d5266; }
.calc-btn.eq { background: var(--accent); color: #000; }

/* Generic dialogs */
.dialog-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 15000; display: flex; align-items: center; justify-content: center; }
.dialog { background: var(--popover-bg); border: 1px solid #111; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,0.5); min-width: 280px; max-width: 420px; }
.dialog-header { padding: 10px 14px; font-weight: 600; border-bottom: 1px solid #444; }
.dialog-body { padding: 14px; color: #ddd; font-size: 13px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid #444; }
.dialog-footer button { background: #444; border: 1px solid #555; color: #fff; padding: 5px 12px; border-radius: 3px; cursor: pointer; }
.dialog-footer button.primary { background: var(--accent); color: #000; border-color: var(--accent); }

/* Loading spinner */
.spinner { width: 24px; height: 24px; border: 3px solid rgba(53,191,92,0.25); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.12); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
