:root {
  --bg-deep: #060913;
  --panel-glass: rgba(13, 19, 36, 0.72);
  --panel-glass-border: rgba(255, 255, 255, 0.08);
  --panel-glass-glow: rgba(56, 189, 248, 0.15);
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --radius-xl: 18px;
  --radius-md: 10px;
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Dynamic Ambient Glows */
.ambient-glow {
  position: absolute;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  border-radius: 50%;
}

.glow-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.18) 0%, transparent 70%);
  top: -150px;
  left: 15%;
}

.glow-2 {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, transparent 70%);
  bottom: -200px;
  right: 10%;
}

.glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
  bottom: 20%;
  left: -100px;
}

/* System Ribbon (Top Bar) */
.system-ribbon {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: var(--panel-glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: 1px solid var(--panel-glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
}

.ribbon-left, .ribbon-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.os-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.os-brand:hover {
  background: rgba(255, 255, 255, 0.05);
}

.brand-glyph {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--panel-glass-glow);
}

.brand-glyph svg {
  stroke: #ffffff;
}

.brand-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.brand-title strong {
  color: var(--accent-cyan);
}

.workspace-pill {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-glass-border);
  border-radius: 8px;
  padding: 2px;
}

.ws-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.ws-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.search-capsule {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-glass-border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.search-capsule:hover {
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(0, 0, 0, 0.5);
}

.search-capsule kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.edge-telemetry {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
}

.pulse-beacon {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.digital-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Desktop Surface */
.desktop-surface {
  position: absolute;
  top: 44px;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

/* Desktop Interactive Widget Tiles */
.desktop-widgets {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 290px;
  z-index: 2;
}

.widget-tile {
  background: var(--panel-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-glass-border);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.info-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.info-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(6, 182, 212, 0.35);
}

.tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-icon svg {
  width: 20px;
  height: 20px;
  stroke: #ffffff;
}

.icon-gui { background: linear-gradient(135deg, #0284c7, #3b82f6); }
.icon-term { background: linear-gradient(135deg, #1e293b, #0f172a); border: 1px solid rgba(255, 255, 255, 0.12); }

.tile-meta h3 {
  font-size: 13px;
  font-weight: 600;
}

.tile-meta p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.tile-arrow {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-tile h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-line strong.highlight {
  color: var(--accent-cyan);
}

.badge-cf {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  padding: 1px 6px;
  border-radius: 4px;
}

/* Neo-Windows (Draggable & Floating & Resizable) */
.neo-window {
  position: absolute;
  background: rgba(10, 15, 30, 0.94);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--panel-glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: none;
  flex-direction: column;
  overflow: visible; /* Allows resize handles on corners */
  z-index: 10;
  min-width: 360px;
  min-height: 220px;
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}

/* While dragging or resizing, disable iframe interactions to ensure 60fps tracking */
body.is-resizing iframe,
body.is-dragging iframe {
  pointer-events: none !important;
}

body.is-resizing,
body.is-resizing * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* 8-Directional Window Resize Handles */
.resize-handle {
  position: absolute;
  z-index: 9995;
}

.resize-handle.handle-r {
  top: 15px;
  right: -5px;
  width: 14px;
  bottom: 15px;
  cursor: ew-resize;
}

.resize-handle.handle-l {
  top: 15px;
  left: -5px;
  width: 14px;
  bottom: 15px;
  cursor: ew-resize;
}

.resize-handle.handle-b {
  bottom: -5px;
  left: 15px;
  right: 15px;
  height: 14px;
  cursor: ns-resize;
}

.resize-handle.handle-t {
  top: -5px;
  left: 15px;
  right: 15px;
  height: 14px;
  cursor: ns-resize;
}

.resize-handle.handle-br {
  bottom: 0px;
  right: 0px;
  width: 32px;
  height: 32px;
  cursor: nwse-resize;
  z-index: 9999;
}

.resize-handle.handle-bl {
  bottom: 0px;
  left: 0px;
  width: 24px;
  height: 24px;
  cursor: nesw-resize;
  z-index: 9999;
}

.resize-handle.handle-tr {
  top: 0px;
  right: 0px;
  width: 24px;
  height: 24px;
  cursor: nesw-resize;
  z-index: 9999;
}

.resize-handle.handle-tl {
  top: 0px;
  left: 0px;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  z-index: 9999;
}

/* Visible Corner Gripper Indicator (Bottom-Right) */
.corner-gripper-ui {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 2px;
  opacity: 0.65;
  transition: opacity 0.2s, transform 0.15s;
  pointer-events: none !important; /* Critical: allows mouse events to pass through directly to handle-br */
}

.corner-gripper-ui svg {
  width: 13px;
  height: 13px;
  stroke: var(--accent-cyan);
  stroke-width: 2.2;
}

.neo-window:hover .corner-gripper-ui {
  opacity: 1;
  transform: scale(1.15);
}

.neo-window.is-maximized .resize-handle,
.neo-window.is-maximized .corner-gripper-ui {
  display: none !important;
}

.neo-window.active {
  display: flex;
  z-index: 50;
}

.window-glass-bar {
  height: 42px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--panel-glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  cursor: grab;
}

.traffic-lights {
  display: flex;
  gap: 7px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  color: rgba(0, 0, 0, 0.7);
  transition: transform 0.15s, filter 0.15s;
}

.dot:hover {
  transform: scale(1.15);
  filter: brightness(1.1);
}

.dot-close { background: #ef4444; }
.dot-close:hover::after { content: '✕'; font-size: 8px; }

.dot-min { background: #f59e0b; }
.dot-min:hover::after { content: '−'; font-size: 10px; }

.dot-max { background: #10b981; }
.dot-max:hover::after { content: '+'; font-size: 9px; }

.window-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.window-quick-tools {
  display: flex;
  gap: 6px;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.tool-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.window-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000000;
}

.frame-canvas iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Settings Canvas */
.settings-canvas {
  background: rgba(13, 19, 36, 0.95);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.settings-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.settings-card h4 {
  font-size: 14px;
  margin-bottom: 6px;
}

.settings-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.field-row select {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-glass-border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

.info-badge-row {
  display: flex;
  gap: 8px;
}

.chip {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

/* Futuristic Floating Dock */
.dock-shelf-container {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 100;
}

.dock-shelf {
  background: var(--panel-glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--panel-glass-border);
  border-radius: 22px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.dock-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
}

.app-icon svg {
  width: 22px;
  height: 22px;
  stroke: #ffffff;
}

.gui-icon { background: linear-gradient(135deg, #0284c7, #2563eb); }
.term-icon { background: linear-gradient(135deg, #1e293b, #0f172a); border: 1px solid rgba(255, 255, 255, 0.12); }
.chrome-icon { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.cfg-icon { background: linear-gradient(135deg, #475569, #64748b); }

.dock-app:hover .app-icon {
  transform: translateY(-10px) scale(1.15);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.app-indicator {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  margin-top: 4px;
}

.app-indicator.active-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.dock-separator {
  width: 1px;
  height: 30px;
  background: var(--panel-glass-border);
}

/* Window Smooth Minimize Animation */
.neo-window.minimized {
  transform: translateY(180px) scale(0.6) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.neo-window.is-maximized {
  border-radius: 0 !important;
  border-top: none !important;
}

/* Web Browser Navbar */
.browser-navbar {
  height: 44px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--panel-glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.nav-controls {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-glass-border);
  color: var(--text-primary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.address-capsule {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--panel-glass-border);
  border-radius: 8px;
  padding: 3px 10px;
}

.address-capsule svg {
  stroke: var(--accent-cyan);
}

.address-capsule input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
  font-family: var(--font-main);
}

.nav-go-btn {
  background: var(--accent-cyan);
  color: #060913;
  border: none;
  font-weight: 700;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.nav-go-btn:hover {
  background: #38bdf8;
}

.quick-bookmarks {
  display: flex;
  gap: 6px;
}

.bm-tag {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-glass-border);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.bm-tag:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent-cyan);
}

/* Fullscreen Launchpad / App Drawer */
.launchpad-overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 19, 0.82);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeInLaunchpad 0.22s ease;
}

.launchpad-overlay.active {
  display: flex;
}

@keyframes fadeInLaunchpad {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.launchpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 140px);
  gap: 36px;
  text-align: center;
}

.launchpad-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.launchpad-item:hover {
  transform: translateY(-8px) scale(1.08);
}

.lp-icon {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
}

.lp-icon svg {
  width: 32px;
  height: 32px;
  stroke: #ffffff;
}

.launchpad-item span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.restart-icon {
  background: linear-gradient(135deg, #e11d48, #be123c);
}

.ribbon-btn {
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(225, 29, 72, 0.35);
  color: #fb7185;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.ribbon-btn:hover {
  background: rgba(225, 29, 72, 0.3);
  color: #ffffff;
}

/* Edge shell (Workers free Web OS) */
.edge-shell-wrap {
  display: flex;
  flex-direction: column;
  background: #0b1220;
  color: #d7e2ff;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.edge-shell {
  flex: 1;
  overflow: auto;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.45;
}
.edge-shell-line { margin: 0 0 4px; white-space: pre-wrap; word-break: break-word; }
.edge-shell-form {
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 10px 12px;
  background: rgba(0,0,0,0.35);
}
.edge-shell-prompt, .shell-prompt { color: #7dd3fc; white-space: nowrap; }
.edge-shell-form input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  color: #f8fafc;
  font: inherit;
}
.shell-muted { color: #94a3b8; }
.shell-out { color: #e2e8f0; }
.shell-err { color: #fca5a5; }
.notes-area {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 0;
  resize: none;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  font: 15px/1.5 "Plus Jakarta Sans", sans-serif;
  outline: none;
}
.resize-handle { position: absolute; z-index: 5; }
.resize-n, .resize-s { left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.resize-e, .resize-w { top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.resize-n { top: 0; }
.resize-s { bottom: 0; }
.resize-e { right: 0; }
.resize-w { left: 0; }
.resize-ne, .resize-nw, .resize-se, .resize-sw { width: 10px; height: 10px; }
.resize-ne { top: 0; right: 0; cursor: nesw-resize; }
.resize-nw { top: 0; left: 0; cursor: nwse-resize; }
.resize-se { bottom: 0; right: 0; cursor: nwse-resize; }
.resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
.neo-window.maximized {
  top: 44px !important;
  left: 0 !important;
  width: 100vw !important;
  height: calc(100vh - 110px) !important;
}
.neo-window.minimized { display: none !important; }
.launchpad { display: none; }
.launchpad.active {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(8,12,24,0.72);
  backdrop-filter: blur(18px);
  align-items: center;
  justify-content: center;
}
.launchpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 120px);
  gap: 22px;
}
.launchpad-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #fff;
  cursor: pointer;
}
.lp-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: rgba(255,255,255,0.12);
}
