:root {
  --menubar-h: 28px;
  --dock-clearance: 92px;
  --accent: #2f7dff;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#desktop {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: url("assets/wallpaper.png") center center / cover no-repeat;
  overflow: hidden;
}

/* ============ MENU BAR ============ */
.menubar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--menubar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 1px 6px rgba(0, 0, 0, 0.08);
  color: rgba(20, 20, 24, 0.92);
  font-size: 13px;
  z-index: 5000;
}

.menubar-left, .menubar-right {
  display: flex;
  align-items: center;
  height: 100%;
}

.menu-item {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  height: 100%;
  padding: 0 10px;
  display: flex;
  align-items: center;
  cursor: default;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.menu-item:hover { background: rgba(0, 0, 0, 0.06); }
.menu-item.active-menu { background: var(--accent); color: #fff; }
.menu-item.apple-logo svg { fill: currentColor; display: block; }
.menu-item.app-name { font-weight: 700; }

.status-icons { display: flex; align-items: center; gap: 12px; margin-right: 12px; opacity: 0.9; }
.status-icon { display: block; fill: currentColor; }
.clock { font-variant-numeric: tabular-nums; opacity: 0.92; padding-right: 2px; }

/* ---- dropdowns ---- */
.dropdown {
  position: absolute;
  top: calc(var(--menubar-h) + 4px);
  left: 8px;
  min-width: 190px;
  background: rgba(246, 246, 248, 0.72);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border-radius: 9px;
  padding: 5px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.28), 0 0 0 0.5px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 1px;
  transform-origin: top left;
  transform: scale(0.85) translateY(-6px);
  opacity: 0;
  pointer-events: none;
  transition: transform 150ms var(--ease-out), opacity 120ms ease;
  z-index: 5001;
}
.dropdown.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.dropdown-item {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: #1a1a1e;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: default;
}
.dropdown-item:hover:not(:disabled) { background: var(--accent); color: #fff; }
.dropdown-item:disabled { color: rgba(0,0,0,0.32); }
.dropdown-sep { height: 1px; background: rgba(0,0,0,0.1); margin: 4px 2px; }
.dropdown-empty { padding: 6px 10px; font-size: 12px; color: rgba(0,0,0,0.4); }

/* ============ DESKTOP ICONS ============ */
.icons-layer { position: absolute; inset: 0; z-index: 10; }

.folder {
  position: absolute;
  width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: default;
  touch-action: none;
  transform: translate(-50%, -50%);
}
.folder.dragging { z-index: 4000; }
.folder.cleanup-anim { transition: left 380ms var(--ease-out), top 380ms var(--ease-out); }
.folder.selected .folder-icon { filter: brightness(0.82) saturate(1.2); }
.folder.selected .label { background: rgba(47, 125, 255, 0.75); color: #fff; }

.folder-icon {
  position: relative;
  width: 110px;
  height: 87px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
  transition: transform 120ms var(--ease-out), filter 120ms ease;
}
.folder:active .folder-icon { transform: scale(1.04); }

.folder-icon .tab {
  position: absolute;
  top: 4px;
  left: 2px;
  width: 42%;
  height: 30%;
  border-radius: 6px 8px 0 0;
  background: linear-gradient(160deg, #bfe9ff, #6fc2f2);
}
.folder-icon.image-icon { display: flex; align-items: center; justify-content: center; }
.folder-icon.image-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 18%; }

.folder-icon .body {
  position: absolute;
  top: 12px;
  left: 0;
  width: 100%;
  height: 76%;
  border-radius: 7px;
  background: linear-gradient(165deg, #a9e2ff 0%, #57b3ee 45%, #2f8fda 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), inset 0 -8px 14px rgba(10, 70, 130, 0.25);
}

.label {
  font-size: 12.5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 1px rgba(0,0,0,0.6);
  text-align: center;
  line-height: 1.25;
  padding: 1px 6px;
  border-radius: 4px;
  max-width: 100%;
}

/* ============ WINDOWS ============ */
.windows-layer { position: absolute; inset: 0; z-index: 20; pointer-events: none; }

.window {
  position: absolute;
  width: 640px;
  height: 420px;
  min-width: 340px;
  min-height: 220px;
  background: rgba(244, 244, 246, 0.82);
  backdrop-filter: blur(30px) saturate(190%);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  border-radius: 11px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  transition: transform 380ms var(--ease-out), opacity 240ms ease, width 260ms var(--ease-out), height 260ms var(--ease-out), left 260ms var(--ease-out), top 260ms var(--ease-out);
}
.window.no-anim { transition: none; }
.window.dragging-window { transition: none; }
.window.inactive { box-shadow: 0 14px 34px rgba(0,0,0,0.22), 0 0 0 0.5px rgba(0,0,0,0.1); }

.window-titlebar {
  height: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  background: linear-gradient(rgba(255,255,255,0.35), rgba(255,255,255,0));
  border-bottom: 1px solid rgba(0,0,0,0.06);
  cursor: default;
}
.traffic-lights { display: flex; gap: 8px; }
.tl {
  width: 12px; height: 12px; border-radius: 50%;
  border: 0.5px solid rgba(0,0,0,0.12);
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.tl.red { background: #ff5f57; }
.tl.yellow { background: #ffbd2e; }
.tl.green { background: #28c840; }
.window.inactive .tl { background: #d5d5d7; }
.tl svg { width: 7px; height: 7px; opacity: 0; transition: opacity 100ms ease; }
.window-titlebar:hover .tl svg { opacity: 0.55; }
.tl:active { filter: brightness(0.85); }

.window-title {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: rgba(0,0,0,0.75);
  margin-right: 62px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.window.inactive .window-title { color: rgba(0,0,0,0.4); }

.window-toolbar {
  flex: 0 0 auto;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.18);
}
.nav-btn {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: none;
  background: rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center;
  color: rgba(0,0,0,0.35);
  cursor: default;
}
.nav-btn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toolbar-spacer { flex: 1; }
.search-box {
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.06);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: rgba(0,0,0,0.4);
  width: 130px;
}
.search-box svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.window-content {
  flex: 1;
  overflow: auto;
  padding: 18px;
}
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 16px 6px;
}
.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 6px;
  text-align: center;
}
.file-item:hover { background: rgba(0,0,0,0.05); }
.social-link-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 16px; }
.social-link-item { padding: 8px; }
.social-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
  color: rgba(0,0,0,0.78);
  font-size: 11.5px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}
.social-link-card img {
  display: block;
  width: 112px;
  height: 106px;
  object-fit: contain;
  border-radius: 22px;
}
.file-icon {
  width: 44px; height: 52px;
  border-radius: 4px;
  background: linear-gradient(160deg, #eef0f3, #d7dbe1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
  display: flex; align-items: flex-end; justify-content: center;
  position: relative;
  overflow: hidden;
}
.file-icon::before {
  content: attr(data-ext);
  display: block;
  width: 100%;
  font-size: 8.5px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  padding: 2px 0;
  letter-spacing: 0.3px;
}
.file-icon.ext-pdf::before { background: #ff5c4d; }
.file-icon.ext-doc::before { background: #2f7dff; }
.file-icon.ext-xls::before { background: #1fa551; }
.file-icon.ext-key::before, .file-icon.ext-ppt::before { background: #4aa8ff; }
.file-icon.ext-img::before { background: #ff9f2e; }
.file-icon.ext-num::before { background: #22b06b; }
.file-icon.ext-folder { background: linear-gradient(165deg, #a9e2ff 0%, #57b3ee 45%, #2f8fda 100%); }
.file-icon.ext-folder::before { display: none; }
.file-icon.ext-link::before { background: #8a8f99; }
.file-name { font-size: 11.5px; color: rgba(0,0,0,0.75); line-height: 1.2; word-break: break-word; }

.resize-handle {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
}

/* curators image map */
.curators-wrap { position: relative; width: 100%; line-height: 0; }
.curators-wrap img { width: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.curators-wrap--mobile { height: 100%; }
.curators-wrap--mobile img { height: 100%; object-fit: fill; }
.curator-link {
  position: absolute;
  z-index: 2;
  display: block;
  pointer-events: auto;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}
.curator-link:hover { background: rgba(47, 125, 255, 0.16); box-shadow: inset 0 0 0 2px rgba(47, 125, 255, 0.55); }

.curator-link .tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(30, 30, 34, 0.95);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms var(--ease-out);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
  line-height: 1.4;
}
.curator-link:hover .tooltip { opacity: 1; transform: translateX(-50%) translateY(-6px); }

/* calculator */
.calculator-content { padding: 0 !important; overflow: hidden; background: #1c1c1e; }
.calculator {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #1c1c1e;
}
.calculator-display {
  min-height: 92px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  overflow: hidden;
  padding: 8px 6px;
  color: #fff;
  font-size: clamp(38px, 11vw, 58px);
  font-weight: 300;
  line-height: 1;
  white-space: nowrap;
}
.calculator-keys { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.calculator-key {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  background: #333336;
  color: #fff;
  font: inherit;
  font-size: clamp(20px, 6vw, 28px);
  cursor: pointer;
  touch-action: manipulation;
}
.calculator-key:active { filter: brightness(1.35); }
.calculator-key.function { background: #a5a5a5; color: #111; }
.calculator-key.operator { background: #ff9f0a; }
.calculator-key.operator.active { background: #fff; color: #ff9f0a; }
.calculator-key.zero { grid-column: span 2; text-align: left; padding-left: 28%; }
/* about panel content */
.about-content { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 20px; text-align: center; }
.about-content .apple-big { width: 46px; height: 52px; fill: rgba(0,0,0,0.75); }
.about-content h2 { margin: 4px 0 0; font-size: 17px; }
.about-content p { margin: 0; font-size: 12px; color: rgba(0,0,0,0.55); }

/* ============ DOCK ============ */
.dock-wrap {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  display: flex;
  justify-content: center;
  z-index: 3000;
  pointer-events: none;
}
.dock {
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3), inset 0 0.5px 0 rgba(255,255,255,0.4);
}
.dock-icon {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  width: 48px;
  height: 48px;
  cursor: default;
  transform: scale(1) translateY(0);
  transform-origin: bottom center;
  transition: transform 90ms ease-out;
  position: relative;
  flex: 0 0 auto;
}
.dock-icon svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 3px 4px rgba(0,0,0,0.25)); }
.dock-icon::after {
  content: "";
  position: absolute;
  bottom: -9px; left: 50%;
  width: 4px; height: 4px;
  background: rgba(40,40,44,0.8);
  border-radius: 50%;
  opacity: 0;
  transform: translateX(-50%);
}
.dock-icon.running::after { opacity: 1; }
.dock-icon.bounce { animation: dockBounce 520ms ease; }
@keyframes dockBounce {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-22px) scale(1); }
  50% { transform: translateY(0) scale(1); }
  65% { transform: translateY(-9px) scale(1); }
  80% { transform: translateY(0) scale(1); }
  100% { transform: translateY(0) scale(1); }
}
.dock-sep { width: 1px; align-self: stretch; background: rgba(0,0,0,0.15); margin: 4px 2px; }

.dock-tooltip {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(50, 50, 54, 0.85);
  color: #fff;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
  backdrop-filter: blur(10px);
}

/* ============ ASSISTANT / SEARCH ============ */
.assistant-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.assistant-avatar {
  position: relative;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: none;
  padding: 4px;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: transform 150ms var(--ease-out);
}
.assistant-avatar:hover { transform: scale(1.07); }
.assistant-avatar img {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  object-fit: contain;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  transition: opacity 150ms var(--ease-out);
}
.assistant-img-hover { opacity: 0; }
.assistant-avatar:hover .assistant-img-default { opacity: 0; }
.assistant-avatar:hover .assistant-img-hover { opacity: 1; }

.assistant-panel {
  width: 260px;
  max-height: 320px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 8px;
  transform-origin: bottom right;
}
.assistant-widget.open .assistant-panel { display: flex; }

.assistant-input {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.assistant-input:focus { border-color: var(--accent); }

.assistant-results {
  overflow-y: auto;
  max-height: 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assistant-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: #222;
}
.assistant-result-item:hover { background: rgba(47, 125, 255, 0.14); }
.assistant-result-item .result-path { color: rgba(0, 0, 0, 0.4); font-size: 11px; margin-left: auto; }
.assistant-result-empty { font-size: 12px; color: rgba(0, 0, 0, 0.4); padding: 6px 8px; }
.dock-icon:hover .dock-tooltip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ RESPONSIVE / MOBILE ============ */
@media (max-width: 900px) {
  :root {
    --menubar-h: 26px;
    --dock-clearance: 78px;
  }

  .menu-item:not(.apple-logo):not(.app-name) { display: none; }
  .status-icons .status-icon:not(.search-icon) { display: none; }
  .status-icons { gap: 8px; margin-right: 8px; }
  .clock { font-size: 12px; }
  .menubar { padding: 0 10px; }

  .icons-layer {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px;
    padding: calc(var(--menubar-h) + var(--safe-top) + 14px) 10px calc(var(--dock-clearance) + var(--safe-bottom) + 12px);
    align-content: start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .folder {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: auto;
    padding: 6px 4px;
    gap: 4px;
  }

  .folder-icon { width: 72px; height: 57px; }
  .label { font-size: 11px; }

  .window {
    min-width: 280px;
    min-height: 200px;
    border-radius: 10px;
  }

  .window-titlebar { height: 38px; padding: 0 10px; }
  .tl { width: 14px; height: 14px; }
  .window-title { font-size: 12px; margin-right: 52px; }
  .window-toolbar { height: 34px; padding: 0 8px; }
  .search-box { width: 90px; font-size: 11px; }
  .window-content { padding: 12px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 12px 4px; }
  .social-link-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .social-link-card img { width: 90px; height: 85px; border-radius: 18px; }
  .resize-handle { display: none; }

  .dock-wrap {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    bottom: calc(4px + var(--safe-bottom));
    padding: 0 6px;
    justify-content: center;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  .dock-wrap::-webkit-scrollbar { display: none; }

  .dock {
    width: 100%;
    max-width: 520px;
    justify-content: space-between;
    gap: clamp(2px, 1vw, 6px);
    padding: 6px 8px;
    border-radius: 14px;
    margin: 0 auto;
  }

  .dock-icon { width: clamp(30px, 9.5vw, 42px); height: clamp(30px, 9.5vw, 42px); flex: 0 1 42px; min-width: 0; }

  .assistant-widget {
    right: 12px;
    bottom: calc(var(--dock-clearance) - 8px + var(--safe-bottom));
  }

  .assistant-avatar { width: 88px; height: 88px; }
  .assistant-panel { width: min(260px, calc(100vw - 24px)); }
  #desktop.calculator-open .assistant-widget { display: none; }
}

@media (max-width: 520px) {
  :root {
    --menubar-h: 24px;
    --dock-clearance: 68px;
  }

  .icons-layer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 6px;
    padding-top: calc(var(--menubar-h) + var(--safe-top) + 10px);
  }

  .folder-icon { width: 64px; height: 51px; }
  .label { font-size: 10.5px; line-height: 1.2; }

  .dock-icon { width: clamp(28px, 9.5vw, 38px); height: clamp(28px, 9.5vw, 38px); }
  .dock { gap: 2px; padding: 5px 6px; }

  .assistant-avatar { width: 76px; height: 76px; }
  .assistant-widget { right: 8px; }

  .dropdown { min-width: 170px; font-size: 12px; }
}

/* Mobile layout mode set by JS */
#desktop.mobile-layout .window.mobile-fit {
  left: 8px !important;
  width: calc(100vw - 16px) !important;
  max-width: calc(100vw - 16px);
}

#desktop.mobile-layout .window.minimized {
  pointer-events: none;
}

#desktop.compact-height .icons-layer {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-height: 500px) and (orientation: landscape) {
  :root { --dock-clearance: 58px; }

  .icons-layer {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-bottom: calc(var(--dock-clearance) + 8px);
  }

  .folder-icon { width: 56px; height: 45px; }
  .assistant-avatar { width: 64px; height: 64px; }
  .assistant-widget { bottom: calc(var(--dock-clearance) - 4px); }
}
