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

:root {
  --green:   #a5f503;
  --pink:    #ff005d;
  --gray:    #d4d4d4;
  --dim:     #888;
  --bg:      #1e1e1e;
  --header:  #2d2d2d;
  --surface: rgba(30, 30, 30, 0.97);
  --radius:  8px;
}

body {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(120deg, #120020 0%, #6b0f8e 45%, #ff6b1a 100%);
  position: relative;
  user-select: none; /* overridden for terminal below */
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Clock ───────────────────────────────────────────── */
#clock {
  position: fixed;
  top: 14px;
  right: 20px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  z-index: 10;
  letter-spacing: 0.05em;
}

/* ── Icon dock ───────────────────────────────────────── */
#icon-dock {
  position: fixed;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 10;
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.desktop-icon:hover { transform: scale(1.1); }
.desktop-icon:active { transform: scale(0.95); }

.icon-label {
  color: #fff;
  font-size: 11px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* Terminal icon */
.terminal-icon-graphic {
  width: 64px;
  height: 64px;
  background: #111;
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  border: 1px solid #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.terminal-icon-graphic span {
  color: var(--green);
  font-size: 22px;
  font-weight: bold;
  margin: 8px 0 0 8px;
}

/* Folder icon */
.folder-icon-graphic {
  width: 64px;
  height: 64px;
  position: relative;
}
.folder-tab {
  width: 26px;
  height: 10px;
  background: #5b9bd5;
  border-radius: 3px 3px 0 0;
  position: absolute;
  top: 0;
  left: 0;
}
.folder-body {
  width: 64px;
  height: 54px;
  background: #5b9bd5;
  border-radius: 0 5px 5px 5px;
  position: absolute;
  bottom: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.desktop-icon:hover .folder-body,
.desktop-icon:hover .folder-tab { background: #79b3e8; }

/* About icon */
.about-img-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* unicrons.cloud / link icons */
#unicrons-icon-btn,
#awsug-icon-btn {
  text-decoration: none;
}
.unicrons-img-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

/* ── Window base ─────────────────────────────────────── */
.window {
  position: fixed;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.window.hidden { display: none; }

.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  z-index: 10;
}

.resize-handle::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-right: 2px solid rgba(255,255,255,0.2);
  border-bottom: 2px solid rgba(255,255,255,0.2);
}

.window-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--header);
  cursor: move;
  flex-shrink: 0;
}

.window-title {
  color: var(--dim);
  font-size: 12px;
  flex: 1;
  text-align: center;
}

.window-buttons { display: flex; gap: 8px; }

.win-btn {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  transition: filter 0.1s;
}
.win-btn:hover { filter: brightness(1.3); }
.win-btn.close    { background: #ff5f57; }
.win-btn.minimize { background: #febc2e; }
.win-btn.maximize { background: #28c840; }

/* ── Terminal window ─────────────────────────────────── */
#terminal-window {
  width: min(720px, 85vw);
  height: min(440px, 65vh);
  top: 50%;
  left: 55%;
  transform: translate(-50%, -50%);
  background: var(--surface);
}

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #444 #111;
  user-select: text;
}

.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-track { background: #111; }
.terminal-body::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }

#terminal-output {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.output-line {
  color: var(--gray);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-line.cmd    { color: var(--dim); }
.output-line.error  { color: var(--pink); }
.output-line.success { color: var(--green); }
.output-line.info   { color: #79b3e8; }

.output-line a,
.fm-file-content a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.85;
}
.output-line a:hover,
.fm-file-content a:hover { opacity: 1; }

.input-line {
  display: flex;
  align-items: center;
  margin-top: 4px;
  font-size: 13px;
}

.prompt { color: var(--green); white-space: nowrap; }

#terminal-input-display {
  color: var(--gray);
  min-width: 1px;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--gray);
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Mobile input bar */
.mobile-input-bar {
  display: none;
  align-items: center;
  padding: 8px 14px;
  background: var(--header);
  border-top: 1px solid #3a3a3a;
  gap: 6px;
}

.mobile-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--gray);
  font-family: inherit;
  font-size: 13px;
}

.mobile-input-bar input::placeholder { color: #555; }

/* ── File manager window ─────────────────────────────── */
#file-manager-window {
  width: min(660px, 88vw);
  height: min(420px, 62vh);
  top: 45%;
  left: 52%;
  transform: translate(-50%, -50%);
  background: #1c1c28;
}

.fm-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #252535;
  border-bottom: 1px solid #333348;
  flex-shrink: 0;
}

