* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family: "Fira Code", monospace;
  background: #1e1e1e;
  color: #e5e5e5;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: 42px;
}

/* Fenêtre style Windows / PuTTY */
.window-shell {
  position: absolute;
  width: 960px;
  max-width: 100%;
  min-width: 640px;
  min-height: 420px;
  height: 540px;
  background: #0f0f0f;
  border: 1px solid #3c3c3c;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.7), 0 0 0 1px #000;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s, height 0.25s, left 0.15s, top 0.15s;
}
.window-shell.maximized {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0;
}
.window-shell.minimized {
  height: 38px;
  overflow: hidden;
}
.window-titlebar {
  height: 32px;
  background: linear-gradient(#1f1f1f, #1a1a1a);
  border-bottom: 1px solid #2c2c2c;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  cursor: move;
  user-select: none;
}
.window-title {
  font-size: 13px;
  font-weight: 500;
  color: #d0d0d0;
  letter-spacing: 0.5px;
}
.window-controls {
  display: flex;
  gap: 4px;
}
.win-btn {
  width: 36px;
  height: 24px;
  border: none;
  background: #2a2a2a;
  color: #dcdcdc;
  font: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
}
.win-btn:hover {
  background: #373737;
}
.win-btn:active {
  background: #444;
}
.win-close {
  background: #c04242;
}
.win-close:hover {
  background: #d84c4c;
}
.win-close:active {
  background: #a63636;
}
.window-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Terminal container ajusté */
.terminal-container {
  width: 100%;
  height: 100%;
  max-width: none;
  background: #000;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-family: monospace;
}
.terminal-view {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.35;
  font-family: monospace;
  background: #000;
  color: #e5e5e5;
}
.input-line {
  display: flex;
  gap: 0.5rem;
  padding: 6px 8px;
  border-top: 1px solid #222;
  background: #111;
  font-size: 13px;
}
.prompt {
  display: flex;
  gap: 0;
  font-weight: 500;
}
.pr-user {
  font-weight: 600;
}
.pr-host {
  font-weight: 600;
}
.pr-path {
  font-weight: 500;
}
.pr-symbol {
  padding-left: 2px;
}
#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e5e5e5;
  font: inherit;
  caret-color: #00ff00;
}
.line {
  width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}
.line.info {
  color: #58a6ff;
}
.line.notice {
  color: #b3e5ff;
}
.line.success {
  color: #33dd66;
}
.line.error {
  color: #ff5555;
}
.line .error {
  color: #ff5555;
}
.line .warn {
  color: #ffaa00;
}
.line .dir {
  color: #ffd700;
}
.line .success {
  color: #33dd66;
}
.line .fg-red {
  color: #ff5555;
}
.line .fg-green {
  color: #50fa7b;
}
.line .fg-yellow {
  color: #f1fa8c;
}
.line .fg-blue {
  color: #61afef;
}
.line .fg-magenta {
  color: #bd93f9;
}
.line .fg-cyan {
  color: #8be9fd;
}
.line .fg-gray {
  color: #888;
}

/* Scrollbars */
.terminal-view::-webkit-scrollbar,
.nano-body::-webkit-scrollbar {
  width: 10px;
}
.terminal-view::-webkit-scrollbar-track,
nano-body::-webkit-scrollbar-track {
  background: #0a0a0a;
}
.terminal-view::-webkit-scrollbar-thumb,
nano-body::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 4px;
}
.terminal-view::-webkit-scrollbar-thumb:hover,
nano-body::-webkit-scrollbar-thumb:hover {
  background: #2f2f2f;
}

/* Nano embed adaptation couleurs */
.nano-wrapper {
  margin-top: 1rem;
  border: 1px solid #2b2b2b;
  background: #050505;
  border-radius: 4px;
}
.nano-title {
  background: #161616;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 12px;
  color: #cccccc;
}
.nano-body {
  background: #000;
  color: #d0d0d0;
  padding: 8px 10px 34px 10px;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.35;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
}
.nano-status {
  position: relative;
  margin-top: -30px;
  height: 30px;
  background: #161616;
  border-top: 1px solid #2b2b2b;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  color: #888;
}
.nano-status.dirty::before {
  content: "●";
  color: #ffaa00;
  margin-right: 4px;
}

