
.desktop {
  position: fixed;
  top: calc(var(--menubar-height) + var(--safe-top));
  left: 0;
  right: 0;
  bottom: calc(var(--taskbar-height) + var(--safe-bottom));
  overflow: hidden;
  background-color: var(--primary-bg);
  
  background-image:
    linear-gradient(45deg, var(--light-grey) 25%, transparent 25%),
    linear-gradient(-45deg, var(--light-grey) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--light-grey) 75%),
    linear-gradient(-45deg, transparent 75%, var(--light-grey) 75%);
  background-size: 4px 4px;
  background-position: 0 0, 0 2px, 2px -2px, -2px 0;
}

.desktop-grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-right)) var(--space-lg) calc(var(--space-lg) + var(--safe-left));
  display: grid;
  align-content: start;
  justify-content: start;
  
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 92px);
  grid-auto-columns: 108px;
  gap: 4px 6px;
  overflow: hidden;
}

.desktop-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: var(--space-xs) 2px;
  min-width: 0;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.desktop-item .icon-wrap {
  height: 44px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.item-label {
  max-width: 100%;
  padding: 1px 4px;
  font-size: calc(var(--font-size-normal) - 1px);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: none;
  background: var(--primary-bg);
  pointer-events: none;
  text-transform: uppercase;
}

.desktop-item:hover .item-label,
.desktop-item:focus-visible .item-label,
.desktop-item:active .item-label {
  background: var(--selected-bg);
  color: var(--selected-text);
}
.desktop-item:focus-visible { outline: 0; }

.folder-graphic,
.disk-graphic,
.file-graphic,
.app-graphic,
.image-graphic {
  position: relative;
  flex-shrink: 0;
  background: var(--primary-bg);
  border: var(--window-border) solid var(--border-color);
}

.folder-graphic { width: calc(var(--icon-size) * 1.35); height: calc(var(--icon-size) * 1.0); margin-top: 6px; }
.folder-tab {
  position: absolute;
  left: 12%;
  top: calc(-0.25 * var(--icon-size) - 2px);
  width: 40%;
  height: calc(0.25 * var(--icon-size));
  background: var(--primary-bg);
  border: var(--window-border) solid var(--border-color);
  border-bottom: 0;
}

.disk-graphic { width: calc(var(--icon-size) * 1.4); height: calc(var(--icon-size) * 1.1); background: var(--medium-grey); }
.disk-graphic::before {
  content: '';
  position: absolute;
  left: 14%; right: 14%; top: 18%;
  height: 24%;
  background: var(--primary-bg);
  border: var(--window-border) solid var(--border-color);
}
.disk-graphic::after {
  content: '';
  position: absolute;
  right: 12%; bottom: 14%;
  width: 14%; height: 14%;
  background: var(--black);
}

.file-graphic {
  width: calc(var(--icon-size) * 1.0);
  height: calc(var(--icon-size) * 1.3);
  background-image: repeating-linear-gradient(to bottom, transparent 0 4px, var(--black) 4px 5px);
  background-size: 62% 62%;
  background-position: 50% 78%;
  background-repeat: no-repeat;
}
.file-graphic::before {
  content: '';
  position: absolute;
  top: calc(var(--window-border) * -1);
  right: calc(var(--window-border) * -1);
  width: 30%; height: 24%;
  background: var(--medium-grey);
  border: var(--window-border) solid var(--border-color);
  border-top: 0; border-right: 0;
}

.app-graphic {
  width: calc(var(--icon-size) * 1.3);
  height: calc(var(--icon-size) * 1.05);
  background: var(--primary-bg);
  background-image: repeating-linear-gradient(to bottom, var(--black) 0 1px, transparent 1px 3px);
  background-size: 100% 26%;
  background-repeat: no-repeat;
}
.app-graphic::after {
  content: '';
  position: absolute;
  left: 18%; right: 18%; bottom: 16%;
  top: 44%;
  background: var(--medium-grey);
  border: 1px solid var(--black);
}

.image-graphic { width: calc(var(--icon-size) * 1.3); height: calc(var(--icon-size) * 1.05); background: var(--light-grey); }
.image-graphic::after {
  content: '';
  position: absolute;
  left: 14%; right: 14%; bottom: 14%;
  height: 40%;
  background: var(--black);
  clip-path: polygon(0 100%, 30% 20%, 55% 65%, 75% 35%, 100% 100%);
}

.news-note {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 5;
  width: 256px;
  max-height: calc(100% - 2 * var(--space-lg));
  overflow-y: auto;
  background: var(--light-grey);
  border: var(--window-border) solid var(--border-color);
  box-shadow: var(--hard-shadow);
  font-size: var(--font-size-small);
  line-height: 1.45;
}
.news-note { display: none; }

.news-note-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--medium-grey);
  border-bottom: var(--window-border) solid var(--border-color);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.news-note-close {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--primary-bg);
  line-height: 1;
}
.news-note-close:hover { background: var(--selected-bg); color: var(--selected-text); }
.news-note-body { padding: var(--space-md); }
.news-note-body h4 { font-size: var(--font-size-small); margin-top: var(--space-md); text-transform: uppercase; }
.news-note-body h4:first-child { margin-top: 0; }
.news-note-body p { margin: 0; }
.news-note-body a { text-decoration: underline; cursor: pointer; }
.news-note-body a:hover { background: var(--selected-bg); color: var(--selected-text); }

#window-container:empty + .news-note { display: block; }
@media (min-width: 1800px) { .news-note { display: block; } }
html.is-compact .news-note { display: none !important; }

@media (max-width: 767px) {
  .desktop-grid {
    grid-auto-flow: row;
    grid-template-rows: none;
    grid-auto-rows: 96px;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: var(--space-sm) 0;
    padding: var(--space-md);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .item-label { font-size: 11px; padding: 1px 2px; }
}

@media (max-height: 520px) {
  .desktop-grid { grid-template-rows: repeat(auto-fill, 92px); grid-auto-rows: 92px; }
  .desktop-item .icon-wrap { height: 40px; }
}