.fm-toolbar-btn {
  background: #333348;
  border: 1px solid #444460;
  border-radius: 4px;
  color: #a0a8c0;
  font-family: inherit;
  font-size: 13px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  line-height: 1.4;
}
.fm-toolbar-btn:hover  { background: #3e3e58; color: #d0d8f0; }
.fm-toolbar-btn:active { background: #2a2a40; }
.fm-toolbar-btn:disabled { opacity: 0.35; cursor: default; }

.fm-path-bar {
  flex: 1;
  background: #14141e;
  border: 1px solid #333348;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: #a5f503;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fm-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.fm-sidebar {
  width: 140px;
  flex-shrink: 0;
  background: #16161f;
  border-right: 1px solid #2a2a3a;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.fm-sidebar-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555570;
  padding: 6px 12px 4px;
}

.fm-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 12px;
  color: #8888a8;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
}
.fm-sidebar-item:hover  { background: #22223a; color: #c0c0e0; }
.fm-sidebar-item.active { background: #1e1e36; color: #00b4d8; border-left-color: #00b4d8; }

.fm-sidebar-icon {
  font-size: 13px;
  opacity: 0.7;
  width: 16px;
  text-align: center;
}

/* File grid */
.fm-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: #333348 #1c1c28;
}

.fm-body::-webkit-scrollbar       { width: 6px; }
.fm-body::-webkit-scrollbar-track { background: #1c1c28; }
.fm-body::-webkit-scrollbar-thumb { background: #333348; border-radius: 3px; }

.fm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 76px;
  cursor: pointer;
  padding: 8px 4px 6px;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.fm-item:hover  { background: #252538; border-color: #333350; }
.fm-item:active { background: #1e1e30; }
.fm-item.selected { background: #1a2a3a; border-color: #00b4d8; }

.fm-item-name {
  font-size: 11px;
  color: #b0b8d0;
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
  max-width: 100%;
}

/* CSS folder icon */
.fm-folder-icon {
  position: relative;
  width: 36px;
  height: 30px;
  flex-shrink: 0;
}
.fm-folder-tab {
  position: absolute;
  top: 0; left: 0;
  width: 15px; height: 6px;
  background: #00b4d8;
  border-radius: 2px 2px 0 0;
  opacity: 0.8;
}
.fm-folder-body {
  position: absolute;
  bottom: 0;
  width: 36px; height: 24px;
  background: #00b4d8;
  border-radius: 0 3px 3px 3px;
  opacity: 0.75;
}
.fm-item:hover .fm-folder-body,
.fm-item:hover .fm-folder-tab { opacity: 1; }

/* CSS file icon */
.fm-file-icon {
  position: relative;
  width: 28px;
  height: 34px;
  background: #2e3050;
  border: 1px solid #4a4e72;
  border-radius: 2px 5px 2px 2px;
  flex-shrink: 0;
}
.fm-file-icon::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 8px; height: 8px;
  background: #1c1c28;
  border-left: 1px solid #4a4e72;
  border-bottom: 1px solid #4a4e72;
  border-radius: 0 4px 0 0;
}
.fm-file-lines {
  position: absolute;
  bottom: 6px;
  left: 5px;
  right: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.fm-file-line {
  height: 2px;
  background: #4a4e72;
  border-radius: 1px;
}
.fm-file-line:last-child { width: 60%; }

.fm-item:hover .fm-file-icon { border-color: #6a6ea2; }

/* File content viewer */
.fm-file-content {
  flex: 1;
  padding: 16px;
  font-size: 12px;
  color: #a0a8c0;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-y: auto;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  background: #1c1c28;
}

/* Status bar */
.fm-statusbar {
  padding: 4px 12px;
  background: #16161f;
  border-top: 1px solid #2a2a3a;
  font-size: 11px;
  color: #555570;
  flex-shrink: 0;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
}

/* ── About window ────────────────────────────────────── */
#about-window {
  width: min(420px, 75vw);
  top: 40%;
  left: 55%;
  transform: translate(-50%, -50%);
  background: var(--surface);
}

.about-body {
  padding: 24px;
  color: var(--gray);
  font-size: 13px;
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.about-body h2 { color: var(--green); font-size: 16px; }
.about-body code {
  background: #333;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--green);
}

.about-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Mobile responsive ───────────────────────────────── */
@media (max-width: 600px) {
  #icon-dock {
    top: auto;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, 80px);
    gap: 28px 20px;
    justify-items: center;
    background: none;
  }

  #unicrons-icon-btn { order: 1; grid-column: 1; }
  #awsug-icon-btn    { order: 2; grid-column: 3; }
  #terminal-icon-btn { order: 3; }
  #files-icon-btn    { order: 4; }
  #about-icon-btn    { order: 5; }

  #terminal-window {
    width: 95vw;
    height: 65vh;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .mobile-input-bar { display: flex; }
  .input-line { display: none; }

  #file-manager-window {
    width: 95vw;
    height: 60vh;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  #about-window {
    width: 90vw;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