/* Suppression styles éventuels de l'ancien modal éditeur (non utilisés) */
.editor-modal,
.editor {
  display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
  .window-shell {
    width: 100%;
  }
}
@media (max-width: 600px) {
  body {
    padding: 0.25rem;
  }
  .window-shell {
    width: 100%;
  }
}

/* palette alternative classes (ex futur commande theme) */
.theme-matrix .terminal-view {
  background: #000;
  color: #0f0;
}
.theme-matrix .prompt .pr-user,
.theme-matrix .prompt .pr-host,
.theme-matrix .prompt .pr-path {
  color: #0f0 !important;
}
.help-table {
  border-collapse: collapse;
  font-size: 12px;
}
.help-table th,
.help-table td {
  border: 1px solid #333;
  padding: 2px 6px;
}
.help-table th {
  background: #111;
  color: #66d9ef;
}
.help-table tr:nth-child(even) {
  background: #111;
}
.app-window {
  position: absolute;
  top: 60px;
  left: 60px;
  width: 640px;
  height: 420px;
  background: #121212;
  border: 1px solid #333;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 22px -6px rgba(0, 0, 0, 0.55), 0 0 0 1px #000;
}
.app-window-titlebar {
  height: 30px;
  background: #1e1e1e;
  border-bottom: 1px solid #292929;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  cursor: move;
  user-select: none;
}
.app-window-title {
  font-size: 12px;
  font-weight: 500;
  color: #d0d0d0;
}
.app-window-controls {
  display: flex;
  gap: 4px;
}
.wm-btn {
  width: 28px;
  height: 20px;
  border: none;
  background: #2a2a2a;
  color: #ccc;
  cursor: pointer;
  border-radius: 3px;
  font-size: 12px;
}
.wm-btn:hover {
  background: #353535;
}
.wm-btn:active {
  background: #444;
}
.app-window-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.app-window-iframe {
  flex: 1;
  border: 0;
  background: #fff;
}

/* Window resize handles */
.app-window .wm-resize-handle {
  position: absolute;
  z-index: 10;
}
.app-window .wm-resize-n,
.app-window .wm-resize-s {
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
}
.app-window .wm-resize-n {
  top: -3px;
}
.app-window .wm-resize-s {
  bottom: -3px;
}
.app-window .wm-resize-e,
.app-window .wm-resize-w {
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
}
.app-window .wm-resize-e {
  right: -3px;
}
.app-window .wm-resize-w {
  left: -3px;
}
.app-window .wm-resize-ne,
.app-window .wm-resize-se,
.app-window .wm-resize-sw,
.app-window .wm-resize-nw {
  width: 10px;
  height: 10px;
  position: absolute;
}
.app-window .wm-resize-ne {
  top: -4px;
  right: -4px;
  cursor: nesw-resize;
}
.app-window .wm-resize-se {
  bottom: -4px;
  right: -4px;
  cursor: nwse-resize;
}
.app-window .wm-resize-sw {
  bottom: -4px;
  left: -4px;
  cursor: nesw-resize;
}
.app-window .wm-resize-nw {
  top: -4px;
  left: -4px;
  cursor: nwse-resize;
}
.app-window.maximized .wm-resize-handle {
  display: none;
}
/* subtle hover feedback */
.app-window .wm-resize-handle:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Taskbar styles */
.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: #1a1a1a;
  border-top: 1px solid #292929;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 12px;
  z-index: 5000;
}
.task-btn {
  background: #2a2a2a;
  color: #ccc;
  border: 1px solid #333;
  border-radius: 4px;
  height: 26px;
  padding: 0 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-btn-icon {
  margin-right: 6px;
  font-size: 14px;
  line-height: 1;
}
.task-btn-label {
  pointer-events: none;
}
.app-window.minimized {
  display: none !important;
}
#window-shell.minimized {
  display: none !important;
}
.task-btn.active {
  background: #3d3d3d;
  border-color: #555;
}
.task-btn:hover {
  background: #393939;
}
.task-btn:active {
  background: #444;
}
.desktop {
  position: fixed;
  inset: 0;
  background: #101010 url();
  background-size: cover;
  overflow: hidden;
}
.desktop-icon {
  width: 72px;
  padding: 8px 4px;
  text-align: center;
  color: #ddd;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 6px;
}
.desktop-icon.desktop-file-icon {
  position: absolute;
}
.desktop-icon:focus,
.desktop-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: #333;
}
.icon-graphic {
  width: 40px;
  height: 40px;
  background: #1d1d1d;
  border: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: 10px;
  font-size: 14px;
}
.icon-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Scientific Calculator */
.calc-root {
  padding: 6px;
  display: flex;
  flex: 1;
}
.calc {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  font-family: Consolas, monospace;
}
.calc-display {
  background: #0c0c0c;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  box-shadow: inset 0 0 0 1px #111;
}
.calc-prev {
  font-size: 11px;
  color: #6d8699;
  min-height: 14px;
  letter-spacing: 0.5px;
  display: flex;
  justify-content: space-between;
}
.calc-curr {
  font-size: 22px;
  color: #e9f1f6;
  text-align: right;
  font-weight: 500;
  word-break: break-all;
}
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-content: start;
}
.calc-btn {
  position: relative;
  border: 1px solid #2d2d2d;
  background: linear-gradient(#1c1c1c, #171717);
  color: #d5dfe6;
  font-size: 13px;
  padding: 10px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  box-shadow: 0 1px 2px #000;
}
.calc-btn:hover {
  background: linear-gradient(#222, #191919);
}
.calc-btn:active {
  background: #141414;
  transform: translateY(1px);
}
.calc-btn.op {
  background: linear-gradient(#2a3244, #1e2430);
  color: #fff;
}
.calc-btn.op:hover {
  background: linear-gradient(#324055, #252f3d);
}
.calc-btn.fn {
  background: linear-gradient(#25352d, #1b261f);
  color: #d3ffe4;
}
.calc-btn.fn:hover {
  background: linear-gradient(#2d4237, #223128);
}
.calc-btn.util {
  background: linear-gradient(#3b2d25, #2b211c);
  color: #ffe1d2;
}
.calc-btn.util:hover {
  background: linear-gradient(#4a372d, #362820);
}
.calc-btn.num {
  background: linear-gradient(#202020, #181818);
}
.calc-status {
  font-size: 11px;
  color: #6a7d84;
  min-height: 14px;
}
.calc-mode {
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  color: #7fb4ff;
}

/* Desktop selection rectangle */
.desktop-selection-box {
  position: absolute;
  border: 1px solid #3a6ea5;
  background: rgba(70, 130, 180, 0.25);
  pointer-events: none;
  z-index: 10;
}
.desktop-icon.selected {
  background: rgba(100, 150, 220, 0.25);
  border-color: #3a6ea5;
  box-shadow: 0 0 0 1px #3a6ea5;
}
.desktop-icon.dragging {
  opacity: 0.85;
}

/* Desktop context menu */
.desktop-context-menu {
  position: absolute;
  min-width: 180px;
  background: #1e1e1e;
  border: 1px solid #333;
  box-shadow: 0 6px 18px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px #000;
  border-radius: 6px;
  font-size: 12px;
  padding: 4px 0;
  z-index: 6500;
  user-select: none;
}
.desktop-context-menu.hidden {
  display: none;
}
.desktop-context-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.desktop-context-menu li {
  padding: 6px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #d0d0d0;
}
.desktop-context-menu li:hover {
  background: #2a2f37;
}
.desktop-context-menu li:active {
  background: #344150;
}
.desktop-context-menu .sep {
  height: 1px;
  background: #2d2d2d;
  margin: 4px 6px;
}

/* Desktop dialog windows */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 6400;
}
.dialog-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  min-width: 300px;
  max-width: 420px;
  padding: 0;
  box-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.7), 0 0 0 1px #000;
  font-size: 13px;
  z-index: 6450;
  display: flex;
  flex-direction: column;
}
.dialog-header {
  padding: 10px 14px;
  font-weight: 600;
  background: #232323;
  border-bottom: 1px solid #2d2d2d;
}
.dialog-body {
  padding: 14px 16px;
  line-height: 1.4;
}
.dialog-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dialog-body td {
  padding: 3px 4px;
  vertical-align: top;
}
.dialog-body td.label {
  color: #79a2c6;
  width: 90px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  background: #202020;
  border-top: 1px solid #2b2b2b;
}
.dialog-actions button {
  background: #2d2d2d;
  border: 1px solid #3a3a3a;
  padding: 6px 14px;
  border-radius: 5px;
  color: #ddd;
  cursor: pointer;
  font-size: 12px;
}
.dialog-actions button.primary {
  background: #345e94;
  border-color: #3f6fae;
  color: #fff;
}
.dialog-actions button.danger {
  background: #7f2e2e;
  border-color: #9a3939;
}
.dialog-actions button:hover {
  filter: brightness(1.12);
}
.dialog-actions button:active {
  transform: translateY(1px);
}
.dialog-window input[type="text"] {
  width: 100%;
  background: #181818;
  border: 1px solid #303030;
  border-radius: 4px;
  padding: 6px 8px;
  color: #ddd;
  font: inherit;
}

/* Taskbar clock */
.taskbar-clock {
  position: absolute;
  right: 8px;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.05;
  font-family: Consolas, monospace;
  color: #d5d5d5;
  text-align: right;
  user-select: none;
}
.taskbar-clock .tb-time {
  font-weight: 500;
  letter-spacing: 0.5px;
}
.taskbar-clock .tb-date {
  font-size: 10px;
  color: #9aa3ad;
}
@media (max-width: 600px) {
  .taskbar-clock .tb-date {
    display: none;
  }
}

/* Start button & menu */
.start-button {
  width: 44px;
  height: 26px;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: #e0e0e0;
  position: relative;
}
.start-button:hover {
  background: #343434;
}
.start-button.active {
  background: #3d3d3d;
  box-shadow: inset 0 0 0 1px #4a4a4a;
}
.start-menu {
  position: fixed;
  left: 4px;
  bottom: 40px;
  width: 280px;
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 8px;
  box-shadow: 0 14px 32px -8px rgba(0, 0, 0, 0.7), 0 0 0 1px #000;
  padding: 14px 16px;
  z-index: 7000;
  display: none;
  font-size: 13px;
}
.start-menu.visible {
  display: block;
  animation: fadeInScale 0.16s ease;
}
.start-menu .start-user {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: #e5e5e5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.start-menu .settings-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #2d2d2d;
  background: #252525;
  border-radius: 6px;
  cursor: pointer;
}
.start-menu .settings-row:hover {
  background: #2d2d2d;
}
.start-menu .settings-row:active {
  background: #333;
}
.start-menu .start-settings-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #2d2d2d;
  background: #252525;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.start-menu .start-settings-row:hover {
  background: #2f2f2f;
  border-color: #3a3a3a;
}
.start-menu .start-settings-row:active {
  background: #383838;
  border-color: #444;
}
.start-menu .settings-icon {
  font-size: 16px;
}
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* snap preview */
#wm-snap-preview {
  background: rgba(65, 130, 200, 0.15);
  backdrop-filter: blur(2px);
}
.app-window.vert-max {
  border-top: 2px solid var(--accent-color, #2d6db5);
  border-bottom: 2px solid var(--accent-color, #2d6db5);
}
/* thin top edge hit area (invisible) */
.app-window .wm-vert-max-edge {
  background: transparent;
}

/* Advanced snap zones */
#wm-snap-preview {
  box-shadow: 0 0 0 2px rgba(45, 109, 181, 0.9) inset,
    0 0 0 9999px rgba(45, 109, 181, 0.08);
  backdrop-filter: blur(1px);
}
#wm-zones {
  pointer-events: none;
}
#wm-zones .wm-zone {
  outline: 2px dashed rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.12s ease, outline-color 0.12s ease;
}
#wm-zones .wm-zone.active {
  background: rgba(45, 109, 181, 0.2);
  outline-color: rgba(45, 109, 181, 0.6);
}

/* Alt+Tab overlay */
#wm-alt-tab .alt-item {
  width: 160px;
  min-width: 120px;
  max-width: 220px;
  padding: 10px;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  background: #151515;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.8;
}
#wm-alt-tab .alt-item .alt-ico {
  font-size: 24px;
}
#wm-alt-tab .alt-item .alt-title {
  font-size: 12px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
#wm-alt-tab .alt-item.active {
  border-color: #4d79b8;
  box-shadow: 0 0 0 2px rgba(77, 121, 184, 0.4) inset;
  opacity: 1;
}
.desktop-icon.drop-hover {
  outline: 2px dashed #5a5a5a;
  background: rgba(90, 90, 90, 0.15);
  border-radius: 8px;
}
#desktop.drop-hover {
  outline: 2px dashed #5a5a5a;
  outline-offset: -6px;
}
